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;
}
}
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);
}
}
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);
}
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);
}
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;
}
Aggregations