Search in sources :

Example 1 with HEADER_RECORD_SIZE

use of org.apache.ignite.internal.processors.cache.persistence.wal.serializer.RecordV1Serializer.HEADER_RECORD_SIZE 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)

Aggregations

File (java.io.File)1 Serializable (java.io.Serializable)1 Arrays (java.util.Arrays)1 Collections.emptyList (java.util.Collections.emptyList)1 Objects (java.util.Objects)1 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 Consumer (java.util.function.Consumer)1 UnaryOperator (java.util.function.UnaryOperator)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 DataRegionMetrics (org.apache.ignite.DataRegionMetrics)1 DataStorageMetrics (org.apache.ignite.DataStorageMetrics)1 IgniteCache (org.apache.ignite.IgniteCache)1 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1 IgniteException (org.apache.ignite.IgniteException)1 CacheAtomicityMode (org.apache.ignite.cache.CacheAtomicityMode)1 ATOMIC (org.apache.ignite.cache.CacheAtomicityMode.ATOMIC)1 CacheMode (org.apache.ignite.cache.CacheMode)1