Search in sources :

Example 1 with NettyClientFactory

use of com.ctrip.xpipe.netty.commands.NettyClientFactory in project x-pipe by ctripcorp.

the class AbstractCommandTest method createClientPool.

protected FixedObjectPool<NettyClient> createClientPool(String host, int port) throws Exception {
    NettyClientFactory nettyClientFactory = new NettyClientFactory(new InetSocketAddress(host, port));
    nettyClientFactory.start();
    stoppables.add(nettyClientFactory);
    NettyClient nettyClient = nettyClientFactory.makeObject().getObject();
    FixedObjectPool<NettyClient> clientPool = new FixedObjectPool<NettyClient>(nettyClient);
    return clientPool;
}
Also used : NettyClient(com.ctrip.xpipe.netty.commands.NettyClient) InetSocketAddress(java.net.InetSocketAddress) NettyClientFactory(com.ctrip.xpipe.netty.commands.NettyClientFactory) FixedObjectPool(com.ctrip.xpipe.pool.FixedObjectPool)

Example 2 with NettyClientFactory

use of com.ctrip.xpipe.netty.commands.NettyClientFactory in project x-pipe by ctripcorp.

the class XpipeNettyClientPool method doInitialize.

@Override
protected void doInitialize() throws Exception {
    this.factory = new NettyClientFactory(target);
    this.factory.start();
    GenericObjectPool<NettyClient> genericObjectPool = new GenericObjectPool<>(factory, config);
    genericObjectPool.setTestOnBorrow(true);
    genericObjectPool.setTestOnCreate(true);
    this.objectPool = genericObjectPool;
}
Also used : NettyClient(com.ctrip.xpipe.netty.commands.NettyClient) NettyClientFactory(com.ctrip.xpipe.netty.commands.NettyClientFactory) GenericObjectPool(org.apache.commons.pool2.impl.GenericObjectPool)

Aggregations

NettyClient (com.ctrip.xpipe.netty.commands.NettyClient)2 NettyClientFactory (com.ctrip.xpipe.netty.commands.NettyClientFactory)2 FixedObjectPool (com.ctrip.xpipe.pool.FixedObjectPool)1 InetSocketAddress (java.net.InetSocketAddress)1 GenericObjectPool (org.apache.commons.pool2.impl.GenericObjectPool)1