use of org.apache.ignite.internal.processors.cache.GridCacheContext in project ignite by apache.
the class GridDhtTxPrepareFuture method addDhtValues.
/**
* @param res Response being sent.
*/
private void addDhtValues(GridNearTxPrepareResponse res) {
// Interceptor on near node needs old values to execute callbacks.
if (!F.isEmpty(writes)) {
for (IgniteTxEntry e : writes) {
IgniteTxEntry txEntry = tx.entry(e.txKey());
assert txEntry != null : "Missing tx entry for key [tx=" + tx + ", key=" + e.txKey() + ']';
GridCacheContext cacheCtx = txEntry.context();
while (true) {
try {
GridCacheEntryEx entry = txEntry.cached();
GridCacheVersion dhtVer = entry.version();
CacheObject val0 = entry.valueBytes();
if (val0 != null)
res.addOwnedValue(txEntry.txKey(), dhtVer, val0);
break;
} catch (GridCacheEntryRemovedException ignored) {
// Retry.
txEntry.cached(cacheCtx.cache().entryEx(txEntry.key(), tx.topologyVersion()));
}
}
}
}
for (Map.Entry<IgniteTxKey, GridCacheVersion> ver : dhtVerMap.entrySet()) {
IgniteTxEntry txEntry = tx.entry(ver.getKey());
if (res.hasOwnedValue(ver.getKey()))
continue;
assert txEntry != null : ver;
GridCacheContext cacheCtx = txEntry.context();
while (true) {
try {
GridCacheEntryEx entry = txEntry.cached();
GridCacheVersion dhtVer = entry.version();
if (ver.getValue() == null || !ver.getValue().equals(dhtVer)) {
CacheObject val0 = entry.valueBytes();
res.addOwnedValue(txEntry.txKey(), dhtVer, val0);
}
break;
} catch (GridCacheEntryRemovedException ignored) {
// Retry.
txEntry.cached(cacheCtx.cache().entryEx(txEntry.key(), tx.topologyVersion()));
}
}
}
}
use of org.apache.ignite.internal.processors.cache.GridCacheContext in project ignite by apache.
the class GridDhtTxPrepareFuture method versionCheckError.
/**
* @param entry Entry.
* @return Optimistic version check error.
*/
private IgniteTxOptimisticCheckedException versionCheckError(IgniteTxEntry entry) {
StringBuilder msg = new StringBuilder("Failed to prepare transaction, read/write conflict [");
GridCacheContext cctx = entry.context();
try {
Object key = cctx.unwrapBinaryIfNeeded(entry.key(), entry.keepBinary(), false);
assert key != null : entry.key();
if (S.INCLUDE_SENSITIVE)
msg.append("key=").append(key.toString()).append(", keyCls=").append(key.getClass().getName());
} catch (Exception e) {
msg.append("key=<failed to get key: ").append(e.toString()).append(">");
}
try {
GridCacheEntryEx entryEx = entry.cached();
CacheObject cacheVal = entryEx != null ? entryEx.rawGet() : null;
Object val = cacheVal != null ? cctx.unwrapBinaryIfNeeded(cacheVal, entry.keepBinary(), false) : null;
if (val != null) {
if (S.INCLUDE_SENSITIVE)
msg.append(", val=").append(val.toString()).append(", valCls=").append(val.getClass().getName());
} else
msg.append(", val=null");
} catch (Exception e) {
msg.append(", val=<failed to get value: ").append(e.toString()).append(">");
}
msg.append(", cache=").append(cctx.name()).append(", thread=").append(Thread.currentThread()).append("]");
return new IgniteTxOptimisticCheckedException(msg.toString());
}
use of org.apache.ignite.internal.processors.cache.GridCacheContext in project ignite by apache.
the class GridDhtAtomicSingleUpdateRequest method finishUnmarshal.
/** {@inheritDoc} */
@Override
public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException {
super.finishUnmarshal(ctx, ldr);
GridCacheContext cctx = ctx.cacheContext(cacheId);
finishUnmarshalObject(key, cctx, ldr);
finishUnmarshalObject(val, cctx, ldr);
finishUnmarshalObject(prevVal, cctx, ldr);
}
use of org.apache.ignite.internal.processors.cache.GridCacheContext in project ignite by apache.
the class GridNearAtomicFullUpdateRequest method prepareMarshal.
/** {@inheritDoc} */
@Override
public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException {
super.prepareMarshal(ctx);
GridCacheContext cctx = ctx.cacheContext(cacheId);
if (expiryPlc != null && expiryPlcBytes == null)
expiryPlcBytes = CU.marshal(cctx, new IgniteExternalizableExpiryPolicy(expiryPlc));
prepareMarshalCacheObjects(keys, cctx);
if (filter != null) {
boolean hasFilter = false;
for (CacheEntryPredicate p : filter) {
if (p != null) {
hasFilter = true;
p.prepareMarshal(cctx);
}
}
if (!hasFilter)
filter = null;
}
if (op == TRANSFORM) {
// force addition of deployment info for entry processors if P2P is enabled globally.
if (!addDepInfo && ctx.deploymentEnabled())
addDepInfo = true;
if (entryProcessorsBytes == null)
entryProcessorsBytes = marshalCollection(entryProcessors, cctx);
if (invokeArgsBytes == null)
invokeArgsBytes = marshalInvokeArguments(invokeArgs, cctx);
} else
prepareMarshalCacheObjects(vals, cctx);
}
use of org.apache.ignite.internal.processors.cache.GridCacheContext in project ignite by apache.
the class GridNearAtomicFullUpdateRequest method finishUnmarshal.
/** {@inheritDoc} */
@Override
public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException {
super.finishUnmarshal(ctx, ldr);
GridCacheContext cctx = ctx.cacheContext(cacheId);
if (expiryPlcBytes != null && expiryPlc == null)
expiryPlc = U.unmarshal(ctx, expiryPlcBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
finishUnmarshalCacheObjects(keys, cctx, ldr);
if (filter != null) {
for (CacheEntryPredicate p : filter) {
if (p != null)
p.finishUnmarshal(cctx, ldr);
}
}
if (op == TRANSFORM) {
if (entryProcessors == null)
entryProcessors = unmarshalCollection(entryProcessorsBytes, ctx, ldr);
if (invokeArgs == null)
invokeArgs = unmarshalInvokeArguments(invokeArgsBytes, ctx, ldr);
} else
finishUnmarshalCacheObjects(vals, cctx, ldr);
}
Aggregations