Search in sources :

Example 1 with PHYSICAL

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));
}
Also used : WALIterator(org.apache.ignite.internal.pagemem.wal.WALIterator) PHYSICAL(org.apache.ignite.internal.pagemem.wal.record.WALRecord.RecordPurpose.PHYSICAL) MIXED(org.apache.ignite.internal.pagemem.wal.record.WALRecord.RecordPurpose.MIXED) Predicate(java.util.function.Predicate) Collection(java.util.Collection) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) WALRecord(org.apache.ignite.internal.pagemem.wal.record.WALRecord) IgniteWalIteratorFactory(org.apache.ignite.internal.processors.cache.persistence.wal.reader.IgniteWalIteratorFactory) Set(java.util.Set) FilteredWalIterator(org.apache.ignite.internal.processors.cache.persistence.wal.reader.FilteredWalIterator) Collectors(java.util.stream.Collectors) WALPointer(org.apache.ignite.internal.processors.cache.persistence.wal.WALPointer) T2(org.apache.ignite.internal.util.typedef.T2) IgniteBiTuple(org.apache.ignite.lang.IgniteBiTuple) HashSet(java.util.HashSet) WalFilters.partitionMetaStateUpdate(org.apache.ignite.internal.processors.cache.persistence.wal.reader.WalFilters.partitionMetaStateUpdate) IgniteThrowableSupplier(org.apache.ignite.internal.util.lang.IgniteThrowableSupplier) IteratorParametersBuilder(org.apache.ignite.internal.processors.cache.persistence.wal.reader.IgniteWalIteratorFactory.IteratorParametersBuilder) PageIdUtils(org.apache.ignite.internal.pagemem.PageIdUtils) Objects.requireNonNull(java.util.Objects.requireNonNull) WalFilters.checkpoint(org.apache.ignite.internal.processors.cache.persistence.wal.reader.WalFilters.checkpoint) WalFilters.pageOwner(org.apache.ignite.internal.processors.cache.persistence.wal.reader.WalFilters.pageOwner) NotNull(org.jetbrains.annotations.NotNull) FilteredWalIterator(org.apache.ignite.internal.processors.cache.persistence.wal.reader.FilteredWalIterator) IgniteBiTuple(org.apache.ignite.lang.IgniteBiTuple) T2(org.apache.ignite.internal.util.typedef.T2) HashSet(java.util.HashSet) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with PHYSICAL

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);
}
Also used : IgniteWalIteratorFactory(org.apache.ignite.internal.processors.cache.persistence.wal.reader.IgniteWalIteratorFactory) IgniteWalIteratorFactory(org.apache.ignite.internal.processors.cache.persistence.wal.reader.IgniteWalIteratorFactory) U(org.apache.ignite.internal.util.typedef.internal.U) Random(java.util.Random) IgniteEx(org.apache.ignite.internal.IgniteEx) WALPointer(org.apache.ignite.internal.processors.cache.persistence.wal.WALPointer) GridCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager) LOGICAL(org.apache.ignite.internal.pagemem.wal.record.WALRecord.RecordPurpose.LOGICAL) DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) DFLT_WAL_PATH(org.apache.ignite.configuration.DataStorageConfiguration.DFLT_WAL_PATH) WALMode(org.apache.ignite.configuration.WALMode) PHYSICAL(org.apache.ignite.internal.pagemem.wal.record.WALRecord.RecordPurpose.PHYSICAL) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test) CHECKPOINT_RECORD(org.apache.ignite.internal.pagemem.wal.record.WALRecord.RecordType.CHECKPOINT_RECORD) Collectors(java.util.stream.Collectors) File(java.io.File) IgniteCache(org.apache.ignite.IgniteCache) GridTestUtils(org.apache.ignite.testframework.GridTestUtils) WithSystemProperty(org.apache.ignite.testframework.junits.WithSystemProperty) List(java.util.List) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) IgniteWriteAheadLogManager(org.apache.ignite.internal.pagemem.wal.IgniteWriteAheadLogManager) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) FileDescriptor(org.apache.ignite.internal.processors.cache.persistence.wal.FileDescriptor) IgniteWriteAheadLogManager(org.apache.ignite.internal.pagemem.wal.IgniteWriteAheadLogManager) File(java.io.File) WALPointer(org.apache.ignite.internal.processors.cache.persistence.wal.WALPointer) FileDescriptor(org.apache.ignite.internal.processors.cache.persistence.wal.FileDescriptor) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Aggregations

Collectors (java.util.stream.Collectors)2 PHYSICAL (org.apache.ignite.internal.pagemem.wal.record.WALRecord.RecordPurpose.PHYSICAL)2 WALPointer (org.apache.ignite.internal.processors.cache.persistence.wal.WALPointer)2 IgniteWalIteratorFactory (org.apache.ignite.internal.processors.cache.persistence.wal.reader.IgniteWalIteratorFactory)2 File (java.io.File)1 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Objects.requireNonNull (java.util.Objects.requireNonNull)1 Random (java.util.Random)1 Set (java.util.Set)1 Predicate (java.util.function.Predicate)1 IgniteCache (org.apache.ignite.IgniteCache)1 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)1 DataRegionConfiguration (org.apache.ignite.configuration.DataRegionConfiguration)1 DataStorageConfiguration (org.apache.ignite.configuration.DataStorageConfiguration)1 DFLT_WAL_PATH (org.apache.ignite.configuration.DataStorageConfiguration.DFLT_WAL_PATH)1 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)1 WALMode (org.apache.ignite.configuration.WALMode)1