Search in sources :

Example 6 with GridCacheContext

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

the class GridDistributedCacheEntry method checkThreadChain.

/** {@inheritDoc} */
@Override
protected final void checkThreadChain(GridCacheMvccCandidate owner) {
    assert !Thread.holdsLock(this);
    assert owner != null;
    assert owner.owner() || owner.used() : "Neither owner or used flags are set on ready local candidate: " + owner;
    if (owner.local() && owner.next() != null) {
        for (GridCacheMvccCandidate cand = owner.next(); cand != null; cand = cand.next()) {
            assert cand.local() : "Remote candidate cannot be part of thread chain: " + cand;
            // Allow next lock in the thread to proceed.
            if (!cand.used()) {
                GridCacheContext cctx0 = cand.parent().context();
                GridDistributedCacheEntry e = (GridDistributedCacheEntry) cctx0.cache().peekEx(cand.parent().key());
                if (e != null)
                    e.recheck();
                break;
            }
        }
    }
}
Also used : GridCacheContext(org.apache.ignite.internal.processors.cache.GridCacheContext) GridCacheMvccCandidate(org.apache.ignite.internal.processors.cache.GridCacheMvccCandidate)

Example 7 with GridCacheContext

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

the class GridDhtLockResponse method finishUnmarshal.

/** {@inheritDoc} */
@Override
public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException {
    super.finishUnmarshal(ctx, ldr);
    GridCacheContext cctx = ctx.cacheContext(cacheId);
    if (nearEvicted != null) {
        for (IgniteTxKey key : nearEvicted) key.finishUnmarshal(cctx, ldr);
    }
    if (preloadEntries != null)
        unmarshalInfos(preloadEntries, ctx.cacheContext(cacheId), ldr);
}
Also used : GridCacheContext(org.apache.ignite.internal.processors.cache.GridCacheContext) IgniteTxKey(org.apache.ignite.internal.processors.cache.transactions.IgniteTxKey)

Example 8 with GridCacheContext

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

the class GridDhtLockResponse method prepareMarshal.

/** {@inheritDoc}
     * @param ctx*/
@Override
public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException {
    super.prepareMarshal(ctx);
    GridCacheContext cctx = ctx.cacheContext(cacheId);
    if (nearEvicted != null) {
        for (IgniteTxKey key : nearEvicted) key.prepareMarshal(cctx);
    }
    if (preloadEntries != null)
        marshalInfos(preloadEntries, cctx);
}
Also used : GridCacheContext(org.apache.ignite.internal.processors.cache.GridCacheContext) IgniteTxKey(org.apache.ignite.internal.processors.cache.transactions.IgniteTxKey)

Example 9 with GridCacheContext

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

the class GridDhtTxFinishResponse method prepareMarshal.

/** {@inheritDoc} */
@Override
public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException {
    super.prepareMarshal(ctx);
    if (checkCommittedErr != null && checkCommittedErrBytes == null)
        checkCommittedErrBytes = U.marshal(ctx, checkCommittedErr);
    if (retVal != null && retVal.cacheId() != 0) {
        GridCacheContext cctx = ctx.cacheContext(retVal.cacheId());
        assert cctx != null : retVal.cacheId();
        retVal.prepareMarshal(cctx);
    }
}
Also used : GridCacheContext(org.apache.ignite.internal.processors.cache.GridCacheContext)

Example 10 with GridCacheContext

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

the class GridDhtTxLocalAdapter method mapExplicitLocks.

/**
     * Map explicit locks.
     */
protected void mapExplicitLocks() {
    if (!mapped) {
        // Explicit locks may participate in implicit transactions only.
        if (!implicit()) {
            mapped = true;
            return;
        }
        Map<ClusterNode, List<GridDhtCacheEntry>> dhtEntryMap = null;
        Map<ClusterNode, List<GridDhtCacheEntry>> nearEntryMap = null;
        for (IgniteTxEntry e : allEntries()) {
            assert e.cached() != null;
            GridCacheContext cacheCtx = e.cached().context();
            if (cacheCtx.isNear())
                continue;
            if (e.cached().obsolete()) {
                GridCacheEntryEx cached = cacheCtx.cache().entryEx(e.key(), topologyVersion());
                e.cached(cached);
            }
            if (e.cached().detached() || e.cached().isLocal())
                continue;
            while (true) {
                try {
                    // Map explicit locks.
                    if (e.explicitVersion() != null && !e.explicitVersion().equals(xidVer)) {
                        if (dhtEntryMap == null)
                            dhtEntryMap = new GridLeanMap<>();
                        if (nearEntryMap == null)
                            nearEntryMap = new GridLeanMap<>();
                        cacheCtx.dhtMap((GridDhtCacheEntry) e.cached(), e.explicitVersion(), log, dhtEntryMap, nearEntryMap);
                    }
                    break;
                } catch (GridCacheEntryRemovedException ignore) {
                    GridCacheEntryEx cached = cacheCtx.cache().entryEx(e.key(), topologyVersion());
                    e.cached(cached);
                }
            }
        }
        if (!F.isEmpty(dhtEntryMap))
            addDhtNodeEntryMapping(dhtEntryMap);
        if (!F.isEmpty(nearEntryMap))
            addNearNodeEntryMapping(nearEntryMap);
        mapped = true;
    }
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) IgniteTxEntry(org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry) GridCacheEntryEx(org.apache.ignite.internal.processors.cache.GridCacheEntryEx) GridCacheContext(org.apache.ignite.internal.processors.cache.GridCacheContext) GridLeanMap(org.apache.ignite.internal.util.GridLeanMap) List(java.util.List) GridCacheEntryRemovedException(org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException)

Aggregations

GridCacheContext (org.apache.ignite.internal.processors.cache.GridCacheContext)121 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)27 GridCacheEntryRemovedException (org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException)20 ClusterNode (org.apache.ignite.cluster.ClusterNode)18 KeyCacheObject (org.apache.ignite.internal.processors.cache.KeyCacheObject)17 GridCacheEntryEx (org.apache.ignite.internal.processors.cache.GridCacheEntryEx)15 UUID (java.util.UUID)14 HashMap (java.util.HashMap)13 CacheObject (org.apache.ignite.internal.processors.cache.CacheObject)13 Map (java.util.Map)12 GridCacheVersion (org.apache.ignite.internal.processors.cache.version.GridCacheVersion)12 ArrayList (java.util.ArrayList)11 IgniteTxKey (org.apache.ignite.internal.processors.cache.transactions.IgniteTxKey)11 AffinityTopologyVersion (org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion)10 IgniteTxEntry (org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry)10 List (java.util.List)9 IgniteException (org.apache.ignite.IgniteException)8 GridCacheEntryInfo (org.apache.ignite.internal.processors.cache.GridCacheEntryInfo)8 Ignite (org.apache.ignite.Ignite)7 ClusterTopologyCheckedException (org.apache.ignite.internal.cluster.ClusterTopologyCheckedException)7