Search in sources :

Example 1 with TemplateConfigValidator

use of com.yahoo.elide.datastores.aggregation.validator.TemplateConfigValidator 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]));
}
Also used : JpaDataStore(com.yahoo.elide.datastores.jpa.JpaDataStore) TemplateConfigValidator(com.yahoo.elide.datastores.aggregation.validator.TemplateConfigValidator) ConfigDataStore(com.yahoo.elide.modelconfig.store.ConfigDataStore) AggregationDataStore(com.yahoo.elide.datastores.aggregation.AggregationDataStore) DataStore(com.yahoo.elide.core.datastore.DataStore) MetaDataStore(com.yahoo.elide.datastores.aggregation.metadata.MetaDataStore) JpaDataStore(com.yahoo.elide.datastores.jpa.JpaDataStore) ConfigDataStore(com.yahoo.elide.modelconfig.store.ConfigDataStore) ArrayList(java.util.ArrayList) NonJtaTransaction(com.yahoo.elide.datastores.jpa.transaction.NonJtaTransaction) MultiplexManager(com.yahoo.elide.datastores.multiplex.MultiplexManager)

Example 2 with TemplateConfigValidator

use of com.yahoo.elide.datastores.aggregation.validator.TemplateConfigValidator 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;
}
Also used : JpaDataStore(com.yahoo.elide.datastores.jpa.JpaDataStore) TemplateConfigValidator(com.yahoo.elide.datastores.aggregation.validator.TemplateConfigValidator) ConfigDataStore(com.yahoo.elide.modelconfig.store.ConfigDataStore) AggregationDataStore(com.yahoo.elide.datastores.aggregation.AggregationDataStore) DataStore(com.yahoo.elide.core.datastore.DataStore) MetaDataStore(com.yahoo.elide.datastores.aggregation.metadata.MetaDataStore) JpaDataStore(com.yahoo.elide.datastores.jpa.JpaDataStore) ConfigDataStore(com.yahoo.elide.modelconfig.store.ConfigDataStore) ArrayList(java.util.ArrayList) AggregationDataStore(com.yahoo.elide.datastores.aggregation.AggregationDataStore) NonJtaTransaction(com.yahoo.elide.datastores.jpa.transaction.NonJtaTransaction) MultiplexManager(com.yahoo.elide.datastores.multiplex.MultiplexManager) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) Scope(org.springframework.context.annotation.Scope) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

DataStore (com.yahoo.elide.core.datastore.DataStore)2 AggregationDataStore (com.yahoo.elide.datastores.aggregation.AggregationDataStore)2 MetaDataStore (com.yahoo.elide.datastores.aggregation.metadata.MetaDataStore)2 TemplateConfigValidator (com.yahoo.elide.datastores.aggregation.validator.TemplateConfigValidator)2 JpaDataStore (com.yahoo.elide.datastores.jpa.JpaDataStore)2 NonJtaTransaction (com.yahoo.elide.datastores.jpa.transaction.NonJtaTransaction)2 MultiplexManager (com.yahoo.elide.datastores.multiplex.MultiplexManager)2 ConfigDataStore (com.yahoo.elide.modelconfig.store.ConfigDataStore)2 ArrayList (java.util.ArrayList)2 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 RefreshScope (org.springframework.cloud.context.config.annotation.RefreshScope)1 Bean (org.springframework.context.annotation.Bean)1 Scope (org.springframework.context.annotation.Scope)1