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