shishkovilja commented on code in PR #11612: URL: https://github.com/apache/ignite/pull/11612#discussion_r1829683730
########## modules/core/src/test/java/org/apache/ignite/cdc/AbstractCdcTest.java: ########## @@ -269,6 +261,55 @@ private void checkMetrics(long expCnt, Function<String, Long> longMetric, Functi assertEquals(expCnt, (long)longMetric.apply(EVTS_CNT)); } + /** + * @param cdc - {@link CdcMain} instance. + */ + protected void checkWalProcessingMetrics(CdcMain cdc) { + DynamicMBean jmxCdcReg = getJmxCdcReg(cdc); + + checkWalProcessingMetrics((Function<String, Long>)jmxVal(jmxCdcReg), (Function<String, long[]>)jmxVal(jmxCdcReg)); + + MetricRegistry mreg = getMetricRegistry(cdc); + + checkWalProcessingMetrics( + m -> mreg.<LongMetric>findMetric(m).value(), + m -> mreg.<HistogramMetricImpl>findMetric(m).value() + ); + } + + /** Checks the metrics for WAL processing. */ + private void checkWalProcessingMetrics(Function<String, Long> longMetric, Function<String, long[]> longMetricArray) { + assertNotNull(longMetric.apply(EVENTS_CONSUMPTION_TIME_TOTAL)); + + assertTrue(longMetric.apply(EVENTS_CONSUMPTION_TIME_TOTAL) > 0); + + assertTrue(Arrays.stream(longMetricArray.apply(EVENTS_CONSUMPTION_TIME)).sum() > 0); + } + + /** @return MBean for CDC metrics */ + private DynamicMBean getJmxCdcReg(CdcMain cdc) { Review Comment: ```suggestion private DynamicMBean jmxRegistry(CdcMain cdc) { ``` ########## modules/core/src/test/java/org/apache/ignite/cdc/AbstractCdcTest.java: ########## @@ -269,6 +261,55 @@ private void checkMetrics(long expCnt, Function<String, Long> longMetric, Functi assertEquals(expCnt, (long)longMetric.apply(EVTS_CNT)); } + /** + * @param cdc - {@link CdcMain} instance. + */ + protected void checkWalProcessingMetrics(CdcMain cdc) { + DynamicMBean jmxCdcReg = getJmxCdcReg(cdc); + + checkWalProcessingMetrics((Function<String, Long>)jmxVal(jmxCdcReg), (Function<String, long[]>)jmxVal(jmxCdcReg)); + + MetricRegistry mreg = getMetricRegistry(cdc); + + checkWalProcessingMetrics( + m -> mreg.<LongMetric>findMetric(m).value(), + m -> mreg.<HistogramMetricImpl>findMetric(m).value() + ); + } + + /** Checks the metrics for WAL processing. */ + private void checkWalProcessingMetrics(Function<String, Long> longMetric, Function<String, long[]> longMetricArray) { + assertNotNull(longMetric.apply(EVENTS_CONSUMPTION_TIME_TOTAL)); + + assertTrue(longMetric.apply(EVENTS_CONSUMPTION_TIME_TOTAL) > 0); + + assertTrue(Arrays.stream(longMetricArray.apply(EVENTS_CONSUMPTION_TIME)).sum() > 0); + } + + /** @return MBean for CDC metrics */ + private DynamicMBean getJmxCdcReg(CdcMain cdc) { + IgniteConfiguration cfg = getFieldValue(cdc, "igniteCfg"); + + return metricRegistry(cdcInstanceName(cfg.getIgniteInstanceName()), null, "cdc"); + } + + /** @return {@link MetricRegistry} */ + private MetricRegistry getMetricRegistry(CdcMain cdc) { Review Comment: ```suggestion private MetricRegistry registry(CdcMain cdc) { ``` ########## modules/core/src/test/java/org/apache/ignite/cdc/AbstractCdcTest.java: ########## @@ -269,6 +261,55 @@ private void checkMetrics(long expCnt, Function<String, Long> longMetric, Functi assertEquals(expCnt, (long)longMetric.apply(EVTS_CNT)); } + /** + * @param cdc - {@link CdcMain} instance. + */ + protected void checkWalProcessingMetrics(CdcMain cdc) { + DynamicMBean jmxCdcReg = getJmxCdcReg(cdc); + + checkWalProcessingMetrics((Function<String, Long>)jmxVal(jmxCdcReg), (Function<String, long[]>)jmxVal(jmxCdcReg)); + + MetricRegistry mreg = getMetricRegistry(cdc); + + checkWalProcessingMetrics( + m -> mreg.<LongMetric>findMetric(m).value(), + m -> mreg.<HistogramMetricImpl>findMetric(m).value() + ); + } + + /** Checks the metrics for WAL processing. */ + private void checkWalProcessingMetrics(Function<String, Long> longMetric, Function<String, long[]> longMetricArray) { + assertNotNull(longMetric.apply(EVENTS_CONSUMPTION_TIME_TOTAL)); + + assertTrue(longMetric.apply(EVENTS_CONSUMPTION_TIME_TOTAL) > 0); + + assertTrue(Arrays.stream(longMetricArray.apply(EVENTS_CONSUMPTION_TIME)).sum() > 0); + } + + /** @return MBean for CDC metrics */ + private DynamicMBean getJmxCdcReg(CdcMain cdc) { + IgniteConfiguration cfg = getFieldValue(cdc, "igniteCfg"); + + return metricRegistry(cdcInstanceName(cfg.getIgniteInstanceName()), null, "cdc"); + } + + /** @return {@link MetricRegistry} */ + private MetricRegistry getMetricRegistry(CdcMain cdc) { + return getFieldValue(cdc, "mreg"); + } + + /** */ + private Function<String, ?> jmxVal(DynamicMBean jmxCdcReg) { Review Comment: ```suggestion private Function<String, ?> jmxValue(DynamicMBean jmxCdcReg) { ``` -- 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-unsubscr...@ignite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org