use of org.apache.ignite.internal.processors.cache.GridCacheMvcc in project ignite by apache.
the class GridDistributedCacheEntry method refreshRemotes.
/**
*
*/
private void refreshRemotes() {
GridCacheMvcc mvcc = mvccExtras();
rmts = mvcc == null ? Collections.<GridCacheMvccCandidate>emptyList() : mvcc.remoteCandidates();
}
use of org.apache.ignite.internal.processors.cache.GridCacheMvcc in project ignite by apache.
the class GridNearCacheEntry method removeLock.
/**
* Unlocks local lock.
*
* @return Removed candidate, or <tt>null</tt> if thread still holds the lock.
*/
@Nullable
@Override
public GridCacheMvccCandidate removeLock() {
CacheLockCandidates prev = null;
CacheLockCandidates owner = null;
CacheObject val;
UUID locId = cctx.nodeId();
GridCacheMvccCandidate cand = null;
synchronized (this) {
GridCacheMvcc mvcc = mvccExtras();
if (mvcc != null) {
prev = mvcc.allOwners();
boolean emptyBefore = mvcc.isEmpty();
cand = mvcc.localCandidate(locId, Thread.currentThread().getId());
assert cand == null || cand.nearLocal();
if (cand != null && cand.owner()) {
// If a reentry, then release reentry. Otherwise, remove lock.
GridCacheMvccCandidate reentry = cand.unenter();
if (reentry != null) {
assert reentry.reentry();
return reentry;
}
mvcc.remove(cand.version());
owner = mvcc.allOwners();
} else
return null;
boolean emptyAfter = mvcc.isEmpty();
checkCallbacks(emptyBefore, emptyAfter);
if (emptyAfter)
mvccExtras(null);
}
val = this.val;
}
assert cand != null;
assert owner != prev;
if (log.isDebugEnabled())
log.debug("Released local candidate from entry [owner=" + owner + ", prev=" + prev + ", entry=" + this + ']');
cctx.mvcc().removeExplicitLock(cand);
checkThreadChain(cand);
// This call must be outside of synchronization.
checkOwnerChanged(prev, owner, val);
return cand;
}
use of org.apache.ignite.internal.processors.cache.GridCacheMvcc in project ignite by apache.
the class GridLocalCacheEntry method readyLocal.
/**
* @param cand Candidate.
*/
void readyLocal(GridCacheMvccCandidate cand) {
CacheObject val;
CacheLockCandidates prev = null;
CacheLockCandidates owner = null;
synchronized (this) {
GridCacheMvcc mvcc = mvccExtras();
if (mvcc != null) {
prev = mvcc.localOwners();
owner = mvcc.readyLocal(cand);
if (mvcc.isEmpty())
mvccExtras(null);
}
val = this.val;
}
checkOwnerChanged(prev, owner, val);
}
use of org.apache.ignite.internal.processors.cache.GridCacheMvcc in project ignite by apache.
the class GridLocalCacheEntry method recheck.
/**
* Rechecks if lock should be reassigned.
*/
public void recheck() {
CacheObject val;
CacheLockCandidates prev = null;
CacheLockCandidates owner = null;
synchronized (this) {
GridCacheMvcc mvcc = mvccExtras();
if (mvcc != null) {
prev = mvcc.allOwners();
owner = mvcc.recheck();
if (mvcc.isEmpty())
mvccExtras(null);
}
val = this.val;
}
checkOwnerChanged(prev, owner, val);
}
use of org.apache.ignite.internal.processors.cache.GridCacheMvcc in project ignite by apache.
the class GridLocalCacheEntry method releaseLocal.
/**
* Releases local lock.
*
* @param threadId Thread ID.
*/
private void releaseLocal(long threadId) {
CacheObject val;
CacheLockCandidates prev = null;
CacheLockCandidates owner = null;
synchronized (this) {
GridCacheMvcc mvcc = mvccExtras();
if (mvcc != null) {
prev = mvcc.localOwners();
mvcc.releaseLocal(threadId);
if (mvcc.isEmpty())
mvccExtras(null);
else
owner = mvcc.allOwners();
}
val = this.val;
}
if (prev != null) {
for (int i = 0; i < prev.size(); i++) {
GridCacheMvccCandidate cand = prev.candidate(i);
boolean unlocked = owner == null || !owner.hasCandidate(cand.version());
if (unlocked)
checkThreadChain(cand);
}
}
checkOwnerChanged(prev, owner, val);
}
Aggregations