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)));
}
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;
}
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);
}
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();
}
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");
}
Aggregations