Search in sources :

Example 16 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 17 with GridCacheContext

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

the class GridDhtPartitionSupplyMessage method finishUnmarshal.

/** {@inheritDoc} */
@SuppressWarnings("ForLoopReplaceableByForEach")
@Override
public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException {
    super.finishUnmarshal(ctx, ldr);
    GridCacheContext cacheCtx = ctx.cacheContext(cacheId);
    for (CacheEntryInfoCollection col : infos().values()) {
        List<GridCacheEntryInfo> entries = col.infos();
        for (int i = 0; i < entries.size(); i++) entries.get(i).unmarshal(cacheCtx, ldr);
    }
}
Also used : GridCacheEntryInfo(org.apache.ignite.internal.processors.cache.GridCacheEntryInfo) GridCacheContext(org.apache.ignite.internal.processors.cache.GridCacheContext) CacheEntryInfoCollection(org.apache.ignite.internal.processors.cache.CacheEntryInfoCollection)

Example 18 with GridCacheContext

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

the class GridDhtForceKeysRequest method finishUnmarshal.

/** {@inheritDoc} */
@Override
public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException {
    super.finishUnmarshal(ctx, ldr);
    GridCacheContext cctx = ctx.cacheContext(cacheId);
    finishUnmarshalCacheObjects(keys, cctx, ldr);
}
Also used : GridCacheContext(org.apache.ignite.internal.processors.cache.GridCacheContext)

Example 19 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);
    }
    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 20 with GridCacheContext

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

the class GridNearOptimisticTxPrepareFuture method map.

/**
     * @param entry Transaction entry.
     * @param topVer Topology version.
     * @param cur Current mapping.
     * @param topLocked {@code True} if thread already acquired lock preventing topology change.
     * @param remap Remap flag.
     * @return Mapping.
     */
private GridDistributedTxMapping map(IgniteTxEntry entry, AffinityTopologyVersion topVer, @Nullable GridDistributedTxMapping cur, boolean topLocked, boolean remap) {
    GridCacheContext cacheCtx = entry.context();
    List<ClusterNode> nodes;
    GridCacheEntryEx cached0 = entry.cached();
    if (cached0.isDht())
        nodes = cacheCtx.topology().nodes(cached0.partition(), topVer);
    else
        nodes = cacheCtx.isLocal() ? cacheCtx.affinity().nodesByKey(entry.key(), topVer) : cacheCtx.topology().nodes(cacheCtx.affinity().partition(entry.key()), topVer);
    txMapping.addMapping(nodes);
    ClusterNode primary = F.first(nodes);
    assert primary != null;
    if (log.isDebugEnabled()) {
        log.debug("Mapped key to primary node [key=" + entry.key() + ", part=" + cacheCtx.affinity().partition(entry.key()) + ", primary=" + U.toShortString(primary) + ", topVer=" + topVer + ']');
    }
    // Must re-initialize cached entry while holding topology lock.
    if (cacheCtx.isNear())
        entry.cached(cacheCtx.nearTx().entryExx(entry.key(), topVer));
    else if (!cacheCtx.isLocal())
        entry.cached(cacheCtx.colocated().entryExx(entry.key(), topVer, true));
    else
        entry.cached(cacheCtx.local().entryEx(entry.key(), topVer));
    if (cacheCtx.isNear() || cacheCtx.isLocal()) {
        if (entry.explicitVersion() == null && !remap) {
            if (keyLockFut == null) {
                keyLockFut = new KeyLockFuture();
                add(keyLockFut);
            }
            keyLockFut.addLockKey(entry.txKey());
        }
    }
    if (cur == null || !cur.primary().id().equals(primary.id()) || (primary.isLocal() && cur.hasNearCacheEntries() != cacheCtx.isNear())) {
        boolean clientFirst = cur == null && !topLocked && cctx.kernalContext().clientNode();
        cur = new GridDistributedTxMapping(primary);
        cur.clientFirst(clientFirst);
    }
    cur.add(entry);
    if (entry.explicitVersion() != null) {
        tx.markExplicit(primary.id());
        cur.markExplicitLock();
    }
    entry.nodeId(primary.id());
    if (cacheCtx.isNear()) {
        while (true) {
            try {
                GridNearCacheEntry cached = (GridNearCacheEntry) entry.cached();
                cached.dhtNodeId(tx.xidVersion(), primary.id());
                break;
            } catch (GridCacheEntryRemovedException ignore) {
                entry.cached(cacheCtx.near().entryEx(entry.key(), topVer));
            }
        }
    }
    return cur;
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) GridCacheEntryEx(org.apache.ignite.internal.processors.cache.GridCacheEntryEx) GridCacheContext(org.apache.ignite.internal.processors.cache.GridCacheContext) GridDistributedTxMapping(org.apache.ignite.internal.processors.cache.distributed.GridDistributedTxMapping) 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