use of com.yahoo.elide.datastores.multiplex.MultiplexManager in project elide by yahoo.
the class AggregationDataStoreTestHarness method getDataStore.
@Override
public DataStore getDataStore() {
AggregationDataStore.AggregationDataStoreBuilder aggregationDataStoreBuilder = AggregationDataStore.builder();
ClassScanner scanner = DefaultClassScanner.getInstance();
MetaDataStore metaDataStore;
if (validator != null) {
metaDataStore = new MetaDataStore(scanner, validator.getElideTableConfig().getTables(), validator.getElideNamespaceConfig().getNamespaceconfigs(), true);
aggregationDataStoreBuilder.dynamicCompiledClasses(metaDataStore.getDynamicTypes());
} else {
metaDataStore = new MetaDataStore(scanner, true);
}
AggregationDataStore aggregationDataStore = aggregationDataStoreBuilder.queryEngine(new SQLQueryEngine(metaDataStore, (name) -> connectionDetailsMap.getOrDefault(name, defaultConnectionDetails), new HashSet<>(Arrays.asList(new AggregateBeforeJoinOptimizer(metaDataStore))), new DefaultQueryPlanMerger(metaDataStore), new DefaultQueryValidator(metaDataStore.getMetadataDictionary()))).queryLogger(new Slf4jQueryLogger()).build();
Consumer<EntityManager> txCancel = em -> em.unwrap(Session.class).cancelQuery();
DataStore jpaStore = new JpaDataStore(() -> entityManagerFactory.createEntityManager(), em -> new NonJtaTransaction(em, txCancel));
return new MultiplexManager(jpaStore, metaDataStore, aggregationDataStore);
}
use of com.yahoo.elide.datastores.multiplex.MultiplexManager in project elide by yahoo.
the class ElideStandaloneSettings method getDataStore.
/**
* Gets the DataStore for elide.
* @param metaDataStore MetaDataStore object.
* @param aggregationDataStore AggregationDataStore object.
* @param entityManagerFactory EntityManagerFactory object.
* @return DataStore object initialized.
*/
default DataStore getDataStore(MetaDataStore metaDataStore, AggregationDataStore aggregationDataStore, EntityManagerFactory entityManagerFactory) {
List<DataStore> stores = new ArrayList<>();
DataStore jpaDataStore = new JpaDataStore(() -> entityManagerFactory.createEntityManager(), em -> new NonJtaTransaction(em, TXCANCEL, DEFAULT_LOGGER, true, true));
stores.add(jpaDataStore);
if (getAnalyticProperties().enableDynamicModelConfigAPI()) {
stores.add(new ConfigDataStore(getAnalyticProperties().getDynamicConfigPath(), new TemplateConfigValidator(getClassScanner(), getAnalyticProperties().getDynamicConfigPath())));
}
stores.add(metaDataStore);
stores.add(aggregationDataStore);
return new MultiplexManager(stores.toArray(new DataStore[0]));
}
use of com.yahoo.elide.datastores.multiplex.MultiplexManager in project elide by yahoo.
the class ElideAutoConfiguration method buildDataStore.
/**
* Creates the DataStore Elide. Override to use a different store.
* @param entityManagerFactory The JPA factory which creates entity managers.
* @param scanner Class Scanner
* @param queryEngine QueryEngine instance for aggregation data store.
* @param settings Elide configuration settings.
* @param cache Analytics query cache
* @param querylogger Analytics query logger
* @return An instance of a JPA DataStore.
*/
@Bean
@ConditionalOnMissingBean
@Scope(SCOPE_PROTOTYPE)
public DataStore buildDataStore(EntityManagerFactory entityManagerFactory, ClassScanner scanner, @Autowired(required = false) QueryEngine queryEngine, ElideConfigProperties settings, @Autowired(required = false) Cache cache, @Autowired(required = false) QueryLogger querylogger) {
List<DataStore> stores = new ArrayList<>();
JpaDataStore jpaDataStore = new JpaDataStore(entityManagerFactory::createEntityManager, em -> new NonJtaTransaction(em, txCancel, DEFAULT_LOGGER, settings.getJpaStore().isDelegateToInMemoryStore(), true));
stores.add(jpaDataStore);
if (isAggregationStoreEnabled(settings)) {
AggregationDataStore.AggregationDataStoreBuilder aggregationDataStoreBuilder = AggregationDataStore.builder().queryEngine(queryEngine);
if (isDynamicConfigEnabled(settings)) {
aggregationDataStoreBuilder.dynamicCompiledClasses(queryEngine.getMetaDataStore().getDynamicTypes());
if (settings.getDynamicConfig().isConfigApiEnabled()) {
stores.add(new ConfigDataStore(settings.getDynamicConfig().getPath(), new TemplateConfigValidator(scanner, settings.getDynamicConfig().getPath())));
}
}
aggregationDataStoreBuilder.cache(cache);
aggregationDataStoreBuilder.queryLogger(querylogger);
AggregationDataStore aggregationDataStore = aggregationDataStoreBuilder.build();
stores.add(queryEngine.getMetaDataStore());
stores.add(aggregationDataStore);
// meta data store needs to be put at first to populate meta data models
return new MultiplexManager(stores.toArray(new DataStore[0]));
}
return jpaDataStore;
}
Aggregations