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 25f0c407002..1f4c950e441 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 @@ -42,6 +42,8 @@ public interface MetricsHBaseServerSource extends BaseSource { String QUEUE_CALL_TIME_DESC = "Queue Call Time."; String PROCESS_CALL_TIME_NAME = "processCallTime"; String PROCESS_CALL_TIME_DESC = "Processing call time."; + String TOTAL_CALL_TIME_NAME = "totalCallTime"; + String TOTAL_CALL_TIME_DESC = "Total call time, including both queued and processing time."; String QUEUE_SIZE_NAME = "queueSize"; String QUEUE_SIZE_DESC = "Number of bytes in the call queues."; String GENERAL_QUEUE_NAME = "numCallsInGeneralQueue"; @@ -71,4 +73,6 @@ public interface MetricsHBaseServerSource extends BaseSource { void dequeuedCall(int qTime); void processedCall(int processingTime); -} + + void queuedAndProcessedCall(int totalTime); + } 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 04cf9536428..8eefb082039 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 @@ -40,6 +40,7 @@ public class MetricsHBaseServerSourceImpl extends BaseSourceImpl private final MutableCounterLong receivedBytes; private MutableHistogram queueCallTime; private MutableHistogram processCallTime; + private MutableHistogram totalCallTime; public MetricsHBaseServerSourceImpl(String metricsName, String metricsDescription, @@ -66,6 +67,8 @@ public class MetricsHBaseServerSourceImpl extends BaseSourceImpl QUEUE_CALL_TIME_DESC); this.processCallTime = this.getMetricsRegistry().newHistogram(PROCESS_CALL_TIME_NAME, PROCESS_CALL_TIME_DESC); + this.totalCallTime = this.getMetricsRegistry().newHistogram(TOTAL_CALL_TIME_NAME, + TOTAL_CALL_TIME_DESC); } @Override @@ -108,6 +111,11 @@ public class MetricsHBaseServerSourceImpl extends BaseSourceImpl processCallTime.add(processingTime); } + @Override + public void queuedAndProcessedCall(int totalTime) { + totalCallTime.add(totalTime); + } + @Override public void getMetrics(MetricsCollector metricsCollector, boolean all) { MetricsRecordBuilder mrb = metricsCollector.addRecord(metricsName); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/MetricsHBaseServer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/MetricsHBaseServer.java index 8ca8659a890..825e6887e2c 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/MetricsHBaseServer.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/MetricsHBaseServer.java @@ -63,6 +63,10 @@ public class MetricsHBaseServer { source.processedCall(processingTime); } + void totalCall(int totalTime) { + source.queuedAndProcessedCall(totalTime); + } + public MetricsHBaseServerSource getMetricsSource() { return source; } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcServer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcServer.java index 8f4bbf90611..07921dbe30c 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcServer.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcServer.java @@ -2071,16 +2071,20 @@ public class RpcServer implements RpcServerInterface { long startTime = System.currentTimeMillis(); PayloadCarryingRpcController controller = new PayloadCarryingRpcController(cellScanner); Message result = service.callBlockingMethod(md, controller, param); - int processingTime = (int) (System.currentTimeMillis() - startTime); + long endTime = System.currentTimeMillis(); + int processingTime = (int) (endTime - startTime); int qTime = (int) (startTime - receiveTime); + int totalTime = (int) (endTime - receiveTime); if (LOG.isTraceEnabled()) { LOG.trace(CurCall.get().toString() + ", response " + TextFormat.shortDebugString(result) + " queueTime: " + qTime + - " processingTime: " + processingTime); + " processingTime: " + processingTime + + " totalTime: " + totalTime); } metrics.dequeuedCall(qTime); metrics.processedCall(processingTime); + metrics.totalCall(totalTime); long responseSize = result.getSerializedSize(); // log any RPC responses that are slower than the configured warn // response time or larger than configured warning size 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 443ec781ba3..c2b0344662f 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 @@ -99,8 +99,10 @@ public class TestRpcMetrics { mrpc.dequeuedCall(100); mrpc.processedCall(101); + mrpc.totalCall(102); HELPER.assertCounter("queueCallTime_NumOps", 1, serverSource); HELPER.assertCounter("processCallTime_NumOps", 1, serverSource); + HELPER.assertCounter("totalCallTime_NumOps", 1, serverSource); mrpc.sentBytes(103); mrpc.sentBytes(103);