HBASE-17387 Reduce the overhead of exception report in RegionActionResult for multi()

This commit is contained in:
tedyu 2016-12-29 19:23:44 -08:00
parent cec40f941f
commit 36f16bbe10
1 changed files with 12 additions and 9 deletions

View File

@ -646,8 +646,11 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
RpcCallContext context = RpcServer.getCurrentCall();
IOException sizeIOE = null;
Object lastBlock = null;
ClientProtos.ResultOrException.Builder resultOrExceptionBuilder = ResultOrException.newBuilder();
boolean hasResultOrException = false;
for (ClientProtos.Action action : actions.getActionList()) {
ClientProtos.ResultOrException.Builder resultOrExceptionBuilder = null;
hasResultOrException = false;
resultOrExceptionBuilder.clear();
try {
Result r = null;
@ -676,8 +679,8 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
// use it for the response.
//
// This will create a copy in the builder.
resultOrExceptionBuilder = ResultOrException.newBuilder().
setException(ResponseConverter.buildException(sizeIOE));
hasResultOrException = true;
resultOrExceptionBuilder.setException(ResponseConverter.buildException(sizeIOE));
resultOrExceptionBuilder.setIndex(action.getIndex());
builder.addResultOrException(resultOrExceptionBuilder.build());
if (cellScanner != null) {
@ -697,7 +700,7 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
}
}
} else if (action.hasServiceCall()) {
resultOrExceptionBuilder = ResultOrException.newBuilder();
hasResultOrException = true;
try {
Message result = execServiceOnRegion(region, action.getServiceCall());
ClientProtos.CoprocessorServiceResult.Builder serviceResultBuilder =
@ -753,8 +756,8 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
pbResult = ProtobufUtil.toResult(r);
}
lastBlock = addSize(context, r, lastBlock);
resultOrExceptionBuilder =
ClientProtos.ResultOrException.newBuilder().setResult(pbResult);
hasResultOrException = true;
resultOrExceptionBuilder.setResult(pbResult);
}
// Could get to here and there was no result and no exception. Presumes we added
// a Put or Delete to the collecting Mutations List for adding later. In this
@ -762,10 +765,10 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
// down in the doBatchOp method call rather than up here.
} catch (IOException ie) {
rpcServer.getMetrics().exception(ie);
resultOrExceptionBuilder = ResultOrException.newBuilder().
setException(ResponseConverter.buildException(ie));
hasResultOrException = true;
resultOrExceptionBuilder.setException(ResponseConverter.buildException(ie));
}
if (resultOrExceptionBuilder != null) {
if (hasResultOrException) {
// Propagate index.
resultOrExceptionBuilder.setIndex(action.getIndex());
builder.addResultOrException(resultOrExceptionBuilder.build());