diff --git a/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsMasterSourceImpl.java b/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsMasterSourceImpl.java index 8280083e472f..e0abf77bea44 100644 --- a/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsMasterSourceImpl.java +++ b/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsMasterSourceImpl.java @@ -121,7 +121,8 @@ public void getMetrics(MetricsCollector metricsCollector, boolean all) { masterWrapper.getNumDeadRegionServers()) .tag(Interns.info(DRAINING_REGION_SERVER_NAME, DRAINING_REGION_SERVER_DESC), masterWrapper.getDrainingRegionServers()) - .addGauge(Interns.info(NUM_DRAINING_REGION_SERVERS_NAME, NUMBER_OF_REGION_SERVERS_DESC), + .addGauge( + Interns.info(NUM_DRAINING_REGION_SERVERS_NAME, NUMBER_OF_DRAINING_REGION_SERVERS_DESC), masterWrapper.getNumDrainingRegionServers()) .tag(Interns.info(ZOOKEEPER_QUORUM_NAME, ZOOKEEPER_QUORUM_DESC), masterWrapper.getZookeeperQuorum()) diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterMetricsWrapper.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterMetricsWrapper.java index f6ec64025486..f73ebde89c11 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterMetricsWrapper.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterMetricsWrapper.java @@ -20,6 +20,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; +import java.io.IOException; import java.util.AbstractMap.SimpleImmutableEntry; import java.util.List; import org.apache.hadoop.hbase.HBaseClassTestRule; @@ -70,7 +71,7 @@ public static void teardown() throws Exception { } @Test - public void testInfo() { + public void testInfo() throws IOException { HMaster master = TEST_UTIL.getHBaseCluster().getMaster(); MetricsMasterWrapperImpl info = new MetricsMasterWrapperImpl(master); assertEquals(master.getRegionNormalizerManager().getSplitPlanCount(), info.getSplitPlanCount(), @@ -107,6 +108,12 @@ public void testInfo() { // now we do not expose this information as WALProcedureStore is not the only ProcedureStore // implementation any more. assertEquals(0, info.getNumWALFiles()); + // We decommission the first online region server and verify the metrics. + TEST_UTIL.getMiniHBaseCluster().getMaster().decommissionRegionServers( + master.getServerManager().getOnlineServersList().subList(0, 1), false); + assertEquals(1, info.getNumDrainingRegionServers()); + assertEquals(master.getServerManager().getOnlineServersList().get(0).toString(), + info.getDrainingRegionServers()); } @Test