use of org.apache.ignite.internal.processors.cache.CacheLockCandidates in project ignite by apache.
the class GridDistributedCacheEntry method removeLock.
/**
* Unlocks local lock.
*
* @return Removed candidate, or <tt>null</tt> if thread still holds the lock.
*/
@Nullable
public GridCacheMvccCandidate removeLock() {
GridCacheMvccCandidate rmvd = null;
CacheLockCandidates prev = null;
CacheLockCandidates owner = null;
CacheObject val;
synchronized (this) {
GridCacheMvcc mvcc = mvccExtras();
if (mvcc != null) {
prev = mvcc.allOwners();
boolean emptyBefore = mvcc.isEmpty();
rmvd = mvcc.releaseLocal();
boolean emptyAfter = mvcc.isEmpty();
checkCallbacks(emptyBefore, emptyAfter);
if (emptyAfter)
mvccExtras(null);
else
owner = mvcc.allOwners();
}
val = this.val;
}
if (log.isDebugEnabled()) {
log.debug("Released local candidate from entry [owner=" + owner + ", prev=" + prev + ", rmvd=" + rmvd + ", entry=" + this + ']');
}
if (prev != null) {
for (int i = 0; i < prev.size(); i++) {
GridCacheMvccCandidate cand = prev.candidate(i);
checkThreadChain(cand);
}
}
// This call must be outside of synchronization.
checkOwnerChanged(prev, owner, val);
return rmvd;
}
use of org.apache.ignite.internal.processors.cache.CacheLockCandidates in project ignite by apache.
the class GridLocalCacheEntry method removeLock.
/** {@inheritDoc} */
@Override
public boolean removeLock(GridCacheVersion ver) throws GridCacheEntryRemovedException {
CacheObject val;
CacheLockCandidates prev = null;
CacheLockCandidates owner = null;
GridCacheMvccCandidate doomed;
synchronized (this) {
GridCacheVersion obsoleteVer = obsoleteVersionExtras();
if (obsoleteVer != null && !obsoleteVer.equals(ver))
checkObsolete();
GridCacheMvcc mvcc = mvccExtras();
doomed = mvcc == null ? null : mvcc.candidate(ver);
if (doomed != null) {
prev = mvcc.allOwners();
mvcc.remove(ver);
if (mvcc.isEmpty())
mvccExtras(null);
else
owner = mvcc.allOwners();
}
val = this.val;
}
if (doomed != null)
checkThreadChain(doomed);
checkOwnerChanged(prev, owner, val);
return doomed != null;
}
use of org.apache.ignite.internal.processors.cache.CacheLockCandidates in project ignite by apache.
the class GridLocalCacheEntry method addLocal.
/**
* Add local candidate.
*
* @param threadId Owning thread ID.
* @param ver Lock version.
* @param serOrder Version for serializable transactions ordering.
* @param serReadVer Optional read entry version for optimistic serializable transaction.
* @param timeout Timeout to acquire lock.
* @param reenter Reentry flag.
* @param tx Transaction flag.
* @param implicitSingle Implicit transaction flag.
* @param read Read lock flag.
* @return New candidate.
* @throws GridCacheEntryRemovedException If entry has been removed.
*/
@Nullable
GridCacheMvccCandidate addLocal(long threadId, GridCacheVersion ver, @Nullable GridCacheVersion serOrder, @Nullable GridCacheVersion serReadVer, long timeout, boolean reenter, boolean tx, boolean implicitSingle, boolean read) throws GridCacheEntryRemovedException {
assert serReadVer == null || serOrder != null;
CacheObject val;
GridCacheMvccCandidate cand;
CacheLockCandidates prev;
CacheLockCandidates owner = null;
synchronized (this) {
checkObsolete();
if (serReadVer != null) {
if (!checkSerializableReadVersion(serReadVer))
return null;
}
GridCacheMvcc mvcc = mvccExtras();
if (mvcc == null) {
mvcc = new GridCacheMvcc(cctx);
mvccExtras(mvcc);
}
prev = mvcc.localOwners();
cand = mvcc.addLocal(this, /*nearNodeId*/
null, /*nearVer*/
null, threadId, ver, timeout, serOrder, reenter, tx, implicitSingle, /*dht-local*/
false, read);
if (mvcc.isEmpty())
mvccExtras(null);
else
owner = mvcc.localOwners();
val = this.val;
}
if (cand != null && !cand.reentry())
cctx.mvcc().addNext(cctx, cand);
checkOwnerChanged(prev, owner, val);
return cand;
}
Aggregations