Search in sources :

Example 1 with XSlaveofCommand

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

the class TransactionalSlaveOfCommand method doExecute.

@Override
protected void doExecute() throws CommandExecutionException {
    logger.info("[doExecute][try xslaveof]{}", this);
    TransactionalCommand slaveofTransaction = new TransactionalCommand(getClientPool(), scheduled, new XSlaveofCommand(null, ip, port, scheduled), new ConfigRewrite(null, scheduled));
    try {
        slaveofTransaction.execute().addListener(new CommandFutureListener<Object[]>() {

            @Override
            public void operationComplete(CommandFuture<Object[]> commandFuture) throws Exception {
                if (!commandFuture.isSuccess()) {
                    failXslaveof(commandFuture.cause());
                } else {
                    logger.info("[doExecute][xslaveof success]{}", this);
                    future().setSuccess(commandFuture.get());
                }
            }
        });
    } catch (Exception e) {
        failXslaveof(e);
    }
}
Also used : XSlaveofCommand(com.ctrip.xpipe.redis.core.protocal.cmd.XSlaveofCommand) ConfigRewrite(com.ctrip.xpipe.redis.core.protocal.cmd.ConfigRewrite) IOException(java.io.IOException) CommandExecutionException(com.ctrip.xpipe.command.CommandExecutionException)

Example 2 with XSlaveofCommand

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

the class XSlaveofTest method test.

@Test
public void test() throws Exception {
    XSlaveofCommand command = new XSlaveofCommand(clientPool, "10.2.58.242", 6479, scheduled);
    command.execute().get();
}
Also used : XSlaveofCommand(com.ctrip.xpipe.redis.core.protocal.cmd.XSlaveofCommand) Test(org.junit.Test)

Aggregations

XSlaveofCommand (com.ctrip.xpipe.redis.core.protocal.cmd.XSlaveofCommand)2 CommandExecutionException (com.ctrip.xpipe.command.CommandExecutionException)1 ConfigRewrite (com.ctrip.xpipe.redis.core.protocal.cmd.ConfigRewrite)1 IOException (java.io.IOException)1 Test (org.junit.Test)1