Search in sources :

Example 1 with KeeperSetStateCommand

use of com.ctrip.xpipe.redis.core.protocal.cmd.AbstractKeeperCommand.KeeperSetStateCommand in project x-pipe by ctripcorp.

the class AbstractKeeperIntegrated method setKeeperState.

protected void setKeeperState(KeeperMeta keeperMeta, KeeperState keeperState, String ip, Integer port, boolean sync) throws Exception {
    KeeperSetStateCommand command = new KeeperSetStateCommand(keeperMeta, keeperState, new Pair<String, Integer>(ip, port), scheduled);
    CommandFuture<?> future = command.execute();
    if (sync) {
        future.sync();
    }
}
Also used : KeeperSetStateCommand(com.ctrip.xpipe.redis.core.protocal.cmd.AbstractKeeperCommand.KeeperSetStateCommand)

Example 2 with KeeperSetStateCommand

use of com.ctrip.xpipe.redis.core.protocal.cmd.AbstractKeeperCommand.KeeperSetStateCommand in project x-pipe by ctripcorp.

the class KeeperStateChangeJob method createKeeperSetStateCommand.

private Command<?> createKeeperSetStateCommand(KeeperMeta keeper, Pair<String, Integer> masterAddress) {
    SimpleObjectPool<NettyClient> pool = new XpipeObjectPoolFromKeyed<InetSocketAddress, NettyClient>(clientPool, new InetSocketAddress(keeper.getIp(), keeper.getPort()));
    KeeperSetStateCommand command = new KeeperSetStateCommand(pool, keeper.isActive() ? KeeperState.ACTIVE : KeeperState.BACKUP, masterAddress, scheduled);
    return CommandRetryWrapper.buildCountRetry(retryTimes, new RetryDelay(delayBaseMilli), command, scheduled);
}
Also used : NettyClient(com.ctrip.xpipe.netty.commands.NettyClient) XpipeObjectPoolFromKeyed(com.ctrip.xpipe.pool.XpipeObjectPoolFromKeyed) InetSocketAddress(java.net.InetSocketAddress) RetryDelay(com.ctrip.xpipe.retry.RetryDelay) KeeperSetStateCommand(com.ctrip.xpipe.redis.core.protocal.cmd.AbstractKeeperCommand.KeeperSetStateCommand)

Aggregations

KeeperSetStateCommand (com.ctrip.xpipe.redis.core.protocal.cmd.AbstractKeeperCommand.KeeperSetStateCommand)2 NettyClient (com.ctrip.xpipe.netty.commands.NettyClient)1 XpipeObjectPoolFromKeyed (com.ctrip.xpipe.pool.XpipeObjectPoolFromKeyed)1 RetryDelay (com.ctrip.xpipe.retry.RetryDelay)1 InetSocketAddress (java.net.InetSocketAddress)1