Search in sources :

Example 1 with Executor

use of org.apache.flink.table.delegation.Executor in project flink by apache.

the class ExecutionContext method createTableEnvironment.

// ------------------------------------------------------------------------------------------------------------------
// Helper to create Table Environment
// ------------------------------------------------------------------------------------------------------------------
private StreamTableEnvironment createTableEnvironment() {
    // checks the value of RUNTIME_MODE
    EnvironmentSettings settings = EnvironmentSettings.fromConfiguration(flinkConfig);
    if (!settings.isBlinkPlanner()) {
        throw new TableException("The old planner is not supported anymore. Please update to new default planner.");
    }
    TableConfig tableConfig = new TableConfig();
    tableConfig.addConfiguration(flinkConfig);
    StreamExecutionEnvironment streamExecEnv = createStreamExecutionEnvironment();
    final Executor executor = lookupExecutor(settings.getExecutor(), streamExecEnv);
    return createStreamTableEnvironment(streamExecEnv, settings, tableConfig, executor, sessionState.catalogManager, sessionState.moduleManager, sessionState.functionCatalog, classLoader);
}
Also used : EnvironmentSettings(org.apache.flink.table.api.EnvironmentSettings) TableException(org.apache.flink.table.api.TableException) Executor(org.apache.flink.table.delegation.Executor) TableConfig(org.apache.flink.table.api.TableConfig) StreamExecutionEnvironment(org.apache.flink.streaming.api.environment.StreamExecutionEnvironment)

Example 2 with Executor

use of org.apache.flink.table.delegation.Executor in project flink by apache.

the class DefaultExecutorTest method testDefaultBatchProperties.

@Test
public void testDefaultBatchProperties() {
    final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
    final Executor executor = new DefaultExecutor(env);
    final List<Transformation<?>> dummyTransformations = Collections.singletonList(env.fromElements(1, 2, 3).addSink(new DiscardingSink<>()).getTransformation());
    final Configuration configuration = new Configuration();
    configuration.set(ExecutionOptions.RUNTIME_MODE, RuntimeExecutionMode.BATCH);
    final StreamGraph streamGraph = (StreamGraph) executor.createPipeline(dummyTransformations, configuration, "Default Name");
    assertTrue(streamGraph.getExecutionConfig().isObjectReuseEnabled());
    assertEquals(0, streamGraph.getExecutionConfig().getLatencyTrackingInterval());
    assertTrue(streamGraph.isChainingEnabled());
    assertFalse(streamGraph.isAllVerticesInSameSlotSharingGroupByDefault());
    assertFalse(streamGraph.getCheckpointConfig().isCheckpointingEnabled());
    assertEquals(GlobalStreamExchangeMode.ALL_EDGES_BLOCKING, streamGraph.getGlobalStreamExchangeMode());
}
Also used : Transformation(org.apache.flink.api.dag.Transformation) Executor(org.apache.flink.table.delegation.Executor) Configuration(org.apache.flink.configuration.Configuration) StreamGraph(org.apache.flink.streaming.api.graph.StreamGraph) StreamExecutionEnvironment(org.apache.flink.streaming.api.environment.StreamExecutionEnvironment) Test(org.junit.Test)

Example 3 with Executor

use of org.apache.flink.table.delegation.Executor in project zeppelin by apache.

the class Flink113Shims method createPlannerAndExecutor.

@Override
public ImmutablePair<Object, Object> createPlannerAndExecutor(ClassLoader classLoader, Object environmentSettings, Object sEnv, Object tableConfig, Object functionCatalog, Object catalogManager) {
    EnvironmentSettings settings = (EnvironmentSettings) environmentSettings;
    Executor executor = (Executor) lookupExecutor(classLoader, settings, sEnv);
    Map<String, String> plannerProperties = settings.toPlannerProperties();
    Planner planner = ComponentFactoryService.find(PlannerFactory.class, plannerProperties).create(plannerProperties, executor, (TableConfig) tableConfig, (FunctionCatalog) functionCatalog, (CatalogManager) catalogManager);
    return ImmutablePair.of(planner, executor);
}
Also used : EnvironmentSettings(org.apache.flink.table.api.EnvironmentSettings) Executor(org.apache.flink.table.delegation.Executor) Planner(org.apache.flink.table.delegation.Planner) PlannerFactory(org.apache.flink.table.delegation.PlannerFactory) AttributedString(org.jline.utils.AttributedString)

Example 4 with Executor

use of org.apache.flink.table.delegation.Executor in project zeppelin by apache.

the class Flink112Shims method createPlannerAndExecutor.

@Override
public ImmutablePair<Object, Object> createPlannerAndExecutor(ClassLoader classLoader, Object environmentSettings, Object sEnv, Object tableConfig, Object functionCatalog, Object catalogManager) {
    EnvironmentSettings settings = (EnvironmentSettings) environmentSettings;
    Executor executor = (Executor) lookupExecutor(classLoader, settings, sEnv);
    Map<String, String> plannerProperties = settings.toPlannerProperties();
    Planner planner = ComponentFactoryService.find(PlannerFactory.class, plannerProperties).create(plannerProperties, executor, (TableConfig) tableConfig, (FunctionCatalog) functionCatalog, (CatalogManager) catalogManager);
    return ImmutablePair.of(planner, executor);
}
Also used : EnvironmentSettings(org.apache.flink.table.api.EnvironmentSettings) Executor(org.apache.flink.table.delegation.Executor) Planner(org.apache.flink.table.delegation.Planner) PlannerFactory(org.apache.flink.table.delegation.PlannerFactory) AttributedString(org.jline.utils.AttributedString)

Example 5 with Executor

use of org.apache.flink.table.delegation.Executor in project zeppelin by apache.

the class TableEnvFactory method createJavaFlinkStreamTableEnvironment.

public TableEnvironment createJavaFlinkStreamTableEnvironment(EnvironmentSettings settings, ClassLoader classLoader) {
    try {
        ImmutablePair<Object, Object> pair = flinkShims.createPlannerAndExecutor(classLoader, settings, senv.getJavaEnv(), oldPlannerBatchTableConfig, functionCatalog, catalogManager);
        Planner planner = (Planner) pair.left;
        Executor executor = (Executor) pair.right;
        Class clazz = Class.forName("org.apache.flink.table.api.bridge.java.internal.StreamTableEnvironmentImpl");
        try {
            Constructor constructor = clazz.getConstructor(CatalogManager.class, ModuleManager.class, FunctionCatalog.class, TableConfig.class, org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.class, Planner.class, Executor.class, boolean.class);
            return (TableEnvironment) constructor.newInstance(oldPlannerCatalogManager, moduleManager, oldPlannerFunctionCatalog, oldPlannerStreamTableConfig, senv.getJavaEnv(), planner, executor, settings.isStreamingMode());
        } catch (NoSuchMethodException e) {
            // Flink 1.11.1 change the constructor signature, FLINK-18419
            Constructor constructor = clazz.getConstructor(CatalogManager.class, ModuleManager.class, FunctionCatalog.class, TableConfig.class, org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.class, Planner.class, Executor.class, boolean.class, ClassLoader.class);
            return (TableEnvironment) constructor.newInstance(oldPlannerCatalogManager, moduleManager, oldPlannerFunctionCatalog, oldPlannerStreamTableConfig, senv.getJavaEnv(), planner, executor, settings.isStreamingMode(), classLoader);
        }
    } catch (Exception e) {
        throw new TableException("Fail to createJavaFlinkStreamTableEnvironment", e);
    }
}
Also used : FunctionCatalog(org.apache.flink.table.catalog.FunctionCatalog) TableException(org.apache.flink.table.api.TableException) Constructor(java.lang.reflect.Constructor) TableEnvironment(org.apache.flink.table.api.TableEnvironment) ModuleManager(org.apache.flink.table.module.ModuleManager) CatalogManager(org.apache.flink.table.catalog.CatalogManager) TableException(org.apache.flink.table.api.TableException) Executor(org.apache.flink.table.delegation.Executor) TableConfig(org.apache.flink.table.api.TableConfig) Planner(org.apache.flink.table.delegation.Planner) StreamExecutionEnvironment(org.apache.flink.streaming.api.environment.StreamExecutionEnvironment)

Aggregations

Executor (org.apache.flink.table.delegation.Executor)15 Planner (org.apache.flink.table.delegation.Planner)10 StreamExecutionEnvironment (org.apache.flink.streaming.api.environment.StreamExecutionEnvironment)9 TableException (org.apache.flink.table.api.TableException)8 TableConfig (org.apache.flink.table.api.TableConfig)7 CatalogManager (org.apache.flink.table.catalog.CatalogManager)7 FunctionCatalog (org.apache.flink.table.catalog.FunctionCatalog)7 ModuleManager (org.apache.flink.table.module.ModuleManager)7 Constructor (java.lang.reflect.Constructor)5 EnvironmentSettings (org.apache.flink.table.api.EnvironmentSettings)5 TableEnvironment (org.apache.flink.table.api.TableEnvironment)5 ExecutorFactory (org.apache.flink.table.delegation.ExecutorFactory)3 AttributedString (org.jline.utils.AttributedString)3 Method (java.lang.reflect.Method)2 Transformation (org.apache.flink.api.dag.Transformation)2 Configuration (org.apache.flink.configuration.Configuration)2 GenericInMemoryCatalog (org.apache.flink.table.catalog.GenericInMemoryCatalog)2 PlannerFactory (org.apache.flink.table.delegation.PlannerFactory)2 Test (org.junit.Test)2 IOException (java.io.IOException)1