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;
}
}
Aggregations