Search in sources :

Example 6 with GridCacheMvcc

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();
}
Also used : GridCacheMvcc(org.apache.ignite.internal.processors.cache.GridCacheMvcc) GridCacheMvccCandidate(org.apache.ignite.internal.processors.cache.GridCacheMvccCandidate)

Example 7 with GridCacheMvcc

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;
}
Also used : GridCacheMvcc(org.apache.ignite.internal.processors.cache.GridCacheMvcc) CacheLockCandidates(org.apache.ignite.internal.processors.cache.CacheLockCandidates) CacheObject(org.apache.ignite.internal.processors.cache.CacheObject) KeyCacheObject(org.apache.ignite.internal.processors.cache.KeyCacheObject) UUID(java.util.UUID) GridCacheMvccCandidate(org.apache.ignite.internal.processors.cache.GridCacheMvccCandidate) Nullable(org.jetbrains.annotations.Nullable)

Example 8 with GridCacheMvcc

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);
}
Also used : GridCacheMvcc(org.apache.ignite.internal.processors.cache.GridCacheMvcc) CacheObject(org.apache.ignite.internal.processors.cache.CacheObject) KeyCacheObject(org.apache.ignite.internal.processors.cache.KeyCacheObject) CacheLockCandidates(org.apache.ignite.internal.processors.cache.CacheLockCandidates)

Example 9 with GridCacheMvcc

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);
}
Also used : GridCacheMvcc(org.apache.ignite.internal.processors.cache.GridCacheMvcc) CacheObject(org.apache.ignite.internal.processors.cache.CacheObject) KeyCacheObject(org.apache.ignite.internal.processors.cache.KeyCacheObject) CacheLockCandidates(org.apache.ignite.internal.processors.cache.CacheLockCandidates)

Example 10 with GridCacheMvcc

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);
}
Also used : GridCacheMvcc(org.apache.ignite.internal.processors.cache.GridCacheMvcc) CacheObject(org.apache.ignite.internal.processors.cache.CacheObject) KeyCacheObject(org.apache.ignite.internal.processors.cache.KeyCacheObject) CacheLockCandidates(org.apache.ignite.internal.processors.cache.CacheLockCandidates) GridCacheMvccCandidate(org.apache.ignite.internal.processors.cache.GridCacheMvccCandidate)

Aggregations

GridCacheMvcc (org.apache.ignite.internal.processors.cache.GridCacheMvcc)22 CacheLockCandidates (org.apache.ignite.internal.processors.cache.CacheLockCandidates)17 CacheObject (org.apache.ignite.internal.processors.cache.CacheObject)17 KeyCacheObject (org.apache.ignite.internal.processors.cache.KeyCacheObject)17 GridCacheMvccCandidate (org.apache.ignite.internal.processors.cache.GridCacheMvccCandidate)14 Nullable (org.jetbrains.annotations.Nullable)10 GridCacheVersion (org.apache.ignite.internal.processors.cache.version.GridCacheVersion)3 UUID (java.util.UUID)2