Search in sources :

Example 31 with PageSnapshot

use of org.apache.ignite.internal.pagemem.wal.record.PageSnapshot in project ignite by apache.

the class IgniteWalConverterTest method testPages.

/**
 * Check that when using the "pages" argument we will see WalRecord with this pages in the utility output.
 *
 * @throws Exception If failed.
 */
@Test
public void testPages() throws Exception {
    List<T2<PageSnapshot, String>> walRecords = new ArrayList<>();
    String nodeDir = createWal(new ArrayList<>(), n -> {
        try (WALIterator walIter = n.context().cache().context().wal().replay(new WALPointer(0, 0, 0))) {
            while (walIter.hasNextX()) {
                WALRecord walRecord = walIter.nextX().get2();
                if (walRecord instanceof PageSnapshot)
                    walRecords.add(new T2<>((PageSnapshot) walRecord, walRecord.toString()));
            }
        }
    });
    assertFalse(walRecords.isEmpty());
    File walDir = U.resolveWorkDirectory(U.defaultWorkDirectory(), DFLT_WAL_PATH, false);
    assertTrue(U.fileCount(walDir.toPath()) > 0);
    File walNodeDir = new File(walDir, nodeDir);
    assertTrue(U.fileCount(walNodeDir.toPath()) > 0);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PrintStream ps = new PrintStream(baos);
    T2<PageSnapshot, String> expRec = walRecords.get(0);
    IgniteWalConverterArguments args = parse(ps, "walDir=" + walDir.getAbsolutePath(), "pages=" + expRec.get1().fullPageId().groupId() + ':' + expRec.get1().fullPageId().pageId(), "skipCrc=" + true);
    baos.reset();
    convert(ps, args);
    assertContains(log, baos.toString(), expRec.get2());
}
Also used : WALRecord(org.apache.ignite.internal.pagemem.wal.record.WALRecord) PrintStream(java.io.PrintStream) ArrayList(java.util.ArrayList) ByteArrayOutputStream(java.io.ByteArrayOutputStream) WALIterator(org.apache.ignite.internal.pagemem.wal.WALIterator) WALPointer(org.apache.ignite.internal.processors.cache.persistence.wal.WALPointer) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File) T2(org.apache.ignite.internal.util.typedef.T2) PageSnapshot(org.apache.ignite.internal.pagemem.wal.record.PageSnapshot) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Aggregations

PageSnapshot (org.apache.ignite.internal.pagemem.wal.record.PageSnapshot)31 FullPageId (org.apache.ignite.internal.pagemem.FullPageId)23 WALPointer (org.apache.ignite.internal.processors.cache.persistence.wal.WALPointer)19 CheckpointRecord (org.apache.ignite.internal.pagemem.wal.record.CheckpointRecord)18 WALRecord (org.apache.ignite.internal.pagemem.wal.record.WALRecord)17 Test (org.junit.Test)13 File (java.io.File)12 WALIterator (org.apache.ignite.internal.pagemem.wal.WALIterator)12 ByteBuffer (java.nio.ByteBuffer)11 IgniteEx (org.apache.ignite.internal.IgniteEx)10 T2 (org.apache.ignite.internal.util.typedef.T2)10 ArrayList (java.util.ArrayList)9 MetastoreDataRecord (org.apache.ignite.internal.pagemem.wal.record.MetastoreDataRecord)9 HashSet (java.util.HashSet)8 DataRecord (org.apache.ignite.internal.pagemem.wal.record.DataRecord)8 MemoryRecoveryRecord (org.apache.ignite.internal.pagemem.wal.record.MemoryRecoveryRecord)8 HashMap (java.util.HashMap)7 UUID (java.util.UUID)7 FixCountRecord (org.apache.ignite.internal.pagemem.wal.record.delta.FixCountRecord)6 Map (java.util.Map)5