use of org.apache.ignite.internal.pagemem.wal.record.WALRecord.RecordType.CHECKPOINT_RECORD in project ignite by apache.
the class IgniteWithoutArchiverWalIteratorInvalidCrcTest method nodeShouldStartIfBinaryRecordCorruptedBeforeEndCheckpoint.
/**
* Binary record was corrupted, before start last checkpoint without end.
* -----||--X---||--------->
* Node can't start.
*/
@Test
public void nodeShouldStartIfBinaryRecordCorruptedBeforeEndCheckpoint() throws Exception {
startNodeAndPopulate();
stopGrid(0, true);
IgniteWriteAheadLogManager walMgr = ignite.context().cache().context().wal();
File walDir = U.field(walMgr, "walWorkDir");
IgniteWalIteratorFactory iterFactory = new IgniteWalIteratorFactory();
List<FileDescriptor> walFiles = getWalFiles(walDir, iterFactory);
FileDescriptor lastWalFile = walFiles.get(walFiles.size() - 1);
List<WALPointer> checkpoints = WalTestUtils.getPointers(lastWalFile, iterFactory, CHECKPOINT_RECORD);
List<WALPointer> binary = WalTestUtils.getPointers(lastWalFile, iterFactory, PHYSICAL).stream().filter(p -> p.fileOffset() < checkpoints.get(checkpoints.size() - 1).fileOffset()).collect(Collectors.toList());
WALPointer pointer = binary.get(binary.size() - 1);
WalTestUtils.corruptWalSegmentFile(lastWalFile, pointer);
GridTestUtils.assertThrows(log, () -> startGrid(0), Exception.class, null);
}
Aggregations