Search in sources :

Example 1 with IgniteHistoricalIteratorException

use of org.apache.ignite.internal.processors.cache.distributed.dht.preloader.IgniteHistoricalIteratorException in project ignite by apache.

the class GridCacheOffheapManager method historicalIterator.

/**
 * {@inheritDoc}
 */
@Override
@Nullable
protected IgniteHistoricalIterator historicalIterator(CachePartitionPartialCountersMap partCntrs, Set<Integer> missing) throws IgniteCheckedException {
    if (partCntrs == null || partCntrs.isEmpty())
        return null;
    if (// TODO IGNITE-7384
    grp.mvccEnabled())
        return super.historicalIterator(partCntrs, missing);
    GridCacheDatabaseSharedManager database = (GridCacheDatabaseSharedManager) grp.shared().database();
    Map<Integer, Long> partsCounters = new HashMap<>();
    for (int i = 0; i < partCntrs.size(); i++) {
        int p = partCntrs.partitionAt(i);
        long initCntr = partCntrs.initialUpdateCounterAt(i);
        partsCounters.put(p, initCntr);
    }
    try {
        WALPointer minPtr = database.checkpointHistory().searchEarliestWalPointer(grp.groupId(), partsCounters, grp.hasAtomicCaches() ? walAtomicCacheMargin : 0L);
        WALPointer latestReservedPointer = database.latestWalPointerReservedForPreloading();
        assert latestReservedPointer == null || latestReservedPointer.compareTo(minPtr) <= 0 : "Historical iterator tries to iterate WAL out of reservation [cache=" + grp.cacheOrGroupName() + ", reservedPointer=" + latestReservedPointer + ", historicalPointer=" + minPtr + ']';
        if (latestReservedPointer == null)
            log.warning("History for the preloading has not reserved yet.");
        WALIterator it = grp.shared().wal().replay(minPtr);
        WALHistoricalIterator histIt = new WALHistoricalIterator(log, grp, partCntrs, partsCounters, it);
        // Add historical partitions which are unabled to reserve to missing set.
        missing.addAll(histIt.missingParts);
        return histIt;
    } catch (Exception ex) {
        if (!X.hasCause(ex, IgniteHistoricalIteratorException.class))
            throw new IgniteHistoricalIteratorException(ex);
        throw ex;
    }
}
Also used : HashMap(java.util.HashMap) WALIterator(org.apache.ignite.internal.pagemem.wal.WALIterator) AtomicLong(java.util.concurrent.atomic.AtomicLong) IgniteHistoricalIteratorException(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.IgniteHistoricalIteratorException) WALPointer(org.apache.ignite.internal.processors.cache.persistence.wal.WALPointer) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteHistoricalIteratorException(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.IgniteHistoricalIteratorException) IgniteException(org.apache.ignite.IgniteException) NoSuchElementException(java.util.NoSuchElementException) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

HashMap (java.util.HashMap)1 NoSuchElementException (java.util.NoSuchElementException)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1 IgniteException (org.apache.ignite.IgniteException)1 WALIterator (org.apache.ignite.internal.pagemem.wal.WALIterator)1 IgniteHistoricalIteratorException (org.apache.ignite.internal.processors.cache.distributed.dht.preloader.IgniteHistoricalIteratorException)1 WALPointer (org.apache.ignite.internal.processors.cache.persistence.wal.WALPointer)1 Nullable (org.jetbrains.annotations.Nullable)1