Search in sources :

Example 36 with IgniteEx

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

the class SchemaExchangeSelfTest method checkClientCacheStart.

/**
 * Check client cache start.
 *
 * @throws Exception If failed.
 */
private void checkClientCacheStart(boolean dynamic) throws Exception {
    IgniteEx node1 = startNoCache(1);
    IgniteEx node2;
    if (dynamic) {
        node2 = startClientNoCache(2);
        createSqlCache(node2, cacheConfiguration(KeyClass.class, ValueClass.class));
    } else
        node2 = startClient(2, KeyClass.class, ValueClass.class);
    assertTypes(node1, ValueClass.class);
    assertTypes(node2, ValueClass.class);
    IgniteEx node3 = start(3);
    IgniteEx node4 = start(4, KeyClass.class, ValueClass.class, KeyClass2.class, ValueClass2.class);
    IgniteEx node5 = startNoCache(5);
    IgniteEx node6 = startClient(6);
    IgniteEx node7 = startClient(7, KeyClass.class, ValueClass.class, KeyClass2.class, ValueClass2.class);
    IgniteEx node8 = startClientNoCache(8);
    assertTypes(node1, ValueClass.class);
    assertTypes(node2, ValueClass.class);
    assertTypes(node3, ValueClass.class);
    assertTypes(node4, ValueClass.class);
    assertTypes(node5, ValueClass.class);
    assertTypes(node6, ValueClass.class);
    assertTypes(node7, ValueClass.class);
    assertTypes(node8);
    node8.cache(CACHE_NAME);
    assertTypes(node8, ValueClass.class);
    destroySqlCache(node2);
    node2.getOrCreateCache(cacheConfiguration(KeyClass.class, ValueClass.class, KeyClass2.class, ValueClass2.class));
    assertTypes(node1, ValueClass.class, ValueClass2.class);
    assertTypes(node2, ValueClass.class, ValueClass2.class);
    assertTypes(node3, ValueClass.class, ValueClass2.class);
    assertTypes(node4, ValueClass.class, ValueClass2.class);
    assertTypes(node5, ValueClass.class, ValueClass2.class);
    assertTypes(node6);
    assertTypes(node7);
    assertTypes(node8);
    node6.cache(CACHE_NAME);
    node7.cache(CACHE_NAME);
    node8.cache(CACHE_NAME);
    assertTypes(node6, ValueClass.class, ValueClass2.class);
    assertTypes(node7, ValueClass.class, ValueClass2.class);
    assertTypes(node8, ValueClass.class, ValueClass2.class);
}
Also used : IgniteEx(org.apache.ignite.internal.IgniteEx)

Example 37 with IgniteEx

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

the class SchemaExchangeSelfTest method testServerRestartWithNewTypes.

/**
 * Test client reconnect after server restart accompanied by schema change.
 *
 * @throws Exception If failed.
 */
public void testServerRestartWithNewTypes() throws Exception {
    IgniteEx node1 = start(1, KeyClass.class, ValueClass.class);
    assertTypes(node1, ValueClass.class);
    IgniteEx node2 = startClientNoCache(2);
    assertTypes(node2);
    node2.cache(CACHE_NAME);
    assertTypes(node2, ValueClass.class);
    stopGrid(1);
    assertTrue(GridTestUtils.waitForCondition(new GridAbsPredicate() {

        @Override
        public boolean apply() {
            return grid(2).context().clientDisconnected();
        }
    }, 10_000L));
    IgniteFuture reconnFut = null;
    try {
        node2.cache(CACHE_NAME);
        fail();
    } catch (IgniteClientDisconnectedException e) {
        reconnFut = e.reconnectFuture();
    }
    node1 = start(1, KeyClass.class, ValueClass.class, KeyClass2.class, ValueClass2.class);
    assertTypes(node1, ValueClass.class, ValueClass2.class);
    reconnFut.get();
    assertTypes(node2);
    node2.cache(CACHE_NAME);
    assertTypes(node2, ValueClass.class, ValueClass2.class);
}
Also used : GridAbsPredicate(org.apache.ignite.internal.util.lang.GridAbsPredicate) IgniteEx(org.apache.ignite.internal.IgniteEx) IgniteClientDisconnectedException(org.apache.ignite.IgniteClientDisconnectedException) IgniteFuture(org.apache.ignite.lang.IgniteFuture)

Example 38 with IgniteEx

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

the class SchemaExchangeSelfTest method testDynamicRestarts.

/**
 * Make sure that new metadata can be propagated after destroy.
 *
 * @throws Exception If failed.
 */
public void testDynamicRestarts() throws Exception {
    IgniteEx node1 = start(1, KeyClass.class, ValueClass.class);
    IgniteEx node2 = startNoCache(2);
    IgniteEx node3 = startClientNoCache(3);
    IgniteEx node4 = startClientNoCache(4);
    assertTypes(node1, ValueClass.class);
    assertTypes(node2, ValueClass.class);
    assertTypes(node3);
    node3.cache(CACHE_NAME);
    assertTypes(node3, ValueClass.class);
    // Check restarts from the first node.
    destroySqlCache(node1);
    node1.getOrCreateCache(cacheConfiguration());
    assertTypes(node1);
    assertTypes(node2);
    assertTypes(node3);
    node1.destroyCache(CACHE_NAME);
    node1.getOrCreateCache(cacheConfiguration(KeyClass.class, ValueClass.class, KeyClass2.class, ValueClass2.class));
    assertTypes(node1, ValueClass.class, ValueClass2.class);
    assertTypes(node2, ValueClass.class, ValueClass2.class);
    assertTypes(node3);
    node3.cache(CACHE_NAME);
    assertTypes(node3, ValueClass.class, ValueClass2.class);
    // Check restarts from the second node.
    node2.destroyCache(CACHE_NAME);
    node2.getOrCreateCache(cacheConfiguration());
    assertTypes(node1);
    assertTypes(node2);
    assertTypes(node3);
    node2.destroyCache(CACHE_NAME);
    node2.getOrCreateCache(cacheConfiguration(KeyClass.class, ValueClass.class, KeyClass2.class, ValueClass2.class));
    assertTypes(node1, ValueClass.class, ValueClass2.class);
    assertTypes(node2, ValueClass.class, ValueClass2.class);
    assertTypes(node3);
    node3.cache(CACHE_NAME);
    assertTypes(node3, ValueClass.class, ValueClass2.class);
    assertTypes(node4);
    node4.cache(CACHE_NAME);
    assertTypes(node4, ValueClass.class, ValueClass2.class);
    // Make sure that joining node observes correct state.
    assertTypes(start(5), ValueClass.class, ValueClass2.class);
    assertTypes(startNoCache(6), ValueClass.class, ValueClass2.class);
    assertTypes(startClient(7), ValueClass.class, ValueClass2.class);
    IgniteEx node8 = startClientNoCache(8);
    assertTypes(node8);
    node8.cache(CACHE_NAME);
    assertTypes(node8, ValueClass.class, ValueClass2.class);
}
Also used : IgniteEx(org.apache.ignite.internal.IgniteEx)

Example 39 with IgniteEx

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

the class SchemaExchangeSelfTest method testNodeFilter.

/**
 * Test behavior when node filter is set.
 *
 * @throws Exception If failed.
 */
public void testNodeFilter() throws Exception {
    filterNodeName = getTestIgniteInstanceName(1);
    IgniteEx node1 = start(1, KeyClass.class, ValueClass.class);
    assertTypes(node1, ValueClass.class);
    IgniteEx node2 = start(2, KeyClass.class, ValueClass.class);
    assertTypes(node1, ValueClass.class);
    assertTypes(node2, ValueClass.class);
    IgniteEx node3 = startNoCache(3);
    assertTypes(node1, ValueClass.class);
    assertTypes(node2, ValueClass.class);
    assertTypes(node3);
    node3.cache(CACHE_NAME);
    assertTypes(node3, ValueClass.class);
}
Also used : IgniteEx(org.apache.ignite.internal.IgniteEx)

Example 40 with IgniteEx

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

the class IgniteDbSingleNodeWithIndexingPutGetTest method testGroupIndexes.

/**
 */
public void testGroupIndexes() {
    IgniteEx ig = grid(0);
    IgniteCache<Integer, Abc> cache = ig.cache("abc");
    long cnt = 50_000;
    for (int i = 0; i < cnt; i++) cache.put(i, new Abc(i, i % 10, i % 100));
    assertEquals(1, querySize(cache, "select count(*) from Abc"));
    assertEquals(Long.valueOf(cnt), queryOne(cache, "select count(*) from Abc"));
    assertEquals((int) cnt, querySize(cache, "select count(*) from Abc group by a"));
    assertEquals(Long.valueOf(1L), queryOne(cache, "select count(*) from Abc group by a"));
    assertEquals(Long.valueOf(1L), queryOne(cache, "select count(*) from Abc where a = 1"));
    assertEquals(10, querySize(cache, "select count(*) from Abc group by b"));
    assertEquals(Long.valueOf(cnt / 10), queryOne(cache, "select count(*) from Abc group by b"));
    assertEquals(Long.valueOf(cnt / 10), queryOne(cache, "select count(*) from Abc where b = 1"));
    assertEquals(100, querySize(cache, "select count(*) from Abc group by c"));
    assertEquals(Long.valueOf(cnt / 100), queryOne(cache, "select count(*) from Abc group by c"));
    assertEquals(Long.valueOf(cnt / 100), queryOne(cache, "select count(*) from Abc where c = 1"));
}
Also used : IgniteEx(org.apache.ignite.internal.IgniteEx)

Aggregations

IgniteEx (org.apache.ignite.internal.IgniteEx)396 Ignite (org.apache.ignite.Ignite)85 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)64 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)60 IgniteException (org.apache.ignite.IgniteException)46 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)37 Transaction (org.apache.ignite.transactions.Transaction)34 ArrayList (java.util.ArrayList)31 HashMap (java.util.HashMap)31 CountDownLatch (java.util.concurrent.CountDownLatch)28 NearCacheConfiguration (org.apache.ignite.configuration.NearCacheConfiguration)27 IgniteCache (org.apache.ignite.IgniteCache)25 Map (java.util.Map)24 ClusterNode (org.apache.ignite.cluster.ClusterNode)20 CacheException (javax.cache.CacheException)19 GridCacheDatabaseSharedManager (org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager)19 UUID (java.util.UUID)18 Callable (java.util.concurrent.Callable)17 List (java.util.List)16 Random (java.util.Random)16