Search in sources :

Example 1 with XpipeNettyClientKeyedObjectPool

use of com.ctrip.xpipe.pool.XpipeNettyClientKeyedObjectPool in project x-pipe by ctripcorp.

the class ConsoleContextConfig method getClientPool.

@Bean
public XpipeNettyClientKeyedObjectPool getClientPool() throws Exception {
    XpipeNettyClientKeyedObjectPool keyedObjectPool = new XpipeNettyClientKeyedObjectPool();
    keyedObjectPool.initialize();
    keyedObjectPool.start();
    return keyedObjectPool;
}
Also used : XpipeNettyClientKeyedObjectPool(com.ctrip.xpipe.pool.XpipeNettyClientKeyedObjectPool) FilterRegistrationBean(org.springframework.boot.context.embedded.FilterRegistrationBean)

Example 2 with XpipeNettyClientKeyedObjectPool

use of com.ctrip.xpipe.pool.XpipeNettyClientKeyedObjectPool in project x-pipe by ctripcorp.

the class AbstractRedisCommandTest method testLogRequest.

// manual test
@Test
public void testLogRequest() throws Exception {
    XpipeNettyClientKeyedObjectPool keyedObjectPool = getXpipeNettyClientKeyedObjectPool();
    SimpleObjectPool<NettyClient> clientPool = keyedObjectPool.getKeyPool(new InetSocketAddress("127.0.0.1", 6379));
    ScheduledExecutorService scheduled = Executors.newScheduledThreadPool(1);
    InfoCommand infoCommand = new InfoCommand(clientPool, InfoCommand.INFO_TYPE.REPLICATION, scheduled);
    infoCommand.logResponse(false);
    // infoCommand.logRequest(false);
    infoCommand.execute().get();
}
Also used : NettyClient(com.ctrip.xpipe.netty.commands.NettyClient) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) InetSocketAddress(java.net.InetSocketAddress) XpipeNettyClientKeyedObjectPool(com.ctrip.xpipe.pool.XpipeNettyClientKeyedObjectPool) AbstractRedisTest(com.ctrip.xpipe.redis.core.AbstractRedisTest) Test(org.junit.Test)

Example 3 with XpipeNettyClientKeyedObjectPool

use of com.ctrip.xpipe.pool.XpipeNettyClientKeyedObjectPool in project x-pipe by ctripcorp.

the class AbstractTest method getXpipeNettyClientKeyedObjectPool.

protected XpipeNettyClientKeyedObjectPool getXpipeNettyClientKeyedObjectPool() throws Exception {
    XpipeNettyClientKeyedObjectPool result;
    try {
        result = getBean(XpipeNettyClientKeyedObjectPool.class);
    } catch (Exception e) {
        result = new XpipeNettyClientKeyedObjectPool();
        add(result);
    }
    LifecycleHelper.initializeIfPossible(result);
    LifecycleHelper.startIfPossible(result);
    return result;
}
Also used : XpipeNettyClientKeyedObjectPool(com.ctrip.xpipe.pool.XpipeNettyClientKeyedObjectPool)

Example 4 with XpipeNettyClientKeyedObjectPool

use of com.ctrip.xpipe.pool.XpipeNettyClientKeyedObjectPool in project x-pipe by ctripcorp.

the class TransactionalSlaveOfCommandTest method testXslaveof.

@SuppressWarnings("deprecation")
@Test
public void testXslaveof() throws Exception {
    XpipeNettyClientKeyedObjectPool pool = getXpipeNettyClientKeyedObjectPool();
    for (int i = 0; i < testCount; i++) {
        logger.info(remarkableMessage("{}"), i);
        TransactionalSlaveOfCommand command = new TransactionalSlaveOfCommand(getXpipeNettyClientKeyedObjectPool().getKeyPool(new InetSocketAddress(ip, port)), ip, port, scheduled);
        Object[] result = command.execute().get();
        logger.info("{}", (Object) result);
        Assert.assertEquals(0, pool.getObjectPool().getNumActive());
        Assert.assertEquals(1, pool.getObjectPool().getNumIdle());
    }
}
Also used : InetSocketAddress(java.net.InetSocketAddress) XpipeNettyClientKeyedObjectPool(com.ctrip.xpipe.pool.XpipeNettyClientKeyedObjectPool) AbstractRedisTest(com.ctrip.xpipe.redis.core.AbstractRedisTest) Test(org.junit.Test)

Aggregations

XpipeNettyClientKeyedObjectPool (com.ctrip.xpipe.pool.XpipeNettyClientKeyedObjectPool)4 AbstractRedisTest (com.ctrip.xpipe.redis.core.AbstractRedisTest)2 InetSocketAddress (java.net.InetSocketAddress)2 Test (org.junit.Test)2 NettyClient (com.ctrip.xpipe.netty.commands.NettyClient)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 FilterRegistrationBean (org.springframework.boot.context.embedded.FilterRegistrationBean)1