Search in sources :

Example 1 with SegmentRouter

use of org.apache.ignite.internal.processors.cache.persistence.wal.SegmentRouter in project ignite by apache.

the class IgniteDataStorageMetricsSelfTest method checkWalArchiveAndTotalSize.

/**
 * Check the state of wal archive, and whether the total size of
 * wal (and possibly wal archive) match what is expected.
 *
 * @param igniteEx Node.
 * @param hasWalArchive Whether wal archiving is enabled.
 * @throws Exception If failed.
 */
private void checkWalArchiveAndTotalSize(IgniteEx igniteEx, boolean hasWalArchive) throws Exception {
    FileWriteAheadLogManager walMgr = walMgr(igniteEx);
    SegmentRouter router = walMgr.getSegmentRouter();
    assertEquals(router.hasArchive(), hasWalArchive);
    // Wait to avoid race condition where new segments(and corresponding .tmp files) are created after totalSize has been calculated.
    if (router.hasArchive()) {
        int expWalWorkSegements = igniteEx.configuration().getDataStorageConfiguration().getWalSegments();
        assertTrue(waitForCondition(() -> walFiles(router.getWalWorkDir()).length == expWalWorkSegements, 3000l));
        assertTrue(waitForCondition(() -> walMgr.lastArchivedSegment() == walMgr.currentSegment() - 1, 3000l));
    }
    long totalSize = walMgr.totalSize(walFiles(router.getWalWorkDir()));
    if (router.hasArchive())
        totalSize += walMgr.totalSize(walFiles(router.getWalArchiveDir()));
    assertEquals(totalSize, dbMgr(igniteEx).persistentStoreMetrics().getWalTotalSize());
    assertEquals(totalSize, dsMetricsMXBean(igniteEx).getWalTotalSize());
    assertEquals(totalSize, ((LongGauge) dsMetricRegistry(igniteEx).findMetric("WalTotalSize")).value());
}
Also used : SegmentRouter(org.apache.ignite.internal.processors.cache.persistence.wal.SegmentRouter) FileWriteAheadLogManager(org.apache.ignite.internal.processors.cache.persistence.wal.FileWriteAheadLogManager)

Example 2 with SegmentRouter

use of org.apache.ignite.internal.processors.cache.persistence.wal.SegmentRouter in project ignite by apache.

the class DiagnosticProcessorTest method expWalDirs.

/**
 * Getting expected WAL directories.
 *
 * @param n Node.
 * @return WAL directories.
 */
@Nullable
private File[] expWalDirs(IgniteEx n) {
    FileWriteAheadLogManager walMgr = walMgr(n);
    if (walMgr != null) {
        SegmentRouter sr = walMgr.getSegmentRouter();
        assertNotNull(sr);
        File workDir = sr.getWalWorkDir();
        return sr.hasArchive() ? F.asArray(workDir, sr.getWalArchiveDir()) : F.asArray(workDir);
    }
    return null;
}
Also used : SegmentRouter(org.apache.ignite.internal.processors.cache.persistence.wal.SegmentRouter) FileWriteAheadLogManager(org.apache.ignite.internal.processors.cache.persistence.wal.FileWriteAheadLogManager) DiagnosticProcessor.corruptedPagesFile(org.apache.ignite.internal.processors.diagnostic.DiagnosticProcessor.corruptedPagesFile) File(java.io.File) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

FileWriteAheadLogManager (org.apache.ignite.internal.processors.cache.persistence.wal.FileWriteAheadLogManager)2 SegmentRouter (org.apache.ignite.internal.processors.cache.persistence.wal.SegmentRouter)2 File (java.io.File)1 DiagnosticProcessor.corruptedPagesFile (org.apache.ignite.internal.processors.diagnostic.DiagnosticProcessor.corruptedPagesFile)1 Nullable (org.jetbrains.annotations.Nullable)1