use of org.apache.ignite.internal.processors.cache.CacheObject in project ignite by apache.
the class GridDistributedCacheEntry method readyNearLock.
/**
* Notifies mvcc that near local lock is ready to be acquired.
*
* @param ver Lock version.
* @param mapped Mapped dht lock version.
* @param committed Committed versions.
* @param rolledBack Rolled back versions.
* @param pending Pending locks on dht node with version less then mapped.
*
* @throws GridCacheEntryRemovedException If entry is removed.
*/
public void readyNearLock(GridCacheVersion ver, GridCacheVersion mapped, Collection<GridCacheVersion> committed, Collection<GridCacheVersion> rolledBack, Collection<GridCacheVersion> pending) throws GridCacheEntryRemovedException {
CacheLockCandidates prev = null;
CacheLockCandidates owner = null;
CacheObject val;
lockEntry();
try {
checkObsolete();
GridCacheMvcc mvcc = mvccExtras();
if (mvcc != null) {
prev = mvcc.allOwners();
boolean emptyBefore = mvcc.isEmpty();
owner = mvcc.readyNearLocal(ver, mapped, committed, rolledBack, pending);
assert owner == null || owner.candidate(0).owner() : "Owner flag is not set for owner: " + owner;
boolean emptyAfter = mvcc.isEmpty();
checkCallbacks(emptyBefore, emptyAfter);
if (emptyAfter)
mvccExtras(null);
}
val = this.val;
} finally {
unlockEntry();
}
// This call must be made outside of synchronization.
checkOwnerChanged(prev, owner, val);
}
use of org.apache.ignite.internal.processors.cache.CacheObject in project ignite by apache.
the class GridDistributedCacheEntry method removeExplicitNodeLocks.
/**
* Removes all lock candidates for node.
*
* @param nodeId ID of node to remove locks from.
* @throws GridCacheEntryRemovedException If entry was removed.
*/
public void removeExplicitNodeLocks(UUID nodeId) throws GridCacheEntryRemovedException {
CacheLockCandidates prev = null;
CacheLockCandidates owner = null;
CacheObject val = null;
lockEntry();
try {
checkObsolete();
GridCacheMvcc mvcc = mvccExtras();
if (mvcc != null) {
prev = mvcc.allOwners();
boolean emptyBefore = mvcc.isEmpty();
owner = mvcc.removeExplicitNodeCandidates(nodeId);
boolean emptyAfter = mvcc.isEmpty();
checkCallbacks(emptyBefore, emptyAfter);
val = this.val;
refreshRemotes();
if (emptyAfter) {
mvccExtras(null);
onUnlock();
}
}
} finally {
unlockEntry();
}
// This call must be outside of synchronization.
checkOwnerChanged(prev, owner, val);
}
use of org.apache.ignite.internal.processors.cache.CacheObject in project ignite by apache.
the class GridDistributedCacheEntry method addLocal.
/**
* Add local candidate.
*
* @param threadId Owning thread ID.
* @param ver Lock version.
* @param topVer Topology version.
* @param timeout Timeout to acquire lock.
* @param reenter Reentry flag.
* @param tx Transaction flag.
* @param implicitSingle Implicit flag.
* @param read Read lock flag.
* @return New candidate.
* @throws GridCacheEntryRemovedException If entry has been removed.
*/
@Nullable
public GridCacheMvccCandidate addLocal(long threadId, GridCacheVersion ver, AffinityTopologyVersion topVer, long timeout, boolean reenter, boolean tx, boolean implicitSingle, boolean read) throws GridCacheEntryRemovedException {
GridCacheMvccCandidate cand;
CacheLockCandidates prev;
CacheLockCandidates owner;
CacheObject val;
lockEntry();
try {
checkObsolete();
GridCacheMvcc mvcc = mvccExtras();
if (mvcc == null) {
mvcc = new GridCacheMvcc(cctx);
mvccExtras(mvcc);
}
prev = mvcc.allOwners();
boolean emptyBefore = mvcc.isEmpty();
cand = mvcc.addLocal(this, threadId, ver, timeout, reenter, tx, implicitSingle, read);
if (cand != null)
cand.topologyVersion(topVer);
owner = mvcc.allOwners();
boolean emptyAfter = mvcc.isEmpty();
checkCallbacks(emptyBefore, emptyAfter);
val = this.val;
if (emptyAfter)
mvccExtras(null);
} finally {
unlockEntry();
}
// Don't link reentries.
if (cand != null && !cand.reentry())
// Link with other candidates in the same thread.
cctx.mvcc().addNext(cctx, cand);
checkOwnerChanged(prev, owner, val);
return cand;
}
use of org.apache.ignite.internal.processors.cache.CacheObject in project ignite by apache.
the class GridDistributedCacheEntry method readyLock.
/**
* @param ver Version of candidate to acquire lock for.
* @return Owner.
* @throws GridCacheEntryRemovedException If entry is removed.
*/
@Nullable
public CacheLockCandidates readyLock(GridCacheVersion ver) throws GridCacheEntryRemovedException {
CacheLockCandidates prev = null;
CacheLockCandidates owner = null;
CacheObject val;
lockEntry();
try {
checkObsolete();
GridCacheMvcc mvcc = mvccExtras();
if (mvcc != null) {
prev = mvcc.allOwners();
boolean emptyBefore = mvcc.isEmpty();
owner = mvcc.readyLocal(ver);
assert owner == null || owner.candidate(0).owner() : "Owner flag not set for owner: " + owner;
boolean emptyAfter = mvcc.isEmpty();
checkCallbacks(emptyBefore, emptyAfter);
if (emptyAfter)
mvccExtras(null);
}
val = this.val;
} finally {
unlockEntry();
}
// This call must be made outside of synchronization.
checkOwnerChanged(prev, owner, val);
return owner;
}
use of org.apache.ignite.internal.processors.cache.CacheObject in project ignite by apache.
the class GridDistributedCacheEntry method addRemote.
/**
* Adds new lock candidate.
*
* @param nodeId Node ID.
* @param otherNodeId Other node ID.
* @param threadId Thread ID.
* @param ver Lock version.
* @param tx Transaction flag.
* @param implicitSingle Implicit flag.
* @param owned Owned candidate version.
* @throws GridDistributedLockCancelledException If lock has been canceled.
* @throws GridCacheEntryRemovedException If this entry is obsolete.
*/
public void addRemote(UUID nodeId, @Nullable UUID otherNodeId, long threadId, GridCacheVersion ver, boolean tx, boolean implicitSingle, @Nullable GridCacheVersion owned) throws GridDistributedLockCancelledException, GridCacheEntryRemovedException {
CacheLockCandidates prev;
CacheLockCandidates owner;
CacheObject val;
lockEntry();
try {
// Check removed locks prior to obsolete flag.
checkRemoved(ver);
checkObsolete();
GridCacheMvcc mvcc = mvccExtras();
if (mvcc == null) {
mvcc = new GridCacheMvcc(cctx);
mvccExtras(mvcc);
}
prev = mvcc.allOwners();
boolean emptyBefore = mvcc.isEmpty();
mvcc.addRemote(this, nodeId, otherNodeId, threadId, ver, tx, implicitSingle, /*near-local*/
false);
if (owned != null)
mvcc.markOwned(ver, owned);
owner = mvcc.allOwners();
boolean emptyAfter = mvcc.isEmpty();
checkCallbacks(emptyBefore, emptyAfter);
val = this.val;
refreshRemotes();
if (emptyAfter)
mvccExtras(null);
} finally {
unlockEntry();
}
// This call must be outside of synchronization.
checkOwnerChanged(prev, owner, val);
}
Aggregations