Search in sources :

Example 1 with StoreExecutor

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);
}
Also used : InMemoryStoreExecutor(org.finos.legend.engine.plan.execution.stores.inMemory.plugin.InMemoryStoreExecutor) FakeServiceStoreExecutorBuilder(org.finos.legend.engine.plan.execution.stores.relational.plugin.FakeServiceStoreExecutorBuilder) PlanExecutor(org.finos.legend.engine.plan.execution.PlanExecutor) InMemoryStoreExecutor(org.finos.legend.engine.plan.execution.stores.inMemory.plugin.InMemoryStoreExecutor) StoreExecutor(org.finos.legend.engine.plan.execution.stores.StoreExecutor) FakeRelationalStoreExecutorBuilder(org.finos.legend.engine.plan.execution.stores.relational.plugin.FakeRelationalStoreExecutorBuilder) Test(org.junit.Test)

Example 2 with StoreExecutor

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);
}
Also used : InMemoryStoreExecutor(org.finos.legend.engine.plan.execution.stores.inMemory.plugin.InMemoryStoreExecutor) StoreExecutor(org.finos.legend.engine.plan.execution.stores.StoreExecutor) PlanExecutor(org.finos.legend.engine.plan.execution.PlanExecutor) InMemoryStoreExecutor(org.finos.legend.engine.plan.execution.stores.inMemory.plugin.InMemoryStoreExecutor) FakeServiceStoreExecutorBuilder(org.finos.legend.engine.plan.execution.stores.relational.plugin.FakeServiceStoreExecutorBuilder) PlanExecutor(org.finos.legend.engine.plan.execution.PlanExecutor) InMemoryStoreExecutor(org.finos.legend.engine.plan.execution.stores.inMemory.plugin.InMemoryStoreExecutor) StoreExecutor(org.finos.legend.engine.plan.execution.stores.StoreExecutor) StoreExecutorConfiguration(org.finos.legend.engine.plan.execution.stores.StoreExecutorConfiguration) FakeRelationalStoreExecutorBuilder(org.finos.legend.engine.plan.execution.stores.relational.plugin.FakeRelationalStoreExecutorBuilder) Test(org.junit.Test)

Example 3 with StoreExecutor

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);
}
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

StoreExecutor (org.finos.legend.engine.plan.execution.stores.StoreExecutor)3 PlanExecutor (org.finos.legend.engine.plan.execution.PlanExecutor)2 StoreExecutorConfiguration (org.finos.legend.engine.plan.execution.stores.StoreExecutorConfiguration)2 InMemoryStoreExecutor (org.finos.legend.engine.plan.execution.stores.inMemory.plugin.InMemoryStoreExecutor)2 FakeRelationalStoreExecutorBuilder (org.finos.legend.engine.plan.execution.stores.relational.plugin.FakeRelationalStoreExecutorBuilder)2 FakeServiceStoreExecutorBuilder (org.finos.legend.engine.plan.execution.stores.relational.plugin.FakeServiceStoreExecutorBuilder)2 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 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