use of org.apache.ignite.internal.processors.cache.IgniteCacheOffheapManagerImpl.PRELOAD_SIZE_UNDER_CHECKPOINT_LOCK in project ignite by apache.
the class GridDhtPartitionDemander method mvccPreloadEntries.
/**
* Adds mvcc entries with theirs history to partition p.
*
* @param topVer Topology version.
* @param node Node which sent entry.
* @param p Partition id.
* @param infos Entries info for preload.
* @throws IgniteCheckedException If failed.
*/
private void mvccPreloadEntries(AffinityTopologyVersion topVer, ClusterNode node, int p, Iterator<GridCacheEntryInfo> infos) throws IgniteCheckedException {
if (!infos.hasNext())
return;
// Received keys by caches, for statistics.
IntHashMap<GridMutableLong> receivedKeys = new IntHashMap<>();
List<GridCacheMvccEntryInfo> entryHist = new ArrayList<>();
GridCacheContext<?, ?> cctx = grp.sharedGroup() ? null : grp.singleCacheContext();
// Loop through all received entries and try to preload them.
while (infos.hasNext() || !entryHist.isEmpty()) {
ctx.database().checkpointReadLock();
try {
for (int i = 0; i < PRELOAD_SIZE_UNDER_CHECKPOINT_LOCK; i++) {
boolean hasMore = infos.hasNext();
assert hasMore || !entryHist.isEmpty();
GridCacheMvccEntryInfo entry = null;
boolean flushHistory;
if (hasMore) {
entry = (GridCacheMvccEntryInfo) infos.next();
GridCacheMvccEntryInfo prev = entryHist.isEmpty() ? null : entryHist.get(0);
flushHistory = prev != null && ((grp.sharedGroup() && prev.cacheId() != entry.cacheId()) || !prev.key().equals(entry.key()));
} else
flushHistory = true;
if (flushHistory) {
assert !entryHist.isEmpty();
int cacheId = entryHist.get(0).cacheId();
if (grp.sharedGroup() && (cctx == null || cacheId != cctx.cacheId())) {
assert cacheId != CU.UNDEFINED_CACHE_ID;
cctx = grp.shared().cacheContext(cacheId);
}
if (cctx != null) {
mvccPreloadEntry(cctx, node, entryHist, topVer, p);
rebalanceFut.onReceivedKeys(p, 1, node);
receivedKeys.computeIfAbsent(cacheId, cid -> new GridMutableLong()).incrementAndGet();
}
entryHist.clear();
if (!hasMore)
break;
}
entryHist.add(entry);
}
} finally {
ctx.database().checkpointReadUnlock();
}
}
updateKeyReceivedMetrics(grp, receivedKeys);
}
Aggregations