use of org.apache.ignite.internal.processors.cache.mvcc.MvccSnapshotWithoutTxs in project ignite by apache.
the class GridDhtTransactionalCacheAdapter method processDhtTxQueryEnlistRequest.
/**
* @param primary Primary node.
* @param req Message.
* @param first Flag if this is a first request in current operation.
*/
private void processDhtTxQueryEnlistRequest(UUID primary, GridDhtTxQueryEnlistRequest req, boolean first) {
try {
assert req.version() != null && req.op() != null;
GridDhtTxRemote tx = ctx.tm().tx(req.version());
if (tx == null) {
if (!first)
throw new IgniteCheckedException("Can not find a transaction for version [version=" + req.version() + ']');
GridDhtTxQueryFirstEnlistRequest req0 = (GridDhtTxQueryFirstEnlistRequest) req;
tx = new GridDhtTxRemote(ctx.shared(), req0.nearNodeId(), req0.dhtFutureId(), primary, req0.nearXidVersion(), req0.topologyVersion(), req0.version(), null, ctx.systemTx(), ctx.ioPolicy(), PESSIMISTIC, REPEATABLE_READ, false, req0.timeout(), -1, securitySubjectId(ctx), req0.taskNameHash(), false, null);
tx.mvccSnapshot(new MvccSnapshotWithoutTxs(req0.coordinatorVersion(), req0.counter(), MVCC_OP_COUNTER_NA, req0.cleanupVersion()));
tx = ctx.tm().onCreated(null, tx);
if (tx == null || !ctx.tm().onStarted(tx)) {
throw new IgniteTxRollbackCheckedException("Failed to update backup " + "(transaction has been completed): " + req0.version());
}
}
assert tx != null;
MvccSnapshot s0 = tx.mvccSnapshot();
MvccSnapshot snapshot = new MvccSnapshotWithoutTxs(s0.coordinatorVersion(), s0.counter(), req.operationCounter(), s0.cleanupVersion());
ctx.tm().txHandler().mvccEnlistBatch(tx, ctx, req.op(), req.keys(), req.values(), snapshot, req.dhtFutureId(), req.batchId());
GridDhtTxQueryEnlistResponse res = new GridDhtTxQueryEnlistResponse(req.cacheId(), req.dhtFutureId(), req.batchId(), null);
try {
ctx.io().send(primary, res, ctx.ioPolicy());
} catch (IgniteCheckedException ioEx) {
U.error(log, "Failed to send DHT enlist reply to primary node [node: " + primary + ", req=" + req + ']', ioEx);
}
} catch (Throwable e) {
GridDhtTxQueryEnlistResponse res = new GridDhtTxQueryEnlistResponse(ctx.cacheId(), req.dhtFutureId(), req.batchId(), e);
try {
ctx.io().send(primary, res, ctx.ioPolicy());
} catch (IgniteCheckedException ioEx) {
U.error(log, "Failed to send DHT enlist reply to primary node " + "[node: " + primary + ", req=" + req + ']', ioEx);
}
if (e instanceof Error)
throw (Error) e;
}
}
use of org.apache.ignite.internal.processors.cache.mvcc.MvccSnapshotWithoutTxs in project ignite by apache.
the class GridNearTxQueryResultsEnlistFuture method processBatchLocalBackupKeys.
/**
* @param primaryId Primary node id.
* @param rows Rows.
* @param dhtVer Dht version assigned at primary node.
* @param dhtFutId Dht future id assigned at primary node.
*/
private void processBatchLocalBackupKeys(UUID primaryId, List<Object> rows, GridCacheVersion dhtVer, IgniteUuid dhtFutId) {
assert dhtVer != null;
assert dhtFutId != null;
EnlistOperation op = it.operation();
assert op != EnlistOperation.LOCK;
boolean keysOnly = op.isDeleteOrLock();
final ArrayList<KeyCacheObject> keys = new ArrayList<>(rows.size());
final ArrayList<Message> vals = keysOnly ? null : new ArrayList<>(rows.size());
for (Object row : rows) {
if (keysOnly)
keys.add(cctx.toCacheKeyObject(row));
else {
keys.add(cctx.toCacheKeyObject(((IgniteBiTuple) row).getKey()));
vals.add(cctx.toCacheObject(((IgniteBiTuple) row).getValue()));
}
}
try {
GridDhtTxRemote dhtTx = cctx.tm().tx(dhtVer);
if (dhtTx == null) {
dhtTx = new GridDhtTxRemote(cctx.shared(), cctx.localNodeId(), dhtFutId, primaryId, lockVer, topVer, dhtVer, null, cctx.systemTx(), cctx.ioPolicy(), PESSIMISTIC, REPEATABLE_READ, false, tx.remainingTime(), -1, SecurityUtils.securitySubjectId(cctx), tx.taskNameHash(), false, tx.label());
dhtTx.mvccSnapshot(new MvccSnapshotWithoutTxs(mvccSnapshot.coordinatorVersion(), mvccSnapshot.counter(), MVCC_OP_COUNTER_NA, mvccSnapshot.cleanupVersion()));
dhtTx = cctx.tm().onCreated(null, dhtTx);
if (dhtTx == null || !cctx.tm().onStarted(dhtTx)) {
throw new IgniteTxRollbackCheckedException("Failed to update backup " + "(transaction has been completed): " + dhtVer);
}
}
cctx.tm().txHandler().mvccEnlistBatch(dhtTx, cctx, it.operation(), keys, vals, mvccSnapshot.withoutActiveTransactions(), null, -1);
} catch (IgniteCheckedException e) {
onDone(e);
return;
}
sendNextBatches(primaryId);
}
use of org.apache.ignite.internal.processors.cache.mvcc.MvccSnapshotWithoutTxs in project ignite by apache.
the class GridNearTxEnlistFuture method processBatchLocalBackupKeys.
/**
* @param primaryId Primary node id.
* @param rows Rows.
* @param dhtVer Dht version assigned at primary node.
* @param dhtFutId Dht future id assigned at primary node.
*/
private void processBatchLocalBackupKeys(UUID primaryId, List<Object> rows, GridCacheVersion dhtVer, IgniteUuid dhtFutId) {
assert dhtVer != null;
assert dhtFutId != null;
EnlistOperation op = it.operation();
assert op != EnlistOperation.LOCK;
boolean keysOnly = op.isDeleteOrLock();
final ArrayList<KeyCacheObject> keys = new ArrayList<>(rows.size());
final ArrayList<Message> vals = keysOnly ? null : new ArrayList<>(rows.size());
for (Object row : rows) {
if (keysOnly)
keys.add(cctx.toCacheKeyObject(row));
else {
keys.add(cctx.toCacheKeyObject(((IgniteBiTuple) row).getKey()));
if (op.isInvoke())
vals.add((Message) ((IgniteBiTuple) row).getValue());
else
vals.add(cctx.toCacheObject(((IgniteBiTuple) row).getValue()));
}
}
try {
GridDhtTxRemote dhtTx = cctx.tm().tx(dhtVer);
if (dhtTx == null) {
dhtTx = new GridDhtTxRemote(cctx.shared(), cctx.localNodeId(), dhtFutId, primaryId, lockVer, topVer, dhtVer, null, cctx.systemTx(), cctx.ioPolicy(), PESSIMISTIC, REPEATABLE_READ, false, tx.remainingTime(), -1, SecurityUtils.securitySubjectId(cctx), tx.taskNameHash(), false, null);
dhtTx.mvccSnapshot(new MvccSnapshotWithoutTxs(mvccSnapshot.coordinatorVersion(), mvccSnapshot.counter(), MVCC_OP_COUNTER_NA, mvccSnapshot.cleanupVersion()));
dhtTx = cctx.tm().onCreated(null, dhtTx);
if (dhtTx == null || !cctx.tm().onStarted(dhtTx)) {
throw new IgniteTxRollbackCheckedException("Failed to update backup " + "(transaction has been completed): " + dhtVer);
}
}
cctx.tm().txHandler().mvccEnlistBatch(dhtTx, cctx, it.operation(), keys, vals, mvccSnapshot.withoutActiveTransactions(), null, -1);
} catch (IgniteCheckedException e) {
onDone(e);
return;
}
sendNextBatches(primaryId);
}
Aggregations