Search in sources :

Example 1 with ExecutorFactory

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

the class Flink113Shims method lookupExecutor.

private Object lookupExecutor(ClassLoader classLoader, Object settings, Object sEnv) {
    try {
        Map<String, String> executorProperties = ((EnvironmentSettings) settings).toExecutorProperties();
        ExecutorFactory executorFactory = ComponentFactoryService.find(ExecutorFactory.class, executorProperties);
        Method createMethod = executorFactory.getClass().getMethod("create", Map.class, StreamExecutionEnvironment.class);
        return createMethod.invoke(executorFactory, executorProperties, sEnv);
    } catch (Exception e) {
        throw new TableException("Could not instantiate the executor. Make sure a planner module is on the classpath", e);
    }
}
Also used : EnvironmentSettings(org.apache.flink.table.api.EnvironmentSettings) TableException(org.apache.flink.table.api.TableException) ExecutorFactory(org.apache.flink.table.delegation.ExecutorFactory) AttributedString(org.jline.utils.AttributedString) Method(java.lang.reflect.Method) FlinkException(org.apache.flink.util.FlinkException) TableException(org.apache.flink.table.api.TableException) IOException(java.io.IOException)

Example 2 with ExecutorFactory

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

the class Flink114Shims method lookupExecutor.

private Object lookupExecutor(ClassLoader classLoader, Object settings, Object sEnv) {
    try {
        final ExecutorFactory executorFactory = FactoryUtil.discoverFactory(classLoader, ExecutorFactory.class, ((EnvironmentSettings) settings).getExecutor());
        final Method createMethod = executorFactory.getClass().getMethod("create", StreamExecutionEnvironment.class);
        return createMethod.invoke(executorFactory, sEnv);
    } catch (Exception e) {
        throw new TableException("Could not instantiate the executor. Make sure a planner module is on the classpath", e);
    }
}
Also used : TableException(org.apache.flink.table.api.TableException) ExecutorFactory(org.apache.flink.table.delegation.ExecutorFactory) Method(java.lang.reflect.Method) FlinkException(org.apache.flink.util.FlinkException) TableException(org.apache.flink.table.api.TableException) IOException(java.io.IOException)

Example 3 with ExecutorFactory

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

the class Flink112Shims method lookupExecutor.

private Object lookupExecutor(ClassLoader classLoader, Object settings, Object sEnv) {
    try {
        Map<String, String> executorProperties = ((EnvironmentSettings) settings).toExecutorProperties();
        ExecutorFactory executorFactory = ComponentFactoryService.find(ExecutorFactory.class, executorProperties);
        Method createMethod = executorFactory.getClass().getMethod("create", Map.class, StreamExecutionEnvironment.class);
        return (Executor) createMethod.invoke(executorFactory, executorProperties, (StreamExecutionEnvironment) sEnv);
    } catch (Exception e) {
        throw new TableException("Could not instantiate the executor. Make sure a planner module is on the classpath", e);
    }
}
Also used : EnvironmentSettings(org.apache.flink.table.api.EnvironmentSettings) TableException(org.apache.flink.table.api.TableException) Executor(org.apache.flink.table.delegation.Executor) ExecutorFactory(org.apache.flink.table.delegation.ExecutorFactory) StreamExecutionEnvironment(org.apache.flink.streaming.api.environment.StreamExecutionEnvironment) AttributedString(org.jline.utils.AttributedString) Method(java.lang.reflect.Method) FlinkException(org.apache.flink.util.FlinkException) TableException(org.apache.flink.table.api.TableException) IOException(java.io.IOException)

Example 4 with ExecutorFactory

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

the class ExecutionContext method lookupExecutor.

private Executor lookupExecutor(String executorIdentifier, StreamExecutionEnvironment executionEnvironment) {
    try {
        final ExecutorFactory executorFactory = FactoryUtil.discoverFactory(classLoader, ExecutorFactory.class, executorIdentifier);
        final Method createMethod = executorFactory.getClass().getMethod("create", StreamExecutionEnvironment.class);
        return (Executor) createMethod.invoke(executorFactory, executionEnvironment);
    } catch (Exception e) {
        throw new TableException("Could not instantiate the executor. Make sure a planner module is on the classpath", e);
    }
}
Also used : TableException(org.apache.flink.table.api.TableException) Executor(org.apache.flink.table.delegation.Executor) ExecutorFactory(org.apache.flink.table.delegation.ExecutorFactory) Method(java.lang.reflect.Method) TableException(org.apache.flink.table.api.TableException)

Example 5 with ExecutorFactory

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

the class TableEnvironmentImpl method create.

private static TableEnvironmentImpl create(EnvironmentSettings settings, Configuration configuration) {
    // temporary solution until FLINK-15635 is fixed
    final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    // use configuration to init table config
    final TableConfig tableConfig = new TableConfig();
    tableConfig.addConfiguration(configuration);
    final ModuleManager moduleManager = new ModuleManager();
    final CatalogManager catalogManager = CatalogManager.newBuilder().classLoader(classLoader).config(tableConfig.getConfiguration()).defaultCatalog(settings.getBuiltInCatalogName(), new GenericInMemoryCatalog(settings.getBuiltInCatalogName(), settings.getBuiltInDatabaseName())).build();
    final FunctionCatalog functionCatalog = new FunctionCatalog(tableConfig, catalogManager, moduleManager);
    final ExecutorFactory executorFactory = FactoryUtil.discoverFactory(classLoader, ExecutorFactory.class, settings.getExecutor());
    final Executor executor = executorFactory.create(configuration);
    final Planner planner = PlannerFactoryUtil.createPlanner(settings.getPlanner(), executor, tableConfig, moduleManager, catalogManager, functionCatalog);
    return new TableEnvironmentImpl(catalogManager, moduleManager, tableConfig, executor, functionCatalog, planner, settings.isStreamingMode(), classLoader);
}
Also used : FunctionCatalog(org.apache.flink.table.catalog.FunctionCatalog) Executor(org.apache.flink.table.delegation.Executor) ExecutorFactory(org.apache.flink.table.delegation.ExecutorFactory) TableConfig(org.apache.flink.table.api.TableConfig) Planner(org.apache.flink.table.delegation.Planner) ModuleManager(org.apache.flink.table.module.ModuleManager) CatalogManager(org.apache.flink.table.catalog.CatalogManager) GenericInMemoryCatalog(org.apache.flink.table.catalog.GenericInMemoryCatalog)

Aggregations

ExecutorFactory (org.apache.flink.table.delegation.ExecutorFactory)6 Method (java.lang.reflect.Method)4 TableException (org.apache.flink.table.api.TableException)4 IOException (java.io.IOException)3 Executor (org.apache.flink.table.delegation.Executor)3 FlinkException (org.apache.flink.util.FlinkException)3 EnvironmentSettings (org.apache.flink.table.api.EnvironmentSettings)2 AttributedString (org.jline.utils.AttributedString)2 StreamExecutionEnvironment (org.apache.flink.streaming.api.environment.StreamExecutionEnvironment)1 TableConfig (org.apache.flink.table.api.TableConfig)1 CatalogManager (org.apache.flink.table.catalog.CatalogManager)1 FunctionCatalog (org.apache.flink.table.catalog.FunctionCatalog)1 GenericInMemoryCatalog (org.apache.flink.table.catalog.GenericInMemoryCatalog)1 Planner (org.apache.flink.table.delegation.Planner)1 ModuleManager (org.apache.flink.table.module.ModuleManager)1 Test (org.junit.jupiter.api.Test)1