Search in sources :

Example 1 with StoreExecutorBuilder

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);
}
Also used : RelationalStoreExecutorBuilder(org.finos.legend.engine.plan.execution.stores.relational.plugin.RelationalStoreExecutorBuilder) RelationalStoreExecutor(org.finos.legend.engine.plan.execution.stores.relational.plugin.RelationalStoreExecutor) RelationalStoreExecutorBuilder(org.finos.legend.engine.plan.execution.stores.relational.plugin.RelationalStoreExecutorBuilder) StoreExecutorBuilder(org.finos.legend.engine.plan.execution.stores.StoreExecutorBuilder)

Example 2 with StoreExecutorBuilder

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);
}
Also used : StoreExecutorBuilder(org.finos.legend.engine.plan.execution.stores.StoreExecutorBuilder) Test(org.junit.Test)

Example 3 with StoreExecutorBuilder

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);
}
Also used : ArrayList(java.util.ArrayList) StoreExecutorBuilder(org.finos.legend.engine.plan.execution.stores.StoreExecutorBuilder) Test(org.junit.Test)

Example 4 with StoreExecutorBuilder

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);
}
Also used : Maps(org.eclipse.collections.impl.factory.Maps) StoreType(org.finos.legend.engine.plan.execution.stores.StoreType) java.util(java.util) CommonProfile(org.pac4j.core.profile.CommonProfile) StreamProviderHolder(org.finos.legend.engine.shared.core.url.StreamProviderHolder) ExecutionState(org.finos.legend.engine.plan.execution.nodes.state.ExecutionState) Lists(org.eclipse.collections.api.factory.Lists) StreamProvider(org.finos.legend.engine.shared.core.url.StreamProvider) MutableList(org.eclipse.collections.api.list.MutableList) StoreExecutor(org.finos.legend.engine.plan.execution.stores.StoreExecutor) InputStreamProvider(org.finos.legend.engine.shared.core.url.InputStreamProvider) ByteArrayInputStream(java.io.ByteArrayInputStream) StoreExecutorConfiguration(org.finos.legend.engine.plan.execution.stores.StoreExecutorConfiguration) ExecutionNodeExecutor(org.finos.legend.engine.plan.execution.nodes.ExecutionNodeExecutor) JavaHelper(org.finos.legend.engine.plan.execution.nodes.helpers.platform.JavaHelper) ConstantResult(org.finos.legend.engine.plan.execution.result.ConstantResult) Result(org.finos.legend.engine.plan.execution.result.Result) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) EngineJavaCompiler(org.finos.legend.engine.shared.javaCompiler.EngineJavaCompiler) SingleExecutionPlan(org.finos.legend.engine.protocol.pure.v1.model.executionPlan.SingleExecutionPlan) IOException(java.io.IOException) Reader(java.io.Reader) Iterate(org.eclipse.collections.impl.utility.Iterate) ImmutableListMultimap(org.eclipse.collections.api.multimap.list.ImmutableListMultimap) Collectors(java.util.stream.Collectors) StandardCharsets(java.nio.charset.StandardCharsets) JavaCompileException(org.finos.legend.engine.shared.javaCompiler.JavaCompileException) ImmutableList(org.eclipse.collections.api.list.ImmutableList) ObjectMapperFactory(org.finos.legend.engine.shared.core.ObjectMapperFactory) ExecutionPlan(org.finos.legend.engine.protocol.pure.v1.model.executionPlan.ExecutionPlan) IterableIterate(org.eclipse.collections.impl.utility.internal.IterableIterate) StoreExecutorBuilder(org.finos.legend.engine.plan.execution.stores.StoreExecutorBuilder) EngineUrlStreamHandlerFactory(org.finos.legend.engine.shared.core.url.EngineUrlStreamHandlerFactory) InputStream(java.io.InputStream) StoreExecutor(org.finos.legend.engine.plan.execution.stores.StoreExecutor) StoreExecutorBuilder(org.finos.legend.engine.plan.execution.stores.StoreExecutorBuilder) StoreExecutorConfiguration(org.finos.legend.engine.plan.execution.stores.StoreExecutorConfiguration)

Aggregations

StoreExecutorBuilder (org.finos.legend.engine.plan.execution.stores.StoreExecutorBuilder)4 Test (org.junit.Test)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Reader (java.io.Reader)1 StandardCharsets (java.nio.charset.StandardCharsets)1 java.util (java.util)1 ArrayList (java.util.ArrayList)1 Collectors (java.util.stream.Collectors)1 Lists (org.eclipse.collections.api.factory.Lists)1 ImmutableList (org.eclipse.collections.api.list.ImmutableList)1 MutableList (org.eclipse.collections.api.list.MutableList)1 ImmutableListMultimap (org.eclipse.collections.api.multimap.list.ImmutableListMultimap)1 Maps (org.eclipse.collections.impl.factory.Maps)1 Iterate (org.eclipse.collections.impl.utility.Iterate)1 IterableIterate (org.eclipse.collections.impl.utility.internal.IterableIterate)1 ExecutionNodeExecutor (org.finos.legend.engine.plan.execution.nodes.ExecutionNodeExecutor)1 JavaHelper (org.finos.legend.engine.plan.execution.nodes.helpers.platform.JavaHelper)1