use of org.apache.ignite.client.ClientTransaction in project ignite by apache.
the class PerformanceStatisticsThinClientTest method checkTx.
/**
* @param commited {@code True} if check transaction commited.
*/
private void checkTx(boolean commited) throws Exception {
long startTime = U.currentTimeMillis();
cleanPerformanceStatisticsDir();
startCollectStatistics();
try (ClientTransaction tx = thinClient.transactions().txStart()) {
for (int i = 0; i < 10; i++) thinClient.cache(DEFAULT_CACHE_NAME).put(i, i * 2);
if (commited)
tx.commit();
else
tx.rollback();
}
AtomicInteger txs = new AtomicInteger();
stopCollectStatisticsAndRead(new TestHandler() {
@Override
public void transaction(UUID nodeId, GridIntList cacheIds, long txStartTime, long duration, boolean txCommited) {
txs.incrementAndGet();
assertTrue(F.nodeIds(grid(0).cluster().forServers().nodes()).contains(nodeId));
assertEquals(1, cacheIds.size());
assertEquals(CU.cacheId(DEFAULT_CACHE_NAME), cacheIds.get(0));
assertTrue(txStartTime >= startTime);
assertTrue(duration >= 0);
assertEquals(commited, txCommited);
}
});
assertEquals(1, txs.get());
}
use of org.apache.ignite.client.ClientTransaction in project ignite by apache.
the class WrongQueryEntityFieldTypeTest method testPutFromThinClientTx.
/**
*/
@Test
public void testPutFromThinClientTx() throws Exception {
if (mode == ATOMIC)
return;
withThinClient((cli, cache) -> {
for (TransactionConcurrency conc : TransactionConcurrency.values()) {
for (TransactionIsolation iso : TransactionIsolation.values()) {
if (conc == OPTIMISTIC && mode == TRANSACTIONAL_SNAPSHOT)
continue;
assertThrowsWithCause(() -> {
try (ClientTransaction tx = cli.transactions().txStart(conc, iso)) {
cache.put(1, val.get());
tx.commit();
}
}, ClientException.class);
assertNull(cache.withKeepBinary().get(1));
}
}
});
}
Aggregations