use of org.finos.legend.engine.plan.execution.stores.StoreExecutor in project legend-engine by finos.
the class TestPlanExecutor method testPlanExecutorConstructionWithNoConfig.
@Test
public void testPlanExecutorConstructionWithNoConfig() {
// assert that we construct a plan executor with all known store executors even when no configuration is supplied
PlanExecutor planExecutor = PlanExecutor.newPlanExecutorWithConfigurations();
ImmutableList<StoreExecutor> extraExecutors = planExecutor.getExtraExecutors();
StoreExecutor relationalExecutor = extraExecutors.detect(storeExecutor -> storeExecutor instanceof FakeRelationalStoreExecutorBuilder.Executor);
assertNotNull("failed to locate relational executor", relationalExecutor);
StoreExecutor serviceStoreExecutor = extraExecutors.detect(storeExecutor -> storeExecutor instanceof FakeServiceStoreExecutorBuilder.Executor);
assertNotNull("failed to locate service store executor", serviceStoreExecutor);
StoreExecutor inmemoryExecutor = extraExecutors.detect(storeExecutor -> storeExecutor instanceof InMemoryStoreExecutor);
assertNotNull("failed to locate inmemory executor", inmemoryExecutor);
}
use of org.finos.legend.engine.plan.execution.stores.StoreExecutor in project legend-engine by finos.
the class TestPlanExecutor method testPlanExecutorConstructionWithConfig.
@Test
public void testPlanExecutorConstructionWithConfig() {
// assert that we construct a plan executor with the proper configs
PlanExecutor planExecutor = PlanExecutor.newPlanExecutorWithConfigurations(new FakeRelationalStoreExecutorBuilder.Configuration(), new FakeServiceStoreExecutorBuilder.Configuration());
ImmutableList<StoreExecutor> extraExecutors = planExecutor.getExtraExecutors();
StoreExecutor relationalExecutor = extraExecutors.detect(storeExecutor -> storeExecutor instanceof FakeRelationalStoreExecutorBuilder.Executor);
assertNotNull("failed to locate relational executor", relationalExecutor);
StoreExecutorConfiguration relationalConfiguration = ((FakeRelationalStoreExecutorBuilder.Executor) relationalExecutor).getConfiguration();
assertNotNull("builder not invoked with config", relationalConfiguration);
StoreExecutor serviceStoreExecutor = extraExecutors.detect(storeExecutor -> storeExecutor instanceof FakeServiceStoreExecutorBuilder.Executor);
assertNotNull("failed to locate service store executor", serviceStoreExecutor);
StoreExecutorConfiguration serviceStoreConfiguration = ((FakeServiceStoreExecutorBuilder.Executor) serviceStoreExecutor).getConfiguration();
assertNotNull("builder not invoked with config", serviceStoreConfiguration);
StoreExecutor inmemoryExecutor = extraExecutors.detect(storeExecutor -> storeExecutor instanceof InMemoryStoreExecutor);
assertNotNull("failed to locate inmemory executor", inmemoryExecutor);
}
use of org.finos.legend.engine.plan.execution.stores.StoreExecutor in project legend-engine by finos.
the class PlanExecutor method buildStoreExecutor.
private static Optional<StoreExecutor> buildStoreExecutor(StoreType storeType, ImmutableList<StoreExecutorConfiguration> configurations, ImmutableList<StoreExecutorBuilder> builders) {
if (builders.size() == 0) {
return Optional.empty();
}
if (builders.size() > 1) {
List<String> builderClasses = builders.stream().map(builder -> builder.getClass().getCanonicalName()).collect(Collectors.toList());
String message = String.format("Found more than one builder for store type %s. Builders=%s", storeType, builderClasses);
throw new RuntimeException(message);
}
if (configurations.size() > 1) {
List<String> configurationClasses = configurations.stream().map(config -> config.getClass().getCanonicalName()).collect(Collectors.toList());
String message = String.format("Found more than one configuration for store type %s. Configuration object types=%s", storeType, configurationClasses.size());
throw new RuntimeException(message);
}
StoreExecutorBuilder builder = builders.get(0);
StoreExecutorConfiguration configuration = configurations.size() == 1 ? configurations.get(0) : null;
StoreExecutor storeExecutor = configuration == null ? builder.build() : builder.build(configuration);
return Optional.of(storeExecutor);
}
Aggregations