/** {@inheritDoc} */ @Override protected void commitTx() { tx.commit(); } }
@Override public Object call() throws Exception { Thread.currentThread().setName("put-thread"); try (Transaction tx = ignite2.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { for (Map.Entry<Integer, Integer> e : map.entrySet()) cache.put(e.getKey(), e.getValue()); tx.commit(); } return null; } });
@Override public Object call() throws Exception { Thread.currentThread().setName("put-thread"); try (Transaction tx = ignite3.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { for (Map.Entry<Integer, Integer> e : map.entrySet()) cache.put(e.getKey(), e.getValue()); tx.commit(); } return null; } });
@Override public Object call() throws Exception { Thread.currentThread().setName("put-thread"); try (Transaction tx = ignite2.transactions().txStart(OPTIMISTIC, SERIALIZABLE)) { cache.putAll(map); tx.commit(); } return null; } });
@Override public void apply(Integer key, IgniteCache<Object, Object> cache) { Map<Integer, Integer> map = new HashMap<>(); for (int i = 0; i < 50; i++) map.put(i, i); map.put(key, key); Ignite ignite = cache.unwrap(Ignite.class); try (Transaction tx = ignite.transactions().txStart(concurrency, isolation)) { cache.putAll(map); tx.commit(); } } });
@Override public Object call() { try (Transaction tx = ignite(0).transactions().txStart(OPTIMISTIC, isolation)) { info(">>> TX started."); txStarted.countDown(); cache.putAll(txValues); tx.commit(); info(">>> TX committed."); } return null; } });
/** * Run command in transaction. * * @param startNode Ignite node to start transaction and run passed command. * @param cmdInTx Command which should be done in transaction. */ private void runTransactionally(Ignite startNode, Consumer<Ignite> cmdInTx) { try (Transaction tx = startNode.transactions().withLabel(TX_LABEL).txStart(concurrency, isolation)) { cmdInTx.accept(startNode); tx.commit(); } }
@Override public Void call() throws Exception { IgniteCache<Object, Object> cache = node1.cache(DEFAULT_CACHE_NAME); try (Transaction tx = node1.transactions().txStart()) { Integer key = keys.get(idx.getAndIncrement()); cache.getAndPut(key, "new-" + key); tx.commit(); } return null; } }, txCnt, "tx");
@Override public void apply(IgniteCache<Object, Object> cache) { final IgniteTransactions txs = cache.unwrap(Ignite.class).transactions(); Map<Integer, Integer> vals = new LinkedHashMap<>(); for (int i = 0; i < TOTAL; i++) vals.put(i, N); try (Transaction tx = txs.txStart(PESSIMISTIC, REPEATABLE_READ)) { writeAllByMode(cache, vals, writeMode, INTEGER_CODEC); tx.commit(); } } };
@Override public void apply(IgniteCache<Object, Object> cache) { final IgniteTransactions txs = cache.unwrap(Ignite.class).transactions(); Map<Integer, MvccTestAccount> accounts = new HashMap<>(); for (int i = 0; i < ACCOUNTS; i++) accounts.put(i, new MvccTestAccount(ACCOUNT_START_VAL, 1)); try (Transaction tx = txs.txStart(PESSIMISTIC, REPEATABLE_READ)) { cache.putAll(accounts); tx.commit(); } } };
@Override public Void call() throws Exception { IgniteTransactions txs = transactions(); try (Transaction tx = txs.txStart()) { cache.put(key, 2); cache.remove(null); tx.commit(); } return null; } }, NullPointerException.class, null);
@Override public Void call() throws Exception { try (Transaction tx = client.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { cache.put(key1, 1); tx.commit(); } return null; } }, "put1");
@Override public void run() { try (final Transaction tx = ignite.transactions().txStart()) { cache.put(0, 0); l.countDown(); U.awaitQuiet(l2); tx.commit(); } } });
@Override public void apply(Integer key, IgniteCache<Object, Object> cache) { Ignite ignite = cache.unwrap(Ignite.class); try (Transaction tx = ignite.transactions().txStart(concurrency, isolation)) { cache.put(key, key); tx.commit(); } } });
@Override public Void call() throws Exception { try (Transaction tx = ignite.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { cache.put(2, 2); cache.put(3, 2); tx.commit(); } return null; } });
@Override public void run() { U.awaitQuiet(blocked); try (Transaction tx = other.transactions().txStart(PESSIMISTIC, REPEATABLE_READ, 0, recordsCnt)) { for (int i = 0; i < recordsCnt; i++) other.cache(CACHE_NAME).put(i, i); // Will wait until timeout on first tx will unblock put. tx.commit(); } } }, 1, "Second");
@Override public Void call() throws Exception { try (Transaction tx = node.transactions().txStart(OPTIMISTIC, REPEATABLE_READ)) { mvccCache.query(new SqlFieldsQuery("SELECT * FROM Integer")).getAll(); tx.commit(); } return null; } }, CacheException.class, "Only pessimistic transactions are supported when MVCC is enabled");
@Override public Void call() throws Exception { try (Transaction tx = ignite1.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { log.info("Start tx lock."); ignite1.cache(DEFAULT_CACHE_NAME).get(key); log.info("Tx locked key."); tx.commit(); } return null; } }, "lock-thread2");
@Override public Object call() throws Exception { try (QueryCursor<Cache.Entry<Integer, Integer>> ignored = cache.query(qry)) { try (Transaction tx = node.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { for (int i = 0; i < TX_SIZE_THRESHOLD + 1; i++) cache.query(new SqlFieldsQuery("INSERT INTO Integer (_key, _val) values (" + i + ", 1)")).getAll(); tx.commit(); } } return null; } }, CacheException.class, "Failed to run update. Transaction is too large. Consider reducing transaction size");
@Override public Object call() throws Exception { try (Transaction tx = updateNode.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { tx.timeout(TX_TIMEOUT); SqlFieldsQuery qry = new SqlFieldsQuery("INSERT INTO Integer (_key, _val) values (1,1),(1,2),(1,3)"); IgniteCache<Object, Object> cache0 = updateNode.cache(DEFAULT_CACHE_NAME); cache0.query(qry).getAll(); tx.commit(); } return null; } }, CacheException.class, "Duplicate key during INSERT [key=KeyCacheObjectImpl");