From 4f9896ebc09f5f5561520ac7d178569cdf411e08 Mon Sep 17 00:00:00 2001 From: litao Date: Tue, 17 May 2022 13:05:35 +0800 Subject: [PATCH] HBASE-27032 The draining region servers metric description is incorrect (#4428) Signed-off-by: Xiaolin Ha Signed-off-by: Pankaj Kumar (cherry picked from commit ed1665355a221f9f36ce7c8905d9ed063c6e9eac) --- .../hadoop/hbase/master/MetricsMasterSourceImpl.java | 3 ++- .../hadoop/hbase/master/TestMasterMetricsWrapper.java | 9 ++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsMasterSourceImpl.java b/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsMasterSourceImpl.java index 5e06f61082de..2dbdeff0dd49 100644 --- a/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsMasterSourceImpl.java +++ b/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsMasterSourceImpl.java @@ -98,7 +98,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 7a1d05e5725b..c37cbc773452 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 @@ -19,6 +19,7 @@ import static org.junit.Assert.assertEquals; +import java.io.IOException; import java.util.AbstractMap.SimpleImmutableEntry; import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HBaseTestingUtility; @@ -59,7 +60,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(), @@ -97,6 +98,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