use of com.ctrip.xpipe.redis.core.protocal.cmd.ConfigRewrite 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);
}
}
use of com.ctrip.xpipe.redis.core.protocal.cmd.ConfigRewrite in project x-pipe by ctripcorp.
the class TransactionalSlaveOfCommand method failXslaveof.
private void failXslaveof(Throwable e) {
Throwable rootCause = ExceptionUtils.getRootCause(e);
if ((rootCause instanceof IOException)) {
logger.info("[failXslaveof][do not try slaveof]");
fail(e);
return;
}
logger.error("[doExecute][xlaveof fail, try slaveof]" + ip + ":" + port, e);
TransactionalCommand slaveofTransaction = new TransactionalCommand(getClientPool(), scheduled, new SlaveOfCommand(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()) {
fail(commandFuture.cause());
} else {
logger.info("[doExecute][slaveof success]{}", this);
future().setSuccess(commandFuture.get());
}
}
});
} catch (Exception ex) {
fail(ex);
}
}
use of com.ctrip.xpipe.redis.core.protocal.cmd.ConfigRewrite in project x-pipe by ctripcorp.
the class MinSlavesRedisReadOnly method createTransactionalCommand.
private Command<?> createTransactionalCommand(int number) {
SimpleObjectPool<NettyClient> clientPool = keyedObjectPool.getKeyPool(new InetSocketAddress(ip, port));
ConfigSetMinSlavesToWrite configSetMinSlavesToWrite = new ConfigSetMinSlavesToWrite(null, number, scheduled);
return new TransactionalCommand(clientPool, scheduled, configSetMinSlavesToWrite, new ConfigRewrite(null, scheduled));
}
Aggregations