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