Search in sources :

Example 1 with RedisCommand

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

the class TransactionalCommand method doWork.

@SuppressWarnings("unchecked")
protected void doWork(final SimpleObjectPool<NettyClient> clientPool) {
    SequenceCommandChain chain = new SequenceCommandChain(false);
    for (RedisCommand currentCommand : commands) {
        OneTranscationCommand oneTranscationCommand = new OneTranscationCommand(clientPool, currentCommand, scheduled);
        chain.add(oneTranscationCommand);
    }
    chain.execute().addListener(new CommandFutureListener() {

        @Override
        public void operationComplete(CommandFuture commandFuture) throws Exception {
            if (!commandFuture.isSuccess()) {
                logger.error("[doWork][fail]", commandFuture.cause());
            }
            endTranscation(clientPool);
        }
    });
}
Also used : CommandFuture(com.ctrip.xpipe.api.command.CommandFuture) CommandFutureListener(com.ctrip.xpipe.api.command.CommandFutureListener) AbstractRedisCommand(com.ctrip.xpipe.redis.core.protocal.cmd.AbstractRedisCommand) RedisCommand(com.ctrip.xpipe.redis.core.protocal.RedisCommand) CommandExecutionException(com.ctrip.xpipe.command.CommandExecutionException) ReturnObjectException(com.ctrip.xpipe.pool.ReturnObjectException) BorrowObjectException(com.ctrip.xpipe.pool.BorrowObjectException) SequenceCommandChain(com.ctrip.xpipe.command.SequenceCommandChain)

Aggregations

CommandFuture (com.ctrip.xpipe.api.command.CommandFuture)1 CommandFutureListener (com.ctrip.xpipe.api.command.CommandFutureListener)1 CommandExecutionException (com.ctrip.xpipe.command.CommandExecutionException)1 SequenceCommandChain (com.ctrip.xpipe.command.SequenceCommandChain)1 BorrowObjectException (com.ctrip.xpipe.pool.BorrowObjectException)1 ReturnObjectException (com.ctrip.xpipe.pool.ReturnObjectException)1 RedisCommand (com.ctrip.xpipe.redis.core.protocal.RedisCommand)1 AbstractRedisCommand (com.ctrip.xpipe.redis.core.protocal.cmd.AbstractRedisCommand)1