From ca613bae911c4b478c4d982446f626abc6e82d0c Mon Sep 17 00:00:00 2001 From: Robert Yokota Date: Thu, 10 Aug 2017 14:13:04 -0700 Subject: [PATCH] Add histogram to MetricsConnection to track concurrent calls per server --- .../apache/hadoop/hbase/client/MetricsConnection.java | 16 ++++++++++++++++ .../org/apache/hadoop/hbase/ipc/AbstractRpcClient.java | 3 ++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/MetricsConnection.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/MetricsConnection.java index 410e7d8785..3c1789c0b9 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/MetricsConnection.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/MetricsConnection.java @@ -73,6 +73,7 @@ public class MetricsConnection implements StatisticTrackable { private long responseSizeBytes = 0; private long startTime = 0; private long callTimeMs = 0; + private int concurrentCallsPerServer = 0; public long getRequestSizeBytes() { return requestSizeBytes; @@ -105,6 +106,14 @@ public class MetricsConnection implements StatisticTrackable { public void setCallTimeMs(long callTimeMs) { this.callTimeMs = callTimeMs; } + + public int getConcurrentCallsPerServer() { + return concurrentCallsPerServer; + } + + public void setConcurrentCallsPerServer(int callsPerServer) { + this.concurrentCallsPerServer = callsPerServer; + } } @VisibleForTesting @@ -269,6 +278,7 @@ public class MetricsConnection implements StatisticTrackable { @VisibleForTesting protected final RunnerStats runnerStats; @VisibleForTesting protected final Counter metaCacheNumClearServer; @VisibleForTesting protected final Counter metaCacheNumClearRegion; + @VisibleForTesting protected final Histogram concurrentCallsPerServerHist; // dynamic metrics @@ -323,6 +333,8 @@ public class MetricsConnection implements StatisticTrackable { this.putTracker = new CallTracker(this.registry, "Mutate", "Put", scope); this.multiTracker = new CallTracker(this.registry, "Multi", scope); this.runnerStats = new RunnerStats(this.registry); + this.concurrentCallsPerServerHist = registry.histogram(name(MetricsConnection.class, + "concurrentCallsPerServer", scope)); this.reporter = JmxReporter.forRegistry(this.registry).build(); this.reporter.start(); @@ -408,6 +420,10 @@ public class MetricsConnection implements StatisticTrackable { /** Report RPC context to metrics system. */ public void updateRpc(MethodDescriptor method, Message param, CallStats stats) { + int callsPerServer = stats.getConcurrentCallsPerServer(); + if (callsPerServer > 0) { + concurrentCallsPerServerHist.update(callsPerServer); + } // this implementation is tied directly to protobuf implementation details. would be better // if we could dispatch based on something static, ie, request Message type. if (method.getService() == ClientService.getDescriptor()) { diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/AbstractRpcClient.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/AbstractRpcClient.java index 55895f27fb..014929e77a 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/AbstractRpcClient.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/AbstractRpcClient.java @@ -415,6 +415,7 @@ public abstract class AbstractRpcClient implements RpcC if (count > maxConcurrentCallsPerServer) { throw new ServerTooBusyException(addr, count); } + cs.setConcurrentCallsPerServer(count); T connection = getConnection(remoteId); connection.sendRequest(call, hrc); } catch (Exception e) { @@ -593,4 +594,4 @@ public abstract class AbstractRpcClient implements RpcC param, returnType, ticket, addr, done); } } -} \ No newline at end of file +} -- 2.11.0