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

This commit is contained in:
tedyu 2016-12-29 17:54:02 -08:00
parent 7572e96e3a
commit 1c477b2df9
1 changed files with 12 additions and 9 deletions

View File

@ -719,8 +719,11 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
long maxQuotaResultSize = Math.min(maxScannerResultSize, quota.getReadAvailable()); long maxQuotaResultSize = Math.min(maxScannerResultSize, quota.getReadAvailable());
IOException sizeIOE = null; IOException sizeIOE = null;
Object lastBlock = null; Object lastBlock = null;
ClientProtos.ResultOrException.Builder resultOrExceptionBuilder = ResultOrException.newBuilder();
boolean hasResultOrException = false;
for (ClientProtos.Action action : actions.getActionList()) { for (ClientProtos.Action action : actions.getActionList()) {
ClientProtos.ResultOrException.Builder resultOrExceptionBuilder = null; hasResultOrException = false;
resultOrExceptionBuilder.clear();
try { try {
Result r = null; Result r = null;
@ -749,8 +752,8 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
// use it for the response. // use it for the response.
// //
// This will create a copy in the builder. // This will create a copy in the builder.
resultOrExceptionBuilder = ResultOrException.newBuilder(). hasResultOrException = true;
setException(ResponseConverter.buildException(sizeIOE)); resultOrExceptionBuilder.setException(ResponseConverter.buildException(sizeIOE));
resultOrExceptionBuilder.setIndex(action.getIndex()); resultOrExceptionBuilder.setIndex(action.getIndex());
builder.addResultOrException(resultOrExceptionBuilder.build()); builder.addResultOrException(resultOrExceptionBuilder.build());
if (cellScanner != null) { if (cellScanner != null) {
@ -774,7 +777,7 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
} }
} }
} else if (action.hasServiceCall()) { } else if (action.hasServiceCall()) {
resultOrExceptionBuilder = ResultOrException.newBuilder(); hasResultOrException = true;
try { try {
com.google.protobuf.Message result = com.google.protobuf.Message result =
execServiceOnRegion(region, action.getServiceCall()); execServiceOnRegion(region, action.getServiceCall());
@ -832,8 +835,8 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
pbResult = ProtobufUtil.toResult(r); pbResult = ProtobufUtil.toResult(r);
} }
lastBlock = addSize(context, r, lastBlock); lastBlock = addSize(context, r, lastBlock);
resultOrExceptionBuilder = hasResultOrException = true;
ClientProtos.ResultOrException.newBuilder().setResult(pbResult); resultOrExceptionBuilder.setResult(pbResult);
} }
// Could get to here and there was no result and no exception. Presumes we added // 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 // a Put or Delete to the collecting Mutations List for adding later. In this
@ -841,10 +844,10 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
// down in the doBatchOp method call rather than up here. // down in the doBatchOp method call rather than up here.
} catch (IOException ie) { } catch (IOException ie) {
rpcServer.getMetrics().exception(ie); rpcServer.getMetrics().exception(ie);
resultOrExceptionBuilder = ResultOrException.newBuilder(). hasResultOrException = true;
setException(ResponseConverter.buildException(ie)); resultOrExceptionBuilder.setException(ResponseConverter.buildException(ie));
} }
if (resultOrExceptionBuilder != null) { if (hasResultOrException) {
// Propagate index. // Propagate index.
resultOrExceptionBuilder.setIndex(action.getIndex()); resultOrExceptionBuilder.setIndex(action.getIndex());
builder.addResultOrException(resultOrExceptionBuilder.build()); builder.addResultOrException(resultOrExceptionBuilder.build());