Search in sources :

Example 1 with UntilSuccess

use of com.ctrip.xpipe.command.UntilSuccess in project x-pipe by ctripcorp.

the class DefaultSlaveOfCommand method doExecute.

@Override
protected void doExecute() throws CommandExecutionException {
    SimpleObjectPool<NettyClient> clientPool = getClientPool();
    UntilSuccess slaveOf = new UntilSuccess();
    slaveOf.add(new XSlaveofCommand(clientPool, ip, port, scheduled));
    slaveOf.add(new SlaveOfCommand(clientPool, ip, port, scheduled));
    SequenceCommandChain chain = new SequenceCommandChain(false);
    chain.add(slaveOf);
    chain.add(new ConfigRewrite(clientPool, scheduled));
    chain.execute().addListener(new CommandFutureListener<Object>() {

        @Override
        public void operationComplete(CommandFuture<Object> commandFuture) throws Exception {
            if (commandFuture.isSuccess()) {
                future().setSuccess(RedisClientProtocol.OK);
            } else {
                future().setFailure(commandFuture.cause());
            }
        }
    });
}
Also used : NettyClient(com.ctrip.xpipe.netty.commands.NettyClient) UntilSuccess(com.ctrip.xpipe.command.UntilSuccess) CommandExecutionException(com.ctrip.xpipe.command.CommandExecutionException) SequenceCommandChain(com.ctrip.xpipe.command.SequenceCommandChain)

Aggregations

CommandExecutionException (com.ctrip.xpipe.command.CommandExecutionException)1 SequenceCommandChain (com.ctrip.xpipe.command.SequenceCommandChain)1 UntilSuccess (com.ctrip.xpipe.command.UntilSuccess)1 NettyClient (com.ctrip.xpipe.netty.commands.NettyClient)1