Search in sources :

Example 1 with NettyClient

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

the class XRedisXpipeCommandTest method getSyncFull.

private Integer getSyncFull(RedisMeta redis) throws Exception {
    SimpleObjectPool<NettyClient> keyPool = getXpipeNettyClientKeyedObjectPool().getKeyPool(new InetSocketAddress(redis.getIp(), redis.getPort()));
    InfoCommand infoCommand = new InfoCommand(keyPool, InfoCommand.INFO_TYPE.STATS, scheduled);
    String value = infoCommand.execute().get();
    Integer sync_full = new InfoResultExtractor(value).extractAsInteger("sync_full");
    return sync_full;
}
Also used : NettyClient(com.ctrip.xpipe.netty.commands.NettyClient) InfoResultExtractor(com.ctrip.xpipe.redis.core.protocal.cmd.InfoResultExtractor) InetSocketAddress(java.net.InetSocketAddress) InfoCommand(com.ctrip.xpipe.redis.core.protocal.cmd.InfoCommand)

Example 2 with NettyClient

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

the class RedisSlaveReplAllTest method makeSlaveReplAll.

public void makeSlaveReplAll(RedisMeta slave, boolean replAll) throws Exception {
    SimpleObjectPool<NettyClient> keyPool = getXpipeNettyClientKeyedObjectPool().getKeyPool(new InetSocketAddress(slave.getIp(), slave.getPort()));
    ConfigSetCommand.ConfigSetReplAll configSetReplAll = new ConfigSetCommand.ConfigSetReplAll(replAll, keyPool, scheduled);
    configSetReplAll.execute().get();
}
Also used : NettyClient(com.ctrip.xpipe.netty.commands.NettyClient) ConfigSetCommand(com.ctrip.xpipe.redis.core.protocal.cmd.ConfigSetCommand) InetSocketAddress(java.net.InetSocketAddress)

Example 3 with NettyClient

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

the class DefaultSentinelManager method getMasterOfMonitor.

@Override
public HostPort getMasterOfMonitor(Sentinel sentinel, String sentinelMonitorName) {
    SimpleObjectPool<NettyClient> clientPool = keyedClientPool.getKeyPool(new InetSocketAddress(sentinel.getIp(), sentinel.getPort()));
    AbstractSentinelCommand.SentinelMaster sentinelMaster = new AbstractSentinelCommand.SentinelMaster(clientPool, scheduled, sentinelMonitorName);
    sentinelMaster.logResponse(false);
    HostPort result = null;
    try {
        result = sentinelMaster.execute().get();
        logger.info("[getMasterOfMonitor]getMasterOfMonitor {} from {} : {}", sentinelMonitorName, sentinel, result);
    } catch (Exception e) {
        logger.error("[getMasterOfMonitor] {} from {} : {}", sentinelMonitorName, sentinel, e.getMessage());
    }
    return result;
}
Also used : NettyClient(com.ctrip.xpipe.netty.commands.NettyClient) InetSocketAddress(java.net.InetSocketAddress) HostPort(com.ctrip.xpipe.endpoint.HostPort) AbstractSentinelCommand(com.ctrip.xpipe.redis.core.protocal.cmd.AbstractSentinelCommand)

Example 4 with NettyClient

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

the class DefaultSentinelManager method removeSentinelMonitor.

@Override
public void removeSentinelMonitor(Sentinel sentinel, String sentinelMonitorName) {
    SimpleObjectPool<NettyClient> clientPool = keyedClientPool.getKeyPool(new InetSocketAddress(sentinel.getIp(), sentinel.getPort()));
    AbstractSentinelCommand.SentinelRemove sentinelRemove = new AbstractSentinelCommand.SentinelRemove(clientPool, sentinelMonitorName, scheduled);
    try {
        String result = sentinelRemove.execute().get();
        logger.info("[removeSentinels]removeSentinelMonitor {} from {} : {}", sentinelMonitorName, sentinel, result);
    } catch (Exception e) {
        logger.error("removeSentinelMonitor {} from {} : {}", sentinelMonitorName, sentinel, e.getMessage());
    }
}
Also used : NettyClient(com.ctrip.xpipe.netty.commands.NettyClient) InetSocketAddress(java.net.InetSocketAddress) AbstractSentinelCommand(com.ctrip.xpipe.redis.core.protocal.cmd.AbstractSentinelCommand)

Example 5 with NettyClient

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

the class AbstractRedisesSlaveofJob method createSlaveofCommand.

private Command<?> createSlaveofCommand(RedisMeta redisMeta, String masterHost, int masterPort) {
    SimpleObjectPool<NettyClient> pool = new XpipeObjectPoolFromKeyed<InetSocketAddress, NettyClient>(clientPool, new InetSocketAddress(redisMeta.getIp(), redisMeta.getPort()));
    Command<?> command = createSlaveOfCommand(pool, masterHost, masterPort);
    return CommandRetryWrapper.buildCountRetry(retryTimes, new RetryDelay(delayBaseMilli) {

        @Override
        public boolean retry(Throwable th) {
            Throwable rootCause = ExceptionUtils.getRootCause(th);
            if (rootCause instanceof RedisError) {
                logger.info("[retry][do not retry, because redis error]{}", rootCause.getMessage());
                return false;
            }
            return super.retry(th);
        }
    }, command, scheduled);
}
Also used : NettyClient(com.ctrip.xpipe.netty.commands.NettyClient) XpipeObjectPoolFromKeyed(com.ctrip.xpipe.pool.XpipeObjectPoolFromKeyed) RedisError(com.ctrip.xpipe.redis.core.protocal.error.RedisError) InetSocketAddress(java.net.InetSocketAddress) RetryDelay(com.ctrip.xpipe.retry.RetryDelay)

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