Пример:
Сотрудник загружается в раздел кэш. Распределенные соединения включены), которые объединяют сотрудников с компанией , используя контекст CACHE -сотрудников (то есть, отправляя запрос из вычислительной задачи с использованием ссылки на кэш сотрудника), воспламенено ошибку, говоря:
table 'Company' не обнаружена
. Таблица успешно загружена в свой собственный кэш, Ignite не может распознать его во время запроса.
Код: Выделить всё
private @NotNull CacheConfiguration getCacheConfiguration(EntitySpec entitySpec, String cacheName,
Class entityClass, Object compositeClassInstance, Field primaryKeyField, String pojoTableName) {
CacheConfiguration cacheCfg = new CacheConfiguration(cacheName);
cacheCfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
if (replicateCaches.contains(cacheName)) {
cacheCfg.setCacheMode(CacheMode.REPLICATED);
} else {
cacheCfg.setCacheMode(CacheMode.PARTITIONED);
}
// Initially we disable write-through and then re-enable it after data loading
// has completed
cacheCfg.setWriteThrough(false);
cacheCfg.setReadThrough(false);
cacheCfg.setSqlSchema(schemaName);
cacheCfg.setQueryParallelism(queryParallelism);
// cacheCfg.setAffinity(new RendezvousAffinityFunction(false,
// CACHE_PARTITIONS));
cacheCfg.setOnheapCacheEnabled(enableOnHeapCache);
cacheCfg.setEventsDisabled(false);
cacheCfg.setStatisticsEnabled(true);
cacheCfg.setPartitionLossPolicy(PartitionLossPolicy.IGNORE);
if (enableOnHeapCache) {
log.warn("On-heap caching enabled for {}", entitySpec.getName());
} else {
log.info("Off-heap cache enabled for {}", entitySpec.getName());
}
if (cacheBackups > 0) {
cacheCfg.setBackups(cacheBackups);
cacheCfg.setReadFromBackup(true);
cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_ASYNC);
log.info("Set cache backups to {}", cacheBackups);
} else {
log.info("Cache backups disabled");
}
// Configure JDBC POJO store factory
CacheJdbcPojoStoreFactory jdbcPojoStoreFactory = jdbcPojoStoreConnectionFactoryProducer
.create();
jdbcPojoStoreFactory.setTypes(createJdbcType(entityClass, cacheName, schemaName, entitySpec.getName(),
Objects.isNull(compositeClassInstance) ? primaryKeyField.getName() : null,
Objects.isNull(compositeClassInstance) ? primaryKeyField.getType() : compositeClassInstance.getClass(),
Objects.isNull(compositeClassInstance) ? null : compositeClassInstance.getClass()));
cacheCfg.setCacheStoreFactory(jdbcPojoStoreFactory);
cacheCfg.setIndexedTypes(
Objects.isNull(compositeClassInstance) ? primaryKeyField.getType() : compositeClassInstance.getClass(),
entityClass);
// Set Query Entity
cacheCfg.setQueryEntities(Collections.singletonList(createQueryEntity(entityClass,
Objects.isNull(compositeClassInstance) ? primaryKeyField.getName() : null,
Objects.isNull(compositeClassInstance) ? primaryKeyField.getType() : compositeClassInstance.getClass(),
pojoTableName, Objects.isNull(compositeClassInstance) ? null : compositeClassInstance.getClass())));
return cacheCfg;
}
< /code>
Теперь, как я запускаю запросы < /p>
QueryCursor[*]> getQueryCursor(String sql, IgniteCache cache) {
SqlFieldsQuery query = new SqlFieldsQuery(sql);
query.setDistributedJoins(true);
query.setLazy(true);
query.setTimeout(0, TimeUnit.MILLISECONDS);
QueryCursor
Подробнее здесь: [url]https://stackoverflow.com/questions/79719019/in-apache-ignite-the-replication-mode-and-partition-mode-does-not-work-all-toget[/url]