Search in sources :

Example 1 with FilteredWalIterator

use of org.apache.ignite.internal.processors.cache.persistence.wal.reader.FilteredWalIterator 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 FilteredWalIterator

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

the class IgniteWalConverter method walIterator.

/**
 * Getting WAL iterator.
 *
 * @param walIter WAL iterator.
 * @param pageIds Pages for searching in format grpId:pageId.
 * @return WAL iterator.
 */
private static WALIterator walIterator(WALIterator walIter, Collection<T2<Integer, Long>> pageIds) throws IgniteCheckedException {
    Predicate<IgniteBiTuple<WALPointer, WALRecord>> filter = null;
    if (!pageIds.isEmpty()) {
        Set<T2<Integer, Long>> grpAndPageIds0 = new HashSet<>(pageIds);
        // Collect all (group, partition) partition pairs.
        Set<T2<Integer, Integer>> grpAndParts = grpAndPageIds0.stream().map((tup) -> new T2<>(tup.get1(), PageIdUtils.partId(tup.get2()))).collect(Collectors.toSet());
        // Build WAL filter. (Checkoint, Page, Partition meta)
        filter = checkpoint().or(pageOwner(grpAndPageIds0)).or(partitionMetaStateUpdate(grpAndParts));
    }
    return filter != null ? new FilteredWalIterator(walIter, filter) : walIter;
}
Also used : WALIterator(org.apache.ignite.internal.pagemem.wal.WALIterator) IgniteWalIteratorFactory(org.apache.ignite.internal.processors.cache.persistence.wal.reader.IgniteWalIteratorFactory) U(org.apache.ignite.internal.util.typedef.internal.U) WALPointer(org.apache.ignite.internal.processors.cache.persistence.wal.WALPointer) ArrayList(java.util.ArrayList) IgniteSystemProperties(org.apache.ignite.IgniteSystemProperties) HashSet(java.util.HashSet) WalFilters.pageOwner(org.apache.ignite.internal.processors.cache.persistence.wal.reader.WalFilters.pageOwner) RecordV1Serializer(org.apache.ignite.internal.processors.cache.persistence.wal.serializer.RecordV1Serializer) PrintStream(java.io.PrintStream) F(org.apache.ignite.internal.util.typedef.F) MetastoreDataRecord(org.apache.ignite.internal.pagemem.wal.record.MetastoreDataRecord) Predicate(java.util.function.Predicate) Collection(java.util.Collection) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) WALRecord(org.apache.ignite.internal.pagemem.wal.record.WALRecord) Set(java.util.Set) FilteredWalIterator(org.apache.ignite.internal.processors.cache.persistence.wal.reader.FilteredWalIterator) DataRecord(org.apache.ignite.internal.pagemem.wal.record.DataRecord) Collectors(java.util.stream.Collectors) DataEntry(org.apache.ignite.internal.pagemem.wal.record.DataEntry) T2(org.apache.ignite.internal.util.typedef.T2) IgniteBiTuple(org.apache.ignite.lang.IgniteBiTuple) WalFilters.partitionMetaStateUpdate(org.apache.ignite.internal.processors.cache.persistence.wal.reader.WalFilters.partitionMetaStateUpdate) List(java.util.List) PageIdUtils(org.apache.ignite.internal.pagemem.PageIdUtils) WalFilters.checkpoint(org.apache.ignite.internal.processors.cache.persistence.wal.reader.WalFilters.checkpoint) TimeStampRecord(org.apache.ignite.internal.pagemem.wal.record.TimeStampRecord) FileDescriptor(org.apache.ignite.internal.processors.cache.persistence.wal.FileDescriptor) 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)

Example 3 with FilteredWalIterator

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

the class IgniteWalConverter method getCurrentWalFilePath.

/**
 * Get current wal file path, used in {@code WALIterator}.
 *
 * @param it WALIterator.
 * @return Current wal file path.
 */
private static String getCurrentWalFilePath(WALIterator it) {
    String res = null;
    try {
        WALIterator walIter = it instanceof FilteredWalIterator ? U.field(it, "delegateWalIter") : it;
        Integer curIdx = U.field(walIter, "curIdx");
        List<FileDescriptor> walFileDescriptors = U.field(walIter, "walFileDescriptors");
        if (curIdx != null && walFileDescriptors != null && curIdx < walFileDescriptors.size())
            res = walFileDescriptors.get(curIdx).getAbsolutePath();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return res;
}
Also used : FilteredWalIterator(org.apache.ignite.internal.processors.cache.persistence.wal.reader.FilteredWalIterator) WALIterator(org.apache.ignite.internal.pagemem.wal.WALIterator) FileDescriptor(org.apache.ignite.internal.processors.cache.persistence.wal.FileDescriptor) IgniteCheckedException(org.apache.ignite.IgniteCheckedException)

Aggregations

IgniteCheckedException (org.apache.ignite.IgniteCheckedException)3 WALIterator (org.apache.ignite.internal.pagemem.wal.WALIterator)3 FilteredWalIterator (org.apache.ignite.internal.processors.cache.persistence.wal.reader.FilteredWalIterator)3 Collection (java.util.Collection)2 HashSet (java.util.HashSet)2 Set (java.util.Set)2 Predicate (java.util.function.Predicate)2 Collectors (java.util.stream.Collectors)2 PageIdUtils (org.apache.ignite.internal.pagemem.PageIdUtils)2 WALRecord (org.apache.ignite.internal.pagemem.wal.record.WALRecord)2 FileDescriptor (org.apache.ignite.internal.processors.cache.persistence.wal.FileDescriptor)2 WALPointer (org.apache.ignite.internal.processors.cache.persistence.wal.WALPointer)2 IgniteWalIteratorFactory (org.apache.ignite.internal.processors.cache.persistence.wal.reader.IgniteWalIteratorFactory)2 WalFilters.checkpoint (org.apache.ignite.internal.processors.cache.persistence.wal.reader.WalFilters.checkpoint)2 WalFilters.pageOwner (org.apache.ignite.internal.processors.cache.persistence.wal.reader.WalFilters.pageOwner)2 WalFilters.partitionMetaStateUpdate (org.apache.ignite.internal.processors.cache.persistence.wal.reader.WalFilters.partitionMetaStateUpdate)2 T2 (org.apache.ignite.internal.util.typedef.T2)2 IgniteBiTuple (org.apache.ignite.lang.IgniteBiTuple)2 PrintStream (java.io.PrintStream)1 ArrayList (java.util.ArrayList)1