hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ashishsin...@apache.org
Subject hbase git commit: HBASE-16471 Region Server metrics context will be wrong when machine hostname contain "master" word (Pankaj Kumar)
Date Wed, 24 Aug 2016 13:30:06 GMT
Repository: hbase
Updated Branches:
  refs/heads/master 1ca849269 -> 31f16d6ae


HBASE-16471 Region Server metrics context will be wrong when machine hostname contain "master"
word (Pankaj Kumar)


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

Branch: refs/heads/master
Commit: 31f16d6aec7d09f0a4102ed7651db9ff0d190cf9
Parents: 1ca8492
Author: Ashish Singhi <ashishsinghi@apache.org>
Authored: Wed Aug 24 18:59:44 2016 +0530
Committer: Ashish Singhi <ashishsinghi@apache.org>
Committed: Wed Aug 24 18:59:44 2016 +0530

----------------------------------------------------------------------
 .../ipc/MetricsHBaseServerSourceFactory.java    |  4 +--
 .../apache/hadoop/hbase/ipc/TestRpcMetrics.java | 29 ++++++++++++++++++++
 2 files changed, 31 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/31f16d6a/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/ipc/MetricsHBaseServerSourceFactory.java
----------------------------------------------------------------------
diff --git a/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/ipc/MetricsHBaseServerSourceFactory.java
b/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/ipc/MetricsHBaseServerSourceFactory.java
index d6b1392..e9a3348 100644
--- a/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/ipc/MetricsHBaseServerSourceFactory.java
+++ b/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/ipc/MetricsHBaseServerSourceFactory.java
@@ -47,9 +47,9 @@ public abstract class MetricsHBaseServerSourceFactory {
    * @return The Camel Cased context name.
    */
   protected static String createContextName(String serverName) {
-    if (serverName.contains("HMaster") || serverName.contains("master")) {
+    if (serverName.startsWith("HMaster") || serverName.startsWith("master")) {
       return "Master";
-    } else if (serverName.contains("HRegion") || serverName.contains("regionserver")) {
+    } else if (serverName.startsWith("HRegion") || serverName.startsWith("regionserver"))
{
       return "RegionServer";
     }
     return "IPC";

http://git-wip-us.apache.org/repos/asf/hbase/blob/31f16d6a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestRpcMetrics.java
----------------------------------------------------------------------
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 9f1b63a..4de618f 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
@@ -138,5 +138,34 @@ public class TestRpcMetrics {
     HELPER.assertCounter("exceptions", 5, serverSource);
   }
 
+  @Test
+  public void testServerContextNameWithHostName() {
+    String[] masterServerNames = { "master/node-xyz/10.19.250.253:16020",
+        "master/node-regionserver-xyz/10.19.250.253:16020", "HMaster/node-xyz/10.19.250.253:16020",
+        "HMaster/node-regionserver-xyz/10.19.250.253:16020" };
+
+    String[] regionServerNames = { "regionserver/node-xyz/10.19.250.253:16020",
+        "regionserver/node-master1-xyz/10.19.250.253:16020",
+        "HRegionserver/node-xyz/10.19.250.253:16020",
+        "HRegionserver/node-master1-xyz/10.19.250.253:16020" };
+
+    MetricsHBaseServerSource masterSource = null;
+    for (String serverName : masterServerNames) {
+      masterSource = new MetricsHBaseServer(serverName, new MetricsHBaseServerWrapperStub())
+          .getMetricsSource();
+      assertEquals("master", masterSource.getMetricsContext());
+      assertEquals("Master,sub=IPC", masterSource.getMetricsJmxContext());
+      assertEquals("Master", masterSource.getMetricsName());
+    }
+
+    MetricsHBaseServerSource rsSource = null;
+    for (String serverName : regionServerNames) {
+      rsSource = new MetricsHBaseServer(serverName, new MetricsHBaseServerWrapperStub())
+          .getMetricsSource();
+      assertEquals("regionserver", rsSource.getMetricsContext());
+      assertEquals("RegionServer,sub=IPC", rsSource.getMetricsJmxContext());
+      assertEquals("RegionServer", rsSource.getMetricsName());
+    }
+  }
 }
 


Mime
View raw message