// handle message and ack.
ResponseSender sender = new ResponseSenderImpl(connection, msg.coordinationId);
try {
handle(connection, msg.rpcType, msg.pBody, msg.dBody, sender);
} catch(UserRpcException e){
DrillPBError error = ErrorHelper.logAndConvertError(e.getEndpoint(), e.getUserMessage(), e, logger);
OutboundRpcMessage outMessage = new OutboundRpcMessage(RpcMode.RESPONSE_FAILURE, 0, msg.coordinationId, error);
if (RpcConstants.EXTRA_DEBUGGING) {
logger.debug("Adding message to outbound buffer. {}", outMessage);
}
connection.getChannel().writeAndFlush(outMessage);
}
msg.release(); // we release our ownership. Handle could have taken over ownership.
break;
}
case RESPONSE:
try{
MessageLite m = getResponseDefaultInstance(msg.rpcType);
assert rpcConfig.checkReceive(msg.rpcType, m.getClass());
RpcOutcome<?> rpcFuture = queue.getFuture(msg.rpcType, msg.coordinationId, m.getClass());
Parser<?> parser = m.getParserForType();
Object value = parser.parseFrom(new ByteBufInputStream(msg.pBody, msg.pBody.readableBytes()));
rpcFuture.set(value, msg.dBody);
msg.release(); // we release our ownership. Handle could have taken over ownership.
if (RpcConstants.EXTRA_DEBUGGING) {
logger.debug("Updated rpc future {} with value {}", rpcFuture, value);
}
}catch(Exception ex) {
logger.error("Failure while handling response.", ex);
throw ex;
}
break;
case RESPONSE_FAILURE:
DrillPBError failure = DrillPBError.parseFrom(new ByteBufInputStream(msg.pBody, msg.pBody.readableBytes()));
queue.updateFailedFuture(msg.coordinationId, failure);
msg.release();
if (RpcConstants.EXTRA_DEBUGGING) {
logger.debug("Updated rpc future with coordinationId {} with failure ", msg.coordinationId, failure);
}