/** * @return Public API proxy. */ public TransactionProxy proxy() { if (proxy == null) proxy = new TransactionProxyImpl(this, cctx, false); return proxy; }
/** {@inheritDoc} */ @Override public IgniteFuture<Void> commitAsync() throws IgniteException { enter(); try { return (IgniteFuture<Void>)createFuture(cctx.commitTxAsync(tx)); } finally { leave(); } }
/** {@inheritDoc} */ @Nullable @Override public String label() { if (async) save(tx.label()); return tx.label(); }
/** * @param tx Transaction. * @param syncMode Expected write synchronization mode. */ private void checkSyncMode(Transaction tx, CacheWriteSynchronizationMode syncMode) { assertEquals(syncMode, ((TransactionProxyImpl)tx).tx().syncMode()); }
/** {@inheritDoc} */ @Override public void commit() { enter(); try { IgniteInternalFuture<IgniteInternalTx> commitFut = cctx.commitTxAsync(tx); if (async) saveFuture(commitFut); else commitFut.get(); } catch (IgniteCheckedException e) { throw U.convertException(e); } finally { leave(); } }
/** * Enters a call. */ private void enter() { enter(false); }
/** * @param fut Internal future. */ private void saveFuture(IgniteInternalFuture<IgniteInternalTx> fut) { asyncRes = createFuture(fut); }
/** * Enters a call. * * @param resume Flag to indicate that resume operation in progress. */ private void enter(boolean resume) { if (!resume && state() == SUSPENDED) throw new IgniteException("Tx in SUSPENDED state. All operations except resume are prohibited."); if (cctx.deploymentEnabled()) cctx.deploy().onEnter(); try { cctx.kernalContext().gateway().readLock(); } catch (IllegalStateException | IgniteClientDisconnectedException e) { throw e; } catch (RuntimeException | Error e) { cctx.kernalContext().gateway().readUnlock(); throw e; } }
/** */ private void checkScenario(IgniteEx ign, int srvCnt, ImmutableMap<UUID, Set<UUID>> txNodes, Runnable r) throws Exception { try (Transaction userTx = ign.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { r.run(); GridNearTxLocal nearTx = ((TransactionProxyImpl)userTx).tx(); nearTx.prepareNearTxLocal().get(); List<IgniteInternalTx> txs = IntStream.range(0, srvCnt) .mapToObj(i -> txsOnNode(grid(i), nearTx.nearXidVersion())) .flatMap(Collection::stream) .collect(Collectors.toList()); assertFalse(txs.isEmpty()); txs.forEach(tx -> assertEquals(txNodes, repack(tx.transactionNodes()))); } }
/** {@inheritDoc} */ @Override public void commit() { enter(); try { IgniteInternalFuture<IgniteInternalTx> commitFut = cctx.commitTxAsync(tx); if (async) saveFuture(commitFut); else commitFut.get(); } catch (IgniteCheckedException e) { throw U.convertException(e); } finally { leave(); } }
/** * Enters a call. */ private void enter() { enter(false); }
/** * @param fut Internal future. */ private void saveFuture(IgniteInternalFuture<IgniteInternalTx> fut) { asyncRes = createFuture(fut); }
/** * Enters a call. * * @param resume Flag to indicate that resume operation in progress. */ private void enter(boolean resume) { if (!resume && state() == SUSPENDED) throw new IgniteException("Tx in SUSPENDED state. All operations except resume are prohibited."); if (cctx.deploymentEnabled()) cctx.deploy().onEnter(); try { cctx.kernalContext().gateway().readLock(); } catch (IllegalStateException | IgniteClientDisconnectedException e) { throw e; } catch (RuntimeException | Error e) { cctx.kernalContext().gateway().readUnlock(); throw e; } }
@Override public Object call() throws Exception { IgniteCache<Integer, String> cache = txIgniteNode.cache(DEFAULT_CACHE_NAME); assertNotNull(cache); TransactionProxyImpl tx = (TransactionProxyImpl)txIgniteNode.transactions().txStart(); GridNearTxLocal txEx = tx.tx(); assertTrue(txEx.optimistic()); cache.putAll(map); try { txEx.prepareNearTxLocal().get(3, TimeUnit.SECONDS); } catch (IgniteFutureTimeoutCheckedException ignored) { info("Failed to wait for prepare future completion: " + partial); } return null; } }).get();
/** {@inheritDoc} */ @Override public TransactionConcurrency concurrency() { if (async) save(tx.concurrency()); return tx.concurrency(); }