Example usage for io.netty.channel.group ChannelGroup close

List of usage examples for io.netty.channel.group ChannelGroup close

Introduction

In this page you can find the example usage for io.netty.channel.group ChannelGroup close.

Prototype

ChannelGroupFuture close();

Source Link

Document

Closes all Channel s in this group.

Usage

From source file:com.zhang.pool.NettyChannelPool.java

License:Apache License

/**
 * close all channels in the pool and shut down the eventLoopGroup
 * /*from  w w w  . j  a v a 2s. c  o  m*/
 * @throws InterruptedException
 */
public void close() throws InterruptedException {
    ChannelGroup channelGroup = new DefaultChannelGroup(GlobalEventExecutor.INSTANCE);

    for (LinkedBlockingQueue<Channel> queue : routeToPoolChannels.values()) {
        for (Channel channel : queue) {
            removeChannel(channel, null);
            channelGroup.add(channel);
        }
    }
    channelGroup.close().sync();
    group.shutdownGracefully();
}