/** * @param cctx Context. * @param tx Transaction. */ protected GridNearOptimisticTxPrepareFutureAdapter(GridCacheSharedContext cctx, GridNearTxLocal tx) { super(cctx, tx); assert tx.optimistic() : tx; if (tx.timeout() > 0) { // Init keyLockFut to make sure it is created when {@link #onNearTxLocalTimeout} is called. for (IgniteTxEntry e : tx.writeEntries()) { if (e.context().isNear() || e.context().isLocal()) { keyLockFut = new KeyLockFuture(); break; } } if (tx.serializable() && keyLockFut == null) { for (IgniteTxEntry e : tx.readEntries()) { if (e.context().isNear() || e.context().isLocal()) { keyLockFut = new KeyLockFuture(); break; } } } if (keyLockFut != null) add((IgniteInternalFuture)keyLockFut); } }
/** * Initializes future. * * @param remap Remap flag. */ @Override protected void prepare0(boolean remap, boolean topLocked) { boolean txStateCheck = remap ? tx.state() == PREPARING : tx.state(PREPARING); if (!txStateCheck) { if (tx.isRollbackOnly() || tx.setRollbackOnly()) { if (tx.timedOut()) onDone(null, tx.timeoutException()); else onDone(null, tx.rollbackException()); } else onDone(null, new IgniteCheckedException("Invalid transaction state for " + "prepare [state=" + tx.state() + ", tx=" + this + ']')); return; } boolean set = cctx.tm().setTxTopologyHint(tx.topologyVersionSnapshot()); try { prepare(tx.readEntries(), tx.writeEntries(), remap, topLocked); markInitialized(); } finally { if (set) cctx.tm().setTxTopologyHint(null); } }
/** * @param cctx Context. * @param tx Transaction. */ protected GridNearOptimisticTxPrepareFutureAdapter(GridCacheSharedContext cctx, GridNearTxLocal tx) { super(cctx, tx); assert tx.optimistic() : tx; if (tx.timeout() > 0) { // Init keyLockFut to make sure it is created when {@link #onNearTxLocalTimeout} is called. for (IgniteTxEntry e : tx.writeEntries()) { if (e.context().isNear() || e.context().isLocal()) { keyLockFut = new KeyLockFuture(); break; } } if (tx.serializable() && keyLockFut == null) { for (IgniteTxEntry e : tx.readEntries()) { if (e.context().isNear() || e.context().isLocal()) { keyLockFut = new KeyLockFuture(); break; } } } if (keyLockFut != null) add((IgniteInternalFuture)keyLockFut); } }
/** * Initializes future. * * @param remap Remap flag. */ @Override protected void prepare0(boolean remap, boolean topLocked) { boolean txStateCheck = remap ? tx.state() == PREPARING : tx.state(PREPARING); if (!txStateCheck) { if (tx.isRollbackOnly() || tx.setRollbackOnly()) { if (tx.timedOut()) onDone(null, tx.timeoutException()); else onDone(null, tx.rollbackException()); } else onDone(null, new IgniteCheckedException("Invalid transaction state for " + "prepare [state=" + tx.state() + ", tx=" + this + ']')); return; } boolean set = cctx.tm().setTxTopologyHint(tx.topologyVersionSnapshot()); try { prepare(tx.readEntries(), tx.writeEntries(), remap, topLocked); markInitialized(); } finally { if (set) cctx.tm().setTxTopologyHint(null); } }