HBASE-19366 Backport to branch-1 HBASE-19035 Miss metrics when coprocessor use region scanner to read data

Signed-off-by: Andrew Purtell <apurtell@apache.org>
This commit is contained in:
Guanghao Zhang 2017-11-12 16:15:22 +08:00 committed by Andrew Purtell
parent 525b2852e8
commit 25cc8feeb2
3 changed files with 9 additions and 16 deletions

View File

@ -297,8 +297,10 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
final Counter checkAndMutateChecksPassed = new Counter();
final Counter checkAndMutateChecksFailed = new Counter();
//Number of requests
// Number of requests
// Count rows for scan
final Counter readRequestsCount = new Counter();
// Count rows for multi row mutations
final Counter writeRequestsCount = new Counter();
// Number of requests blocked by memstore size.
@ -2728,7 +2730,6 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
// closest key is across all column families, since the data may be sparse
checkRow(row, "getClosestRowBefore");
startRegionOperation(Operation.GET);
this.readRequestsCount.increment();
try {
Result result = null;
Get get = new Get(row);
@ -6094,7 +6095,6 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
"or a lengthy garbage collection");
}
startRegionOperation(Operation.SCAN);
readRequestsCount.increment();
try {
return nextRaw(outResults, scannerContext);
} finally {
@ -6126,6 +6126,10 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
outResults.addAll(tmpList);
}
if (!outResults.isEmpty()) {
readRequestsCount.increment();
}
// If the size limit was reached it means a partial Result is being returned. Returning a
// partial Result means that we should not reset the filters; filters should only be reset in
// between rows
@ -7349,7 +7353,6 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
@Override
public void mutateRowsWithLocks(Collection<Mutation> mutations,
Collection<byte[]> rowsToLock, long nonceGroup, long nonce) throws IOException {
writeRequestsCount.add(mutations.size());
MultiRowMutationProcessor proc = new MultiRowMutationProcessor(mutations, rowsToLock);
processRowsWithLocks(proc, -1, nonceGroup, nonce);
}
@ -7455,7 +7458,7 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
processor, now, this, mutations, walEdit, timeout);
if (!mutations.isEmpty()) {
writeRequestsCount.add(mutations.size());
// 5. Call the preBatchMutate hook
processor.preBatchMutate(this, walEdit);

View File

@ -181,7 +181,7 @@ class MetricsRegionServerWrapperImpl
@Override
public long getTotalRowActionRequestCount() {
return regionServer.rpcServices.requestRowActionCount.get();
return readRequestsCount + writeRequestsCount;
}
@Override

View File

@ -238,10 +238,6 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
// Count only once for requests with multiple actions like multi/caching-scan/replayBatch
final Counter requestCount = new Counter();
// Request counter. (Excludes requests that are not serviced by regions.)
// Count rows for requests with multiple actions like multi/caching-scan/replayBatch
final Counter requestRowActionCount = new Counter();
// Request counter for rpc get
final Counter rpcGetRequestCount = new Counter();
@ -998,7 +994,6 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
}
}
requestCount.increment();
requestRowActionCount.add(mutations.size());
if (!region.getRegionInfo().isMetaTable()) {
regionServer.cacheFlusher.reclaimMemStoreMemory();
}
@ -2207,7 +2202,6 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
try {
checkOpen();
requestCount.increment();
requestRowActionCount.increment();
rpcGetRequestCount.increment();
region = getRegion(request.getRegion());
@ -2330,7 +2324,6 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
Map<RegionSpecifier, ClientProtos.RegionLoadStats> regionStats = new HashMap<>(request
.getRegionActionCount());
for (RegionAction regionAction : request.getRegionActionList()) {
this.requestRowActionCount.add(regionAction.getActionCount());
OperationQuota quota;
Region region;
regionActionResultBuilder.clear();
@ -2456,7 +2449,6 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
try {
checkOpen();
requestCount.increment();
requestRowActionCount.increment();
rpcMutateRequestCount.increment();
region = getRegion(request.getRegion());
MutateResponse.Builder builder = MutateResponse.newBuilder();
@ -2895,8 +2887,6 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
builder.setScanMetrics(metricBuilder.build());
}
}
region.updateReadRequestsCount(numOfResults);
requestRowActionCount.add(numOfResults);
long end = EnvironmentEdgeManager.currentTime();
long responseCellSize = context != null ? context.getResponseCellSize() : 0;
region.getMetrics().updateScanTime(end - before);