/** {@inheritDoc} */ @Override public final IgniteInternalFuture<T> apply(T t, Exception e) { boolean rollback = true; try { if (e != null) throw new GridClosureException(e); IgniteInternalFuture<T> fut = postMiss(t); rollback = false; return fut; } catch (IgniteCheckedException ex) { throw new GridClosureException(ex); } finally { if (rollback) setRollbackOnly(); } }
/** * @param entries Entries to lock or {@code null} if use default {@link IgniteInternalTx#optimisticLockEntries()}. * @throws IgniteCheckedException If prepare step failed. */ public void userPrepare(@Nullable Collection<IgniteTxEntry> entries) throws IgniteCheckedException { if (state() != PREPARING) { if (remainingTime() == -1) throw new IgniteTxTimeoutCheckedException("Transaction timed out: " + this); TransactionState state = state(); setRollbackOnly(); throw new IgniteCheckedException("Invalid transaction state for prepare [state=" + state + ", tx=" + this + ']'); } checkValid(); try { cctx.tm().prepareTx(this, entries); calculatePartitionUpdateCounters(); } catch (IgniteCheckedException e) { throw e; } catch (Throwable e) { setRollbackOnly(); if (e instanceof Error) throw e; throw new IgniteCheckedException("Transaction validation produced a runtime exception: " + this, e); } }
/** {@inheritDoc} */ @Override public final IgniteInternalFuture<T> apply(Boolean locked, @Nullable Exception e) { boolean rollback = true; try { if (e != null) throw new GridClosureException(e); if (!locked) throw new GridClosureException(new IgniteTxTimeoutCheckedException("Failed to acquire lock " + "within provided timeout for transaction [timeout=" + timeout() + ", tx=" + CU.txString(IgniteTxLocalAdapter.this) + ']')); IgniteInternalFuture<T> fut = postLock(); rollback = false; return fut; } catch (IgniteCheckedException ex) { throw new GridClosureException(ex); } finally { if (rollback) setRollbackOnly(); } }
/** {@inheritDoc} */ @Override public void userRollback(boolean clearThreadMap) throws IgniteCheckedException { TransactionState state = state(); if (state != ROLLING_BACK && state != ROLLED_BACK) { setRollbackOnly(); throw new IgniteCheckedException("Invalid transaction state for rollback [state=" + state + ", tx=" + this + ']'); } if (near()) { // Must evict near entries before rolling back from // transaction manager, so they will be removed from cache. for (IgniteTxEntry e : allEntries()) evictNearEntry(e, false); } if (DONE_FLAG_UPD.compareAndSet(this, 0, 1)) { cctx.tm().rollbackTx(this, clearThreadMap, skipCompletedVersions()); cctx.mvccCaching().onTxFinished(this, false); if (!internal()) { Collection<CacheStoreManager> stores = txState.stores(cctx); if (stores != null && !stores.isEmpty()) { assert isWriteToStoreFromDhtValid(stores) : "isWriteToStoreFromDht can't be different within one transaction"; boolean isWriteToStoreFromDht = F.first(stores).isWriteToStoreFromDht(); if (!stores.isEmpty() && (near() || isWriteToStoreFromDht)) sessionEnd(stores, false); } } } }
throw new IgniteTxTimeoutCheckedException("Transaction timed out: " + this); setRollbackOnly();
/** {@inheritDoc} */ @Override public final IgniteInternalFuture<T> apply(T t, Exception e) { boolean rollback = true; try { if (e != null) throw new GridClosureException(e); IgniteInternalFuture<T> fut = postMiss(t); rollback = false; return fut; } catch (IgniteCheckedException ex) { throw new GridClosureException(ex); } finally { if (rollback) setRollbackOnly(); } }
/** * @param entries Entries to lock or {@code null} if use default {@link IgniteInternalTx#optimisticLockEntries()}. * @throws IgniteCheckedException If prepare step failed. */ @SuppressWarnings({"CatchGenericClass"}) public void userPrepare(@Nullable Collection<IgniteTxEntry> entries) throws IgniteCheckedException { if (state() != PREPARING) { if (remainingTime() == -1) throw new IgniteTxTimeoutCheckedException("Transaction timed out: " + this); TransactionState state = state(); setRollbackOnly(); throw new IgniteCheckedException("Invalid transaction state for prepare [state=" + state + ", tx=" + this + ']'); } checkValid(); try { cctx.tm().prepareTx(this, entries); calculatePartitionUpdateCounters(); } catch (IgniteCheckedException e) { throw e; } catch (Throwable e) { setRollbackOnly(); if (e instanceof Error) throw e; throw new IgniteCheckedException("Transaction validation produced a runtime exception: " + this, e); } }
/** {@inheritDoc} */ @Override public final IgniteInternalFuture<T> apply(Boolean locked, @Nullable Exception e) { boolean rollback = true; try { if (e != null) throw new GridClosureException(e); if (!locked) throw new GridClosureException(new IgniteTxTimeoutCheckedException("Failed to acquire lock " + "within provided timeout for transaction [timeout=" + timeout() + ", tx=" + CU.txString(IgniteTxLocalAdapter.this) + ']')); IgniteInternalFuture<T> fut = postLock(); rollback = false; return fut; } catch (IgniteCheckedException ex) { throw new GridClosureException(ex); } finally { if (rollback) setRollbackOnly(); } }
/** {@inheritDoc} */ @Override public void userRollback(boolean clearThreadMap) throws IgniteCheckedException { TransactionState state = state(); if (state != ROLLING_BACK && state != ROLLED_BACK) { setRollbackOnly(); throw new IgniteCheckedException("Invalid transaction state for rollback [state=" + state + ", tx=" + this + ']'); } if (near()) { // Must evict near entries before rolling back from // transaction manager, so they will be removed from cache. for (IgniteTxEntry e : allEntries()) evictNearEntry(e, false); } if (DONE_FLAG_UPD.compareAndSet(this, 0, 1)) { cctx.tm().rollbackTx(this, clearThreadMap, forceSkipCompletedVers); cctx.mvccCaching().onTxFinished(this, false); if (!internal()) { Collection<CacheStoreManager> stores = txState.stores(cctx); if (stores != null && !stores.isEmpty()) { assert isWriteToStoreFromDhtValid(stores) : "isWriteToStoreFromDht can't be different within one transaction"; boolean isWriteToStoreFromDht = F.first(stores).isWriteToStoreFromDht(); if (!stores.isEmpty() && (near() || isWriteToStoreFromDht)) sessionEnd(stores, false); } } } }
throw new IgniteTxTimeoutCheckedException("Transaction timed out: " + this); setRollbackOnly();