diff --git a/src/main/java/org/apache/hadoop/hbase/ipc/HBaseRpcMetrics.java b/src/main/java/org/apache/hadoop/hbase/ipc/HBaseRpcMetrics.java index 326ff8015d3..0db27604706 100644 --- a/src/main/java/org/apache/hadoop/hbase/ipc/HBaseRpcMetrics.java +++ b/src/main/java/org/apache/hadoop/hbase/ipc/HBaseRpcMetrics.java @@ -90,6 +90,8 @@ public class HBaseRpcMetrics implements Updater { new MetricsIntValue("callQueueLen", registry); public final MetricsIntValue priorityCallQueueLen = new MetricsIntValue("priorityCallQueueLen", registry); + public final MetricsIntValue responseQueueLen = + new MetricsIntValue("responseQueueLen", registry); public final MetricsTimeVaryingInt authenticationFailures = new MetricsTimeVaryingInt("rpcAuthenticationFailures", registry); public final MetricsTimeVaryingInt authenticationSuccesses = diff --git a/src/main/java/org/apache/hadoop/hbase/ipc/HBaseServer.java b/src/main/java/org/apache/hadoop/hbase/ipc/HBaseServer.java index 0ba352a6879..e925786078a 100644 --- a/src/main/java/org/apache/hadoop/hbase/ipc/HBaseServer.java +++ b/src/main/java/org/apache/hadoop/hbase/ipc/HBaseServer.java @@ -203,6 +203,8 @@ public abstract class HBaseServer implements RpcServer { protected int highPriorityLevel; // what level a high priority call is at + private volatile int responseQueueLen; // size of response queue for this server + protected final List connectionList = Collections.synchronizedList(new LinkedList()); //maintain a list @@ -929,6 +931,7 @@ public abstract class HBaseServer implements RpcServer { return true; } if (!call.response.hasRemaining()) { + responseQueueLen--; call.connection.decRpcCount(); //noinspection RedundantIfStatement if (numElements == 1) { // last call fully processes. @@ -998,6 +1001,7 @@ public abstract class HBaseServer implements RpcServer { void doRespond(Call call) throws IOException { // set the serve time when the response has to be sent later call.timestamp = System.currentTimeMillis(); + responseQueueLen++; boolean doRegister = false; synchronized (call.connection.responseQueue) { @@ -1287,6 +1291,7 @@ public abstract class HBaseServer implements RpcServer { } else { LOG.warn("Unknown call queue"); } + rpcMetrics.responseQueueLen.set(responseQueueLen); } /** Handles queued calls . */