diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java index 06f2990fb78..129e01db9ba 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java @@ -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 mutations, Collection 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); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerWrapperImpl.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerWrapperImpl.java index 31cfbd16666..9ba6cc0b2d8 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerWrapperImpl.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerWrapperImpl.java @@ -181,7 +181,7 @@ class MetricsRegionServerWrapperImpl @Override public long getTotalRowActionRequestCount() { - return regionServer.rpcServices.requestRowActionCount.get(); + return readRequestsCount + writeRequestsCount; } @Override diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java index 3ac08f49824..6ea522e3827 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java @@ -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 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);