Java Code Examples for io.netty.channel.group.ChannelGroupFuture#group()
The following examples show how to use
io.netty.channel.group.ChannelGroupFuture#group() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NettyAcceptor.java From activemq-artemis with Apache License 2.0 | 6 votes |
@Override public synchronized void pause() { if (paused) { return; } if (channelClazz == null) { return; } // We *pause* the acceptor so no new connections are made if (serverChannelGroup != null) { ChannelGroupFuture future = serverChannelGroup.close().awaitUninterruptibly(); if (!future.isSuccess()) { ActiveMQServerLogger.LOGGER.nettyChannelGroupBindError(); for (Channel channel : future.group()) { if (channel.isActive()) { ActiveMQServerLogger.LOGGER.nettyChannelStillBound(channel, channel.remoteAddress()); } } } } paused = true; }
Example 2
Source File: NettyAcceptor.java From activemq-artemis with Apache License 2.0 | 4 votes |
@Override public synchronized void asyncStop(Runnable callback) { if (channelClazz == null) { callback.run(); return; } if (protocolHandler != null) { protocolHandler.close(); } if (batchFlusherFuture != null) { batchFlusherFuture.cancel(false); flusher.cancel(); flusher = null; batchFlusherFuture = null; } // serverChannelGroup has been unbound in pause() if (serverChannelGroup != null) { serverChannelGroup.close().awaitUninterruptibly(); } if (channelGroup != null) { ChannelGroupFuture future = channelGroup.close().awaitUninterruptibly(); if (!future.isSuccess()) { ActiveMQServerLogger.LOGGER.nettyChannelGroupError(); for (Channel channel : future.group()) { if (channel.isActive()) { ActiveMQServerLogger.LOGGER.nettyChannelStillOpen(channel, channel.remoteAddress()); } } } } channelClazz = null; for (Connection connection : connections.values()) { listener.connectionDestroyed(connection.getID()); } connections.clear(); if (notificationService != null) { TypedProperties props = new TypedProperties(); props.putSimpleStringProperty(new SimpleString("factory"), new SimpleString(NettyAcceptorFactory.class.getName())); props.putSimpleStringProperty(new SimpleString("host"), new SimpleString(host)); props.putIntProperty(new SimpleString("port"), port); Notification notification = new Notification(null, CoreNotificationType.ACCEPTOR_STOPPED, props); try { notificationService.sendNotification(notification); } catch (Exception e) { ActiveMQServerLogger.LOGGER.failedToSendNotification(e); } } paused = false; // Shutdown the EventLoopGroup if no new task was added for 100ms or if // 3000ms elapsed. eventLoopGroup.shutdownGracefully(quietPeriod, shutdownTimeout, TimeUnit.MILLISECONDS).addListener(f -> callback.run()); eventLoopGroup = null; }