Mmuzaf commented on code in PR #3147:
URL: https://github.com/apache/cassandra/pull/3147#discussion_r1511769868


##########
test/distributed/org/apache/cassandra/distributed/test/ring/BootstrapTest.java:
##########
@@ -154,9 +163,58 @@ public void bootstrapJMXStatus() throws Throwable
                 assertEquals("COMPLETED", 
StorageService.instance.getBootstrapState());
                 assertFalse(StorageService.instance.isBootstrapFailed());
             });
+
+            assertEquals(Long.valueOf(0L), 
getMetricGaugeValue(joiningInstance, "BootstrapFilesTotal", Long.class));
+            assertEquals(Long.valueOf(0L), 
getMetricGaugeValue(joiningInstance, "BootstrapFilesReceived", Long.class));
+            assertEquals("Bootstrap streaming success", 
getMetricGaugeValue(joiningInstance, "BootstrapLastSeenStatus", String.class));
+            assertEquals("", getMetricGaugeValue(joiningInstance, 
"BootstrapLastSeenError", String.class));
         }
     }
 
+    public static <T> T getMetricGaugeValue(IInvokableInstance instance, 
String metricName, Class<T> gaugeReturnType)
+    {
+        return gaugeReturnType.cast(getMetricAttribute(instance, metricName, 
"Value"));
+    }
+
+    public static long getMetricMeterRate(IInvokableInstance instance, String 
metricName)
+    {
+        Object raw = getMetricAttribute(instance, metricName, "Count");
+        return raw == null ? 0 : (Long) raw;
+    }
+
+    public static Object getMetricAttribute(IInvokableInstance instance, 
String metricName, String attributeName)
+    {
+        if (instance.isShutdown())
+            throw new IllegalStateException("Instance is shutdown");
+
+        try (JMXConnector jmxc = JMXUtil.getJmxConnector(instance.config()))
+        {
+            MBeanServerConnection mbsc = jmxc.getMBeanServerConnection();
+            ObjectName metric = mbsc.queryNames(null, null)
+                    .stream()

Review Comment:
   Fixed.



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to