use of org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager in project ignite by apache.
the class IgniteCachePrimaryNodeFailureRecoveryAbstractTest method waitPrepared.
/**
* @param ignite Node.
* @throws Exception If failed.
*/
private void waitPrepared(Ignite ignite) throws Exception {
final IgniteTxManager tm = ((IgniteKernal) ignite).context().cache().context().tm();
boolean wait = GridTestUtils.waitForCondition(new GridAbsPredicate() {
@Override
public boolean apply() {
GridDhtTxLocal locTx = null;
for (IgniteInternalTx tx : tm.txs()) {
if (tx instanceof GridDhtTxLocal) {
assertNull("Only one tx is expected.", locTx);
locTx = (GridDhtTxLocal) tx;
}
}
log.info("Wait for tx, state: " + (locTx != null ? locTx.state() : null));
return locTx != null && locTx.state() == PREPARED;
}
}, 5000);
assertTrue("Failed to wait for tx.", wait);
}
use of org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager in project ignite by apache.
the class IgniteCacheMultiTxLockSelfTest method checkExplicitLock.
/**
* @param keys Number of keys.
* @param testClient If {@code true} uses one client node.
* @throws Exception If failed.
*/
public void checkExplicitLock(int keys, boolean testClient) throws Exception {
Collection<Thread> threads = new ArrayList<>();
try {
// Start grid 1.
IgniteEx grid1 = startGrid(1);
assertFalse(grid1.configuration().isClientMode());
threads.add(runCacheOperations(grid1.cachex(CACHE_NAME), keys));
TimeUnit.SECONDS.sleep(3L);
// If test client start on node in client mode.
client = testClient;
// Start grid 2.
IgniteEx grid2 = startGrid(2);
assertEquals((Object) testClient, grid2.configuration().isClientMode());
client = false;
threads.add(runCacheOperations(grid2.cachex(CACHE_NAME), keys));
TimeUnit.SECONDS.sleep(3L);
// Start grid 3.
IgniteEx grid3 = startGrid(3);
assertFalse(grid3.configuration().isClientMode());
if (testClient)
log.info("Started client node: " + grid3.name());
threads.add(runCacheOperations(grid3.cachex(CACHE_NAME), keys));
TimeUnit.SECONDS.sleep(3L);
// Start grid 4.
IgniteEx grid4 = startGrid(4);
assertFalse(grid4.configuration().isClientMode());
threads.add(runCacheOperations(grid4.cachex(CACHE_NAME), keys));
TimeUnit.SECONDS.sleep(3L);
stopThreads(threads);
for (int i = 1; i <= 4; i++) {
IgniteTxManager tm = ((IgniteKernal) grid(i)).internalCache(CACHE_NAME).context().tm();
assertEquals("txMap is not empty:" + i, 0, tm.idMapSize());
}
} finally {
stopAllGrids();
}
}
use of org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager in project ignite by apache.
the class IgniteCacheSystemTransactionsSelfTest method checkTransactionsCommitted.
/**
* @throws Exception If failed.
*/
private void checkTransactionsCommitted() throws Exception {
for (int i = 0; i < gridCount(); i++) {
IgniteKernal kernal = (IgniteKernal) grid(i);
IgniteTxManager tm = kernal.context().cache().context().tm();
Map map = U.field(tm, "threadMap");
assertEquals(0, map.size());
map = U.field(tm, "sysThreadMap");
assertEquals(0, map.size());
map = U.field(tm, "idMap");
assertEquals(0, map.size());
}
}
use of org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager in project ignite by apache.
the class GridCacheAtomicPreloadSelfTest method checkTransactions.
/**
*
*/
private void checkTransactions() {
for (int i = 0; i < 3; i++) {
IgniteTxManager tm = ((IgniteKernal) grid(i)).context().cache().context().tm();
assertEquals("Uncommitted transactions found on node [idx=" + i + ", mapSize=" + tm.idMapSize() + ']', 0, tm.idMapSize());
}
}
Aggregations