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());
}
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);
}
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());
}
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();
}
}
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"));
}
Aggregations