use of org.apache.ignite.internal.processors.cache.GridCacheMvccCandidate in project ignite by apache.
the class GridDistributedCacheEntry method remoteMvccSnapshot.
/**
* {@inheritDoc}
*/
@Override
public Collection<GridCacheMvccCandidate> remoteMvccSnapshot(GridCacheVersion... exclude) {
Collection<GridCacheMvccCandidate> rmts = this.rmts;
if (rmts.isEmpty() || F.isEmpty(exclude))
return rmts;
Collection<GridCacheMvccCandidate> cands = new ArrayList<>(rmts.size());
for (GridCacheMvccCandidate c : rmts) {
assert !c.reentry();
// Don't include reentries.
if (!U.containsObjectArray(exclude, c.version()))
cands.add(c);
}
return cands;
}
use of org.apache.ignite.internal.processors.cache.GridCacheMvccCandidate in project ignite by apache.
the class GridDistributedCacheEntry method checkThreadChain.
/**
* {@inheritDoc}
*/
@Override
protected final void checkThreadChain(GridCacheMvccCandidate owner) {
assert !lockedByCurrentThread();
assert owner != null;
assert owner.owner() || owner.used() : "Neither owner or used flags are set on ready local candidate: " + owner;
if (owner.local() && owner.next() != null) {
for (GridCacheMvccCandidate cand = owner.next(); cand != null; cand = cand.next()) {
assert cand.local() : "Remote candidate cannot be part of thread chain: " + cand;
// Allow next lock in the thread to proceed.
if (!cand.used()) {
if (cand.owner())
break;
GridCacheContext cctx0 = cand.parent().context();
GridDistributedCacheEntry e = (GridDistributedCacheEntry) cctx0.cache().peekEx(cand.parent().key());
// At this point candidate may have been removed and entry destroyed, so we check for null.
if (e == null || e.recheck(owner.version()))
break;
}
}
}
}
use of org.apache.ignite.internal.processors.cache.GridCacheMvccCandidate in project ignite by apache.
the class GridLocalLockFuture method addEntries.
/**
* @param keys Keys.
* @return {@code False} in case of error.
* @throws IgniteCheckedException If failed.
*/
public boolean addEntries(Collection<KeyCacheObject> keys) throws IgniteCheckedException {
for (KeyCacheObject key : keys) {
while (true) {
GridLocalCacheEntry entry = null;
try {
entry = cache.entryExx(key);
entry.unswap(false);
if (!cctx.isAll(entry, filter)) {
onFailed();
return false;
}
// Removed exception may be thrown here.
GridCacheMvccCandidate cand = addEntry(entry);
if (cand == null && isDone())
return false;
break;
} catch (GridCacheEntryRemovedException ignored) {
if (log.isDebugEnabled())
log.debug("Got removed entry in lockAsync(..) method (will retry): " + entry);
}
}
}
if (timeout > 0) {
timeoutObj = new LockTimeoutObject();
cctx.time().addTimeoutObject(timeoutObj);
}
return true;
}
use of org.apache.ignite.internal.processors.cache.GridCacheMvccCandidate 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;
lockEntry();
try {
GridCacheMvcc mvcc = mvccExtras();
if (mvcc != null) {
prev = mvcc.localOwners();
mvcc.releaseLocal(threadId);
if (mvcc.isEmpty())
mvccExtras(null);
else
owner = mvcc.allOwners();
}
val = this.val;
} finally {
unlockEntry();
}
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);
}
use of org.apache.ignite.internal.processors.cache.GridCacheMvccCandidate in project ignite by apache.
the class GridLocalCacheEntry method checkThreadChain.
/**
* {@inheritDoc}
*/
@Override
protected void checkThreadChain(GridCacheMvccCandidate owner) {
assert !lockedByCurrentThread();
assert owner != null;
assert owner.owner() || owner.used() : "Neither owner or used flags are set on ready local candidate: " + owner;
if (owner.next() != null) {
for (GridCacheMvccCandidate cand = owner.next(); cand != null; cand = cand.next()) {
assert cand.local();
// Allow next lock in the thread to proceed.
if (!cand.used()) {
GridCacheContext cctx0 = cand.parent().context();
GridLocalCacheEntry e = (GridLocalCacheEntry) cctx0.cache().peekEx(cand.parent().key());
// At this point candidate may have been removed and entry destroyed, so we check for null.
if (e == null || e.recheck(owner.version()))
break;
}
}
}
}
Aggregations