use of org.finos.legend.engine.plan.execution.stores.StoreExecutorBuilder in project legend-engine by finos.
the class TestRelationalStoreExecutorBuilder method assertStoreExecutorBuilders.
private void assertStoreExecutorBuilders(List<StoreExecutorBuilder> builders) {
Assert.assertEquals(1, builders.size());
StoreExecutorBuilder builder = builders.get(0);
Assert.assertTrue(builder instanceof RelationalStoreExecutorBuilder);
RelationalStoreExecutor executor = ((RelationalStoreExecutorBuilder) builder).build();
Assert.assertNotNull(executor);
}
use of org.finos.legend.engine.plan.execution.stores.StoreExecutorBuilder in project legend-engine by finos.
the class TestServiceStoreExecutorBuilder method testPlanExecutorLoader.
@Test
public void testPlanExecutorLoader() {
List<StoreExecutorBuilder> builders = PlanExecutor.loadStoreExecutorBuilders();
Assert.assertEquals(2, builders.size());
StoreExecutorBuilder builder = builders.get(0);
Assert.assertTrue(builder instanceof ServiceStoreExecutorBuilder);
ServiceStoreExecutor executor = ((ServiceStoreExecutorBuilder) builder).build();
Assert.assertNotNull(executor);
}
use of org.finos.legend.engine.plan.execution.stores.StoreExecutorBuilder in project legend-engine by finos.
the class TestServiceStoreExecutorBuilder method testServiceLoader.
@Test
public void testServiceLoader() {
List<StoreExecutorBuilder> builders = new ArrayList<>();
ServiceLoader.load(StoreExecutorBuilder.class).forEach(builders::add);
Assert.assertEquals(2, builders.size());
StoreExecutorBuilder builder = builders.get(0);
Assert.assertTrue(builder instanceof ServiceStoreExecutorBuilder);
ServiceStoreExecutor executor = ((ServiceStoreExecutorBuilder) builder).build();
Assert.assertNotNull(executor);
}
use of org.finos.legend.engine.plan.execution.stores.StoreExecutorBuilder 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