use of com.ctrip.xpipe.redis.core.protocal.cmd.PingCommand in project x-pipe by ctripcorp.
the class DefaultSlaveOfCommandTest method testMultiServer.
@Test
public void testMultiServer() throws Exception {
int begin = 10000;
int count = 32;
// make connection active
for (int i = 0; i < count; i++) {
int port = begin + i;
SimpleObjectPool<NettyClient> keyPool = getXpipeNettyClientKeyedObjectPool().getKeyPool(new InetSocketAddress("127.0.0.1", port));
new PingCommand(keyPool, scheduled).execute().get();
}
CountDownLatch latch = new CountDownLatch(count);
for (int i = 0; i < count; i++) {
int port = begin + i;
SimpleObjectPool<NettyClient> keyPool = getXpipeNettyClientKeyedObjectPool().getKeyPool(new InetSocketAddress("127.0.0.1", port));
long beginTime = System.currentTimeMillis();
new DefaultSlaveOfCommand(keyPool, "127.0.0.1", 0, scheduled).execute(executors).addListener(new CommandFutureListener<String>() {
@Override
public void operationComplete(CommandFuture<String> commandFuture) throws Exception {
long endTime = System.currentTimeMillis();
long duration = endTime - beginTime;
if (duration > 50) {
logger.warn("[timeout]127.0.0.1:{}, {}", port, duration);
}
latch.countDown();
}
});
}
latch.await();
sleep(1000);
logger.info("[testMultiServer][end]");
}
Aggregations