HBASE-24199 Procedure related metrics is not consumed in the JMX metric (#1616)

Signed-off-by: stack <stack@apache.org>
This commit is contained in:
gkanade 2020-05-02 00:15:16 +05:30 committed by GitHub
parent 3df1e60bb3
commit 9785f5d1c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 31 additions and 0 deletions

View File

@ -21,6 +21,8 @@ package org.apache.hadoop.hbase.master;
import org.apache.hadoop.hbase.metrics.BaseSourceImpl;
import org.apache.hadoop.hbase.metrics.OperationMetrics;
import org.apache.hadoop.metrics2.MetricHistogram;
import org.apache.hadoop.metrics2.MetricsCollector;
import org.apache.hadoop.metrics2.MetricsRecordBuilder;
import org.apache.hadoop.metrics2.lib.MutableFastCounter;
import org.apache.hadoop.metrics2.lib.MutableGaugeLong;
import org.apache.yetus.audience.InterfaceAudience;
@ -157,4 +159,13 @@ public class MetricsAssignmentManagerSourceImpl
public OperationMetrics getCloseMetrics() {
return closeMetrics;
}
@Override
public void getMetrics(MetricsCollector metricsCollector, boolean all) {
MetricsRecordBuilder metricsRecordBuilder = metricsCollector.addRecord(metricsName);
metricsRegistry.snapshot(metricsRecordBuilder, all);
if(metricsAdapter != null) {
metricsAdapter.snapshotAllMetrics(registry, metricsRecordBuilder);
}
}
}

View File

@ -70,6 +70,9 @@ public class MetricsMasterProcSourceImpl
}
metricsRegistry.snapshot(metricsRecordBuilder, all);
if(metricsAdapter != null) {
metricsAdapter.snapshotAllMetrics(registry, metricsRecordBuilder);
}
}
}

View File

@ -126,6 +126,9 @@ public class MetricsMasterSourceImpl
}
metricsRegistry.snapshot(metricsRecordBuilder, all);
if(metricsAdapter != null) {
metricsAdapter.snapshotAllMetrics(registry, metricsRecordBuilder);
}
}
@Override

View File

@ -161,6 +161,8 @@ public class TestAssignmentManagerMetrics {
METRICS_HELPER.assertGauge(MetricsAssignmentManagerSource.RIT_COUNT_NAME, 1, amSource);
METRICS_HELPER.assertGauge(MetricsAssignmentManagerSource.RIT_COUNT_OVER_THRESHOLD_NAME, 1,
amSource);
METRICS_HELPER.assertCounter(MetricsAssignmentManagerSource.ASSIGN_METRIC_PREFIX
+ "SubmittedCount", 2, amSource);
}
}
}

View File

@ -29,6 +29,7 @@ import java.util.concurrent.CountDownLatch;
import java.util.stream.Collectors;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.CompatibilityFactory;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.StartMiniClusterOption;
@ -41,6 +42,7 @@ import org.apache.hadoop.hbase.master.assignment.ServerStateNode;
import org.apache.hadoop.hbase.master.procedure.ServerCrashProcedure;
import org.apache.hadoop.hbase.procedure2.Procedure;
import org.apache.hadoop.hbase.regionserver.HRegionServer;
import org.apache.hadoop.hbase.test.MetricsAssertHelper;
import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.util.JVMClusterUtil;
@ -59,6 +61,8 @@ public class TestClusterRestartFailover extends AbstractTestRestartCluster {
HBaseClassTestRule.forClass(TestClusterRestartFailover.class);
private static final Logger LOG = LoggerFactory.getLogger(TestClusterRestartFailover.class);
private static final MetricsAssertHelper metricsHelper =
CompatibilityFactory.getInstance(MetricsAssertHelper.class);
private volatile static CountDownLatch SCP_LATCH;
private static ServerName SERVER_FOR_TEST;
@ -136,6 +140,11 @@ public class TestClusterRestartFailover extends AbstractTestRestartCluster {
serverNode = UTIL.getHBaseCluster().getMaster().getAssignmentManager().getRegionStates()
.getServerNode(SERVER_FOR_TEST);
assertNull("serverNode should be deleted after SCP finished", serverNode);
MetricsMasterSource masterSource = UTIL.getHBaseCluster().getMaster().getMasterMetrics()
.getMetricsSource();
metricsHelper.assertCounter(MetricsMasterSource.SERVER_CRASH_METRIC_PREFIX+"SubmittedCount",
4, masterSource);
}
private void setupCluster() throws Exception {

View File

@ -141,6 +141,9 @@ public class TestMasterMetrics {
metricsHelper.assertTag("serverName", master.getServerName().toString(), masterSource);
metricsHelper.assertTag("clusterId", master.getClusterId(), masterSource);
metricsHelper.assertTag("zookeeperQuorum", master.getZooKeeper().getQuorum(), masterSource);
metricsHelper.assertCounter(MetricsMasterSource.SERVER_CRASH_METRIC_PREFIX+"SubmittedCount",
0, masterSource);
}
@Test