i saw a netty4 channelPool 

my question is that 

*final SimpleChannelPool pool = poolMap.get(addr1);*

*if i want to make a different pool in addr1 or addr2 *

*is that proper way to make a problem?*


if(addr1){
*final SimpleChannelPool pool1 = poolMap.get(addr1);*
*}*
*else if (addr2){*
*final SimpleChannelPool pool2= poolMap.get(addr2);*
*}*

*or *

*final SimpleChannelPool pool;*
if(addr1){
* pool = poolMap.get(addr1);*
*}*
*else if (addr2){*
* pool = poolMap.get(addr2);*
*}*

*and  how can i count channelPool?*

*i am new to netty4 and give me a hint~*

http://netty.io/news/2015/05/07/4-0-28-Final.html

EventLoopGroup group = new NioEventLoopGroup();
final Bootstrap cb = new Bootstrap();
InetSocketAddress addr1 = new InetSocketAddress("10.0.0.10", 8888);
InetSocketAddress addr2 = new InetSocketAddress("10.0.0.11", 8888);
cb.group(group).channel(NioSocketChannel.class);
ChannelPoolMap<InetSocketAddress, SimpleChannelPool> poolMap = new 
AbstractChannelPoolMap<InetSocketAddress, SimpleChannelPool>() {
    @Override
    protected SimpleChannelPool newPool(InetSocketAddress key) {
        return new SimpleChannelPool(cb.remoteAddress(key), new 
TestChannelPoolHandler());
    }
};
// depending on when you use addr1 or addr2 you will get different pools.
*final SimpleChannelPool pool = poolMap.get(addr1);*
Future<Channel> f = pool.acquire();
f.addListener(new FutureListener<Channel>() {
    @Override
    public void operationComplete(Future<Channel> f) {
        if (f.isSuccess()) {
            Channel ch = f.getNow();
            // Do somethings
            // ...
            // ...
            // Release back to pool
            pool.release(ch);
        }
    }
});

-- 
You received this message because you are subscribed to the Google Groups 
"Netty discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/netty/0c8d221a-7338-4cc8-8fa5-c1af49dc89a4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to