/** * @param awaitLastFuture If true - method will wait until transaction finish every action started before. * @throws IgniteCheckedException If failed. */ public final void prepare(boolean awaitLastFuture) throws IgniteCheckedException { if (awaitLastFuture) txState().awaitLastFuture(cctx); prepareNearTxLocal().get(); }
/** */ 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()))); } }
final IgniteInternalFuture<?> prepareFut = prepareNearTxLocal();
@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();
.collect(Collectors.toList()); IgniteInternalFuture<?> prepareFut = nearTx.prepareNearTxLocal();
/** * @throws Exception if failed. */ @Test public void testRecoveryCommit() throws Exception { startGridsMultiThreaded(2); client = true; IgniteEx ign = startGrid(2); IgniteCache<Object, Object> cache = ign.getOrCreateCache(basicCcfg()); AtomicInteger keyCntr = new AtomicInteger(); ArrayList<Integer> keys = new ArrayList<>(); ign.cluster().forServers().nodes() .forEach(node -> keys.add(keyForNode(ign.affinity(DEFAULT_CACHE_NAME), keyCntr, node))); GridTestUtils.runAsync(() -> { // run in separate thread to exclude tx from thread-local map Transaction tx = ign.transactions().txStart(PESSIMISTIC, REPEATABLE_READ); for (Integer k : keys) cache.query(new SqlFieldsQuery("insert into Integer(_key, _val) values(?, 42)").setArgs(k)); ((TransactionProxyImpl)tx).tx().prepareNearTxLocal().get(); return null; }).get(); // drop near stopGrid(2, true); IgniteEx srvNode = grid(0); assertConditionEventually( () -> srvNode.cache(DEFAULT_CACHE_NAME).query(new SqlFieldsQuery("select * from Integer")).getAll().size() == 2 ); assertPartitionCountersAreConsistent(keys, G.allGrids()); }
/** * @param awaitLastFuture If true - method will wait until transaction finish every action started before. * @throws IgniteCheckedException If failed. */ public final void prepare(boolean awaitLastFuture) throws IgniteCheckedException { if (awaitLastFuture) txState().awaitLastFuture(cctx); prepareNearTxLocal().get(); }
final IgniteInternalFuture<?> prepareFut = prepareNearTxLocal();