Example usage for io.netty.channel.group ChannelGroupFuture awaitUninterruptibly

List of usage examples for io.netty.channel.group ChannelGroupFuture awaitUninterruptibly

Introduction

In this page you can find the example usage for io.netty.channel.group ChannelGroupFuture awaitUninterruptibly.

Prototype

@Override
    ChannelGroupFuture awaitUninterruptibly();

Source Link

Usage

From source file:com.ancun.netty.httpserver.HttpServer.java

License:Apache License

/**
 * Releases all resources associated with this server so the JVM can
 * shutdown cleanly. Call this method to finish using the server. To utilize
 * the default shutdown hook in main() provided by HttpServer, call
 * awaitShutdown() instead.//w w w. j  ava  2s .  c  om
 * 
 * @param shouldWait true if shutdown() should wait for the shutdown of each thread group.
 */
public void shutdown(boolean shouldWait) {
    ChannelGroupFuture channelFuture = allChannels.close();
    bootstrapFactory.shutdownGracefully(shouldWait);
    channelFuture.awaitUninterruptibly();
}

From source file:org.apache.camel.component.netty4.NettyProducer.java

License:Apache License

@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();

    // and then shutdown the thread pools
    if (workerGroup != null) {
        workerGroup.shutdownGracefully();
        workerGroup = null;/*  w w  w . j a va2  s .  com*/
    }

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

    if (timer != null) {
        timer.stop();
        timer = null;
    }

    super.doStop();
}

From source file:org.apache.camel.component.netty4.SingleTCPNettyServerBootstrapFactory.java

License:Apache License

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();

    if (allChannels != null) {
        allChannels.close();/*from   w w w  .j  a v  a2  s  . c  om*/
    }

    // and then shutdown the thread pools
    if (bossGroup != null) {
        bossGroup.shutdownGracefully();
        bossGroup = null;
    }
    if (workerGroup != null) {
        workerGroup.shutdownGracefully();
        workerGroup = null;
    }
}

From source file:org.apache.camel.component.netty4.SingleUDPNettyServerBootstrapFactory.java

License:Apache License

protected void stopServerBootstrap() {
    // close all channels
    LOG.info("ConnectionlessBootstrap disconnecting from {}:{}", configuration.getHost(),
            configuration.getPort());// w w  w .  ja  v a 2 s .  co  m

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

    // and then shutdown the thread pools
    if (workerGroup != null) {
        workerGroup.shutdownGracefully();
        workerGroup = null;
    }
}

From source file:org.atmosphere.nettosphere.Nettosphere.java

License:Apache License

/**
 * Stop the Server/* w  w w.j  a  va2 s  . co m*/
 */
public void stop() {
    if (started.getAndSet(false)) {
        runtime.destroy();
        final ChannelGroupFuture future = ALL_CHANNELS.close();
        future.awaitUninterruptibly();
        ALL_CHANNELS.clear();
    }
}

From source file:org.restexpress.RestExpress.java

License:Apache License

/**
 * Releases all resources associated with this server so the JVM can
 * shutdown cleanly. Call this method to finish using the server. To utilize
 * the default shutdown hook in main() provided by RestExpress, call
 * awaitShutdown() instead./*  www.  java  2 s.c om*/
 * 
 * @param shouldWait true if shutdown() should wait for the shutdown of each thread group.
 */
public void shutdown(boolean shouldWait) {
    ChannelGroupFuture channelFuture = allChannels.close();
    bootstrapFactory.shutdownGracefully(shouldWait);
    channelFuture.awaitUninterruptibly();
    shutdownPlugins();
}