You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2021/10/07 12:21:29 UTC

[GitHub] [ignite-extensions] nizhikov commented on a change in pull request #73: IGNITE-14355 CDC Consumer metrics added

nizhikov commented on a change in pull request #73:
URL: https://github.com/apache/ignite-extensions/pull/73#discussion_r724125861



##########
File path: modules/cdc-ext/src/test/java/org/apache/ignite/cdc/AbstractReplicationTest.java
##########
@@ -408,4 +438,57 @@ private boolean checkFuts(boolean res, List<IgniteInternalFuture<?>> futs) {
 
     /** */
     protected abstract List<IgniteInternalFuture<?>> startActiveActiveCdc();
+
+    /** */
+    protected abstract void checkConsumerMetrics(Function<String, Long> longMetric);
+
+    /** */
+    protected void checkMetrics() {
+        for (int i = 0; i < cdcs.size(); i++) {
+            IgniteConfiguration cfg = getFieldValue(cdcs.get(i), "igniteCfg");
+
+            MetricRegistry mreg = getFieldValue(cdcs.get(i), "mreg");
+
+            assertNotNull(mreg);
+
+            checkMetrics(
+                m -> mreg.<LongMetric>findMetric(m).value(),
+                m -> mreg.<ObjectMetric<String>>findMetric(m).value()
+            );
+
+            Function<DynamicMBean, Function<String, ?>> jmxVal = mxBean -> m -> {
+                try {
+                    return mxBean.getAttribute(m);
+                }
+                catch (Exception e) {
+                    throw new IgniteException(e);
+                }
+            };
+
+            DynamicMBean jmxCdcReg = metricRegistry(cdcInstanceName(cfg.getIgniteInstanceName()), null, "cdc");
+
+            checkMetrics((Function<String, Long>)jmxVal.apply(jmxCdcReg), (Function<String, String>)jmxVal.apply(jmxCdcReg));
+
+            DynamicMBean jmxConsumerReg = metricRegistry(cdcInstanceName(cfg.getIgniteInstanceName()), "cdc", "consumer");
+
+            checkConsumerMetrics((Function<String, Long>)jmxVal.apply(jmxConsumerReg));
+        }
+    }
+
+    /** */
+    private void checkMetrics(Function<String, Long> longMetric, Function<String, String> strMetric) {
+        long committedSegIdx = longMetric.apply(COMMITTED_SEG_IDX);
+        long curSegIdx = longMetric.apply(CUR_SEG_IDX);
+
+        assertTrue(committedSegIdx <= curSegIdx);
+
+        assertTrue(longMetric.apply(COMMITTED_SEG_OFFSET) >= 0);
+        assertTrue(longMetric.apply(LAST_SEG_CONSUMPTION_TIME) > 0);
+
+        for (String m : new String[] {BINARY_META_DIR, MARSHALLER_DIR, CDC_DIR})
+            assertTrue(new File(strMetric.apply(m)).exists());
+
+        assertNotNull(longMetric.apply(LAST_EVT_TIME));

Review comment:
       There are cases when all data read from one node - therefore `LAST_EVT_TIME` will be 0 on the second.




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org