use of org.apache.ignite.internal.pagemem.wal.record.WALRecord.RecordPurpose.PHYSICAL in project ignite by apache.
the class WalScanner method findAllRecordsFor.
/**
* Finding all page physical records whose pageId is contained in given collection.
*
* @param groupAndPageIds Search pages.
* @return Final step for execution some action on result.
*/
@NotNull
public WalScanner.ScanTerminateStep findAllRecordsFor(@NotNull Collection<T2<Integer, Long>> groupAndPageIds) {
requireNonNull(groupAndPageIds);
HashSet<T2<Integer, Long>> groupAndPageIds0 = new HashSet<>(groupAndPageIds);
// Collect all (group, partition) partition pairs.
Set<T2<Integer, Integer>> groupAndParts = groupAndPageIds0.stream().map((tup) -> new T2<>(tup.get1(), PageIdUtils.partId(tup.get2()))).collect(Collectors.toSet());
// Build WAL filter. (Checkoint, Page, Partition meta)
Predicate<IgniteBiTuple<WALPointer, WALRecord>> filter = checkpoint().or(pageOwner(groupAndPageIds0)).or(partitionMetaStateUpdate(groupAndParts));
return new ScanTerminateStep(() -> new FilteredWalIterator(walIteratorSupplier.get(), filter));
}
use of org.apache.ignite.internal.pagemem.wal.record.WALRecord.RecordPurpose.PHYSICAL 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