Search in sources :

Example 36 with NettyClient

use of com.ctrip.xpipe.netty.commands.NettyClient 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)

Example 37 with NettyClient

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

the class PsyncTest method beforePsyncTest.

@Before
public void beforePsyncTest() throws Exception {
    masterOffset = (long) randomInt(0, Integer.MAX_VALUE - 1);
    replicationStoreManager = createReplicationStoreManager();
    LifecycleHelper.initializeIfPossible(replicationStoreManager);
    replicationStore = (DefaultReplicationStore) replicationStoreManager.create();
    SimpleObjectPool<NettyClient> clientPool = NettyPoolUtil.createNettyPool(new InetSocketAddress("127.0.0.1", 1234));
    psync = new DefaultPsync(clientPool, new DefaultEndPoint("127.0.0.1", 1234), replicationStoreManager, scheduled);
    psync.future().addListener(new CommandFutureListener<Object>() {

        @Override
        public void operationComplete(CommandFuture<Object> commandFuture) throws Exception {
            if (!commandFuture.isSuccess()) {
                logger.error("[operationComplete]", commandFuture.cause());
            }
        }
    });
}
Also used : NettyClient(com.ctrip.xpipe.netty.commands.NettyClient) InetSocketAddress(java.net.InetSocketAddress) DefaultEndPoint(com.ctrip.xpipe.endpoint.DefaultEndPoint) IOException(java.io.IOException) XpipeException(com.ctrip.xpipe.exception.XpipeException) DefaultPsync(com.ctrip.xpipe.redis.core.protocal.cmd.DefaultPsync) Before(org.junit.Before)

Aggregations

NettyClient (com.ctrip.xpipe.netty.commands.NettyClient)37 InetSocketAddress (java.net.InetSocketAddress)31 Test (org.junit.Test)8 ExecutionException (java.util.concurrent.ExecutionException)6 AbstractTest (com.ctrip.xpipe.AbstractTest)4 InfoCommand (com.ctrip.xpipe.redis.core.protocal.cmd.InfoCommand)4 Server (com.ctrip.xpipe.simpleserver.Server)4 IOException (java.io.IOException)4 CommandExecutionException (com.ctrip.xpipe.command.CommandExecutionException)3 SequenceCommandChain (com.ctrip.xpipe.command.SequenceCommandChain)3 FixedObjectPool (com.ctrip.xpipe.pool.FixedObjectPool)3 AbstractRedisTest (com.ctrip.xpipe.redis.core.AbstractRedisTest)3 AbstractSentinelCommand (com.ctrip.xpipe.redis.core.protocal.cmd.AbstractSentinelCommand)3 Replconf (com.ctrip.xpipe.redis.core.protocal.cmd.Replconf)3 DefaultEndPoint (com.ctrip.xpipe.endpoint.DefaultEndPoint)2 XpipeException (com.ctrip.xpipe.exception.XpipeException)2 NettyClientFactory (com.ctrip.xpipe.netty.commands.NettyClientFactory)2 XpipeObjectPoolFromKeyed (com.ctrip.xpipe.pool.XpipeObjectPoolFromKeyed)2 DefaultSlaveOfCommand (com.ctrip.xpipe.redis.core.protocal.cmd.DefaultSlaveOfCommand)2 InMemoryPsync (com.ctrip.xpipe.redis.core.protocal.cmd.InMemoryPsync)2