use of org.apache.ignite.internal.processors.cache.CacheLockCandidates 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;
synchronized (this) {
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();
}
}
}
// This call must be outside of synchronization.
checkOwnerChanged(prev, owner, val);
}
use of org.apache.ignite.internal.processors.cache.CacheLockCandidates 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;
synchronized (this) {
// 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);
}
// This call must be outside of synchronization.
checkOwnerChanged(prev, owner, val);
}
use of org.apache.ignite.internal.processors.cache.CacheLockCandidates 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;
synchronized (this) {
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;
}
// This call must be made outside of synchronization.
checkOwnerChanged(prev, owner, val);
return owner;
}
use of org.apache.ignite.internal.processors.cache.CacheLockCandidates 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;
synchronized (this) {
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;
}
// This call must be made outside of synchronization.
checkOwnerChanged(prev, owner, val);
}
use of org.apache.ignite.internal.processors.cache.CacheLockCandidates in project ignite by apache.
the class GridDistributedCacheEntry method removeLock.
/** {@inheritDoc} */
@Override
public boolean removeLock(GridCacheVersion ver) throws GridCacheEntryRemovedException {
CacheLockCandidates prev = null;
CacheLockCandidates owner = null;
GridCacheMvccCandidate doomed;
CacheObject val;
synchronized (this) {
GridCacheMvcc mvcc = mvccExtras();
doomed = mvcc == null ? null : mvcc.candidate(ver);
if (doomed == null)
addRemoved(ver);
GridCacheVersion obsoleteVer = obsoleteVersionExtras();
if (obsoleteVer != null && !obsoleteVer.equals(ver))
checkObsolete();
if (doomed != null) {
prev = mvcc.allOwners();
boolean emptyBefore = mvcc.isEmpty();
mvcc.remove(doomed.version());
boolean emptyAfter = mvcc.isEmpty();
if (!doomed.local())
refreshRemotes();
checkCallbacks(emptyBefore, emptyAfter);
if (emptyAfter)
mvccExtras(null);
else
owner = mvcc.allOwners();
}
val = this.val;
}
if (log.isDebugEnabled())
log.debug("Removed lock candidate from entry [doomed=" + doomed + ", owner=" + owner + ", prev=" + prev + ", entry=" + this + ']');
if (doomed != null && doomed.nearLocal())
cctx.mvcc().removeExplicitLock(doomed);
if (doomed != null)
checkThreadChain(doomed);
// This call must be outside of synchronization.
checkOwnerChanged(prev, owner, val);
return doomed != null;
}
Aggregations