diff --git a/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/ipc/MetricsHBaseServerSource.java b/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/ipc/MetricsHBaseServerSource.java index 6128c8f073d..21f457216ed 100644 --- a/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/ipc/MetricsHBaseServerSource.java +++ b/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/ipc/MetricsHBaseServerSource.java @@ -72,7 +72,13 @@ public interface MetricsHBaseServerSource extends ExceptionTrackingSource { String NUM_OPEN_CONNECTIONS_NAME = "numOpenConnections"; String NUM_OPEN_CONNECTIONS_DESC = "Number of open connections."; String NUM_ACTIVE_HANDLER_NAME = "numActiveHandler"; - String NUM_ACTIVE_HANDLER_DESC = "Number of active rpc handlers."; + String NUM_ACTIVE_HANDLER_DESC = "Total number of active rpc handlers."; + String NUM_ACTIVE_GENERAL_HANDLER_NAME = "numActiveGeneralHandler"; + String NUM_ACTIVE_GENERAL_HANDLER_DESC = "Number of active general rpc handlers."; + String NUM_ACTIVE_PRIORITY_HANDLER_NAME = "numActivePriorityHandler"; + String NUM_ACTIVE_PRIORITY_HANDLER_DESC = "Number of active priority rpc handlers."; + String NUM_ACTIVE_REPLICATION_HANDLER_NAME = "numActiveReplicationHandler"; + String NUM_ACTIVE_REPLICATION_HANDLER_DESC = "Number of active replication rpc handlers."; String NUM_ACTIVE_WRITE_HANDLER_NAME = "numActiveWriteHandler"; String NUM_ACTIVE_WRITE_HANDLER_DESC = "Number of active write rpc handlers."; String NUM_ACTIVE_READ_HANDLER_NAME = "numActiveReadHandler"; diff --git a/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/ipc/MetricsHBaseServerWrapper.java b/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/ipc/MetricsHBaseServerWrapper.java index b272cd0add4..1a1a96609f2 100644 --- a/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/ipc/MetricsHBaseServerWrapper.java +++ b/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/ipc/MetricsHBaseServerWrapper.java @@ -32,6 +32,12 @@ public interface MetricsHBaseServerWrapper { int getActiveRpcHandlerCount(); + int getActiveGeneralRpcHandlerCount(); + + int getActivePriorityRpcHandlerCount(); + + int getActiveReplicationRpcHandlerCount(); + long getNumGeneralCallsDropped(); long getNumLifoModeSwitches(); diff --git a/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/ipc/MetricsHBaseServerSourceImpl.java b/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/ipc/MetricsHBaseServerSourceImpl.java index eee641a8089..97cc31af8cb 100644 --- a/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/ipc/MetricsHBaseServerSourceImpl.java +++ b/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/ipc/MetricsHBaseServerSourceImpl.java @@ -155,6 +155,14 @@ public class MetricsHBaseServerSourceImpl extends ExceptionTrackingSourceImpl NUM_OPEN_CONNECTIONS_DESC), wrapper.getNumOpenConnections()) .addGauge(Interns.info(NUM_ACTIVE_HANDLER_NAME, NUM_ACTIVE_HANDLER_DESC), wrapper.getActiveRpcHandlerCount()) + .addGauge(Interns.info(NUM_ACTIVE_GENERAL_HANDLER_NAME, NUM_ACTIVE_GENERAL_HANDLER_DESC), + wrapper.getActiveGeneralRpcHandlerCount()) + .addGauge( + Interns.info(NUM_ACTIVE_PRIORITY_HANDLER_NAME, NUM_ACTIVE_PRIORITY_HANDLER_DESC), + wrapper.getActivePriorityRpcHandlerCount()) + .addGauge( + Interns.info(NUM_ACTIVE_REPLICATION_HANDLER_NAME, NUM_ACTIVE_REPLICATION_HANDLER_DESC), + wrapper.getActiveReplicationRpcHandlerCount()) .addCounter(Interns.info(NUM_GENERAL_CALLS_DROPPED_NAME, NUM_GENERAL_CALLS_DROPPED_DESC), wrapper.getNumGeneralCallsDropped()) .addCounter(Interns.info(NUM_LIFO_MODE_SWITCHES_NAME, diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/FifoRpcScheduler.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/FifoRpcScheduler.java index a9b6fd13399..ab24180650c 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/FifoRpcScheduler.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/FifoRpcScheduler.java @@ -109,6 +109,21 @@ public class FifoRpcScheduler extends RpcScheduler { return executor.getActiveCount(); } + @Override + public int getActiveGeneralRpcHandlerCount() { + return getActiveRpcHandlerCount(); + } + + @Override + public int getActivePriorityRpcHandlerCount() { + return 0; + } + + @Override + public int getActiveReplicationRpcHandlerCount() { + return 0; + } + @Override public long getNumGeneralCallsDropped() { return 0; diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/MetricsHBaseServerWrapperImpl.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/MetricsHBaseServerWrapperImpl.java index 73847878841..6ba7ea240bb 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/MetricsHBaseServerWrapperImpl.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/MetricsHBaseServerWrapperImpl.java @@ -79,6 +79,30 @@ public class MetricsHBaseServerWrapperImpl implements MetricsHBaseServerWrapper return server.getScheduler().getActiveRpcHandlerCount(); } + @Override + public int getActiveGeneralRpcHandlerCount() { + if (!isServerStarted() || this.server.getScheduler() == null) { + return 0; + } + return server.getScheduler().getActiveGeneralRpcHandlerCount(); + } + + @Override + public int getActivePriorityRpcHandlerCount() { + if (!isServerStarted() || this.server.getScheduler() == null) { + return 0; + } + return server.getScheduler().getActivePriorityRpcHandlerCount(); + } + + @Override + public int getActiveReplicationRpcHandlerCount() { + if (!isServerStarted() || this.server.getScheduler() == null) { + return 0; + } + return server.getScheduler().getActiveReplicationRpcHandlerCount(); + } + @Override public long getNumGeneralCallsDropped() { if (!isServerStarted() || this.server.getScheduler() == null) { diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcScheduler.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcScheduler.java index fff8373cea6..c3389f34fd1 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcScheduler.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcScheduler.java @@ -74,9 +74,18 @@ public abstract class RpcScheduler { /** Retrieves length of the replication queue for metrics. */ public abstract int getReplicationQueueLength(); - /** Retrieves the number of active handler. */ + /** Retrieves the total number of active handler. */ public abstract int getActiveRpcHandlerCount(); + /** Retrieves the number of active general handler. */ + public abstract int getActiveGeneralRpcHandlerCount(); + + /** Retrieves the number of active priority handler. */ + public abstract int getActivePriorityRpcHandlerCount(); + + /** Retrieves the number of active replication handler. */ + public abstract int getActiveReplicationRpcHandlerCount(); + /** * If CoDel-based RPC executors are used, retrieves the number of Calls that were dropped * from general queue because RPC executor is under high load; returns 0 otherwise. diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/SimpleRpcScheduler.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/SimpleRpcScheduler.java index 8fc0023d03e..dbe4667f5a8 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/SimpleRpcScheduler.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/SimpleRpcScheduler.java @@ -175,9 +175,23 @@ public class SimpleRpcScheduler extends RpcScheduler implements ConfigurationObs @Override public int getActiveRpcHandlerCount() { - return callExecutor.getActiveHandlerCount() + - (priorityExecutor == null ? 0 : priorityExecutor.getActiveHandlerCount()) + - (replicationExecutor == null ? 0 : replicationExecutor.getActiveHandlerCount()); + return callExecutor.getActiveHandlerCount() + getActivePriorityRpcHandlerCount() + + getActiveReplicationRpcHandlerCount(); + } + + @Override + public int getActiveGeneralRpcHandlerCount() { + return callExecutor.getActiveHandlerCount(); + } + + @Override + public int getActivePriorityRpcHandlerCount() { + return (priorityExecutor == null ? 0 : priorityExecutor.getActiveHandlerCount()); + } + + @Override + public int getActiveReplicationRpcHandlerCount() { + return (replicationExecutor == null ? 0 : replicationExecutor.getActiveHandlerCount()); } @Override diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/DelegatingRpcScheduler.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/DelegatingRpcScheduler.java index 3c8f1143b94..36fb015f574 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/DelegatingRpcScheduler.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/DelegatingRpcScheduler.java @@ -59,6 +59,21 @@ public class DelegatingRpcScheduler extends RpcScheduler { return delegate.getActiveRpcHandlerCount(); } + @Override + public int getActiveGeneralRpcHandlerCount() { + return delegate.getActiveGeneralRpcHandlerCount(); + } + + @Override + public int getActivePriorityRpcHandlerCount() { + return delegate.getActivePriorityRpcHandlerCount(); + } + + @Override + public int getActiveReplicationRpcHandlerCount() { + return delegate.getActiveReplicationRpcHandlerCount(); + } + @Override public boolean dispatch(CallRunner task) throws IOException, InterruptedException { return delegate.dispatch(task); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/MetricsHBaseServerWrapperStub.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/MetricsHBaseServerWrapperStub.java index 3b787a91dde..748ee3d1eba 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/MetricsHBaseServerWrapperStub.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/MetricsHBaseServerWrapperStub.java @@ -49,6 +49,21 @@ public class MetricsHBaseServerWrapperStub implements MetricsHBaseServerWrapper{ return 106; } + @Override + public int getActiveGeneralRpcHandlerCount() { + return 201; + } + + @Override + public int getActivePriorityRpcHandlerCount() { + return 202; + } + + @Override + public int getActiveReplicationRpcHandlerCount() { + return 203; + } + @Override public long getNumGeneralCallsDropped() { return 3; diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestRpcMetrics.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestRpcMetrics.java index ffcc9928e86..66afe255090 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestRpcMetrics.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestRpcMetrics.java @@ -69,6 +69,9 @@ public class TestRpcMetrics { HELPER.assertGauge("numCallsInPriorityQueue", 104, serverSource); HELPER.assertGauge("numOpenConnections", 105, serverSource); HELPER.assertGauge("numActiveHandler", 106, serverSource); + HELPER.assertGauge("numActiveGeneralHandler", 201, serverSource); + HELPER.assertGauge("numActivePriorityHandler", 202, serverSource); + HELPER.assertGauge("numActiveReplicationHandler", 203, serverSource); HELPER.assertGauge("numActiveWriteHandler", 50, serverSource); HELPER.assertGauge("numActiveReadHandler", 50, serverSource); HELPER.assertGauge("numActiveScanHandler", 6, serverSource);