Search in sources :

Example 71 with MetricRegistry

use of org.apache.ignite.internal.processors.metric.MetricRegistry in project ignite by apache.

the class ClientListenerMetricsTest method testClientListenerMetricsRejectGeneral.

/**
 * Check that failed connection attempts to the grid affect metrics.
 */
@Test
public void testClientListenerMetricsRejectGeneral() throws Exception {
    IgniteConfiguration nodeCfg = getConfiguration().setClientConnectorConfiguration(new ClientConnectorConfiguration().setThinClientEnabled(false));
    try (IgniteEx ignite = startGrid(nodeCfg)) {
        MetricRegistry mreg = ignite.context().metric().registry(CLIENT_CONNECTOR_METRICS);
        checkRejectMetrics(mreg, 0, 0, 0);
        GridTestUtils.assertThrows(log, () -> {
            Ignition.startClient(getClientConfiguration());
            return null;
        }, RuntimeException.class, "Thin client connection is not allowed");
        checkRejectMetrics(mreg, 0, 0, 1);
    }
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) ClientConnectorConfiguration(org.apache.ignite.configuration.ClientConnectorConfiguration) IgniteEx(org.apache.ignite.internal.IgniteEx) MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 72 with MetricRegistry

use of org.apache.ignite.internal.processors.metric.MetricRegistry in project ignite by apache.

the class CheckpointTest method testCheckpoint.

/**
 * @throws Exception If failed.
 */
@Test
public void testCheckpoint() throws Exception {
    IgniteEx srv = startGrid();
    srv.cluster().state(ClusterState.ACTIVE);
    MetricRegistry mreg = srv.context().metric().registry(DATASTORAGE_METRIC_PREFIX);
    LongMetric lastStart = mreg.findMetric("LastCheckpointStart");
    // Wait for checkpoint to finish on node start.
    assertTrue(waitForCondition(() -> 0 < lastStart.value(), TIMEOUT));
    lastStart.reset();
    startCollectStatistics();
    forceCheckpoint();
    assertTrue(waitForCondition(() -> 0 < lastStart.value(), TIMEOUT));
    AtomicInteger cnt = new AtomicInteger();
    stopCollectStatisticsAndRead(new TestHandler() {

        @Override
        public void checkpoint(UUID nodeId, long beforeLockDuration, long lockWaitDuration, long listenersExecDuration, long markDuration, long lockHoldDuration, long pagesWriteDuration, long fsyncDuration, long walCpRecordFsyncDuration, long writeCpEntryDuration, long splitAndSortCpPagesDuration, long totalDuration, long cpStartTime, int pagesSize, int dataPagesWritten, int cowPagesWritten) {
            assertEquals(srv.localNode().id(), nodeId);
            assertEquals(mreg.<LongMetric>findMetric("LastCheckpointBeforeLockDuration").value(), beforeLockDuration);
            assertEquals(mreg.<LongMetric>findMetric("LastCheckpointLockWaitDuration").value(), lockWaitDuration);
            assertEquals(mreg.<LongMetric>findMetric("LastCheckpointListenersExecuteDuration").value(), listenersExecDuration);
            assertEquals(mreg.<LongMetric>findMetric("LastCheckpointMarkDuration").value(), markDuration);
            assertEquals(mreg.<LongMetric>findMetric("LastCheckpointLockHoldDuration").value(), lockHoldDuration);
            assertEquals(mreg.<LongMetric>findMetric("LastCheckpointPagesWriteDuration").value(), pagesWriteDuration);
            assertEquals(mreg.<LongMetric>findMetric("LastCheckpointFsyncDuration").value(), fsyncDuration);
            assertEquals(mreg.<LongMetric>findMetric("LastCheckpointWalRecordFsyncDuration").value(), walCpRecordFsyncDuration);
            assertEquals(mreg.<LongMetric>findMetric("LastCheckpointWriteEntryDuration").value(), writeCpEntryDuration);
            assertEquals(mreg.<LongMetric>findMetric("LastCheckpointSplitAndSortPagesDuration").value(), splitAndSortCpPagesDuration);
            assertEquals(mreg.<LongMetric>findMetric("LastCheckpointDuration").value(), totalDuration);
            assertEquals(lastStart.value(), cpStartTime);
            assertEquals(mreg.<LongMetric>findMetric("LastCheckpointTotalPagesNumber").value(), pagesSize);
            assertEquals(mreg.<LongMetric>findMetric("LastCheckpointDataPagesNumber").value(), dataPagesWritten);
            assertEquals(mreg.<LongMetric>findMetric("LastCheckpointCopiedOnWritePagesNumber").value(), cowPagesWritten);
            cnt.incrementAndGet();
        }
    });
    assertEquals(1, cnt.get());
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) 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)

Example 73 with MetricRegistry

use of org.apache.ignite.internal.processors.metric.MetricRegistry in project ignite by apache.

the class CheckpointTest method checkThrottling.

/**
 * @throws Exception if failed.
 */
public void checkThrottling() throws Exception {
    IgniteEx srv = startGrid();
    srv.cluster().state(ClusterState.ACTIVE);
    IgniteCache<Long, Long> cache = srv.getOrCreateCache(DEFAULT_CACHE_NAME);
    long start = U.currentTimeMillis();
    MetricRegistry mreg = srv.context().metric().registry(metricName(DATAREGION_METRICS_PREFIX, DFLT_DATA_REG_DEFAULT_NAME));
    LongAdderMetric totalThrottlingTime = mreg.findMetric("TotalThrottlingTime");
    startCollectStatistics();
    AtomicBoolean stop = new AtomicBoolean();
    slowCheckpointEnabled.set(true);
    IgniteInternalFuture<?> fut = GridTestUtils.runAsync(() -> {
        while (!stop.get()) cache.put(ThreadLocalRandom.current().nextLong(1024), ThreadLocalRandom.current().nextLong());
    });
    assertTrue(waitForCondition(() -> 0 < totalThrottlingTime.value(), TIMEOUT));
    stop.set(true);
    AtomicInteger cnt = new AtomicInteger();
    stopCollectStatisticsAndRead(new TestHandler() {

        @Override
        public void pagesWriteThrottle(UUID nodeId, long endTime, long duration) {
            assertEquals(srv.localNode().id(), nodeId);
            assertTrue(start <= endTime);
            assertTrue(duration >= 0);
            cnt.incrementAndGet();
        }
    });
    assertTrue(cnt.get() > 0);
    fut.get(TIMEOUT);
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) IgniteEx(org.apache.ignite.internal.IgniteEx) MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry) LongAdderMetric(org.apache.ignite.internal.processors.metric.impl.LongAdderMetric) UUID(java.util.UUID)

Example 74 with MetricRegistry

use of org.apache.ignite.internal.processors.metric.MetricRegistry in project ignite by apache.

the class MetricsClusterActivationTest method checkDataRegionMetrics.

/**
 * Checks data region metrics.
 */
private void checkDataRegionMetrics(IgniteEx ignite) throws IgniteCheckedException {
    DataRegion region = ignite.context().cache().context().database().dataRegion(DFLT_DATA_REG_DEFAULT_NAME);
    MetricRegistry mreg = ignite.context().metric().registry(metricName(DATAREGION_METRICS_PREFIX, DFLT_DATA_REG_DEFAULT_NAME));
    if (!ignite.cluster().state().active()) {
        assertEquals(0, F.size(mreg.iterator()));
        return;
    }
    long offHeapSize = mreg.<LongMetric>findMetric("OffHeapSize").value();
    long initialSize = mreg.<LongMetric>findMetric("InitialSize").value();
    long maxSize = mreg.<LongMetric>findMetric("MaxSize").value();
    assertTrue(offHeapSize > 0);
    assertTrue(offHeapSize <= region.config().getMaxSize());
    assertEquals(region.config().getInitialSize(), initialSize);
    assertEquals(region.config().getMaxSize(), maxSize);
}
Also used : MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry) DataRegion(org.apache.ignite.internal.processors.cache.persistence.DataRegion)

Example 75 with MetricRegistry

use of org.apache.ignite.internal.processors.metric.MetricRegistry in project ignite by apache.

the class MetricsSelfTest method testRemove.

/**
 */
@Test
public void testRemove() throws Exception {
    MetricRegistry mreg = new MetricRegistry("group", name -> null, name -> null, null);
    AtomicLongMetric cntr = mreg.longMetric("my.name", null);
    AtomicLongMetric cntr2 = mreg.longMetric("my.name.x", null);
    assertNotNull(cntr);
    assertNotNull(cntr2);
    assertNotNull(mreg.findMetric("my.name"));
    assertNotNull(mreg.findMetric("my.name.x"));
    mreg.remove("my.name");
    assertNull(mreg.findMetric("my.name"));
    assertNotNull(mreg.findMetric("my.name.x"));
    cntr = mreg.longMetric("my.name", null);
    assertNotNull(mreg.findMetric("my.name"));
}
Also used : MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry) AtomicLongMetric(org.apache.ignite.internal.processors.metric.impl.AtomicLongMetric) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Aggregations

MetricRegistry (org.apache.ignite.internal.processors.metric.MetricRegistry)86 Test (org.junit.Test)52 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)29 IgniteEx (org.apache.ignite.internal.IgniteEx)26 LongMetric (org.apache.ignite.spi.metric.LongMetric)26 List (java.util.List)11 CountDownLatch (java.util.concurrent.CountDownLatch)11 UUID (java.util.UUID)10 Map (java.util.Map)8 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)8 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)8 ArrayList (java.util.ArrayList)7 IgniteException (org.apache.ignite.IgniteException)7 IgniteInternalFuture (org.apache.ignite.internal.IgniteInternalFuture)7 IntMetric (org.apache.ignite.spi.metric.IntMetric)7 IgniteCache (org.apache.ignite.IgniteCache)6 ClusterNode (org.apache.ignite.cluster.ClusterNode)6 Arrays (java.util.Arrays)5 HashSet (java.util.HashSet)5 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)5