use of org.apache.ignite.internal.processors.metric.MetricRegistry in project ignite by apache.
the class PagesWriteThrottleSmokeTest method totalThrottlingTime.
/**
* @param ignite Ignite instance.
* @return {@code totalThrottlingTime} metric for the default region.
*/
private LongAdderMetric totalThrottlingTime(IgniteEx ignite) {
MetricRegistry mreg = ignite.context().metric().registry(metricName(DATAREGION_METRICS_PREFIX, ignite.configuration().getDataStorageConfiguration().getDefaultDataRegionConfiguration().getName()));
LongAdderMetric totalThrottlingTime = mreg.findMetric("TotalThrottlingTime");
assertNotNull(totalThrottlingTime);
return totalThrottlingTime;
}
use of org.apache.ignite.internal.processors.metric.MetricRegistry 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.MetricRegistry in project ignite by apache.
the class GridJobMetricsSelfTest method testGridJobMetrics.
/**
* Test correct calculation of finished, started, active, canceled metrics of the {@link GridJobProcessor}.
*/
@Test
public void testGridJobMetrics() throws Exception {
latch = new CountDownLatch(1);
try (IgniteEx g = startGrid(0)) {
MetricRegistry mreg = g.context().metric().registry(JOBS_METRICS);
LongMetric started = mreg.findMetric(STARTED);
LongMetric active = mreg.findMetric(ACTIVE);
LongMetric waiting = mreg.findMetric(WAITING);
LongMetric canceled = mreg.findMetric(CANCELED);
LongMetric rejected = mreg.findMetric(REJECTED);
LongMetric finished = mreg.findMetric(FINISHED);
LongMetric totalExecutionTime = mreg.findMetric(EXECUTION_TIME);
LongMetric totalWaitingTime = mreg.findMetric(WAITING_TIME);
assertNotNull(started);
assertNotNull(active);
assertNotNull(waiting);
assertNotNull(canceled);
assertNotNull(rejected);
assertNotNull(finished);
assertNotNull(totalExecutionTime);
assertNotNull(totalWaitingTime);
assertEquals(0, started.value());
assertEquals(0, active.value());
assertEquals(0, waiting.value());
assertEquals(0, canceled.value());
assertEquals(0, rejected.value());
assertEquals(0, finished.value());
assertEquals(0, totalExecutionTime.value());
assertEquals(0, totalWaitingTime.value());
SimplestTask task = new SimplestTask();
g.compute().execute(task, 1);
// Waiting task to finish.
boolean res = waitForCondition(() -> active.value() == 0, TIMEOUT);
assertTrue("Active = " + active.value(), res);
assertEquals(1, started.value());
assertEquals(0, waiting.value());
assertEquals(0, canceled.value());
assertEquals(0, rejected.value());
assertEquals(1, finished.value());
// Task should block until latch is down.
task.block = true;
ComputeTaskFuture<?> fut = g.compute().executeAsync(task, 1);
// Waiting task to start execution.
res = waitForCondition(() -> active.value() == 1, TIMEOUT);
assertTrue("Active = " + active.value(), res);
assertEquals(2, started.value());
assertEquals(0, waiting.value());
assertEquals(0, canceled.value());
assertEquals(0, rejected.value());
assertEquals(1, finished.value());
// Sleeping to make sure totalExecutionTime will become more the zero.
Thread.sleep(100);
// After latch is down, task should finish.
latch.countDown();
fut.get(TIMEOUT);
res = waitForCondition(() -> active.value() == 0, TIMEOUT);
assertTrue("Active = " + active.value(), res);
assertTrue("Execution time should be greater then zero.", totalExecutionTime.value() > 0);
assertEquals(2, finished.value());
latch = new CountDownLatch(1);
fut = g.compute().executeAsync(task, 1);
res = waitForCondition(() -> active.value() == 1, TIMEOUT);
assertTrue("Active = " + active.value(), res);
assertEquals(3, started.value());
assertEquals(0, waiting.value());
assertEquals(0, canceled.value());
assertEquals(0, rejected.value());
assertEquals(2, finished.value());
// First cancel task, then allow it to finish.
fut.cancel();
latch.countDown();
res = waitForCondition(() -> active.value() == 0, TIMEOUT);
assertTrue("Active = " + active.value(), res);
assertEquals(3, started.value());
assertEquals(0, waiting.value());
assertEquals(1, canceled.value());
assertEquals(0, rejected.value());
res = waitForCondition(() -> finished.value() == 3, TIMEOUT);
assertTrue("Finished = " + finished.value(), res);
}
}
use of org.apache.ignite.internal.processors.metric.MetricRegistry in project ignite by apache.
the class ClientListenerMetricsTest method testClientListenerMetricsAccept.
/**
* Check that valid connections and disconnections to the grid affect metrics.
*/
@Test
public void testClientListenerMetricsAccept() throws Exception {
try (IgniteEx ignite = startGrid(0)) {
MetricRegistry mreg = ignite.context().metric().registry(CLIENT_CONNECTOR_METRICS);
checkConnectionsMetrics(mreg, 0, 0);
IgniteClient client0 = Ignition.startClient(getClientConfiguration());
checkConnectionsMetrics(mreg, 1, 1);
client0.close();
checkConnectionsMetrics(mreg, 1, 0);
IgniteClient client1 = Ignition.startClient(getClientConfiguration());
checkConnectionsMetrics(mreg, 2, 1);
IgniteClient client2 = Ignition.startClient(getClientConfiguration());
checkConnectionsMetrics(mreg, 3, 2);
client1.close();
checkConnectionsMetrics(mreg, 3, 1);
client2.close();
checkConnectionsMetrics(mreg, 3, 0);
}
}
use of org.apache.ignite.internal.processors.metric.MetricRegistry in project ignite by apache.
the class ClientListenerMetricsTest method testClientListenerMetricsReject.
/**
* Check that failed connection attempts to the grid affect metrics.
*/
@Test
public void testClientListenerMetricsReject() throws Exception {
cleanPersistenceDir();
IgniteConfiguration nodeCfg = getConfiguration().setClientConnectorConfiguration(new ClientConnectorConfiguration().setHandshakeTimeout(2000)).setAuthenticationEnabled(true).setDataStorageConfiguration(new DataStorageConfiguration().setDefaultDataRegionConfiguration(new DataRegionConfiguration().setPersistenceEnabled(true)));
try (IgniteEx ignite = startGrid(nodeCfg)) {
ignite.cluster().state(ClusterState.ACTIVE);
MetricRegistry mreg = ignite.context().metric().registry(CLIENT_CONNECTOR_METRICS);
checkRejectMetrics(mreg, 0, 0, 0);
ClientConfiguration cfgSsl = getClientConfiguration().setSslMode(SslMode.REQUIRED).setSslClientCertificateKeyStorePath(GridTestUtils.keyStorePath("client")).setSslClientCertificateKeyStoreType(DFLT_STORE_TYPE).setSslClientCertificateKeyStorePassword("123456").setSslTrustCertificateKeyStorePath(GridTestUtils.keyStorePath("trustone")).setSslTrustCertificateKeyStoreType(DFLT_STORE_TYPE).setSslTrustCertificateKeyStorePassword("123456");
GridTestUtils.assertThrows(log, () -> {
Ignition.startClient(cfgSsl);
return null;
}, ClientException.class, null);
checkRejectMetrics(mreg, 1, 0, 1);
ClientConfiguration cfgAuth = getClientConfiguration().setUserName("SomeRandomInvalidName").setUserPassword("42");
GridTestUtils.assertThrows(log, () -> {
Ignition.startClient(cfgAuth);
return null;
}, ClientAuthenticationException.class, null);
checkRejectMetrics(mreg, 1, 1, 2);
}
}
Aggregations