diff --git a/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerSource.java b/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerSource.java index b263e563b5f..51683a14c40 100644 --- a/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerSource.java +++ b/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerSource.java @@ -289,4 +289,16 @@ public interface MetricsRegionServerSource extends BaseSource { String SPLIT_SUCCESS_KEY = "splitSuccessCount"; String SPLIT_SUCCESS_DESC = "Number of successfully executed splits"; String FLUSH_KEY = "flushTime"; + + String RPC_GET_REQUEST_COUNT = "rpcGetRequestCount"; + String RPC_GET_REQUEST_COUNT_DESC = "Number of rpc get requests this region server has answered."; + String RPC_SCAN_REQUEST_COUNT = "rpcScanRequestCount"; + String RPC_SCAN_REQUEST_COUNT_DESC = + "Number of rpc scan requests this region server has answered."; + String RPC_MULTI_REQUEST_COUNT = "rpcMultiRequestCount"; + String RPC_MULTI_REQUEST_COUNT_DESC = + "Number of rpc multi requests this region server has answered."; + String RPC_MUTATE_REQUEST_COUNT = "rpcMutateRequestCount"; + String RPC_MUTATE_REQUEST_COUNT_DESC = + "Number of rpc mutation requests this region server has answered."; } diff --git a/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerWrapper.java b/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerWrapper.java index 7bb0de1e343..048f797b42d 100644 --- a/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerWrapper.java +++ b/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerWrapper.java @@ -282,4 +282,24 @@ public interface MetricsRegionServerWrapper { * @return Count of requests blocked because the memstore size is larger than blockingMemStoreSize */ long getBlockedRequestsCount(); + + /** + * Get the number of rpc get requests to this region server. + */ + long getRpcGetRequestsCount(); + + /** + * Get the number of rpc scan requests to this region server. + */ + long getRpcScanRequestsCount(); + + /** + * Get the number of rpc multi requests to this region server. + */ + long getRpcMultiRequestsCount(); + + /** + * Get the number of rpc mutate requests to this region server. + */ + long getRpcMutateRequestsCount(); } diff --git a/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerSourceImpl.java b/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerSourceImpl.java index 2537f8ece9c..7d392e8eab3 100644 --- a/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerSourceImpl.java +++ b/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerSourceImpl.java @@ -203,6 +203,14 @@ public class MetricsRegionServerSourceImpl rsWrap.getReadRequestsCount()) .addCounter(Interns.info(WRITE_REQUEST_COUNT, WRITE_REQUEST_COUNT_DESC), rsWrap.getWriteRequestsCount()) + .addCounter(Interns.info(RPC_GET_REQUEST_COUNT, RPC_GET_REQUEST_COUNT_DESC), + rsWrap.getRpcGetRequestsCount()) + .addCounter(Interns.info(RPC_SCAN_REQUEST_COUNT, RPC_SCAN_REQUEST_COUNT_DESC), + rsWrap.getRpcScanRequestsCount()) + .addCounter(Interns.info(RPC_MULTI_REQUEST_COUNT, RPC_MULTI_REQUEST_COUNT_DESC), + rsWrap.getRpcMultiRequestsCount()) + .addCounter(Interns.info(RPC_MUTATE_REQUEST_COUNT, RPC_MUTATE_REQUEST_COUNT_DESC), + rsWrap.getRpcMutateRequestsCount()) .addCounter(Interns.info(CHECK_MUTATE_FAILED_COUNT, CHECK_MUTATE_FAILED_COUNT_DESC), rsWrap.getCheckAndMutateChecksFailed()) .addCounter(Interns.info(CHECK_MUTATE_PASSED_COUNT, CHECK_MUTATE_PASSED_COUNT_DESC), diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java index 16e0519270b..46cc8e41311 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java @@ -2296,6 +2296,10 @@ public class HRegionServer extends HasThread implements RegionServerStartupResponse result = null; try { rpcServices.requestCount.set(0); + rpcServices.rpcGetRequestCount.set(0); + rpcServices.rpcScanRequestCount.set(0); + rpcServices.rpcMultiRequestCount.set(0); + rpcServices.rpcMutateRequestCount.set(0); LOG.info("reportForDuty to master=" + masterServerName + " with port=" + rpcServices.isa.getPort() + ", startcode=" + this.startcode); long now = EnvironmentEdgeManager.currentTime(); 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 b179956bcc8..e7827c86e2e 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 @@ -363,6 +363,26 @@ class MetricsRegionServerWrapperImpl return writeRequestsCount; } + @Override + public long getRpcGetRequestsCount() { + return regionServer.rpcServices.rpcGetRequestCount.get(); + } + + @Override + public long getRpcScanRequestsCount() { + return regionServer.rpcServices.rpcScanRequestCount.get(); + } + + @Override + public long getRpcMultiRequestsCount() { + return regionServer.rpcServices.rpcMultiRequestCount.get(); + } + + @Override + public long getRpcMutateRequestsCount() { + return regionServer.rpcServices.rpcMutateRequestCount.get(); + } + @Override public long getCheckAndMutateChecksFailed() { return checkAndMutateChecksFailed; 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 3fcb6d76a06..f9b2b7b54d4 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 @@ -218,6 +218,19 @@ public class RSRpcServices implements HBaseRPCErrorHandler, // Request counter. (Includes requests that are not serviced by regions.) final Counter requestCount = new Counter(); + + // Request counter for rpc get + final Counter rpcGetRequestCount = new Counter(); + + // Request counter for rpc scan + final Counter rpcScanRequestCount = new Counter(); + + // Request counter for rpc multi + final Counter rpcMultiRequestCount = new Counter(); + + // Request counter for rpc mutate + final Counter rpcMutateRequestCount = new Counter(); + // Server to handle client requests. final RpcServerInterface rpcServer; final InetSocketAddress isa; @@ -2020,6 +2033,7 @@ public class RSRpcServices implements HBaseRPCErrorHandler, try { checkOpen(); requestCount.increment(); + rpcGetRequestCount.increment(); Region region = getRegion(request.getRegion()); GetResponse.Builder builder = GetResponse.newBuilder(); @@ -2119,6 +2133,8 @@ public class RSRpcServices implements HBaseRPCErrorHandler, RegionActionResult.Builder regionActionResultBuilder = RegionActionResult.newBuilder(); Boolean processed = null; + RpcCallContext context = RpcServer.getCurrentCall(); + this.rpcMultiRequestCount.increment(); for (RegionAction regionAction : request.getRegionActionList()) { this.requestCount.add(regionAction.getActionCount()); OperationQuota quota; @@ -2233,6 +2249,7 @@ public class RSRpcServices implements HBaseRPCErrorHandler, try { checkOpen(); requestCount.increment(); + rpcMutateRequestCount.increment(); Region region = getRegion(request.getRegion()); MutateResponse.Builder builder = MutateResponse.newBuilder(); MutationProto mutation = request.getMutation(); @@ -2374,6 +2391,7 @@ public class RSRpcServices implements HBaseRPCErrorHandler, throw e; } requestCount.increment(); + rpcScanRequestCount.increment(); int ttl = 0; Region region = null; diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerWrapperStub.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerWrapperStub.java index 30afad5b77a..c048dc005ac 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerWrapperStub.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerWrapperStub.java @@ -90,6 +90,26 @@ public class MetricsRegionServerWrapperStub implements MetricsRegionServerWrappe return 707; } + @Override + public long getRpcGetRequestsCount() { + return 521; + } + + @Override + public long getRpcScanRequestsCount() { + return 101; + } + + @Override + public long getRpcMultiRequestsCount() { + return 486; + } + + @Override + public long getRpcMutateRequestsCount() { + return 606; + } + @Override public long getCheckAndMutateChecksFailed() { return 401;