Search in sources :

Example 1 with ObjectMetric

use of org.apache.ignite.spi.metric.ObjectMetric in project ignite by apache.

the class CacheGroupMetricsTest method testCacheGroupMetrics.

/**
 * @throws Exception If failed.
 */
@Test
public void testCacheGroupMetrics() throws Exception {
    pds = false;
    startGrid(0);
    startGrid(1);
    startGrid(2);
    awaitPartitionMapExchange(true, false, null);
    T2<CacheGroupMetricsMXBean, MetricRegistry> mxBean0Grp1 = cacheGroupMetrics(0, "group1");
    T2<CacheGroupMetricsMXBean, MetricRegistry> mxBean0Grp2 = cacheGroupMetrics(0, "group2");
    T2<CacheGroupMetricsMXBean, MetricRegistry> mxBean0Grp3 = cacheGroupMetrics(0, "cache4");
    T2<CacheGroupMetricsMXBean, MetricRegistry> mxBean1Grp1 = cacheGroupMetrics(1, "group1");
    T2<CacheGroupMetricsMXBean, MetricRegistry> mxBean2Grp1 = cacheGroupMetrics(2, "group1");
    assertEquals("group1", mxBean0Grp1.get1().getGroupName());
    assertEquals(null, mxBean0Grp3.get1().getGroupName());
    assertEquals(3, mxBean0Grp1.get1().getBackups());
    assertEquals(10, mxBean0Grp1.get1().getPartitions());
    assertEquals(1, mxBean0Grp1.get2().<IntMetric>findMetric("MinimumNumberOfPartitionCopies").value());
    assertEquals(3, mxBean0Grp1.get2().<IntMetric>findMetric("MaximumNumberOfPartitionCopies").value());
    assertEquals(0, mxBean0Grp1.get1().getClusterMovingPartitionsCount());
    assertEquals(19, mxBean0Grp1.get1().getClusterOwningPartitionsCount());
    assertEquals(7, mxBean0Grp1.get2().<IntMetric>findMetric("LocalNodeOwningPartitionsCount").value());
    assertEquals(6, mxBean1Grp1.get2().<IntMetric>findMetric("LocalNodeOwningPartitionsCount").value());
    assertEquals(6, mxBean2Grp1.get2().<IntMetric>findMetric("LocalNodeOwningPartitionsCount").value());
    assertEquals(F.asList("cache1"), mxBean0Grp1.get2().<ObjectMetric<List<String>>>findMetric("Caches").value());
    assertEquals(F.asList("cache2", "cache3"), mxBean0Grp2.get2().<ObjectMetric<List<String>>>findMetric("Caches").value());
    assertEquals(F.asList("cache4"), mxBean0Grp3.get2().<ObjectMetric<List<String>>>findMetric("Caches").value());
    assertEquals(arrayToAssignmentMap(assignmentMapArr), mxBean0Grp1.get2().<ObjectMetric<Map<Integer, List<String>>>>findMetric("AffinityPartitionsAssignmentMap").value());
    assertEquals(arrayToAllocationMap(assignmentMapArr), mxBean0Grp1.get2().<ObjectMetric<Map<Integer, List<String>>>>findMetric("OwningPartitionsAllocationMap").value());
    ObjectMetric<Map<Integer, List<String>>> movingPartitionsAllocationMap = mxBean0Grp1.get2().findMetric("MovingPartitionsAllocationMap");
    assertEquals(arrayToAllocationMap(new int[10][]), movingPartitionsAllocationMap.value());
    try (IgniteDataStreamer<Integer, Integer> st = grid(0).dataStreamer("cache1")) {
        for (int i = 0; i < 50_000; i++) st.addData(i, i);
    }
    // Pause rebalance to check instant partitions states.
    grid(0).rebalanceEnabled(false);
    grid(1).rebalanceEnabled(false);
    stopGrid(2);
    // Check moving partitions while rebalancing.
    assertFalse(arrayToAllocationMap(new int[10][]).equals(movingPartitionsAllocationMap.value()));
    int movingCnt = mxBean0Grp1.get2().<IntMetric>findMetric("LocalNodeMovingPartitionsCount").value();
    assertTrue(movingCnt > 0);
    assertTrue(mxBean0Grp1.get1().getClusterMovingPartitionsCount() > 0);
    final CountDownLatch evictLatch = new CountDownLatch(1);
    // Block all evicting threads to count total renting partitions.
    grid(0).events().localListen(new IgnitePredicate<Event>() {

        @Override
        public boolean apply(Event evt) {
            try {
                evictLatch.await();
            } catch (InterruptedException e) {
                log.error("Interrupted", e);
            }
            return true;
        }
    }, EventType.EVT_CACHE_REBALANCE_OBJECT_UNLOADED);
    grid(0).rebalanceEnabled(true);
    grid(1).rebalanceEnabled(true);
    startGrid(2);
    try {
        assertTrue("Renting partitions count when node returns not equals to moved partitions when node left", GridTestUtils.waitForCondition(new GridAbsPredicate() {

            @Override
            public boolean apply() {
                IntMetric localNodeRentingPartitionsCount = mxBean0Grp1.get2().findMetric("LocalNodeRentingPartitionsCount");
                log.info("Renting partitions count: " + localNodeRentingPartitionsCount.value());
                log.info("Renting entries count: " + mxBean0Grp1.get2().findMetric("LocalNodeRentingEntriesCount").getAsString());
                return localNodeRentingPartitionsCount.value() == movingCnt;
            }
        }, 10_000L));
        assertTrue("Renting entries count is 0", mxBean0Grp1.get2().<IntMetric>findMetric("LocalNodeRentingPartitionsCount").value() > 0);
    } finally {
        evictLatch.countDown();
    }
}
Also used : GridAbsPredicate(org.apache.ignite.internal.util.lang.GridAbsPredicate) MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry) CountDownLatch(java.util.concurrent.CountDownLatch) CacheGroupMetricsMXBean(org.apache.ignite.mxbean.CacheGroupMetricsMXBean) ObjectMetric(org.apache.ignite.spi.metric.ObjectMetric) Event(org.apache.ignite.events.Event) ArrayList(java.util.ArrayList) List(java.util.List) IntMetric(org.apache.ignite.spi.metric.IntMetric) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 2 with ObjectMetric

use of org.apache.ignite.spi.metric.ObjectMetric in project ignite by apache.

the class AbstractCdcTest method checkMetrics.

/**
 */
protected void checkMetrics(CdcMain cdc, int expCnt) throws Exception {
    if (metricExporters() != null) {
        IgniteConfiguration cfg = getFieldValue(cdc, "igniteCfg");
        DynamicMBean jmxCdcReg = metricRegistry(cdcInstanceName(cfg.getIgniteInstanceName()), null, "cdc");
        Function<String, ?> jmxVal = m -> {
            try {
                return jmxCdcReg.getAttribute(m);
            } catch (Exception e) {
                throw new IgniteException(e);
            }
        };
        checkMetrics(expCnt, (Function<String, Long>) jmxVal, (Function<String, String>) jmxVal);
    }
    MetricRegistry mreg = getFieldValue(cdc, "mreg");
    assertNotNull(mreg);
    checkMetrics(expCnt, m -> mreg.<LongMetric>findMetric(m).value(), m -> mreg.<ObjectMetric<String>>findMetric(m).value());
}
Also used : IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) Arrays(java.util.Arrays) GridCacheUtils.cacheId(org.apache.ignite.internal.processors.cache.GridCacheUtils.cacheId) CdcMain(org.apache.ignite.internal.cdc.CdcMain) GridTestUtils.waitForCondition(org.apache.ignite.testframework.GridTestUtils.waitForCondition) DELETE(org.apache.ignite.cdc.AbstractCdcTest.ChangeEventType.DELETE) CdcConsumerState(org.apache.ignite.internal.cdc.CdcConsumerState) Function(java.util.function.Function) WALPointer(org.apache.ignite.internal.processors.cache.persistence.wal.WALPointer) ObjectMetric(org.apache.ignite.spi.metric.ObjectMetric) COMMITTED_SEG_IDX(org.apache.ignite.internal.cdc.CdcMain.COMMITTED_SEG_IDX) ArrayList(java.util.ArrayList) ConcurrentMap(java.util.concurrent.ConcurrentMap) LAST_SEG_CONSUMPTION_TIME(org.apache.ignite.internal.cdc.CdcMain.LAST_SEG_CONSUMPTION_TIME) GridTestUtils.runAsync(org.apache.ignite.testframework.GridTestUtils.runAsync) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) GridAbsPredicate(org.apache.ignite.internal.util.lang.GridAbsPredicate) MetricExporterSpi(org.apache.ignite.spi.metric.MetricExporterSpi) IgniteInterruptedCheckedException(org.apache.ignite.internal.IgniteInterruptedCheckedException) COMMITTED_SEG_OFFSET(org.apache.ignite.internal.cdc.CdcMain.COMMITTED_SEG_OFFSET) MARSHALLER_DIR(org.apache.ignite.internal.cdc.CdcMain.MARSHALLER_DIR) CdcMain.cdcInstanceName(org.apache.ignite.internal.cdc.CdcMain.cdcInstanceName) Path(java.nio.file.Path) F(org.apache.ignite.internal.util.typedef.F) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Iterator(java.util.Iterator) IgniteException(org.apache.ignite.IgniteException) BINARY_META_DIR(org.apache.ignite.internal.cdc.CdcMain.BINARY_META_DIR) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) IOException(java.io.IOException) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry) CI3(org.apache.ignite.internal.util.typedef.CI3) LAST_EVT_TIME(org.apache.ignite.internal.cdc.WalRecordsConsumer.LAST_EVT_TIME) File(java.io.File) IgniteCache(org.apache.ignite.IgniteCache) IgniteBiTuple(org.apache.ignite.lang.IgniteBiTuple) CountDownLatch(java.util.concurrent.CountDownLatch) List(java.util.List) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) CUR_SEG_IDX(org.apache.ignite.internal.cdc.CdcMain.CUR_SEG_IDX) UPDATE(org.apache.ignite.cdc.AbstractCdcTest.ChangeEventType.UPDATE) EVTS_CNT(org.apache.ignite.internal.cdc.WalRecordsConsumer.EVTS_CNT) GridTestUtils.getFieldValue(org.apache.ignite.testframework.GridTestUtils.getFieldValue) DynamicMBean(javax.management.DynamicMBean) LongMetric(org.apache.ignite.spi.metric.LongMetric) CDC_DIR(org.apache.ignite.internal.cdc.CdcMain.CDC_DIR) DynamicMBean(javax.management.DynamicMBean) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) IgniteException(org.apache.ignite.IgniteException) ObjectMetric(org.apache.ignite.spi.metric.ObjectMetric) MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry) LongMetric(org.apache.ignite.spi.metric.LongMetric) IgniteInterruptedCheckedException(org.apache.ignite.internal.IgniteInterruptedCheckedException) IgniteException(org.apache.ignite.IgniteException) IOException(java.io.IOException)

Example 3 with ObjectMetric

use of org.apache.ignite.spi.metric.ObjectMetric in project ignite by apache.

the class OpenCensusMetricExporterSpi method export.

/**
 * {@inheritDoc}
 */
@Override
public void export() {
    StatsRecorder recorder = Stats.getStatsRecorder();
    try (Scope globalScope = tagScope()) {
        MeasureMap mmap = recorder.newMeasureMap();
        mreg.forEach(mreg -> {
            if (filter != null && !filter.test(mreg))
                return;
            mreg.forEach(metric -> {
                if (metric instanceof LongMetric || metric instanceof IntMetric || metric instanceof BooleanMetric || (metric instanceof ObjectMetric && ((ObjectMetric) metric).type() == Date.class) || (metric instanceof ObjectMetric && ((ObjectMetric) metric).type() == OffsetDateTime.class)) {
                    long val;
                    if (metric instanceof LongMetric)
                        val = ((LongMetric) metric).value();
                    else if (metric instanceof IntMetric)
                        val = ((IntMetric) metric).value();
                    else if (metric instanceof BooleanMetric)
                        val = ((BooleanMetric) metric).value() ? 1 : 0;
                    else if (metric instanceof ObjectMetric && ((ObjectMetric) metric).type() == Date.class)
                        val = ((ObjectMetric<Date>) metric).value().getTime();
                    else
                        val = ((ObjectMetric<OffsetDateTime>) metric).value().toInstant().toEpochMilli();
                    if (val < 0) {
                        if (log.isDebugEnabled())
                            log.debug("OpenCensus doesn't support negative values. Skip record of " + metric.name());
                        return;
                    }
                    MeasureLong msr = (MeasureLong) measures.computeIfAbsent(metric.name(), k -> createMeasure(metric, CREATE_LONG));
                    mmap.put(msr, val);
                } else if (metric instanceof DoubleMetric) {
                    double val = ((DoubleMetric) metric).value();
                    if (val < 0) {
                        if (log.isDebugEnabled())
                            log.debug("OpenCensus doesn't support negative values. Skip record of " + metric.name());
                        return;
                    }
                    MeasureDouble msr = (MeasureDouble) measures.computeIfAbsent(metric.name(), k -> createMeasure(metric, CREATE_DOUBLE));
                    mmap.put(msr, val);
                } else if (metric instanceof HistogramMetric) {
                    String[] names = histogramBucketNames((HistogramMetric) metric);
                    long[] vals = ((HistogramMetric) metric).value();
                    assert names.length == vals.length;
                    for (int i = 0; i < vals.length; i++) {
                        String name = names[i];
                        MeasureLong msr = (MeasureLong) measures.computeIfAbsent(name, k -> createMeasureLong(name, metric.description()));
                        mmap.put(msr, vals[i]);
                    }
                } else if (log.isDebugEnabled()) {
                    log.debug(metric.name() + "[" + metric.getClass() + "] not supported by Opencensus exporter");
                }
            });
        });
        mmap.record();
    }
}
Also used : StatsRecorder(io.opencensus.stats.StatsRecorder) TagContextBuilder(io.opencensus.tags.TagContextBuilder) StatsRecorder(io.opencensus.stats.StatsRecorder) IgniteSpiContext(org.apache.ignite.spi.IgniteSpiContext) IgniteSpiException(org.apache.ignite.spi.IgniteSpiException) Metric(org.apache.ignite.spi.metric.Metric) Stats(io.opencensus.stats.Stats) Date(java.util.Date) HashMap(java.util.HashMap) IgniteEx(org.apache.ignite.internal.IgniteEx) Function(java.util.function.Function) ObjectMetric(org.apache.ignite.spi.metric.ObjectMetric) ArrayList(java.util.ArrayList) PushMetricsExporterAdapter(org.apache.ignite.internal.processors.metric.PushMetricsExporterAdapter) Measure(io.opencensus.stats.Measure) MeasureDouble(io.opencensus.stats.Measure.MeasureDouble) MeasureMap(io.opencensus.stats.MeasureMap) Map(java.util.Map) TagMetadata(io.opencensus.tags.TagMetadata) TagValue(io.opencensus.tags.TagValue) View(io.opencensus.stats.View) ReadOnlyMetricManager(org.apache.ignite.spi.metric.ReadOnlyMetricManager) Tags(io.opencensus.tags.Tags) BooleanMetric(org.apache.ignite.spi.metric.BooleanMetric) HistogramMetric(org.apache.ignite.spi.metric.HistogramMetric) IntMetric(org.apache.ignite.spi.metric.IntMetric) Scope(io.opencensus.common.Scope) Name(io.opencensus.stats.View.Name) MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry) LastValue(io.opencensus.stats.Aggregation.LastValue) MeasureLong(io.opencensus.stats.Measure.MeasureLong) T2(org.apache.ignite.internal.util.typedef.T2) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) OffsetDateTime(java.time.OffsetDateTime) TagKey(io.opencensus.tags.TagKey) MetricUtils(org.apache.ignite.internal.processors.metric.impl.MetricUtils) UNLIMITED_PROPAGATION(io.opencensus.tags.TagMetadata.TagTtl.UNLIMITED_PROPAGATION) GridMetricManager(org.apache.ignite.internal.processors.metric.GridMetricManager) LongMetric(org.apache.ignite.spi.metric.LongMetric) DoubleMetric(org.apache.ignite.spi.metric.DoubleMetric) BooleanMetric(org.apache.ignite.spi.metric.BooleanMetric) HistogramMetric(org.apache.ignite.spi.metric.HistogramMetric) LongMetric(org.apache.ignite.spi.metric.LongMetric) MeasureDouble(io.opencensus.stats.Measure.MeasureDouble) MeasureMap(io.opencensus.stats.MeasureMap) Scope(io.opencensus.common.Scope) OffsetDateTime(java.time.OffsetDateTime) ObjectMetric(org.apache.ignite.spi.metric.ObjectMetric) MeasureLong(io.opencensus.stats.Measure.MeasureLong) DoubleMetric(org.apache.ignite.spi.metric.DoubleMetric) IntMetric(org.apache.ignite.spi.metric.IntMetric)

Example 4 with ObjectMetric

use of org.apache.ignite.spi.metric.ObjectMetric in project ignite by apache.

the class TcpDiscoverySpiMBeanTest method testMBean.

/**
 * Tests TcpDiscoverySpiMBean#getCurrentTopologyVersion() and TcpDiscoverySpiMBean#dumpRingStructure().
 *
 * @throws Exception if fails.
 */
@Test
public void testMBean() throws Exception {
    int cnt = 3;
    int cliIdx = cnt - 1;
    startGrids(cnt - 1);
    startClientGrid(cliIdx);
    ClusterNode crd = U.oldest(grid(0).context().discovery().aliveServerNodes(), null);
    assertNotNull(crd);
    try {
        for (int i = 0; i < cnt; i++) {
            IgniteEx grid = grid(i);
            MetricRegistry discoReg = grid.context().metric().registry(DISCO_METRICS);
            TcpDiscoverySpiMBean bean = getMxBean(grid.context().igniteInstanceName(), "SPIs", TcpDiscoverySpi.class, TcpDiscoverySpiMBean.class);
            assertNotNull(bean);
            assertEquals(grid.cluster().topologyVersion(), bean.getCurrentTopologyVersion());
            assertEquals(grid.cluster().topologyVersion(), discoReg.<LongMetric>findMetric("CurrentTopologyVersion").value());
            if (i != cliIdx) {
                assertEquals(crd.id(), bean.getCoordinator());
                assertEquals(crd.id(), discoReg.<ObjectMetric<UUID>>findMetric("Coordinator").value());
            } else {
                assertNull(bean.getCoordinator());
                assertNull(discoReg.findMetric("Coordinator"));
            }
            if (grid.localNode().id().equals(bean.getCoordinator())) {
                assertTrue(bean.getCoordinatorSinceTimestamp() > 0);
                assertTrue(discoReg.<LongMetric>findMetric("CoordinatorSince").value() > 0);
            } else {
                assertEquals(0, bean.getCoordinatorSinceTimestamp());
                if (i == cliIdx)
                    assertNull(discoReg.findMetric("CoordinatorSince"));
                else
                    assertEquals(0L, discoReg.<LongMetric>findMetric("CoordinatorSince").value());
            }
            // `getNodesJoined` returns count of joined nodes since local node startup.
            assertEquals((cnt - 1) - i, bean.getNodesJoined());
            assertEquals((cnt - 1) - i, discoReg.<IntMetric>findMetric("JoinedNodes").value());
            assertEquals(0L, bean.getNodesFailed());
            assertEquals(0, discoReg.<IntMetric>findMetric("FailedNodes").value());
            assertEquals(0L, bean.getNodesLeft());
            assertEquals(0, discoReg.<IntMetric>findMetric("LeftNodes").value());
            assertTrue(bean.getTotalReceivedMessages() > 0);
            assertTrue(discoReg.<IntMetric>findMetric("TotalReceivedMessages").value() > 0);
            assertTrue(bean.getTotalProcessedMessages() > 0);
            assertTrue(discoReg.<IntMetric>findMetric("TotalProcessedMessages").value() > 0);
            if (i != cliIdx) {
                assertTrue(bean.getPendingMessagesRegistered() > 0);
                assertTrue(discoReg.<IntMetric>findMetric("PendingMessagesRegistered").value() > 0);
            } else {
                assertEquals(0, bean.getPendingMessagesRegistered());
                assertEquals(0, discoReg.<IntMetric>findMetric("PendingMessagesRegistered").value());
            }
            assertEquals(0, bean.getPendingMessagesDiscarded());
            bean.dumpRingStructure();
            assertTrue(strLog.toString().contains("TcpDiscoveryNodesRing"));
            assertFalse(bean.getProcessedMessages().isEmpty());
            assertFalse(bean.getReceivedMessages().isEmpty());
            assertTrue(bean.getMaxMessageProcessingTime() >= 0);
            assertEquals(i == cliIdx, bean.isClientMode());
        }
        stopGrid(0);
        crd = U.oldest(grid(1).context().discovery().aliveServerNodes(), null);
        for (int i = 1; i < cnt; i++) {
            IgniteEx grid = grid(i);
            MetricRegistry discoReg = grid.context().metric().registry(DISCO_METRICS);
            TcpDiscoverySpiMBean bean = getMxBean(grid.context().igniteInstanceName(), "SPIs", TcpDiscoverySpi.class, TcpDiscoverySpiMBean.class);
            assertNotNull(bean);
            assertEquals(grid.cluster().topologyVersion(), bean.getCurrentTopologyVersion());
            assertEquals(grid.cluster().topologyVersion(), discoReg.<LongMetric>findMetric("CurrentTopologyVersion").value());
            if (i != cliIdx) {
                assertEquals(crd.id(), bean.getCoordinator());
                assertEquals(crd.id(), discoReg.<ObjectMetric<UUID>>findMetric("Coordinator").value());
            }
            if (grid.localNode().id().equals(crd.id())) {
                assertTrue(bean.getCoordinatorSinceTimestamp() > 0);
                assertTrue(discoReg.<LongMetric>findMetric("CoordinatorSince").value() > 0);
            }
            assertTrue(waitForCondition(() -> bean.getNodesLeft() == 1 && discoReg.<IntMetric>findMetric("LeftNodes").value() == 1, getTestTimeout()));
        }
    } finally {
        stopAllGrids();
    }
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) ObjectMetric(org.apache.ignite.spi.metric.ObjectMetric) IgniteEx(org.apache.ignite.internal.IgniteEx) MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry) LongMetric(org.apache.ignite.spi.metric.LongMetric) IntMetric(org.apache.ignite.spi.metric.IntMetric) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 5 with ObjectMetric

use of org.apache.ignite.spi.metric.ObjectMetric in project ignite by apache.

the class ZookeeperDiscoveryMiscTest method testMbean.

/**
 * @throws Exception if failed.
 */
@Test
public void testMbean() throws Exception {
    int cnt = 3;
    startGrids(cnt);
    UUID crdNodeId = grid(0).localNode().id();
    try {
        for (int i = 0; i < cnt; i++) {
            IgniteEx grid = grid(i);
            ZookeeperDiscoverySpiMBean bean = getMxBean(grid.context().igniteInstanceName(), "SPIs", ZookeeperDiscoverySpi.class, ZookeeperDiscoverySpiMBean.class);
            MetricRegistry discoReg = grid.context().metric().registry(DISCO_METRICS);
            assertNotNull(bean);
            assertEquals(String.valueOf(grid.cluster().node(crdNodeId)), bean.getCoordinatorNodeFormatted());
            assertEquals(String.valueOf(grid.cluster().localNode()), bean.getLocalNodeFormatted());
            assertEquals(zkCluster.getConnectString(), bean.getZkConnectionString());
            assertEquals((long) grid.configuration().getFailureDetectionTimeout(), bean.getZkSessionTimeout());
            assertEquals(grid.cluster().topologyVersion(), discoReg.<LongMetric>findMetric("CurrentTopologyVersion").value());
            assertEquals(grid.cluster().node(crdNodeId).id(), discoReg.<ObjectMetric<UUID>>findMetric("Coordinator").value());
            assertEquals(cnt - i - 1, bean.getNodesJoined());
            assertEquals(cnt - i - 1, discoReg.<LongMetric>findMetric("JoinedNodes").value());
            Arrays.asList("LeftNodes", "FailedNodes", "CommunicationErrors").forEach(name -> {
                assertEquals(0, discoReg.<LongMetric>findMetric(name).value());
            });
            assertEquals(0, bean.getNodesLeft());
            assertEquals(0, bean.getNodesFailed());
            assertEquals(0, bean.getCommErrorProcNum());
        }
    } finally {
        stopAllGrids();
    }
}
Also used : ZookeeperDiscoverySpiMBean(org.apache.ignite.spi.discovery.zk.ZookeeperDiscoverySpiMBean) ObjectMetric(org.apache.ignite.spi.metric.ObjectMetric) IgniteEx(org.apache.ignite.internal.IgniteEx) MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry) LongMetric(org.apache.ignite.spi.metric.LongMetric) UUID(java.util.UUID) Test(org.junit.Test)

Aggregations

MetricRegistry (org.apache.ignite.internal.processors.metric.MetricRegistry)5 ObjectMetric (org.apache.ignite.spi.metric.ObjectMetric)5 LongMetric (org.apache.ignite.spi.metric.LongMetric)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 IgniteEx (org.apache.ignite.internal.IgniteEx)3 IntMetric (org.apache.ignite.spi.metric.IntMetric)3 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)3 Test (org.junit.Test)3 Map (java.util.Map)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 Function (java.util.function.Function)2 GridAbsPredicate (org.apache.ignite.internal.util.lang.GridAbsPredicate)2 Scope (io.opencensus.common.Scope)1 LastValue (io.opencensus.stats.Aggregation.LastValue)1 Measure (io.opencensus.stats.Measure)1 MeasureDouble (io.opencensus.stats.Measure.MeasureDouble)1 MeasureLong (io.opencensus.stats.Measure.MeasureLong)1 MeasureMap (io.opencensus.stats.MeasureMap)1 Stats (io.opencensus.stats.Stats)1