use of org.apache.ignite.internal.processors.cache.GridCacheMvcc in project ignite by apache.
the class GridDistributedCacheEntry method doneRemote.
/**
*
* @param lockVer Done version.
* @param baseVer Base version.
* @param pendingVers Pending versions that are less than lock version.
* @param committedVers Completed versions for reordering.
* @param rolledbackVers Rolled back versions for reordering.
* @param sysInvalidate Flag indicating if this entry is done from invalidated transaction (in case of tx
* salvage). In this case all locks before salvaged lock will marked as used and corresponding
* transactions will be invalidated.
* @throws GridCacheEntryRemovedException If entry has been removed.
*/
public void doneRemote(GridCacheVersion lockVer, GridCacheVersion baseVer, @Nullable Collection<GridCacheVersion> pendingVers, Collection<GridCacheVersion> committedVers, Collection<GridCacheVersion> rolledbackVers, boolean sysInvalidate) throws GridCacheEntryRemovedException {
CacheLockCandidates prev = null;
CacheLockCandidates owner = null;
CacheObject val;
synchronized (this) {
checkObsolete();
GridCacheMvcc mvcc = mvccExtras();
if (mvcc != null) {
prev = mvcc.allOwners();
boolean emptyBefore = mvcc.isEmpty();
// Order completed versions.
if (!F.isEmpty(committedVers) || !F.isEmpty(rolledbackVers)) {
mvcc.orderCompleted(lockVer, committedVers, rolledbackVers);
if (!baseVer.equals(lockVer))
mvcc.orderCompleted(baseVer, committedVers, rolledbackVers);
}
if (sysInvalidate && baseVer != null)
mvcc.salvageRemote(baseVer);
owner = mvcc.doneRemote(lockVer, maskNull(pendingVers), maskNull(committedVers), maskNull(rolledbackVers));
boolean emptyAfter = mvcc.isEmpty();
checkCallbacks(emptyBefore, emptyAfter);
if (emptyAfter)
mvccExtras(null);
}
val = this.val;
}
// This call must be made outside of synchronization.
checkOwnerChanged(prev, owner, val);
}
use of org.apache.ignite.internal.processors.cache.GridCacheMvcc in project ignite by apache.
the class GridDistributedCacheEntry method recheck.
/**
* Rechecks if lock should be reassigned.
*/
public void recheck() {
CacheLockCandidates prev = null;
CacheLockCandidates owner = null;
CacheObject val;
synchronized (this) {
GridCacheMvcc mvcc = mvccExtras();
if (mvcc != null) {
prev = mvcc.allOwners();
boolean emptyBefore = mvcc.isEmpty();
owner = mvcc.recheck();
boolean emptyAfter = mvcc.isEmpty();
checkCallbacks(emptyBefore, emptyAfter);
if (emptyAfter)
mvccExtras(null);
}
val = this.val;
}
// This call must be made outside of synchronization.
checkOwnerChanged(prev, owner, val);
}
use of org.apache.ignite.internal.processors.cache.GridCacheMvcc in project ignite by apache.
the class GridDhtCacheEntry method localCandidateByNearVersion.
/**
* @param nearVer Near version.
* @param rmv If {@code true}, then add to removed list if not found.
* @return Local candidate by near version.
* @throws GridCacheEntryRemovedException If removed.
*/
@Nullable
synchronized GridCacheMvccCandidate localCandidateByNearVersion(GridCacheVersion nearVer, boolean rmv) throws GridCacheEntryRemovedException {
checkObsolete();
GridCacheMvcc mvcc = mvccExtras();
if (mvcc != null) {
for (GridCacheMvccCandidate c : mvcc.localCandidatesNoCopy(false)) {
GridCacheVersion ver = c.otherVersion();
if (ver != null && ver.equals(nearVer))
return c;
}
}
if (rmv)
addRemoved(nearVer);
return null;
}
use of org.apache.ignite.internal.processors.cache.GridCacheMvcc in project ignite by apache.
the class GridDhtCacheEntry method mappings.
/**
* Sets mappings into entry.
*
* @param ver Version.
* @return Candidate, if one existed for the version, or {@code null} if candidate was not found.
* @throws GridCacheEntryRemovedException If removed.
*/
@Nullable
public synchronized GridCacheMvccCandidate mappings(GridCacheVersion ver, Collection<ClusterNode> dhtNodeIds, Collection<ClusterNode> nearNodeIds) throws GridCacheEntryRemovedException {
checkObsolete();
GridCacheMvcc mvcc = mvccExtras();
GridCacheMvccCandidate cand = mvcc == null ? null : mvcc.candidate(ver);
if (cand != null)
cand.mappedNodeIds(dhtNodeIds, nearNodeIds);
return cand;
}
use of org.apache.ignite.internal.processors.cache.GridCacheMvcc in project ignite by apache.
the class GridDhtCacheEntry method removeMapping.
/**
* @param ver Version.
* @param mappedNode Mapped node to remove.
*/
public synchronized void removeMapping(GridCacheVersion ver, ClusterNode mappedNode) {
GridCacheMvcc mvcc = mvccExtras();
GridCacheMvccCandidate cand = mvcc == null ? null : mvcc.candidate(ver);
if (cand != null)
cand.removeMappedNode(mappedNode);
}
Aggregations