Search in sources :

Example 21 with GridCacheMvcc

use of org.apache.ignite.internal.processors.cache.GridCacheMvcc 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;
    lockEntry();
    try {
        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;
    } finally {
        unlockEntry();
    }
    if (doomed != null)
        checkThreadChain(doomed);
    checkOwnerChanged(prev, owner, val);
    return doomed != null;
}
Also used : GridCacheVersion(org.apache.ignite.internal.processors.cache.version.GridCacheVersion) 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)

Example 22 with GridCacheMvcc

use of org.apache.ignite.internal.processors.cache.GridCacheMvcc 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;
    lockEntry();
    try {
        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;
    } finally {
        unlockEntry();
    }
    if (cand != null && !cand.reentry())
        cctx.mvcc().addNext(cctx, cand);
    checkOwnerChanged(prev, owner, val);
    return cand;
}
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) Nullable(org.jetbrains.annotations.Nullable)

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