hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From huaxiang...@apache.org
Subject hbase git commit: HBASE-21107 add a metrics for netty direct memory
Date Wed, 05 Sep 2018 23:05:36 GMT
Repository: hbase
Updated Branches:
  refs/heads/master b7cdfe3ab -> bdc168713


HBASE-21107 add a metrics for netty direct memory


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/bdc16871
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/bdc16871
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/bdc16871

Branch: refs/heads/master
Commit: bdc168713dc505d82812de12dd5855f0a06c2124
Parents: b7cdfe3
Author: Huaxiang Sun <huaxiangsun@apache.org>
Authored: Wed Sep 5 16:03:07 2018 -0700
Committer: Huaxiang Sun <hsun@cloudera.com>
Committed: Wed Sep 5 16:04:25 2018 -0700

----------------------------------------------------------------------
 .../hadoop/hbase/ipc/MetricsHBaseServerSource.java    |  5 +++++
 .../hadoop/hbase/ipc/MetricsHBaseServerWrapper.java   |  2 ++
 .../hbase/ipc/MetricsHBaseServerSourceImpl.java       |  4 +++-
 .../hbase/ipc/MetricsHBaseServerWrapperImpl.java      | 10 ++++++++++
 .../apache/hadoop/hbase/util/DirectMemoryUtils.java   | 14 ++++++++++++++
 .../hbase/ipc/MetricsHBaseServerWrapperStub.java      |  5 +++++
 6 files changed, 39 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/bdc16871/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/ipc/MetricsHBaseServerSource.java
----------------------------------------------------------------------
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 d98837f..3877aae 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
@@ -95,6 +95,11 @@ public interface MetricsHBaseServerSource extends ExceptionTrackingSource
{
   String NUM_LIFO_MODE_SWITCHES_NAME = "numLifoModeSwitches";
   String NUM_LIFO_MODE_SWITCHES_DESC = "Total number of calls in general queue which " +
     "were served from the tail of the queue";
+  // Direct Memory Usage metrics
+  String NETTY_DM_USAGE_NAME = "nettyDirectMemoryUsage";
+
+  String NETTY_DM_USAGE_DESC = "Current Netty direct memory usage.";
+
 
   void authorizationSuccess();
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/bdc16871/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/ipc/MetricsHBaseServerWrapper.java
----------------------------------------------------------------------
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 c66ec59..9e5a549 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
@@ -56,4 +56,6 @@ public interface MetricsHBaseServerWrapper {
   int getActiveReadRpcHandlerCount();
 
   int getActiveScanRpcHandlerCount();
+
+  long getNettyDmUsage();
 }

http://git-wip-us.apache.org/repos/asf/hbase/blob/bdc16871/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/ipc/MetricsHBaseServerSourceImpl.java
----------------------------------------------------------------------
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 45f60c4..88673ce 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
@@ -179,7 +179,9 @@ public class MetricsHBaseServerSourceImpl extends ExceptionTrackingSourceImpl
           .addGauge(Interns.info(NUM_ACTIVE_READ_HANDLER_NAME, NUM_ACTIVE_READ_HANDLER_DESC),
             wrapper.getActiveReadRpcHandlerCount())
           .addGauge(Interns.info(NUM_ACTIVE_SCAN_HANDLER_NAME, NUM_ACTIVE_SCAN_HANDLER_DESC),
-            wrapper.getActiveScanRpcHandlerCount());
+            wrapper.getActiveScanRpcHandlerCount())
+          .addGauge(Interns.info(NETTY_DM_USAGE_NAME, NETTY_DM_USAGE_DESC),
+            wrapper.getNettyDmUsage());
     }
 
     metricsRegistry.snapshot(mrb, all);

http://git-wip-us.apache.org/repos/asf/hbase/blob/bdc16871/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/MetricsHBaseServerWrapperImpl.java
----------------------------------------------------------------------
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 e7341c5..c855b94 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
@@ -19,6 +19,7 @@
 
 package org.apache.hadoop.hbase.ipc;
 
+import org.apache.hadoop.hbase.util.DirectMemoryUtils;
 import org.apache.yetus.audience.InterfaceAudience;
 
 @InterfaceAudience.Private
@@ -169,4 +170,13 @@ public class MetricsHBaseServerWrapperImpl implements MetricsHBaseServerWrapper
     }
     return server.getScheduler().getActiveScanRpcHandlerCount();
   }
+
+  @Override
+  public long getNettyDmUsage() {
+    if (!isServerStarted() || this.server.getScheduler() == null) {
+      return 0L;
+    }
+
+    return DirectMemoryUtils.getNettyDirectMemoryUsage();
+  }
 }

http://git-wip-us.apache.org/repos/asf/hbase/blob/bdc16871/hbase-server/src/main/java/org/apache/hadoop/hbase/util/DirectMemoryUtils.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/DirectMemoryUtils.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/DirectMemoryUtils.java
index 607efe1..aba421d 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/DirectMemoryUtils.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/DirectMemoryUtils.java
@@ -37,6 +37,10 @@ import org.apache.yetus.audience.InterfaceStability;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.apache.hbase.thirdparty.com.google.common.base.Preconditions;
+import org.apache.hbase.thirdparty.io.netty.buffer.ByteBufAllocatorMetric;
+import org.apache.hbase.thirdparty.io.netty.buffer.ByteBufAllocatorMetricProvider;
+import org.apache.hbase.thirdparty.io.netty.buffer.PooledByteBufAllocator;
+
 
 /**
  * Utilities for interacting with and monitoring DirectByteBuffer allocations.
@@ -125,6 +129,16 @@ public class DirectMemoryUtils {
   }
 
   /**
+   * @return the current amount of direct memory used by netty module.
+   */
+  public static long getNettyDirectMemoryUsage() {
+
+    ByteBufAllocatorMetric metric = ((ByteBufAllocatorMetricProvider)
+        PooledByteBufAllocator.DEFAULT).metric();
+    return metric.usedDirectMemory();
+  }
+
+  /**
    * DirectByteBuffers are garbage collected by using a phantom reference and a
    * reference queue. Every once a while, the JVM checks the reference queue and
    * cleans the DirectByteBuffers. However, as this doesn't happen

http://git-wip-us.apache.org/repos/asf/hbase/blob/bdc16871/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/MetricsHBaseServerWrapperStub.java
----------------------------------------------------------------------
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 748ee3d..5679324 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
@@ -103,4 +103,9 @@ public class MetricsHBaseServerWrapperStub implements MetricsHBaseServerWrapper{
   public int getActiveScanRpcHandlerCount() {
     return 6;
   }
+
+  @Override
+  public long getNettyDmUsage() {
+    return 100L;
+  }
 }


Mime
View raw message