use of org.apache.ignite.transactions.Transaction in project ignite by apache.
the class IgniteSqlNotNullConstraintTest method testTxGetAndReplace.
/**
*/
public void testTxGetAndReplace() throws Exception {
executeWithAllTxCaches(new TestClosure() {
@Override
public void run() throws Exception {
GridTestUtils.assertThrows(log, new Callable<Object>() {
@Override
public Object call() throws Exception {
cache.put(key1, okValue);
try (Transaction tx = ignite.transactions().txStart(concurrency, isolation)) {
cache.getAndReplace(key1, badValue);
tx.commit();
}
assertEquals(1, cache.size());
assertEquals(okValue, cache.get(key1));
return null;
}
}, CacheException.class, ERR_MSG);
}
});
}
use of org.apache.ignite.transactions.Transaction in project ignite by apache.
the class IgniteSqlNotNullConstraintTest method testTxReplace.
/**
*/
public void testTxReplace() throws Exception {
executeWithAllTxCaches(new TestClosure() {
@Override
public void run() throws Exception {
GridTestUtils.assertThrows(log, new Callable<Object>() {
@Override
public Object call() throws Exception {
cache.put(1, okValue);
try (Transaction tx = ignite.transactions().txStart(concurrency, isolation)) {
cache.replace(key1, badValue);
tx.commit();
}
assertEquals(1, cache.size());
assertEquals(okValue, cache.get(key1));
return null;
}
}, CacheException.class, ERR_MSG);
}
});
}
use of org.apache.ignite.transactions.Transaction in project ignite by apache.
the class IgniteSqlNotNullConstraintTest method testTxPutAll.
/**
*/
public void testTxPutAll() throws Exception {
executeWithAllTxCaches(new TestClosure() {
@Override
public void run() throws Exception {
GridTestUtils.assertThrows(log, new Callable<Object>() {
@Override
public Object call() throws Exception {
try (Transaction tx = ignite.transactions().txStart(concurrency, isolation)) {
cache.putAll(F.asMap(key1, okValue, key2, badValue));
tx.commit();
}
assertEquals(0, cache.size());
return null;
}
}, CacheException.class, ERR_MSG);
}
});
}
use of org.apache.ignite.transactions.Transaction in project ignite by apache.
the class IgniteSqlNotNullConstraintTest method testTxGetAndPutIfAbsent.
/**
*/
public void testTxGetAndPutIfAbsent() throws Exception {
executeWithAllTxCaches(new TestClosure() {
@Override
public void run() throws Exception {
GridTestUtils.assertThrows(log, new Callable<Object>() {
@Override
public Object call() throws Exception {
try (Transaction tx = ignite.transactions().txStart(concurrency, isolation)) {
cache.getAndPutIfAbsent(key1, badValue);
tx.commit();
}
assertEquals(0, cache.size());
return null;
}
}, CacheException.class, ERR_MSG);
}
});
}
use of org.apache.ignite.transactions.Transaction in project ignite by apache.
the class SpringTransactionManager method doCleanupAfterCompletion.
/**
* {@inheritDoc}
*/
@Override
protected void doCleanupAfterCompletion(Object transaction) {
IgniteTransactionObject txObj = (IgniteTransactionObject) transaction;
// Remove the transaction holder from the thread, if exposed.
if (txObj.isNewTransactionHolder()) {
Transaction tx = txObj.getTransactionHolder().getTransaction();
TransactionSynchronizationManager.unbindResource(this.ignite);
if (log.isDebugEnabled())
log.debug("Releasing Ignite transaction: " + tx);
}
txObj.getTransactionHolder().clear();
}
Aggregations