If i understood you correctly its not really a question about netty but
java in general. Both work but I would go with the second one


On 14. June 2017 at 02:20:05, James Kim ([email protected]) wrote:

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
<https://groups.google.com/d/msgid/netty/0c8d221a-7338-4cc8-8fa5-c1af49dc89a4%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.

-- 
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/CAKrGPjwrN8K0h1NnK_0_yMmf3ys_d7bJ2OaWJRTLACBNeHD-ag%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
  • netty4 channelPool James Kim
    • Re: netty4 channelPool 'Norman Maurer' via Netty discussions

Reply via email to