Search in sources :

Example 41 with IgniteEx

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

the class IgniteDbSingleNodeWithIndexingWalRestoreTest method testClasslessBinaryValuesRestored.

/**
 * Test for values without class created with BinaryObjectBuilder.
 */
public void testClasslessBinaryValuesRestored() throws Exception {
    IgniteEx ig = startGrid(0);
    ig.active(true);
    GridCacheDatabaseSharedManager dbMgr = (GridCacheDatabaseSharedManager) ig.context().cache().context().database();
    dbMgr.enableCheckpoints(false).get();
    IgniteCache<Object, Object> cache = ig.cache("indexedCache").withKeepBinary();
    IgniteBinary bin = ig.binary();
    for (int i = 0; i < ENTRIES_COUNT; i++) {
        BinaryObjectBuilder bldr = bin.builder(BINARY_TYPE_NAME);
        bldr.setField(BINARY_TYPE_FIELD_NAME, "Peter" + i);
        cache.put(i, bldr.build());
    }
    stopGrid(0, true);
    ig = startGrid(0);
    ig.active(true);
    cache = ig.cache("indexedCache").withKeepBinary();
    for (int i = 0; i < ENTRIES_COUNT; i++) assertEquals("Peter" + i, (((BinaryObject) cache.get(i)).field(BINARY_TYPE_FIELD_NAME)));
}
Also used : GridCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager) IgniteEx(org.apache.ignite.internal.IgniteEx) BinaryObject(org.apache.ignite.binary.BinaryObject) BinaryObjectBuilder(org.apache.ignite.binary.BinaryObjectBuilder) IgniteBinary(org.apache.ignite.IgniteBinary)

Example 42 with IgniteEx

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

the class IgnitePersistentStoreQueryWithMultipleClassesPerCacheTest method testSimple.

/**
 * @throws Exception If failed.
 */
public void testSimple() throws Exception {
    IgniteEx ig0 = startGrid(0);
    ig0.active(true);
    ig0.cache(CACHE_NAME).put(0, new Person(0));
    ig0.cache(CACHE_NAME).put(1, new Country());
    List<List<?>> all = ig0.cache(CACHE_NAME).query(new SqlFieldsQuery("select depId FROM \"" + CACHE_NAME + "\".Person")).getAll();
    assert all.size() == 1;
}
Also used : IgniteEx(org.apache.ignite.internal.IgniteEx) List(java.util.List) SqlFieldsQuery(org.apache.ignite.cache.query.SqlFieldsQuery)

Example 43 with IgniteEx

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

the class IgnitePersistentStoreSchemaLoadTest method testDynamicSchemaChangesPersistenceWithStaticCache.

/**
 */
@SuppressWarnings("unchecked")
public void testDynamicSchemaChangesPersistenceWithStaticCache() throws Exception {
    IgniteEx node = startGrid(getConfigurationWithStaticCache(getTestIgniteInstanceName(0)));
    node.active(true);
    IgniteCache cache = node.cache(STATIC_CACHE_NAME);
    assertNotNull(cache);
    CountDownLatch cnt = checkpointLatch(node);
    assertEquals(0, indexCnt(node, STATIC_CACHE_NAME));
    makeDynamicSchemaChanges(node, STATIC_CACHE_NAME);
    checkDynamicSchemaChanges(node, STATIC_CACHE_NAME);
    cnt.await();
    stopGrid(0);
    // Restarting with no-cache configuration - otherwise stored configurations
    // will be ignored due to cache names duplication.
    node = startGrid(0);
    node.active(true);
    checkDynamicSchemaChanges(node, STATIC_CACHE_NAME);
}
Also used : IgniteEx(org.apache.ignite.internal.IgniteEx) IgniteCache(org.apache.ignite.IgniteCache) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 44 with IgniteEx

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

the class IgnitePersistentStoreSchemaLoadTest method checkSchemaStateAfterNodeRestart.

/**
 * Perform test with cache created with {@code CREATE TABLE}.
 * @param aliveCluster Whether there should remain an alive node when tested node is restarted.
 * @throws Exception if failed.
 */
private void checkSchemaStateAfterNodeRestart(boolean aliveCluster) throws Exception {
    IgniteEx node = startGrid(0);
    node.active(true);
    if (aliveCluster)
        startGrid(1);
    CountDownLatch cnt = checkpointLatch(node);
    node.context().query().querySqlFields(new SqlFieldsQuery("create table \"Person\" (\"id\" int primary key, \"name\" varchar)"), false);
    assertEquals(0, indexCnt(node, SQL_CACHE_NAME));
    makeDynamicSchemaChanges(node, QueryUtils.DFLT_SCHEMA);
    checkDynamicSchemaChanges(node, SQL_CACHE_NAME);
    cnt.await();
    stopGrid(0);
    node = startGrid(0);
    node.active(true);
    checkDynamicSchemaChanges(node, SQL_CACHE_NAME);
    node.context().query().querySqlFields(new SqlFieldsQuery("drop table \"Person\""), false).getAll();
}
Also used : IgniteEx(org.apache.ignite.internal.IgniteEx) CountDownLatch(java.util.concurrent.CountDownLatch) SqlFieldsQuery(org.apache.ignite.cache.query.SqlFieldsQuery)

Example 45 with IgniteEx

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

the class IgniteSqlNotNullConstraintTest method testDynamicTableCreateNotNullFieldsAllowed.

/**
 */
public void testDynamicTableCreateNotNullFieldsAllowed() throws Exception {
    executeSql("CREATE TABLE test(id INT PRIMARY KEY, field INT NOT NULL)");
    String cacheName = QueryUtils.createTableCacheName("PUBLIC", "TEST");
    IgniteEx client = grid(NODE_CLIENT);
    CacheConfiguration ccfg = client.context().cache().cache(cacheName).configuration();
    QueryEntity qe = (QueryEntity) F.first(ccfg.getQueryEntities());
    assertEquals(Collections.singleton("FIELD"), qe.getNotNullFields());
    checkState("PUBLIC", "TEST", "FIELD");
}
Also used : IgniteEx(org.apache.ignite.internal.IgniteEx) QueryEntity(org.apache.ignite.cache.QueryEntity) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

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