use of org.apache.ignite.internal.processors.cache.GridCacheContext in project ignite by apache.
the class GridCacheQueryRequest method prepareMarshal.
/**
* {@inheritDoc}
*/
@Override
public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException {
super.prepareMarshal(ctx);
GridCacheContext cctx = ctx.cacheContext(cacheId);
if (keyValFilter != null && keyValFilterBytes == null) {
if (addDepInfo)
prepareObject(keyValFilter, cctx);
keyValFilterBytes = CU.marshal(cctx, keyValFilter);
}
if (rdc != null && rdcBytes == null) {
if (addDepInfo)
prepareObject(rdc, cctx);
rdcBytes = CU.marshal(cctx, rdc);
}
if (trans != null && transBytes == null) {
if (addDepInfo)
prepareObject(trans, cctx);
transBytes = CU.marshal(cctx, trans);
}
if (!F.isEmpty(args) && argsBytes == null) {
if (addDepInfo) {
for (Object arg : args) prepareObject(arg, cctx);
}
argsBytes = CU.marshal(cctx, args);
}
}
use of org.apache.ignite.internal.processors.cache.GridCacheContext in project ignite by apache.
the class GridNearSingleGetRequest method prepareMarshal.
/**
* {@inheritDoc}
*/
@Override
public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException {
super.prepareMarshal(ctx);
assert key != null;
GridCacheContext cctx = ctx.cacheContext(cacheId);
prepareMarshalCacheObject(key, cctx);
}
use of org.apache.ignite.internal.processors.cache.GridCacheContext in project ignite by apache.
the class GridNearTxFinishFuture method onDone.
/**
* {@inheritDoc}
*/
@Override
public boolean onDone(IgniteInternalTx tx0, Throwable err) {
if (isDone())
return false;
synchronized (this) {
if (isDone())
return false;
boolean nodeStop = false;
if (err != null) {
tx.setRollbackOnly();
nodeStop = err instanceof NodeStoppingException;
}
if (commit) {
if (tx.commitError() != null)
err = tx.commitError();
else if (err != null)
tx.commitError(err);
}
if (initialized() || err != null) {
if (tx.needCheckBackup()) {
assert tx.onePhaseCommit();
if (err != null)
err = new TransactionRollbackException("Failed to commit transaction.", err);
try {
tx.localFinish(err == null, true);
} catch (IgniteCheckedException e) {
if (err != null)
err.addSuppressed(e);
else
err = e;
}
}
if (tx.onePhaseCommit()) {
boolean commit = this.commit && err == null;
if (!nodeStop)
finishOnePhase(commit);
try {
tx.tmFinish(commit, nodeStop, true);
} catch (IgniteCheckedException e) {
U.error(log, "Failed to finish tx: " + tx, e);
if (err == null)
err = e;
}
}
if (super.onDone(tx0, err)) {
if (error() instanceof IgniteTxHeuristicCheckedException && !nodeStop) {
AffinityTopologyVersion topVer = tx.topologyVersion();
for (IgniteTxEntry e : tx.writeMap().values()) {
GridCacheContext cacheCtx = e.context();
try {
if (e.op() != NOOP && !cacheCtx.affinity().keyLocalNode(e.key(), topVer)) {
GridCacheEntryEx entry = cacheCtx.cache().peekEx(e.key());
if (entry != null)
entry.invalidate(tx.xidVersion());
}
} catch (Throwable t) {
U.error(log, "Failed to invalidate entry.", t);
if (t instanceof Error)
throw (Error) t;
}
}
}
// Don't forget to clean up.
cctx.mvcc().removeFuture(futId);
return true;
}
}
}
return false;
}
use of org.apache.ignite.internal.processors.cache.GridCacheContext in project ignite by apache.
the class GridCacheDatabaseSharedManager method applyUpdatesOnRecovery.
/**
* Apply update from some iterator and with specific filters.
*
* @param it WalIterator.
* @param recPredicate Wal record filter.
* @param entryPredicate Entry filter.
* @param partStates Partition to restore state.
*/
public void applyUpdatesOnRecovery(@Nullable WALIterator it, IgnitePredicate<IgniteBiTuple<WALPointer, WALRecord>> recPredicate, IgnitePredicate<DataEntry> entryPredicate, Map<T2<Integer, Integer>, T2<Integer, Long>> partStates) throws IgniteCheckedException {
if (it != null) {
while (it.hasNextX()) {
IgniteBiTuple<WALPointer, WALRecord> next = it.nextX();
WALRecord rec = next.get2();
if (!recPredicate.apply(next))
break;
switch(rec.type()) {
case DATA_RECORD:
checkpointReadLock();
try {
DataRecord dataRec = (DataRecord) rec;
for (DataEntry dataEntry : dataRec.writeEntries()) {
if (entryPredicate.apply(dataEntry)) {
checkpointReadLock();
try {
int cacheId = dataEntry.cacheId();
GridCacheContext cacheCtx = cctx.cacheContext(cacheId);
if (cacheCtx != null)
applyUpdate(cacheCtx, dataEntry);
else if (log != null)
log.warning("Cache (cacheId=" + cacheId + ") is not started, can't apply updates.");
} finally {
checkpointReadUnlock();
}
}
}
} finally {
checkpointReadUnlock();
}
break;
default:
}
}
}
checkpointReadLock();
try {
restorePartitionState(partStates, Collections.emptySet());
} finally {
checkpointReadUnlock();
}
}
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);
}
Aggregations