Search in sources :

Example 6 with IgniteTxManager

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);
}
Also used : GridAbsPredicate(org.apache.ignite.internal.util.lang.GridAbsPredicate) IgniteInternalTx(org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx) IgniteTxManager(org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager)

Example 7 with IgniteTxManager

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();
    }
}
Also used : IgniteKernal(org.apache.ignite.internal.IgniteKernal) IgniteEx(org.apache.ignite.internal.IgniteEx) ArrayList(java.util.ArrayList) IgniteTxManager(org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager)

Example 8 with IgniteTxManager

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());
    }
}
Also used : IgniteKernal(org.apache.ignite.internal.IgniteKernal) IgniteTxManager(org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager) Map(java.util.Map)

Example 9 with IgniteTxManager

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());
    }
}
Also used : IgniteTxManager(org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager)

Aggregations

IgniteTxManager (org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager)9 IgniteKernal (org.apache.ignite.internal.IgniteKernal)4 ArrayList (java.util.ArrayList)3 Map (java.util.Map)3 IgniteInternalTx (org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx)3 GridAbsPredicate (org.apache.ignite.internal.util.lang.GridAbsPredicate)3 Collection (java.util.Collection)2 HashMap (java.util.HashMap)2 UUID (java.util.UUID)2 Ignite (org.apache.ignite.Ignite)2 IgniteCache (org.apache.ignite.IgniteCache)2 IgniteException (org.apache.ignite.IgniteException)2 ClusterNode (org.apache.ignite.cluster.ClusterNode)2 IgniteEx (org.apache.ignite.internal.IgniteEx)2 GridCacheAdapter (org.apache.ignite.internal.processors.cache.GridCacheAdapter)2 GridNearCacheAdapter (org.apache.ignite.internal.processors.cache.distributed.near.GridNearCacheAdapter)2 IgniteFutureTimeoutException (org.apache.ignite.lang.IgniteFutureTimeoutException)2 IgniteInstanceResource (org.apache.ignite.resources.IgniteInstanceResource)2 IgniteSpiException (org.apache.ignite.spi.IgniteSpiException)2 Transaction (org.apache.ignite.transactions.Transaction)2