@Override public void applyx(Transaction tx) throws Exception { tx.setRollbackOnly(); } }
/** {@inheritDoc} */ @Override protected void doSetRollbackOnly(DefaultTransactionStatus status) throws TransactionException { IgniteTransactionObject txObj = (IgniteTransactionObject)status.getTransaction(); Transaction tx = txObj.getTransactionHolder().getTransaction(); assert tx != null; if (status.isDebug() && log.isDebugEnabled()) log.debug("Setting Ignite transaction rollback-only: " + tx); tx.setRollbackOnly(); }
/** * JUnit. * * @throws Exception If failed. */ @Test public void testOptimisticTxMissingKeyNoCommit() throws Exception { if (txShouldBeUsed()) { try (Transaction tx = transactions().txStart(OPTIMISTIC, READ_COMMITTED)) { // Remove missing key. assertFalse(jcache().remove(UUID.randomUUID().toString())); tx.setRollbackOnly(); } } }
/** * JUnit. * * @throws Exception If failed. */ @Test public void testOptimisticTxMissingKeyNoCommit() throws Exception { if (txShouldBeUsed()) { try (Transaction tx = transactions().txStart(OPTIMISTIC, READ_COMMITTED)) { // Remove missing key. assertFalse(jcache().remove(UUID.randomUUID().toString())); tx.setRollbackOnly(); } } }
/** * JUnit. * * @throws Exception If failed. */ @Test public void testPessimisticTxMissingKeyNoCommit() throws Exception { if (txShouldBeUsed()) { try (Transaction tx = transactions().txStart(PESSIMISTIC, READ_COMMITTED)) { // Remove missing key. assertFalse(jcache().remove(UUID.randomUUID().toString())); tx.setRollbackOnly(); } } }
/** * JUnit. * * @throws Exception If failed. */ @Test public void testPessimisticTxMissingKeyNoCommit() throws Exception { if (txShouldBeUsed()) { try (Transaction tx = transactions().txStart(PESSIMISTIC, READ_COMMITTED)) { // Remove missing key. assertFalse(jcache().remove(UUID.randomUUID().toString())); tx.setRollbackOnly(); } } }
/** {@inheritDoc} */ @Override public long processInLongOutLong(int type, long val) throws IgniteCheckedException { switch (type) { case OP_PREPARE: ((TransactionProxyImpl)tx(val)).tx().prepare(true); return TRUE; case OP_COMMIT: tx(val).commit(); return txClose(val); case OP_ROLLBACK: tx(val).rollback(); return txClose(val); case OP_CLOSE: return txClose(val); case OP_SET_ROLLBACK_ONLY: return tx(val).setRollbackOnly() ? TRUE : FALSE; case OP_STATE: return tx(val).state().ordinal(); case OP_RESET_METRICS: txs.resetMetrics(); return TRUE; } return super.processInLongOutLong(type, val); }
/** * */ @Test public void testLabelFilledLocalGuarantee() throws Exception { Ignite ignite = startGrid(0); ignite.events().localListen((IgnitePredicate<Event>)e -> { assert e instanceof TransactionStateChangedEvent; TransactionStateChangedEvent evt = (TransactionStateChangedEvent)e; Transaction tx = evt.tx(); if (tx.label() == null) tx.setRollbackOnly(); return true; }, EVT_TX_STARTED); IgniteCache cache = ignite.getOrCreateCache(defaultCacheConfiguration()); try (Transaction tx = ignite.transactions().withLabel("test").txStart()) { cache.put(1, 1); tx.commit(); } try (Transaction tx = ignite.transactions().txStart()) { cache.put(1, 2); tx.commit(); fail("Should fail prior this line."); } catch (CacheException ignored) { // No-op. } }
/** {@inheritDoc} */ @Override protected void doSetRollbackOnly(DefaultTransactionStatus status) throws TransactionException { IgniteTransactionObject txObj = (IgniteTransactionObject)status.getTransaction(); Transaction tx = txObj.getTransactionHolder().getTransaction(); assert tx != null; if (status.isDebug() && log.isDebugEnabled()) log.debug("Setting Ignite transaction rollback-only: " + tx); tx.setRollbackOnly(); }
/** {@inheritDoc} */ @Override public long processInLongOutLong(int type, long val) throws IgniteCheckedException { switch (type) { case OP_PREPARE: ((TransactionProxyImpl)tx(val)).tx().prepare(true); return TRUE; case OP_COMMIT: tx(val).commit(); return txClose(val); case OP_ROLLBACK: tx(val).rollback(); return txClose(val); case OP_CLOSE: return txClose(val); case OP_SET_ROLLBACK_ONLY: return tx(val).setRollbackOnly() ? TRUE : FALSE; case OP_STATE: return tx(val).state().ordinal(); case OP_RESET_METRICS: txs.resetMetrics(); return TRUE; } return super.processInLongOutLong(type, val); }