Search in sources :

Example 6 with GridCacheMvccCandidate

use of org.apache.ignite.internal.processors.cache.GridCacheMvccCandidate 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 GridCacheMvccCandidate mappings(GridCacheVersion ver, Collection<ClusterNode> dhtNodeIds, Collection<ClusterNode> nearNodeIds) throws GridCacheEntryRemovedException {
    lockEntry();
    try {
        checkObsolete();
        GridCacheMvcc mvcc = mvccExtras();
        GridCacheMvccCandidate cand = mvcc == null ? null : mvcc.candidate(ver);
        if (cand != null)
            cand.mappedNodeIds(dhtNodeIds, nearNodeIds);
        return cand;
    } finally {
        unlockEntry();
    }
}
Also used : GridCacheMvcc(org.apache.ignite.internal.processors.cache.GridCacheMvcc) GridCacheMvccCandidate(org.apache.ignite.internal.processors.cache.GridCacheMvccCandidate) Nullable(org.jetbrains.annotations.Nullable)

Example 7 with GridCacheMvccCandidate

use of org.apache.ignite.internal.processors.cache.GridCacheMvccCandidate 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
GridCacheMvccCandidate localCandidateByNearVersion(GridCacheVersion nearVer, boolean rmv) throws GridCacheEntryRemovedException {
    lockEntry();
    try {
        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;
    } finally {
        unlockEntry();
    }
}
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 8 with GridCacheMvccCandidate

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

the class GridDhtCacheEntry method removeLock.

/**
 * {@inheritDoc}
 */
@Override
public GridCacheMvccCandidate removeLock() {
    GridCacheMvccCandidate ret = super.removeLock();
    locPart.onUnlock();
    return ret;
}
Also used : GridCacheMvccCandidate(org.apache.ignite.internal.processors.cache.GridCacheMvccCandidate)

Example 9 with GridCacheMvccCandidate

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

the class GridDhtCacheEntry method removeMapping.

/**
 * @param ver Version.
 * @param mappedNode Mapped node to remove.
 */
public void removeMapping(GridCacheVersion ver, ClusterNode mappedNode) {
    lockEntry();
    try {
        GridCacheMvcc mvcc = mvccExtras();
        GridCacheMvccCandidate cand = mvcc == null ? null : mvcc.candidate(ver);
        if (cand != null)
            cand.removeMappedNode(mappedNode);
    } finally {
        unlockEntry();
    }
}
Also used : GridCacheMvcc(org.apache.ignite.internal.processors.cache.GridCacheMvcc) GridCacheMvccCandidate(org.apache.ignite.internal.processors.cache.GridCacheMvccCandidate)

Example 10 with GridCacheMvccCandidate

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

the class VisorTxTask method fetchTxEntriesAndFillUsedCaches.

/**
 * Retrieves detailed information about used keys and locks ownership.
 *
 * @param ignite Ignite.
 * @param locTx Local tx.
 * @param usedCaches Used caches.
 * @param usedCacheGroups Used cache groups.
 * @param locEntries Local entries.
 * @param skipLocksCheck Skip locks check.
 */
private static List<TxVerboseKey> fetchTxEntriesAndFillUsedCaches(IgniteEx ignite, IgniteInternalTx locTx, Map<Integer, String> usedCaches, Map<Integer, String> usedCacheGroups, Collection<IgniteTxEntry> locEntries, boolean skipLocksCheck) {
    List<TxVerboseKey> locTxKeys = new ArrayList<>();
    for (IgniteTxEntry txEntry : locEntries) {
        GridCacheContext cacheCtx = ignite.context().cache().context().cacheContext(txEntry.cacheId());
        usedCaches.put(cacheCtx.cacheId(), cacheCtx.name());
        usedCacheGroups.put(cacheCtx.groupId(), cacheCtx.group().cacheOrGroupName());
        TxKeyLockType keyLockType = TxKeyLockType.NO_LOCK;
        GridCacheVersion ownerVer = null;
        if (!skipLocksCheck) {
            GridCacheEntryEx entryEx = cacheCtx.cache().entryEx(txEntry.key(), locTx.topologyVersion());
            Collection<GridCacheMvccCandidate> locCandidates;
            try {
                locCandidates = entryEx.localCandidates();
            } catch (GridCacheEntryRemovedException ignored) {
                U.warn(ignite.log(), "Failed to process TX key: entry was already removed: " + txEntry.txKey());
                continue;
            }
            boolean owner = false;
            boolean present = false;
            for (GridCacheMvccCandidate mvccCandidate : locCandidates) {
                if (mvccCandidate.owner())
                    ownerVer = mvccCandidate.version();
                if (locTx.xidVersion().equals(mvccCandidate.version())) {
                    present = true;
                    if (mvccCandidate.owner())
                        owner = true;
                }
            }
            keyLockType = present ? (owner ? TxKeyLockType.OWNS_LOCK : TxKeyLockType.AWAITS_LOCK) : TxKeyLockType.NO_LOCK;
        }
        TxVerboseKey txVerboseKey = new TxVerboseKey(txEntry.txKey().toString(), keyLockType, ownerVer, txEntry.isRead());
        locTxKeys.add(txVerboseKey);
    }
    return locTxKeys;
}
Also used : IgniteTxEntry(org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry) GridCacheVersion(org.apache.ignite.internal.processors.cache.version.GridCacheVersion) GridCacheEntryEx(org.apache.ignite.internal.processors.cache.GridCacheEntryEx) GridCacheContext(org.apache.ignite.internal.processors.cache.GridCacheContext) ArrayList(java.util.ArrayList) GridCacheEntryRemovedException(org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException) GridCacheMvccCandidate(org.apache.ignite.internal.processors.cache.GridCacheMvccCandidate)

Aggregations

GridCacheMvccCandidate (org.apache.ignite.internal.processors.cache.GridCacheMvccCandidate)41 KeyCacheObject (org.apache.ignite.internal.processors.cache.KeyCacheObject)17 GridCacheVersion (org.apache.ignite.internal.processors.cache.version.GridCacheVersion)15 Nullable (org.jetbrains.annotations.Nullable)14 GridCacheMvcc (org.apache.ignite.internal.processors.cache.GridCacheMvcc)13 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)11 ClusterNode (org.apache.ignite.cluster.ClusterNode)11 CacheObject (org.apache.ignite.internal.processors.cache.CacheObject)11 GridCacheEntryRemovedException (org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException)10 ArrayList (java.util.ArrayList)9 Map (java.util.Map)9 CacheLockCandidates (org.apache.ignite.internal.processors.cache.CacheLockCandidates)9 IgniteTxEntry (org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry)8 AffinityTopologyVersion (org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion)6 IgniteTxKey (org.apache.ignite.internal.processors.cache.transactions.IgniteTxKey)6 UUID (java.util.UUID)5 ClusterTopologyCheckedException (org.apache.ignite.internal.cluster.ClusterTopologyCheckedException)5 GridCacheEntryEx (org.apache.ignite.internal.processors.cache.GridCacheEntryEx)5 GridDistributedCacheEntry (org.apache.ignite.internal.processors.cache.distributed.GridDistributedCacheEntry)5 Collection (java.util.Collection)4