Search in sources :

Example 1 with IgniteEx

use of org.apache.ignite.internal.IgniteEx in project ignite by apache.

the class GridPartitionedCacheJtaLookupClassNameSelfTest method testUncompatibleTmLookup.

/**
     *
     */
@IgniteIgnore(value = "https://issues.apache.org/jira/browse/IGNITE-1094", forceFailure = true)
public void testUncompatibleTmLookup() {
    final IgniteEx ignite = grid(0);
    final CacheConfiguration cacheCfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
    cacheCfg.setName("Foo");
    cacheCfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
    cacheCfg.setTransactionManagerLookupClassName(TestTmLookup2.class.getName());
    GridTestUtils.assertThrows(log, new Callable<Object>() {

        @Override
        public Object call() throws IgniteException {
            ignite.createCache(cacheCfg);
            return null;
        }
    }, IgniteException.class, null);
}
Also used : IgniteException(org.apache.ignite.IgniteException) IgniteEx(org.apache.ignite.internal.IgniteEx) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) IgniteIgnore(org.apache.ignite.testsuites.IgniteIgnore)

Example 2 with IgniteEx

use of org.apache.ignite.internal.IgniteEx in project ignite by apache.

the class MemoryPolicyInitializationTest method testCustomConfigNoDefault.

/**
     * Verifies that expected memory policies are allocated when used provides MemoryPolicyConfiguration
     * with non-default custom MemoryPolicy.
     */
public void testCustomConfigNoDefault() throws Exception {
    prepareCustomNoDefaultConfig();
    IgniteEx ignite = startGrid(0);
    Collection<MemoryPolicy> allMemPlcs = ignite.context().cache().context().database().memoryPolicies();
    assertTrue(allMemPlcs.size() == 3);
    verifyDefaultAndSystemMemoryPolicies(allMemPlcs);
    assertTrue("Custom non-default memory policy is not presented", isMemoryPolicyPresented(allMemPlcs, CUSTOM_NON_DEFAULT_MEM_PLC_NAME));
}
Also used : IgniteEx(org.apache.ignite.internal.IgniteEx)

Example 3 with IgniteEx

use of org.apache.ignite.internal.IgniteEx in project ignite by apache.

the class MemoryPolicyInitializationTest method testCustomConfigOverridesDefaultNameAndDeclaresDefault.

/**
     * User is allowed to define fully custom memory policy and make it default by setting its name to memory config.
     *
     * At the same time user still can create a memory policy with name 'default'
     * which although won't be used as default.
     */
public void testCustomConfigOverridesDefaultNameAndDeclaresDefault() throws Exception {
    prepareCustomConfigWithOverriddenDefaultName();
    IgniteEx ignite = startGrid(0);
    IgniteCacheDatabaseSharedManager dbMgr = ignite.context().cache().context().database();
    Collection<MemoryPolicy> allMemPlcs = dbMgr.memoryPolicies();
    assertTrue(allMemPlcs.size() == 3);
    verifyDefaultAndSystemMemoryPolicies(allMemPlcs);
    MemoryPolicy dfltMemPlc = U.field(dbMgr, "dfltMemPlc");
    assertTrue(dfltMemPlc.config().getMaxSize() == USER_CUSTOM_MEM_PLC_SIZE);
}
Also used : IgniteEx(org.apache.ignite.internal.IgniteEx)

Example 4 with IgniteEx

use of org.apache.ignite.internal.IgniteEx in project ignite by apache.

the class MemoryPolicyInitializationTest method testNoConfigProvided.

/**
     * Verifies that expected memory policies are allocated when used doesn't provide any MemoryPolicyConfiguration.
     */
public void testNoConfigProvided() throws Exception {
    memCfg = null;
    IgniteEx ignite = startGrid(0);
    Collection<MemoryPolicy> allMemPlcs = ignite.context().cache().context().database().memoryPolicies();
    assertTrue(allMemPlcs.size() == 2);
    verifyDefaultAndSystemMemoryPolicies(allMemPlcs);
}
Also used : IgniteEx(org.apache.ignite.internal.IgniteEx)

Example 5 with IgniteEx

use of org.apache.ignite.internal.IgniteEx in project ignite by apache.

the class ClusterStateAbstractTest method testDeactivationWithPendingTransaction.

/**
     * Tests that state doesn't change until all pending transactions are finished.
     *
     * @throws Exception If fails.
     */
public void testDeactivationWithPendingTransaction() throws Exception {
    fail("https://issues.apache.org/jira/browse/IGNITE-4931");
    startGrids(GRID_CNT);
    final CountDownLatch finishedLatch = new CountDownLatch(1);
    final Ignite ignite0 = grid(0);
    final IgniteCache<Object, Object> cache0 = ignite0.cache(CACHE_NAME);
    IgniteInternalFuture<?> fut;
    try (Transaction tx = ignite0.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) {
        cache0.get(1);
        fut = multithreadedAsync(new Runnable() {

            @Override
            public void run() {
                ignite0.active(false);
                finishedLatch.countDown();
            }
        }, 1);
        U.sleep(2000);
        assert !fut.isDone();
        boolean hasActive = false;
        for (int g = 0; g < GRID_CNT; g++) {
            IgniteEx grid = grid(g);
            if (grid.active()) {
                hasActive = true;
                break;
            }
        }
        assertTrue(hasActive);
        cache0.put(1, 2);
        tx.commit();
    }
    fut.get(getTestTimeout(), TimeUnit.MILLISECONDS);
    checkInactive(GRID_CNT);
    ignite0.active(true);
    for (int g = 0; g < GRID_CNT; g++) assertEquals(2, grid(g).cache(CACHE_NAME).get(1));
    finishedLatch.await();
}
Also used : Transaction(org.apache.ignite.transactions.Transaction) IgniteEx(org.apache.ignite.internal.IgniteEx) Ignite(org.apache.ignite.Ignite) CountDownLatch(java.util.concurrent.CountDownLatch)

Aggregations

IgniteEx (org.apache.ignite.internal.IgniteEx)1733 Test (org.junit.Test)1235 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)730 Ignite (org.apache.ignite.Ignite)329 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)274 CountDownLatch (java.util.concurrent.CountDownLatch)232 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)221 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)193 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)193 IgniteCache (org.apache.ignite.IgniteCache)185 List (java.util.List)175 Transaction (org.apache.ignite.transactions.Transaction)165 IgniteInternalFuture (org.apache.ignite.internal.IgniteInternalFuture)157 IgniteException (org.apache.ignite.IgniteException)155 RendezvousAffinityFunction (org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction)135 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)134 ArrayList (java.util.ArrayList)133 Map (java.util.Map)114 TestRecordingCommunicationSpi (org.apache.ignite.internal.TestRecordingCommunicationSpi)112 ClusterNode (org.apache.ignite.cluster.ClusterNode)108