use of com.ctrip.xpipe.command.CommandExecutionException in project x-pipe by ctripcorp.
the class AbstractRedisesSlaveofJob method doExecute.
@Override
protected void doExecute() throws CommandExecutionException {
ParallelCommandChain commandChain = new ParallelCommandChain(executors);
for (RedisMeta redisMeta : redises) {
Command<?> backupCommand = createSlaveofCommand(redisMeta, masterHost, masterPort);
commandChain.add(backupCommand);
}
commandChain.execute().addListener(new CommandFutureListener<Object>() {
@Override
public void operationComplete(CommandFuture<Object> commandFuture) throws Exception {
if (commandFuture.isSuccess()) {
future().setSuccess(null);
} else {
future().setFailure(commandFuture.cause());
}
}
});
}
use of com.ctrip.xpipe.command.CommandExecutionException in project x-pipe by ctripcorp.
the class RequestResponseCommandTest method testException.
@Test
public void testException() throws CommandExecutionException {
Exception exception = new Exception();
TestCommand testCommand = new TestCommand("something\r\n", 0, clientPool, scheduled, exception);
CommandFuture<String> future = testCommand.execute();
try {
future.get();
Assert.fail();
} catch (InterruptedException e) {
Assert.fail();
} catch (ExecutionException e) {
Assert.assertEquals(exception, e.getCause());
}
}
use of com.ctrip.xpipe.command.CommandExecutionException 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.command.CommandExecutionException 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());
}
}
});
}
use of com.ctrip.xpipe.command.CommandExecutionException in project x-pipe by ctripcorp.
the class TransactionalCommand method doExecute.
@Override
protected void doExecute() throws CommandExecutionException {
try {
final NettyClient nettyClient = parentClientPool.borrowObject();
SimpleObjectPool<NettyClient> clientPool = new FixedObjectPool<NettyClient>(nettyClient);
startTransaction(clientPool);
future().addListener(new CommandFutureListener<Object[]>() {
@Override
public void operationComplete(CommandFuture<Object[]> commandFuture) throws Exception {
if (nettyClient != null) {
try {
parentClientPool.returnObject(nettyClient);
} catch (ReturnObjectException e) {
logger.error("[doExecute]" + this, e);
}
}
}
});
} catch (BorrowObjectException e) {
throw new CommandExecutionException("execute " + this, e);
}
}
Aggregations