use of com.ctrip.xpipe.pool.ReturnObjectException 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);
}
}
use of com.ctrip.xpipe.pool.ReturnObjectException in project x-pipe by ctripcorp.
the class AbstractNettyCommand method doExecute.
@Override
protected void doExecute() throws CommandExecutionException {
NettyClient nettyClient = null;
try {
logger.debug("[doExecute]{}", this);
nettyClient = clientPool.borrowObject();
ByteBuf byteBuf = getRequest();
doSendRequest(nettyClient, byteBuf);
} catch (BorrowObjectException e) {
throw new CommandExecutionException("execute " + this, e);
} finally {
if (nettyClient != null) {
try {
clientPool.returnObject(nettyClient);
} catch (ReturnObjectException e) {
logger.error("[doExecute]", e);
}
}
if (poolCreated) {
future().addListener(new CommandFutureListener<V>() {
@Override
public void operationComplete(CommandFuture<V> commandFuture) throws Exception {
LifecycleHelper.stopIfPossible(clientPool);
LifecycleHelper.disposeIfPossible(clientPool);
}
});
}
}
}
Aggregations