Java 类org.jboss.netty.channel.group.ChannelGroupFuture 实例源码

项目:Camel    文件:SingleUDPNettyServerBootstrapFactory.java   
protected void stopServerBootstrap() {
    // close all channels
    LOG.info("ConnectionlessBootstrap disconnecting from {}:{}", configuration.getHost(), configuration.getPort());

    LOG.trace("Closing {} channels", allChannels.size());
    ChannelGroupFuture future = allChannels.close();
    future.awaitUninterruptibly();

    // close server external resources
    if (datagramChannelFactory != null) {
        datagramChannelFactory.releaseExternalResources();
        datagramChannelFactory = null;
    }

    // and then shutdown the thread pools
    if (workerPool != null) {
        workerPool.shutdown();
        workerPool = null;
    }
}
项目:Camel    文件:SingleTCPNettyServerBootstrapFactory.java   
protected void stopServerBootstrap() {
    // close all channels
    LOG.info("ServerBootstrap unbinding from {}:{}", configuration.getHost(), configuration.getPort());

    LOG.trace("Closing {} channels", allChannels.size());
    ChannelGroupFuture future = allChannels.close();
    future.awaitUninterruptibly();

    // close server external resources
    if (channelFactory != null) {
        channelFactory.releaseExternalResources();
        channelFactory = null;
    }

    // and then shutdown the thread pools
    if (bossPool != null) {
        bossPool.shutdown();
        bossPool = null;
    }
    if (workerPool != null) {
        workerPool.shutdown();
        workerPool = null;
    }
}
项目:jmemcache-daemon    文件:MemCacheDaemon.java   
public void stop() {
    log.info("terminating daemon; closing all channels");

    ChannelGroupFuture future = allChannels.close();
    future.awaitUninterruptibly();
    if (!future.isCompleteSuccess()) {
        throw new RuntimeException("failure to complete closing all network channels");
    }
    log.info("channels closed, freeing cache storage");
    try {
        cache.close();
    } catch (IOException e) {
        throw new RuntimeException("exception while closing storage", e);
    }
    channelFactory.releaseExternalResources();

    running = false;
    log.info("successfully shut down");
}
项目:fqueue    文件:MemCacheDaemon.java   
public void stop() {
    log.info("terminating daemon; closing all channels");

    ChannelGroupFuture future = allChannels.close();
    future.awaitUninterruptibly();
    if (!future.isCompleteSuccess()) {
        throw new RuntimeException("failure to complete closing all network channels");
    }
    log.info("channels closed, freeing cache storage");
    try {
        cache.close();
    } catch (IOException e) {
        throw new RuntimeException("exception while closing storage", e);
    }
    channelFactory.releaseExternalResources();

    running = false;
    log.info("successfully shut down");
}
项目:apm-agent    文件:PinpointServerSocket.java   
private void sendServerClosedPacket() {
    logger.info("sendServerClosedPacket start");
    final ChannelGroupFuture write = this.channelGroup.write(new ServerClosePacket());
    write.awaitUninterruptibly(5000, TimeUnit.MILLISECONDS);
    if (logger.isWarnEnabled()) {
        write.addListener(new ChannelGroupFutureListener() {
            private final ChannelFutureListener listener = new WriteFailFutureListener(logger, "serverClosePacket write fail", "serverClosePacket write success");

            @Override
            public void operationComplete(ChannelGroupFuture future) throws Exception {
                for (ChannelFuture channelFuture : future) {
                    channelFuture.addListener(listener);
                }
            }
        });
    }
    logger.info("sendServerClosedPacket end");
}
项目:flazr    文件:RtmpProxy.java   
public static void main(String[] args) throws Exception {        

        Executor executor = Executors.newCachedThreadPool();
        ChannelFactory factory = new NioServerSocketChannelFactory(executor, executor);
        ServerBootstrap sb = new ServerBootstrap(factory);
        ClientSocketChannelFactory cf = new NioClientSocketChannelFactory(executor, executor);
        sb.setPipelineFactory(new ProxyPipelineFactory(cf,
                RtmpConfig.PROXY_REMOTE_HOST, RtmpConfig.PROXY_REMOTE_PORT));
        InetSocketAddress socketAddress = new InetSocketAddress(RtmpConfig.PROXY_PORT);
        sb.bind(socketAddress);
        logger.info("proxy server started, listening on {}", socketAddress);

        Thread monitor = new StopMonitor(RtmpConfig.PROXY_STOP_PORT);
        monitor.start();
        monitor.join();

        ChannelGroupFuture future = ALL_CHANNELS.close();
        logger.info("closing channels");
        future.awaitUninterruptibly();
        logger.info("releasing resources");
        factory.releaseExternalResources();
        logger.info("server stopped");

    }
项目:jmemcached    文件:MemCacheDaemon.java   
public void stop() {
    log.info("terminating daemon; closing all channels");

    ChannelGroupFuture future = allChannels.close();
    future.awaitUninterruptibly();
    if (!future.isCompleteSuccess()) {
        throw new RuntimeException("failure to complete closing all network channels");
    }
    log.info("channels closed, freeing cache storage");
    try {
        cache.close();
    } catch (IOException e) {
        throw new RuntimeException("exception while closing storage", e);
    }
    channelFactory.releaseExternalResources();

    running = false;
    log.info("successfully shut down");
}
项目:Android-Airplay-Server    文件:AirPlayServer.java   
protected void onShutdown() {
    /* Close channels */
    final ChannelGroupFuture allChannelsClosed = channelGroup.close();

    /* Stop all mDNS responders */
    synchronized(jmDNSInstances) {
        for(final JmDNS jmDNS: jmDNSInstances) {
            try {
                jmDNS.unregisterAllServices();
                LOG.info("Unregistered all services on " + jmDNS.getInterface());
            }
            catch (final IOException e) {
                LOG.log(Level.WARNING, "Failed to unregister some services", e);

            }
        }
    }

    /* Wait for all channels to finish closing */
    allChannelsClosed.awaitUninterruptibly();

    /* Stop the ExecutorService */
    executorService.shutdown();

    /* Release the OrderedMemoryAwareThreadPoolExecutor */
    channelExecutionHandler.releaseExternalResources();
    isOn = false;

}
项目:navi    文件:ANaviTCPServer.java   
@Override
public void stopServer() {
    if (channelGroup != null) {
        ChannelGroupFuture future = channelGroup.close();
        future.awaitUninterruptibly();
    }

    if (bootstrap != null) {
        bootstrap.getFactory().releaseExternalResources();
    }

    if (timer != null) {
        timer.stop();
    }
}
项目:xap-openspaces    文件:MemCacheDaemon.java   
public void destroy() throws Exception {
    ChannelGroupFuture future = allChannels.close();
    future.awaitUninterruptibly();
    if (!future.isCompleteSuccess()) {
        throw new RuntimeException("failure to complete closing all network channels");
    }
    try {
        cache.close();
    } catch (IOException e) {
        throw new RuntimeException("exception while closing storage", e);
    }
    channelFactory.releaseExternalResources();
    logger.info("memcached destroyed");
}
项目:AirSpeakerMobile    文件:AirPlayServer.java   
protected void onShutdown() {
    /* Close channels */
    final ChannelGroupFuture allChannelsClosed = channelGroup.close();

    /* Stop all mDNS responders */
    synchronized(jmDNSInstances) {
        for(final JmDNS jmDNS: jmDNSInstances) {
            try {
                jmDNS.unregisterAllServices();
                LogManager.i("Unregistered all services on " + jmDNS.getInterface());
            }
            catch (final IOException e) {
                LogManager.e("Level.WARNING Failed to unregister some services " +Log.getStackTraceString(e));

            }
        }
    }

    /* Wait for all channels to finish closing */
    allChannelsClosed.awaitUninterruptibly();

    /* Stop the ExecutorService */
    executorService.shutdown();

    /* Release the OrderedMemoryAwareThreadPoolExecutor */
    channelExecutionHandler.releaseExternalResources();

}
项目:apm-agent    文件:PinpointServerSocket.java   
private void sendPing() {
    logger.debug("sendPing");
    final TimerTask pintTask = new TimerTask() {
        @Override
        public void run(Timeout timeout) throws Exception {
            if (timeout.isCancelled()) {
                newPingTimeout(this);
                return;
            }

            final ChannelGroupFuture write = channelGroup.write(PingPacket.PING_PACKET);
            if (logger.isWarnEnabled()) {
                write.addListener(new ChannelGroupFutureListener() {
                    private final ChannelFutureListener listener = new WriteFailFutureListener(logger, "ping write fail", "ping write success");

                    @Override
                    public void operationComplete(ChannelGroupFuture future) throws Exception {

                        if (logger.isWarnEnabled()) {
                            for (ChannelFuture channelFuture : future) {
                                channelFuture.addListener(listener);
                            }
                        }
                    }
                });
            }
            newPingTimeout(this);
        }
    };
    newPingTimeout(pintTask);
}
项目:incubator-tajo    文件:HttpDataServer.java   
public void stop() {
  ChannelGroupFuture future = channelGroup.close();
  future.awaitUninterruptibly();
  factory.releaseExternalResources();

  LOG.info("HttpDataServer shutdown ("
      + this.bindAddr.getAddress().getHostAddress() + ":"
      + this.bindAddr.getPort() + ")");
}
项目:tajo-cdh    文件:HttpDataServer.java   
public void stop() {
  ChannelGroupFuture future = channelGroup.close();
  future.awaitUninterruptibly();
  factory.releaseExternalResources();

  LOG.info("HttpDataServer shutdown ("
      + this.bindAddr.getAddress().getHostAddress() + ":"
      + this.bindAddr.getPort() + ")");
}
项目:rest4j    文件:HttpNettyServer.java   
@Override
public void stop()
{
  System.out.println("Shutting down");
  ChannelGroupFuture shutdown = _allChannels.disconnect();
  shutdown.awaitUninterruptibly();
  _bootstrap.releaseExternalResources();
  _executionHandler.releaseExternalResources();
}
项目:tools-idea    文件:JavacServer.java   
public void stop() {
  try {
    final ChannelGroupFuture closeFuture = myAllOpenChannels.close();
    closeFuture.awaitUninterruptibly();
  }
  finally {
    myChannelFactory.releaseExternalResources();
  }
}
项目:flazr    文件:RtmpServer.java   
public static void main(String[] args) throws Exception {

        final ChannelFactory factory = new NioServerSocketChannelFactory(
                Executors.newCachedThreadPool(),
                Executors.newCachedThreadPool());

        final ServerBootstrap bootstrap = new ServerBootstrap(factory);

        bootstrap.setPipelineFactory(new ServerPipelineFactory());
        bootstrap.setOption("child.tcpNoDelay", true);
        bootstrap.setOption("child.keepAlive", true);

        final InetSocketAddress socketAddress = new InetSocketAddress(RtmpConfig.SERVER_PORT);
        bootstrap.bind(socketAddress);
        logger.info("server started, listening on: {}", socketAddress);

        final Thread monitor = new StopMonitor(RtmpConfig.SERVER_STOP_PORT);
        monitor.start();        
        monitor.join();

        TIMER.stop();
        final ChannelGroupFuture future = CHANNELS.close();
        logger.info("closing channels");
        future.awaitUninterruptibly();
        logger.info("releasing resources");
        factory.releaseExternalResources();
        logger.info("server stopped");

    }
项目:feluca    文件:BaseNioServer.java   
/**
 * stop
 * 
 * Implement this {@link org.shanbo.feluca.common.Server} method
 */
public void postStop() throws Exception {
    ChannelGroupFuture closeFuture = allChannels.close();
    closeFuture.awaitUninterruptibly();

    if (channelFactory != null)
        channelFactory.releaseExternalResources();
}
项目:whois    文件:NrtmChannelsRegistry.java   
public void closeChannels() {
    LOGGER.info("Closing {} open channels.", size());
    channels.close().addListener(new ChannelGroupFutureListener() {
        @Override
        public void operationComplete(ChannelGroupFuture future) {
            LOGGER.info("Closed all channels.");
        }
    });
}
项目:whois    文件:QueryChannelsRegistry.java   
public void closeChannels() {
    LOGGER.info("Closing {} open channels.", size());
    channels.close().addListener(new ChannelGroupFutureListener() {
        @Override
        public void operationComplete(ChannelGroupFuture future) {
            LOGGER.info("Closed all channels.");
        }
    });
}
项目:voyage    文件:RpcServerBootstrap.java   
private void initHttpBootstrap(int myport) {
    logger.info("initHttpBootstrap...........");
    final ServerConfig serverConfig = new ServerConfig(myport);
    final ChannelGroup channelGroup = new DefaultChannelGroup(getClass().getName());
    bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(
            //建议用ThreadPoolExecutor代替
            Executors.newCachedThreadPool(),
            Executors.newCachedThreadPool(), serverConfig.getThreadCnt()));
    //设置常见参数
    bootstrap.setOption("tcpNoDelay","true");//禁用nagle算法
    bootstrap.setOption("reuseAddress", "true");
    bootstrap.setOption("SO_RCVBUF",1024*128);
    bootstrap.setOption("SO_SNDBUF",1024*128);
    timer = new HashedWheelTimer();
    bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
        public ChannelPipeline getPipeline() throws Exception {
            ChannelPipeline pipeline = Channels.pipeline();
            int readTimeout = serverConfig.getReadTimeout();
            if (readTimeout > 0) {
                pipeline.addLast("timeout", new ReadTimeoutHandler(timer, readTimeout, TimeUnit.MILLISECONDS));
            }
            pipeline.addLast("decoder", new RpcRequestDecode());
            pipeline.addLast("encoder", new RpcResponseEncode());
            pipeline.addLast("handler", new NettyRpcServerHandler(channelGroup));
            return pipeline;
        }
    });

    int port = serverConfig.getPort();
    if (!checkPortConfig(port)) {
        throw new IllegalStateException("port: " + port + " already in use!");
    }

    Channel channel = bootstrap.bind(new InetSocketAddress(port));
    channelGroup.add(channel);
    logger.info("voyage server started");

    waitForShutdownCommand();
    ChannelGroupFuture future = channelGroup.close();
    future.awaitUninterruptibly();
    bootstrap.releaseExternalResources();
    timer.stop();
    timer = null;

    logger.info("voyage server stoped");

}
项目:traccar-service    文件:TrackerServer.java   
public void stop() {
    ChannelGroupFuture future = getChannelGroup().close();
    future.awaitUninterruptibly();
}
项目:netty-http-3.x    文件:HttpServer.java   
@Override
protected void serverShutdown() {
    ChannelGroupFuture channelGroupFuture = CHANNEL_GROUP.close();
    channelGroupFuture.awaitUninterruptibly();
}
项目:netty-http-3.x    文件:RemoteServer.java   
@Override
protected void serverShutdown() {
    ChannelGroupFuture channelGroupFuture = CHANNEL_GROUP.close();
    channelGroupFuture.awaitUninterruptibly();
}
项目:Camel    文件:NettyProducer.java   
@Override
protected void doStop() throws Exception {
    LOG.debug("Stopping producer at address: {}", configuration.getAddress());
    // close all channels
    LOG.trace("Closing {} channels", allChannels.size());
    ChannelGroupFuture future = allChannels.close();
    future.awaitUninterruptibly();

    // release the external resource here and we keep the timer open
    // and then shutdown the thread pools
    if (bossPool != null) {
        bossPool.shutdown();
        bossPool = null;
    }
    if (workerPool != null) {
        if (workerPool instanceof ExternalResourceReleasable) {
            // this will first invoke workerPool#shutdown() internally (e.g. org.jboss.netty.channel.socket.nio.AbstractNioWorkerPool)
            ((ExternalResourceReleasable) workerPool).releaseExternalResources();
        } else {
            workerPool.shutdown();
        }
        workerPool = null;
    }

    if (pool != null) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Stopping producer with channel pool[active={}, idle={}]", pool.getNumActive(), pool.getNumIdle());
        }
        pool.close();
        pool = null;
    }

    if (channelFactory != null) {
        // this will first invoke channelFactory#shutdown() internally (see it's javadoc)
        channelFactory.releaseExternalResources();
        channelFactory = null;
    }

    if (datagramChannelFactory != null) {
        // this will first invoke datagramChannelFactory#shutdown() internally (see it's javadoc)
        datagramChannelFactory.releaseExternalResources();
        datagramChannelFactory = null;
    }

    super.doStop();
}
项目:traccar-mongodb    文件:TrackerServer.java   
/**
 * Stop server
 */
public void stop() {
    ChannelGroupFuture future = getChannelGroup().close();
    future.awaitUninterruptibly();
}
项目:tools-idea    文件:BuildManager.java   
public void stopListening() {
  final ChannelGroupFuture closeFuture = myAllOpenChannels.close();
  closeFuture.awaitUninterruptibly();
}
项目:archived-net-virt-platform    文件:OVSDBImplTest.java   
public void shutdownOVSDBServer() {
    ChannelGroupFuture future = allChannels.close();
    future.awaitUninterruptibly();
    sfactory.releaseExternalResources();

}
项目:Mineworld    文件:Server.java   
public void shutdown() {
    ChannelGroupFuture future = allChannels.close();
    future.awaitUninterruptibly();
    factory.releaseExternalResources();
    logger.info("Server shutdown");
}
项目:rsc    文件:LogicHandler.java   
public ChannelGroupFuture closeChannels() {
    return channels.close();
}
项目:samples-switchyard    文件:TCPServer.java   
public void stop() {
    ChannelGroupFuture f = channels.close();
    f.awaitUninterruptibly();
    factory.releaseExternalResources();
}
项目:giraph-gora    文件:ProgressableUtils.java   
/**
 * Wait for {@link ChannelGroupFuture} to finish, while periodically
 * reporting progress.
 *
 * @param future       ChannelGroupFuture
 * @param progressable Progressable for reporting progress (Job context)
 */
public static void awaitChannelGroupFuture(ChannelGroupFuture future,
    Progressable progressable) {
  waitForever(new ChannelGroupFutureWaitable(future), progressable);
}
项目:giraph-gora    文件:ProgressableUtils.java   
/**
 * Constructor
 *
 * @param future ChannelGroupFuture which we want to wait for
 */
public ChannelGroupFutureWaitable(ChannelGroupFuture future) {
  this.future = future;
}
项目:giraph-research    文件:ProgressableUtils.java   
/**
 * Wait for {@link ChannelGroupFuture} to finish, while periodically
 * reporting progress.
 *
 * @param future       ChannelGroupFuture
 * @param progressable Progressable for reporting progress (Job context)
 */
public static void awaitChannelGroupFuture(ChannelGroupFuture future,
    Progressable progressable) {
  waitForever(new ChannelGroupFutureWaitable(future), progressable);
}
项目:giraph-research    文件:ProgressableUtils.java   
/**
 * Constructor
 *
 * @param future ChannelGroupFuture which we want to wait for
 */
public ChannelGroupFutureWaitable(ChannelGroupFuture future) {
  this.future = future;
}
项目:giraph-research    文件:ProgressableUtils.java   
/**
 * Wait for {@link ChannelGroupFuture} to finish, while periodically
 * reporting progress.
 *
 * @param future       ChannelGroupFuture
 * @param progressable Progressable for reporting progress (Job context)
 */
public static void awaitChannelGroupFuture(ChannelGroupFuture future,
    Progressable progressable) {
  waitForever(new ChannelGroupFutureWaitable(future), progressable);
}
项目:giraph-research    文件:ProgressableUtils.java   
/**
 * Constructor
 *
 * @param future ChannelGroupFuture which we want to wait for
 */
public ChannelGroupFutureWaitable(ChannelGroupFuture future) {
  this.future = future;
}
项目:giraph-research    文件:ProgressableUtils.java   
/**
 * Wait for {@link ChannelGroupFuture} to finish, while periodically
 * reporting progress.
 *
 * @param future       ChannelGroupFuture
 * @param progressable Progressable for reporting progress (Job context)
 */
public static void awaitChannelGroupFuture(ChannelGroupFuture future,
    Progressable progressable) {
  waitForever(new ChannelGroupFutureWaitable(future), progressable);
}
项目:giraph-research    文件:ProgressableUtils.java   
/**
 * Constructor
 *
 * @param future ChannelGroupFuture which we want to wait for
 */
public ChannelGroupFutureWaitable(ChannelGroupFuture future) {
  this.future = future;
}