use of org.apache.ignite.internal.processors.cache.GridCacheMvccEntryInfo in project ignite by apache.
the class GridDhtPartitionSupplier method extractEntryInfo.
/**
* Extracts entry info from row.
*
* @param row Cache data row.
* @return Entry info.
*/
private GridCacheEntryInfo extractEntryInfo(CacheDataRow row) {
GridCacheEntryInfo info = grp.mvccEnabled() ? new GridCacheMvccEntryInfo() : new GridCacheEntryInfo();
info.key(row.key());
info.cacheId(row.cacheId());
if (grp.mvccEnabled()) {
assert row.mvccCoordinatorVersion() != MvccUtils.MVCC_CRD_COUNTER_NA;
// Rows from rebalance iterator have actual states already.
if (row.mvccTxState() != TxState.COMMITTED)
return null;
((MvccVersionAware) info).mvccVersion(row);
((GridCacheMvccEntryInfo) info).mvccTxState(TxState.COMMITTED);
if (row.newMvccCoordinatorVersion() != MvccUtils.MVCC_CRD_COUNTER_NA && row.newMvccTxState() == TxState.COMMITTED) {
((MvccUpdateVersionAware) info).newMvccVersion(row);
((GridCacheMvccEntryInfo) info).newMvccTxState(TxState.COMMITTED);
}
}
info.value(row.value());
info.version(row.version());
info.expireTime(row.expireTime());
return info;
}
use of org.apache.ignite.internal.processors.cache.GridCacheMvccEntryInfo in project ignite by apache.
the class GridDhtTxAbstractEnlistFuture method fetchHistoryInfo.
/**
* @param key Key.
* @param hist History rows.
* @return History entries.
* @throws IgniteCheckedException, if failed.
*/
private CacheEntryInfoCollection fetchHistoryInfo(KeyCacheObject key, List<MvccLinkAwareSearchRow> hist) {
List<GridCacheEntryInfo> res = new ArrayList<>();
for (int i = 0; i < hist.size(); i++) {
MvccLinkAwareSearchRow row0 = hist.get(i);
MvccDataRow row = new MvccDataRow(cctx.group(), row0.hash(), row0.link(), key.partition(), CacheDataRowAdapter.RowData.NO_KEY_WITH_HINTS, row0.mvccCoordinatorVersion(), row0.mvccCounter(), row0.mvccOperationCounter(), false);
GridCacheMvccEntryInfo entry = new GridCacheMvccEntryInfo();
entry.cacheId(cctx.cacheId());
entry.version(row.version());
entry.value(row.value());
entry.expireTime(row.expireTime());
// Row should be retrieved with actual hints.
entry.mvccVersion(row);
entry.newMvccVersion(row);
if (MvccUtils.compare(mvccSnapshot, row.mvccCoordinatorVersion(), row.mvccCounter()) != 0)
entry.mvccTxState(row.mvccTxState());
if (row.newMvccCoordinatorVersion() != MvccUtils.MVCC_CRD_COUNTER_NA && MvccUtils.compare(mvccSnapshot, row.newMvccCoordinatorVersion(), row.newMvccCounter()) != 0)
entry.newMvccTxState(row.newMvccTxState());
assert mvccSnapshot.coordinatorVersion() != MvccUtils.MVCC_CRD_COUNTER_NA;
res.add(entry);
}
return new CacheEntryInfoCollection(res);
}
use of org.apache.ignite.internal.processors.cache.GridCacheMvccEntryInfo 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