Search in sources :

Example 1 with GridCacheMvcc

use of org.apache.ignite.internal.processors.cache.GridCacheMvcc 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;
    synchronized (this) {
        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);
            owner = mvcc.doneRemote(lockVer, maskNull(pendingVers), maskNull(committedVers), maskNull(rolledbackVers));
            boolean emptyAfter = mvcc.isEmpty();
            checkCallbacks(emptyBefore, emptyAfter);
            if (emptyAfter)
                mvccExtras(null);
        }
        val = this.val;
    }
    // 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 GridCacheMvcc

use of org.apache.ignite.internal.processors.cache.GridCacheMvcc 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;
    synchronized (this) {
        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;
    }
    // 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 3 with GridCacheMvcc

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

the class GridDhtCacheEntry method localCandidateByNearVersion.

/**
     * @param nearVer Near version.
     * @param rmv If {@code true}, then add to removed list if not found.
     * @return Local candidate by near version.
     * @throws GridCacheEntryRemovedException If removed.
     */
@Nullable
synchronized GridCacheMvccCandidate localCandidateByNearVersion(GridCacheVersion nearVer, boolean rmv) throws GridCacheEntryRemovedException {
    checkObsolete();
    GridCacheMvcc mvcc = mvccExtras();
    if (mvcc != null) {
        for (GridCacheMvccCandidate c : mvcc.localCandidatesNoCopy(false)) {
            GridCacheVersion ver = c.otherVersion();
            if (ver != null && ver.equals(nearVer))
                return c;
        }
    }
    if (rmv)
        addRemoved(nearVer);
    return null;
}
Also used : GridCacheVersion(org.apache.ignite.internal.processors.cache.version.GridCacheVersion) GridCacheMvcc(org.apache.ignite.internal.processors.cache.GridCacheMvcc) GridCacheMvccCandidate(org.apache.ignite.internal.processors.cache.GridCacheMvccCandidate) Nullable(org.jetbrains.annotations.Nullable)

Example 4 with GridCacheMvcc

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

the class GridDhtCacheEntry method mappings.

/**
     * Sets mappings into entry.
     *
     * @param ver Version.
     * @return Candidate, if one existed for the version, or {@code null} if candidate was not found.
     * @throws GridCacheEntryRemovedException If removed.
     */
@Nullable
public synchronized GridCacheMvccCandidate mappings(GridCacheVersion ver, Collection<ClusterNode> dhtNodeIds, Collection<ClusterNode> nearNodeIds) throws GridCacheEntryRemovedException {
    checkObsolete();
    GridCacheMvcc mvcc = mvccExtras();
    GridCacheMvccCandidate cand = mvcc == null ? null : mvcc.candidate(ver);
    if (cand != null)
        cand.mappedNodeIds(dhtNodeIds, nearNodeIds);
    return cand;
}
Also used : GridCacheMvcc(org.apache.ignite.internal.processors.cache.GridCacheMvcc) GridCacheMvccCandidate(org.apache.ignite.internal.processors.cache.GridCacheMvccCandidate) Nullable(org.jetbrains.annotations.Nullable)

Example 5 with GridCacheMvcc

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

the class GridDhtCacheEntry method removeMapping.

/**
     * @param ver Version.
     * @param mappedNode Mapped node to remove.
     */
public synchronized void removeMapping(GridCacheVersion ver, ClusterNode mappedNode) {
    GridCacheMvcc mvcc = mvccExtras();
    GridCacheMvccCandidate cand = mvcc == null ? null : mvcc.candidate(ver);
    if (cand != null)
        cand.removeMappedNode(mappedNode);
}
Also used : GridCacheMvcc(org.apache.ignite.internal.processors.cache.GridCacheMvcc) 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