Search in sources :

Example 16 with QuerySchema

use of org.apache.ignite.internal.processors.query.QuerySchema in project ignite by apache.

the class ClusterCachesInfo method registerReceivedCaches.

/**
 * Register caches received from cluster.
 *
 * @param cachesData Data received from cluster.
 */
private void registerReceivedCaches(CacheNodeCommonDiscoveryData cachesData) {
    Map<DynamicCacheDescriptor, QuerySchemaPatch> patchesToApply = new HashMap<>();
    Collection<DynamicCacheDescriptor> cachesToSave = new HashSet<>();
    boolean hasSchemaPatchConflict = false;
    for (CacheData cacheData : cachesData.caches().values()) {
        CacheGroupDescriptor grpDesc = registeredCacheGrps.get(cacheData.groupId());
        assert grpDesc != null : cacheData.cacheConfiguration().getName();
        CacheConfiguration<?, ?> cfg = cacheData.cacheConfiguration();
        DynamicCacheDescriptor desc = new DynamicCacheDescriptor(ctx, cacheData.cacheConfiguration(), cacheData.cacheType(), grpDesc, false, cacheData.receivedFrom(), cacheData.staticallyConfigured(), cacheData.sql(), cacheData.deploymentId(), new QuerySchema(cacheData.schema().entities()), cacheData.cacheConfigurationEnrichment());
        Collection<QueryEntity> localQueryEntities = getLocalQueryEntities(cfg.getName());
        QuerySchemaPatch schemaPatch = desc.makeSchemaPatch(localQueryEntities);
        if (schemaPatch.hasConflicts()) {
            hasSchemaPatchConflict = true;
            log.warning("Skipping apply patch because conflicts : " + schemaPatch.getConflictsMessage());
        } else if (!schemaPatch.isEmpty())
            patchesToApply.put(desc, schemaPatch);
        else if (!GridFunc.eqNotOrdered(desc.schema().entities(), localQueryEntities))
            // received config is different of local config - need to resave
            cachesToSave.add(desc);
        desc.receivedOnDiscovery(true);
        registeredCaches.put(cacheData.cacheConfiguration().getName(), desc);
        registeredCachesById.put(desc.cacheId(), desc);
        ctx.discovery().setCacheFilter(desc.cacheId(), grpDesc.groupId(), cfg.getName(), cfg.getNearConfiguration() != null);
    }
    updateRegisteredCachesIfNeeded(patchesToApply, cachesToSave, hasSchemaPatchConflict);
}
Also used : QuerySchema(org.apache.ignite.internal.processors.query.QuerySchema) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) QueryEntity(org.apache.ignite.cache.QueryEntity) QuerySchemaPatch(org.apache.ignite.internal.processors.query.QuerySchemaPatch) HashSet(java.util.HashSet)

Example 17 with QuerySchema

use of org.apache.ignite.internal.processors.query.QuerySchema in project ignite by apache.

the class CacheComparatorTest method testDirect.

/**
 * Test if comparator not violates its general contract
 */
@Test
public void testDirect() {
    DynamicCacheDescriptor desc1 = new DynamicCacheDescriptor(null, new CacheConfiguration().setName("1111"), CacheType.DATA_STRUCTURES, null, true, null, true, false, null, new QuerySchema(), null);
    DynamicCacheDescriptor desc2 = new DynamicCacheDescriptor(null, new CacheConfiguration().setName("2222"), CacheType.INTERNAL, null, true, null, true, false, null, new QuerySchema(), null);
    assertEquals(-1, ClusterCachesInfo.CacheComparators.DIRECT.compare(desc1, desc2));
    assertEquals(1, ClusterCachesInfo.CacheComparators.DIRECT.compare(desc2, desc1));
}
Also used : QuerySchema(org.apache.ignite.internal.processors.query.QuerySchema) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) Test(org.junit.Test)

Example 18 with QuerySchema

use of org.apache.ignite.internal.processors.query.QuerySchema in project ignite by apache.

the class IgnitePersistentStoreSchemaLoadTest method colsCnt.

/**
 */
private int colsCnt(IgniteEx node, String cacheName) {
    DynamicCacheDescriptor desc = node.context().cache().cacheDescriptor(cacheName);
    int cnt = 0;
    if (desc != null) {
        QuerySchema schema = desc.schema();
        if (schema != null) {
            for (QueryEntity entity : schema.entities()) cnt += entity.getFields().size();
        }
    }
    return cnt;
}
Also used : QuerySchema(org.apache.ignite.internal.processors.query.QuerySchema) DynamicCacheDescriptor(org.apache.ignite.internal.processors.cache.DynamicCacheDescriptor) QueryEntity(org.apache.ignite.cache.QueryEntity)

Example 19 with QuerySchema

use of org.apache.ignite.internal.processors.query.QuerySchema in project ignite by apache.

the class IgnitePersistentStoreSchemaLoadTest method indexCnt.

/**
 */
private int indexCnt(IgniteEx node, String cacheName) {
    DynamicCacheDescriptor desc = node.context().cache().cacheDescriptor(cacheName);
    int cnt = 0;
    if (desc != null) {
        QuerySchema schema = desc.schema();
        if (schema != null) {
            for (QueryEntity entity : schema.entities()) cnt += entity.getIndexes().size();
        }
    }
    return cnt;
}
Also used : QuerySchema(org.apache.ignite.internal.processors.query.QuerySchema) DynamicCacheDescriptor(org.apache.ignite.internal.processors.cache.DynamicCacheDescriptor) QueryEntity(org.apache.ignite.cache.QueryEntity)

Aggregations

QuerySchema (org.apache.ignite.internal.processors.query.QuerySchema)19 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)10 NearCacheConfiguration (org.apache.ignite.configuration.NearCacheConfiguration)9 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)4 CacheExistsException (org.apache.ignite.cache.CacheExistsException)3 QueryEntity (org.apache.ignite.cache.QueryEntity)3 DynamicCacheDescriptor (org.apache.ignite.internal.processors.cache.DynamicCacheDescriptor)2 QuerySchemaPatch (org.apache.ignite.internal.processors.query.QuerySchemaPatch)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 T2 (org.apache.ignite.internal.util.typedef.T2)1 IgniteUuid (org.apache.ignite.lang.IgniteUuid)1 Test (org.junit.Test)1