Search in sources :

Example 6 with LongAdderMetric

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;
}
Also used : MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry) LongAdderMetric(org.apache.ignite.internal.processors.metric.impl.LongAdderMetric)

Example 7 with LongAdderMetric

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());
}
Also used : CacheAtomicityMode(org.apache.ignite.cache.CacheAtomicityMode) ListeningTestLogger(org.apache.ignite.testframework.ListeningTestLogger) Arrays(java.util.Arrays) UnaryOperator(java.util.function.UnaryOperator) IgniteEx(org.apache.ignite.internal.IgniteEx) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) BinaryConfiguration(org.apache.ignite.configuration.BinaryConfiguration) Matcher(java.util.regex.Matcher) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) LongAdderMetric(org.apache.ignite.internal.processors.metric.impl.LongAdderMetric) AtomicLongMetric(org.apache.ignite.internal.processors.metric.impl.AtomicLongMetric) DataStorageMetricsMXBean(org.apache.ignite.mxbean.DataStorageMetricsMXBean) PARTITIONED(org.apache.ignite.cache.CacheMode.PARTITIONED) WALMode(org.apache.ignite.configuration.WALMode) HistogramMetric(org.apache.ignite.spi.metric.HistogramMetric) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) QuerySqlField(org.apache.ignite.cache.query.annotations.QuerySqlField) Collections.emptyList(java.util.Collections.emptyList) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException) DataRecord(org.apache.ignite.internal.pagemem.wal.record.DataRecord) IgniteCache(org.apache.ignite.IgniteCache) Serializable(java.io.Serializable) Objects(java.util.Objects) DataRegionMetrics(org.apache.ignite.DataRegionMetrics) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) Pattern(java.util.regex.Pattern) FileWriteAheadLogManager(org.apache.ignite.internal.processors.cache.persistence.wal.FileWriteAheadLogManager) LongGauge(org.apache.ignite.internal.processors.metric.impl.LongGauge) WALDisableContext(org.apache.ignite.internal.processors.cache.WalStateManager.WALDisableContext) GridTestUtils.waitForCondition(org.apache.ignite.testframework.GridTestUtils.waitForCondition) U(org.apache.ignite.internal.util.typedef.internal.U) HEADER_RECORD_SIZE(org.apache.ignite.internal.processors.cache.persistence.wal.serializer.RecordV1Serializer.HEADER_RECORD_SIZE) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) PAX(org.apache.ignite.internal.util.typedef.PAX) S(org.apache.ignite.internal.util.typedef.internal.S) DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) SegmentRouter(org.apache.ignite.internal.processors.cache.persistence.wal.SegmentRouter) ACTIVE(org.apache.ignite.cluster.ClusterState.ACTIVE) DataStorageMetrics(org.apache.ignite.DataStorageMetrics) Test(org.junit.Test) MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry) FULL_SYNC(org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC) File(java.io.File) GridToStringInclude(org.apache.ignite.internal.util.tostring.GridToStringInclude) Consumer(java.util.function.Consumer) AtomicLong(java.util.concurrent.atomic.AtomicLong) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) GridTestUtils.setFieldValue(org.apache.ignite.testframework.GridTestUtils.setFieldValue) ATOMIC(org.apache.ignite.cache.CacheAtomicityMode.ATOMIC) DATASTORAGE_METRIC_PREFIX(org.apache.ignite.internal.processors.cache.persistence.DataStorageMetricsImpl.DATASTORAGE_METRIC_PREFIX) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) FileDescriptor(org.apache.ignite.internal.processors.cache.persistence.wal.FileDescriptor) CacheMode(org.apache.ignite.cache.CacheMode) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) IgniteEx(org.apache.ignite.internal.IgniteEx) DataRecord(org.apache.ignite.internal.pagemem.wal.record.DataRecord) WALDisableContext(org.apache.ignite.internal.processors.cache.WalStateManager.WALDisableContext) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 8 with LongAdderMetric

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);
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) IgniteEx(org.apache.ignite.internal.IgniteEx) MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry) LongAdderMetric(org.apache.ignite.internal.processors.metric.impl.LongAdderMetric) UUID(java.util.UUID)

Example 9 with LongAdderMetric

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;
}
Also used : IgniteMessageFactoryImpl(org.apache.ignite.internal.managers.communication.IgniteMessageFactoryImpl) IntHashMap(org.apache.ignite.internal.util.collection.IntHashMap) IgniteBiTuple(org.apache.ignite.lang.IgniteBiTuple) LongAdderMetric(org.apache.ignite.internal.processors.metric.impl.LongAdderMetric)

Example 10 with LongAdderMetric

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());
}
Also used : LongAdderMetric(org.apache.ignite.internal.processors.metric.impl.LongAdderMetric) 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)

Aggregations

LongAdderMetric (org.apache.ignite.internal.processors.metric.impl.LongAdderMetric)10 Test (org.junit.Test)6 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)5 IgniteEx (org.apache.ignite.internal.IgniteEx)4 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 MetricRegistry (org.apache.ignite.internal.processors.metric.MetricRegistry)3 UUID (java.util.UUID)2 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)2 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)2 IgniteException (org.apache.ignite.IgniteException)2 DataRegionConfiguration (org.apache.ignite.configuration.DataRegionConfiguration)2 DataStorageConfiguration (org.apache.ignite.configuration.DataStorageConfiguration)2 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)2 UnsafeMemoryProvider (org.apache.ignite.internal.mem.unsafe.UnsafeMemoryProvider)2 DataRegionMetricsImpl (org.apache.ignite.internal.processors.cache.persistence.DataRegionMetricsImpl)2 File (java.io.File)1 Serializable (java.io.Serializable)1 ByteBuffer (java.nio.ByteBuffer)1 ByteOrder (java.nio.ByteOrder)1