NihalJain commented on code in PR #8758:
URL: https://github.com/apache/hbase/pull/8758#discussion_r4250485712


##########
hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterMetrics.java:
##########
@@ -147,6 +149,33 @@ public static void after() throws Exception {
     TEST_UTIL.shutdownMiniCluster();
   }
 
+  @Test
+  public void testSwitchMetricsFollowAdminChanges() throws IOException {
+    Admin admin = TEST_UTIL.getAdmin();
+    MetricsMasterSource source = master.getMasterMetrics().getMetricsSource();
+    Map<String, IOExceptionConsumer<Boolean>> switches = new HashMap<>();
+    switches.put("balancerEnabled", enabled -> admin.balancerSwitch(enabled, 
false));
+    switches.put("normalizerEnabled", admin::normalizerSwitch);
+    switches.put("splitEnabled", enabled -> admin.splitSwitch(enabled, false));
+    switches.put("mergeEnabled", enabled -> admin.mergeSwitch(enabled, false));
+    switches.put("cleanerChoreEnabled", admin::cleanerChoreSwitch);
+    switches.put("catalogJanitorEnabled", admin::catalogJanitorSwitch);
+    switches.put("snapshotCleanupEnabled", enabled -> 
admin.snapshotCleanupSwitch(enabled, false));
+    switches.put("replicationPeerModificationEnabled", 
admin::replicationPeerModificationSwitch);
+    Map<String, Integer> initialStates = new 
MetricsMasterWrapperImpl(master).getSwitchStates();
+    for (Map.Entry<String, IOExceptionConsumer<Boolean>> entry : 
switches.entrySet()) {
+      try {
+        for (boolean enabled : new boolean[] { false, true }) {
+          entry.getValue().accept(enabled);
+          metricsHelper.assertGauge(entry.getKey(), enabled ? 1L : 0L, source);
+        }
+      } finally {
+        entry.getValue().accept(initialStates.get(entry.getKey()) == 1);
+      }
+    }
+    metricsHelper.assertGauge("rpcThrottleEnabled", 0L, source);

Review Comment:
   nit: worth adding a comment why this is 0 so that other dont get confused 
later?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to