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