use of org.apache.ignite.internal.processors.metric.impl.LongAdderMetric 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.impl.LongAdderMetric in project ignite by apache.
the class IgniteDataStorageMetricsSelfTest method testWalWrittenBytes.
/**
* Checking that the metrics of the total logged bytes are working correctly.
*
* @throws Exception If failed.
*/
@Test
public void testWalWrittenBytes() throws Exception {
IgniteEx n = startGrid(0, (UnaryOperator<IgniteConfiguration>) cfg -> {
cfg.getDataStorageConfiguration().setWalSegmentSize((int) (2 * U.MB));
return cfg;
});
n.cluster().state(ACTIVE);
awaitPartitionMapExchange();
for (int i = 0; i < 10; i++) n.cache("cache").put(ThreadLocalRandom.current().nextLong(), new byte[(int) (32 * U.KB)]);
WALDisableContext walDisableCtx = n.context().cache().context().walState().walDisableContext();
assertNotNull(walDisableCtx);
setFieldValue(walDisableCtx, "disableWal", true);
assertTrue(walDisableCtx.check());
assertNull(walMgr(n).log(new DataRecord(emptyList())));
assertEquals(-1, walMgr(n).lastArchivedSegment());
long exp = walMgr(n).lastWritePointer().fileOffset() - HEADER_RECORD_SIZE;
assertEquals(exp, dbMgr(n).persistentStoreMetrics().getWalWrittenBytes());
assertEquals(exp, dsMetricsMXBean(n).getWalWrittenBytes());
assertEquals(exp, ((LongAdderMetric) dsMetricRegistry(n).findMetric("WalWrittenBytes")).value());
}
use of org.apache.ignite.internal.processors.metric.impl.LongAdderMetric 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.impl.LongAdderMetric in project ignite by apache.
the class TcpCommunicationMetricsListener method createMessageCounters.
/**
* Creates counters of sent and received messages by direct type.
*
* @param factory Message factory.
* @return Counters of sent and received messages grouped by direct type.
*/
private IntMap<IgniteBiTuple<LongAdderMetric, LongAdderMetric>> createMessageCounters(IgniteMessageFactory factory) {
IgniteMessageFactoryImpl msgFactory = (IgniteMessageFactoryImpl) factory;
short[] directTypes = msgFactory.registeredDirectTypes();
IntMap<IgniteBiTuple<LongAdderMetric, LongAdderMetric>> msgCntrsByType = new IntHashMap<>(directTypes.length);
for (short type : directTypes) {
LongAdderMetric sentCnt = mreg.longAdderMetric(sentMessagesByTypeMetricName(type), SENT_MESSAGES_BY_TYPE_METRIC_DESC);
LongAdderMetric rcvCnt = mreg.longAdderMetric(receivedMessagesByTypeMetricName(type), RECEIVED_MESSAGES_BY_TYPE_METRIC_DESC);
msgCntrsByType.put(type, new IgniteBiTuple<>(sentCnt, rcvCnt));
}
return msgCntrsByType;
}
use of org.apache.ignite.internal.processors.metric.impl.LongAdderMetric in project ignite by apache.
the class MetricsSelfTest method testLongAdderCounter.
/**
*/
@Test
public void testLongAdderCounter() throws Exception {
LongAdderMetric l = mreg.longAdderMetric("latest", "test");
run(l::increment, 100);
assertEquals(100 * 100, l.value());
l.reset();
assertEquals(0, l.value());
}
Aggregations