Search in sources :

Example 36 with GridCacheContext

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

the class GridNearAtomicSingleUpdateFilterRequest method prepareMarshal.

/**
 * {@inheritDoc}
 */
@Override
public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException {
    super.prepareMarshal(ctx);
    GridCacheContext cctx = ctx.cacheContext(cacheId);
    if (filter != null) {
        boolean hasFilter = false;
        for (CacheEntryPredicate p : filter) {
            if (p != null) {
                hasFilter = true;
                p.prepareMarshal(cctx);
            }
        }
        if (!hasFilter)
            filter = null;
    }
}
Also used : GridCacheContext(org.apache.ignite.internal.processors.cache.GridCacheContext) CacheEntryPredicate(org.apache.ignite.internal.processors.cache.CacheEntryPredicate)

Example 37 with GridCacheContext

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

the class GridDhtForceKeysResponse method prepareMarshal.

/**
 * {@inheritDoc}
 * @param ctx
 */
@Override
public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException {
    super.prepareMarshal(ctx);
    GridCacheContext cctx = ctx.cacheContext(cacheId);
    if (missedKeys != null)
        prepareMarshalCacheObjects(missedKeys, cctx);
    if (infos != null) {
        for (GridCacheEntryInfo info : infos) info.marshal(cctx.cacheObjectContext());
    }
    if (err != null && errBytes == null)
        errBytes = U.marshal(ctx, err);
}
Also used : GridCacheEntryInfo(org.apache.ignite.internal.processors.cache.GridCacheEntryInfo) GridCacheContext(org.apache.ignite.internal.processors.cache.GridCacheContext)

Example 38 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)

Example 39 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 40 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.shared(), cctx.cacheObjectContext());
}
Also used : GridCacheContext(org.apache.ignite.internal.processors.cache.GridCacheContext) IgniteTxKey(org.apache.ignite.internal.processors.cache.transactions.IgniteTxKey)

Aggregations

GridCacheContext (org.apache.ignite.internal.processors.cache.GridCacheContext)147 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)37 GridCacheEntryRemovedException (org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException)22 HashMap (java.util.HashMap)21 ClusterNode (org.apache.ignite.cluster.ClusterNode)20 Map (java.util.Map)19 UUID (java.util.UUID)18 KeyCacheObject (org.apache.ignite.internal.processors.cache.KeyCacheObject)18 GridCacheEntryEx (org.apache.ignite.internal.processors.cache.GridCacheEntryEx)16 ArrayList (java.util.ArrayList)15 IgniteException (org.apache.ignite.IgniteException)14 CacheObject (org.apache.ignite.internal.processors.cache.CacheObject)14 List (java.util.List)13 AffinityTopologyVersion (org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion)13 GridCacheVersion (org.apache.ignite.internal.processors.cache.version.GridCacheVersion)13 ClusterTopologyCheckedException (org.apache.ignite.internal.cluster.ClusterTopologyCheckedException)11 ConcurrentMap (java.util.concurrent.ConcurrentMap)10 IgniteTxEntry (org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry)10 GridCacheEntryInfo (org.apache.ignite.internal.processors.cache.GridCacheEntryInfo)9 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)8