Search in sources :

Example 1 with CacheLockCandidates

use of org.apache.ignite.internal.processors.cache.CacheLockCandidates in project ignite by apache.

the class GridDistributedCacheEntry method recheck.

/**
 * Rechecks if lock should be reassigned.
 */
public void recheck() {
    CacheLockCandidates prev = null;
    CacheLockCandidates owner = null;
    CacheObject val;
    lockEntry();
    try {
        GridCacheMvcc mvcc = mvccExtras();
        if (mvcc != null) {
            prev = mvcc.allOwners();
            boolean emptyBefore = mvcc.isEmpty();
            owner = mvcc.recheck();
            boolean emptyAfter = mvcc.isEmpty();
            checkCallbacks(emptyBefore, emptyAfter);
            if (emptyAfter)
                mvccExtras(null);
        }
        val = this.val;
    } finally {
        unlockEntry();
    }
    // This call must be made outside of synchronization.
    checkOwnerChanged(prev, owner, val);
}
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)

Example 2 with CacheLockCandidates

use of org.apache.ignite.internal.processors.cache.CacheLockCandidates 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;
    lockEntry();
    try {
        GridCacheMvcc mvcc = mvccExtras();
        if (mvcc != null) {
            prev = mvcc.allOwners();
            owner = mvcc.recheck();
            if (mvcc.isEmpty())
                mvccExtras(null);
        }
        val = this.val;
    } finally {
        unlockEntry();
    }
    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 3 with CacheLockCandidates

use of org.apache.ignite.internal.processors.cache.CacheLockCandidates in project ignite by apache.

the class GridDistributedCacheEntry method doneRemote.

/**
 * @param lockVer Done version.
 * @param baseVer Base version.
 * @param pendingVers Pending versions that are less than lock version.
 * @param committedVers Completed versions for reordering.
 * @param rolledbackVers Rolled back versions for reordering.
 * @param sysInvalidate Flag indicating if this entry is done from invalidated transaction (in case of tx
 *      salvage). In this case all locks before salvaged lock will marked as used and corresponding
 *      transactions will be invalidated.
 * @throws GridCacheEntryRemovedException If entry has been removed.
 */
public void doneRemote(GridCacheVersion lockVer, GridCacheVersion baseVer, @Nullable Collection<GridCacheVersion> pendingVers, Collection<GridCacheVersion> committedVers, Collection<GridCacheVersion> rolledbackVers, boolean sysInvalidate) throws GridCacheEntryRemovedException {
    CacheLockCandidates prev = null;
    CacheLockCandidates owner = null;
    CacheObject val;
    lockEntry();
    try {
        checkObsolete();
        GridCacheMvcc mvcc = mvccExtras();
        if (mvcc != null) {
            prev = mvcc.allOwners();
            boolean emptyBefore = mvcc.isEmpty();
            // Order completed versions.
            if (!F.isEmpty(committedVers) || !F.isEmpty(rolledbackVers)) {
                mvcc.orderCompleted(lockVer, committedVers, rolledbackVers);
                if (!baseVer.equals(lockVer))
                    mvcc.orderCompleted(baseVer, committedVers, rolledbackVers);
            }
            if (sysInvalidate && baseVer != null)
                mvcc.salvageRemote(baseVer, isNear());
            owner = mvcc.doneRemote(lockVer, maskNull(pendingVers), maskNull(committedVers), maskNull(rolledbackVers));
            boolean emptyAfter = mvcc.isEmpty();
            checkCallbacks(emptyBefore, emptyAfter);
            if (emptyAfter)
                mvccExtras(null);
        }
        val = this.val;
    } finally {
        unlockEntry();
    }
    // This call must be made outside of synchronization.
    checkOwnerChanged(prev, owner, val);
}
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)

Example 4 with CacheLockCandidates

use of org.apache.ignite.internal.processors.cache.CacheLockCandidates 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);
}
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)

Example 5 with CacheLockCandidates

use of org.apache.ignite.internal.processors.cache.CacheLockCandidates 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;
    lockEntry();
    try {
        GridCacheMvcc mvcc = mvccExtras();
        if (mvcc != null) {
            prev = mvcc.localOwners();
            owner = mvcc.readyLocal(cand);
            if (mvcc.isEmpty())
                mvccExtras(null);
        }
        val = this.val;
    } finally {
        unlockEntry();
    }
    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)

Aggregations

CacheLockCandidates (org.apache.ignite.internal.processors.cache.CacheLockCandidates)20 CacheObject (org.apache.ignite.internal.processors.cache.CacheObject)19 GridCacheMvcc (org.apache.ignite.internal.processors.cache.GridCacheMvcc)19 KeyCacheObject (org.apache.ignite.internal.processors.cache.KeyCacheObject)19 GridCacheMvccCandidate (org.apache.ignite.internal.processors.cache.GridCacheMvccCandidate)9 Nullable (org.jetbrains.annotations.Nullable)7 UUID (java.util.UUID)2 GridCacheVersion (org.apache.ignite.internal.processors.cache.version.GridCacheVersion)2 GridCacheContext (org.apache.ignite.internal.processors.cache.GridCacheContext)1 GridCacheEntryRemovedException (org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException)1 GridDistributedCacheEntry (org.apache.ignite.internal.processors.cache.distributed.GridDistributedCacheEntry)1 IgniteTxEntry (org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry)1