Search in sources :

Example 1 with AtomicLongMetric

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

the class MetricsSelfTest method testLongCounter.

/**
 */
@Test
public void testLongCounter() throws Exception {
    AtomicLongMetric l = mreg.longMetric("ltest", "test");
    run(l::increment, 100);
    assertEquals(100 * 100, l.value());
    l.reset();
    assertEquals(0, l.value());
}
Also used : AtomicLongMetric(org.apache.ignite.internal.processors.metric.impl.AtomicLongMetric) BooleanMetricImpl(org.apache.ignite.internal.processors.metric.impl.BooleanMetricImpl) DoubleMetricImpl(org.apache.ignite.internal.processors.metric.impl.DoubleMetricImpl) HistogramMetricImpl(org.apache.ignite.internal.processors.metric.impl.HistogramMetricImpl) IntMetricImpl(org.apache.ignite.internal.processors.metric.impl.IntMetricImpl) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 2 with AtomicLongMetric

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

the class MetricsSelfTest method testRegister.

/**
 */
@Test
public void testRegister() throws Exception {
    String mName = "rtest";
    AtomicLongMetric l = new AtomicLongMetric(metricName(mreg.name(), mName), "test");
    mreg.register(l);
    assertEquals(l, mreg.findMetric(mName));
    l.reset();
    assertEquals(0, l.value());
    assertThrowsWithCause(() -> mreg.register(new AtomicLongMetric(mName, "")), StringIndexOutOfBoundsException.class);
    assertThrowsWithCause(() -> mreg.register(new AtomicLongMetric(metricName("mreg", mName), "")), AssertionError.class);
}
Also used : AtomicLongMetric(org.apache.ignite.internal.processors.metric.impl.AtomicLongMetric) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 3 with AtomicLongMetric

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

the class CacheGroupMetricsTest method testInitializedLocalPartitions.

/**
 * Verifies metric for initialized local partitions.
 * It is incremented when partition is actually created on node and decremented when it is destroyed.
 *
 * @throws Exception If failed.
 */
@Test
public void testInitializedLocalPartitions() throws Exception {
    pds = true;
    cleanPersistenceDir();
    IgniteEx ignite = startGrid(0);
    ignite.cluster().active(true);
    MetricRegistry group1Metrics = cacheGroupMetrics(0, "group1").get2();
    AtomicLongMetric locPartsNum = group1Metrics.findMetric("InitializedLocalPartitionsNumber");
    assertEquals(0, locPartsNum.value());
    IgniteCache cache = ignite.cache("cache1");
    for (int i = 0; i < 10; i++) cache.put(i, new byte[100]);
    assertEquals(10, locPartsNum.value());
}
Also used : IgniteEx(org.apache.ignite.internal.IgniteEx) MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry) AtomicLongMetric(org.apache.ignite.internal.processors.metric.impl.AtomicLongMetric) IgniteCache(org.apache.ignite.IgniteCache) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 4 with AtomicLongMetric

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

the class IgniteDataStorageMetricsSelfTest method testCheckpointMetrics.

/**
 * @throws Exception if failed.
 */
@Test
public void testCheckpointMetrics() throws Exception {
    Pattern cpPtrn = Pattern.compile("^Checkpoint started .*" + "checkpointBeforeLockTime=(\\d+)ms, " + "checkpointLockWait=(\\d+)ms, " + "checkpointListenersExecuteTime=(\\d+)ms, " + "checkpointLockHoldTime=(\\d+)ms, " + "walCpRecordFsyncDuration=(\\d+)ms, " + "writeCheckpointEntryDuration=(\\d+)ms, " + "splitAndSortCpPagesDuration=(\\d+)ms");
    AtomicLong expLastCpBeforeLockDuration = new AtomicLong();
    AtomicLong expLastCpLockWaitDuration = new AtomicLong();
    AtomicLong expLastCpListenersExecuteDuration = new AtomicLong();
    AtomicLong expLastCpLockHoldDuration = new AtomicLong();
    AtomicLong expLastCpWalRecordFsyncDuration = new AtomicLong();
    AtomicLong expLastCpWriteEntryDuration = new AtomicLong();
    AtomicLong expLastCpSplitAndSortPagesDuration = new AtomicLong();
    AtomicInteger cpCnt = new AtomicInteger();
    listeningLog.registerListener(s -> {
        Matcher matcher = cpPtrn.matcher(s);
        if (!matcher.find())
            return;
        expLastCpBeforeLockDuration.set(Long.parseLong(matcher.group(1)));
        expLastCpLockWaitDuration.set(Long.parseLong(matcher.group(2)));
        expLastCpListenersExecuteDuration.set(Long.parseLong(matcher.group(3)));
        expLastCpLockHoldDuration.set(Long.parseLong(matcher.group(4)));
        expLastCpWalRecordFsyncDuration.set(Long.parseLong(matcher.group(5)));
        expLastCpWriteEntryDuration.set(Long.parseLong(matcher.group(6)));
        expLastCpSplitAndSortPagesDuration.set(Long.parseLong(matcher.group(7)));
        cpCnt.incrementAndGet();
    });
    IgniteEx node = startGrid(0);
    node.cluster().state(ACTIVE);
    GridCacheDatabaseSharedManager db = (GridCacheDatabaseSharedManager) node.context().cache().context().database();
    db.checkpointReadLock();
    try {
        waitForCondition(() -> cpCnt.get() > 0, getTestTimeout());
        MetricRegistry mreg = node.context().metric().registry(DATASTORAGE_METRIC_PREFIX);
        AtomicLongMetric lastCpBeforeLockDuration = mreg.findMetric("LastCheckpointBeforeLockDuration");
        AtomicLongMetric lastCpLockWaitDuration = mreg.findMetric("LastCheckpointLockWaitDuration");
        AtomicLongMetric lastCpListenersExecuteDuration = mreg.findMetric("LastCheckpointListenersExecuteDuration");
        AtomicLongMetric lastCpLockHoldDuration = mreg.findMetric("LastCheckpointLockHoldDuration");
        AtomicLongMetric lastCpWalRecordFsyncDuration = mreg.findMetric("LastCheckpointWalRecordFsyncDuration");
        AtomicLongMetric lastCpWriteEntryDuration = mreg.findMetric("LastCheckpointWriteEntryDuration");
        AtomicLongMetric lastCpSplitAndSortPagesDuration = mreg.findMetric("LastCheckpointSplitAndSortPagesDuration");
        HistogramMetric cpBeforeLockHistogram = mreg.findMetric("CheckpointBeforeLockHistogram");
        HistogramMetric cpLockWaitHistogram = mreg.findMetric("CheckpointLockWaitHistogram");
        HistogramMetric cpListenersExecuteHistogram = mreg.findMetric("CheckpointListenersExecuteHistogram");
        HistogramMetric cpMarkHistogram = mreg.findMetric("CheckpointMarkHistogram");
        HistogramMetric cpLockHoldHistogram = mreg.findMetric("CheckpointLockHoldHistogram");
        HistogramMetric cpPagesWriteHistogram = mreg.findMetric("CheckpointPagesWriteHistogram");
        HistogramMetric cpFsyncHistogram = mreg.findMetric("CheckpointFsyncHistogram");
        HistogramMetric cpWalRecordFsyncHistogram = mreg.findMetric("CheckpointWalRecordFsyncHistogram");
        HistogramMetric cpWriteEntryHistogram = mreg.findMetric("CheckpointWriteEntryHistogram");
        HistogramMetric cpSplitAndSortPagesHistogram = mreg.findMetric("CheckpointSplitAndSortPagesHistogram");
        HistogramMetric cpHistogram = mreg.findMetric("CheckpointHistogram");
        waitForCondition(() -> cpCnt.get() == Arrays.stream(cpHistogram.value()).sum(), getTestTimeout());
        assertEquals(cpCnt.get(), Arrays.stream(cpBeforeLockHistogram.value()).sum());
        assertEquals(cpCnt.get(), Arrays.stream(cpLockWaitHistogram.value()).sum());
        assertEquals(cpCnt.get(), Arrays.stream(cpListenersExecuteHistogram.value()).sum());
        assertEquals(cpCnt.get(), Arrays.stream(cpMarkHistogram.value()).sum());
        assertEquals(cpCnt.get(), Arrays.stream(cpLockHoldHistogram.value()).sum());
        assertEquals(cpCnt.get(), Arrays.stream(cpPagesWriteHistogram.value()).sum());
        assertEquals(cpCnt.get(), Arrays.stream(cpFsyncHistogram.value()).sum());
        assertEquals(cpCnt.get(), Arrays.stream(cpWalRecordFsyncHistogram.value()).sum());
        assertEquals(cpCnt.get(), Arrays.stream(cpWriteEntryHistogram.value()).sum());
        assertEquals(cpCnt.get(), Arrays.stream(cpSplitAndSortPagesHistogram.value()).sum());
        assertEquals(expLastCpBeforeLockDuration.get(), lastCpBeforeLockDuration.value());
        assertEquals(expLastCpLockWaitDuration.get(), lastCpLockWaitDuration.value());
        assertEquals(expLastCpListenersExecuteDuration.get(), lastCpListenersExecuteDuration.value());
        assertEquals(expLastCpLockHoldDuration.get(), lastCpLockHoldDuration.value());
        assertEquals(expLastCpWalRecordFsyncDuration.get(), lastCpWalRecordFsyncDuration.value());
        assertEquals(expLastCpWriteEntryDuration.get(), lastCpWriteEntryDuration.value());
        assertEquals(expLastCpSplitAndSortPagesDuration.get(), lastCpSplitAndSortPagesDuration.value());
    } finally {
        db.checkpointReadUnlock();
    }
}
Also used : Pattern(java.util.regex.Pattern) AtomicLong(java.util.concurrent.atomic.AtomicLong) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Matcher(java.util.regex.Matcher) IgniteEx(org.apache.ignite.internal.IgniteEx) MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry) AtomicLongMetric(org.apache.ignite.internal.processors.metric.impl.AtomicLongMetric) HistogramMetric(org.apache.ignite.spi.metric.HistogramMetric) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 5 with AtomicLongMetric

use of org.apache.ignite.internal.processors.metric.impl.AtomicLongMetric 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

AtomicLongMetric (org.apache.ignite.internal.processors.metric.impl.AtomicLongMetric)5 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)5 Test (org.junit.Test)5 MetricRegistry (org.apache.ignite.internal.processors.metric.MetricRegistry)3 IgniteEx (org.apache.ignite.internal.IgniteEx)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 IgniteCache (org.apache.ignite.IgniteCache)1 BooleanMetricImpl (org.apache.ignite.internal.processors.metric.impl.BooleanMetricImpl)1 DoubleMetricImpl (org.apache.ignite.internal.processors.metric.impl.DoubleMetricImpl)1 HistogramMetricImpl (org.apache.ignite.internal.processors.metric.impl.HistogramMetricImpl)1 IntMetricImpl (org.apache.ignite.internal.processors.metric.impl.IntMetricImpl)1 HistogramMetric (org.apache.ignite.spi.metric.HistogramMetric)1