Search in sources :

Example 1 with StreamExecutionEnvironmentFactory

use of org.apache.flink.streaming.api.environment.StreamExecutionEnvironmentFactory in project flink by apache.

the class ScalaShellRemoteStreamEnvironment method disableAllContextAndOtherEnvironments.

public static void disableAllContextAndOtherEnvironments() {
    // we create a context environment that prevents the instantiation of further
    // context environments. at the same time, setting the context environment prevents manual
    // creation of local and remote environments
    StreamExecutionEnvironmentFactory factory = new StreamExecutionEnvironmentFactory() {

        @Override
        public StreamExecutionEnvironment createExecutionEnvironment() {
            throw new UnsupportedOperationException("Execution Environment is already defined" + " for this shell.");
        }
    };
    initializeContextEnvironment(factory);
}
Also used : StreamExecutionEnvironmentFactory(org.apache.flink.streaming.api.environment.StreamExecutionEnvironmentFactory)

Example 2 with StreamExecutionEnvironmentFactory

use of org.apache.flink.streaming.api.environment.StreamExecutionEnvironmentFactory in project flink by apache.

the class StreamContextEnvironment method setAsContext.

// --------------------------------------------------------------------------------------------
public static void setAsContext(final PipelineExecutorServiceLoader executorServiceLoader, final Configuration configuration, final ClassLoader userCodeClassLoader, final boolean enforceSingleJobExecution, final boolean suppressSysout) {
    StreamExecutionEnvironmentFactory factory = conf -> {
        final List<String> errors = new ArrayList<>();
        final boolean allowConfigurations = configuration.getBoolean(DeploymentOptions.ALLOW_CLIENT_JOB_CONFIGURATIONS);
        if (!allowConfigurations && !conf.toMap().isEmpty()) {
            conf.toMap().forEach((k, v) -> errors.add(ConfigurationNotAllowedMessage.ofConfigurationKeyAndValue(k, v)));
        }
        Configuration mergedConfiguration = new Configuration();
        mergedConfiguration.addAll(configuration);
        mergedConfiguration.addAll(conf);
        return new StreamContextEnvironment(executorServiceLoader, mergedConfiguration, userCodeClassLoader, enforceSingleJobExecution, suppressSysout, allowConfigurations, errors);
    };
    initializeContextEnvironment(factory);
}
Also used : Arrays(java.util.Arrays) ByteArrayOutputStream(java.io.ByteArrayOutputStream) LoggerFactory(org.slf4j.LoggerFactory) PublicEvolving(org.apache.flink.annotation.PublicEvolving) PipelineExecutorServiceLoader(org.apache.flink.core.execution.PipelineExecutorServiceLoader) ExceptionUtils(org.apache.flink.util.ExceptionUtils) CompletableFuture(java.util.concurrent.CompletableFuture) ShutdownHookUtil(org.apache.flink.util.ShutdownHookUtil) ArrayList(java.util.ArrayList) JobListener(org.apache.flink.core.execution.JobListener) StreamGraph(org.apache.flink.streaming.api.graph.StreamGraph) DeploymentOptions(org.apache.flink.configuration.DeploymentOptions) ObjectOutputStream(java.io.ObjectOutputStream) Preconditions.checkNotNull(org.apache.flink.util.Preconditions.checkNotNull) DetachedJobExecutionResult(org.apache.flink.core.execution.DetachedJobExecutionResult) Logger(org.slf4j.Logger) FlinkRuntimeException(org.apache.flink.util.FlinkRuntimeException) StreamExecutionEnvironmentFactory(org.apache.flink.streaming.api.environment.StreamExecutionEnvironmentFactory) Collection(java.util.Collection) Configuration(org.apache.flink.configuration.Configuration) IOException(java.io.IOException) JobClient(org.apache.flink.core.execution.JobClient) Serializable(java.io.Serializable) JobExecutionResult(org.apache.flink.api.common.JobExecutionResult) TimeUnit(java.util.concurrent.TimeUnit) MapDifference(org.apache.flink.shaded.guava30.com.google.common.collect.MapDifference) Maps(org.apache.flink.shaded.guava30.com.google.common.collect.Maps) List(java.util.List) ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) ConfigurationNotAllowedMessage(org.apache.flink.runtime.dispatcher.ConfigurationNotAllowedMessage) Internal(org.apache.flink.annotation.Internal) Collections(java.util.Collections) StreamExecutionEnvironment(org.apache.flink.streaming.api.environment.StreamExecutionEnvironment) Configuration(org.apache.flink.configuration.Configuration) ArrayList(java.util.ArrayList) List(java.util.List) StreamExecutionEnvironmentFactory(org.apache.flink.streaming.api.environment.StreamExecutionEnvironmentFactory)

Example 3 with StreamExecutionEnvironmentFactory

use of org.apache.flink.streaming.api.environment.StreamExecutionEnvironmentFactory in project flink by apache.

the class StreamPlanEnvironment method setAsContext.

public void setAsContext() {
    StreamExecutionEnvironmentFactory factory = conf -> {
        this.configure(conf, getUserClassloader());
        return this;
    };
    initializeContextEnvironment(factory);
}
Also used : StreamExecutionEnvironmentFactory(org.apache.flink.streaming.api.environment.StreamExecutionEnvironmentFactory) Pipeline(org.apache.flink.api.dag.Pipeline) Configuration(org.apache.flink.configuration.Configuration) StreamGraph(org.apache.flink.streaming.api.graph.StreamGraph) PublicEvolving(org.apache.flink.annotation.PublicEvolving) JobClient(org.apache.flink.core.execution.JobClient) StreamExecutionEnvironment(org.apache.flink.streaming.api.environment.StreamExecutionEnvironment) StreamExecutionEnvironmentFactory(org.apache.flink.streaming.api.environment.StreamExecutionEnvironmentFactory)

Example 4 with StreamExecutionEnvironmentFactory

use of org.apache.flink.streaming.api.environment.StreamExecutionEnvironmentFactory in project flink by apache.

the class ScalaShellRemoteStreamEnvironment method setAsContext.

public void setAsContext() {
    StreamExecutionEnvironmentFactory factory = new StreamExecutionEnvironmentFactory() {

        @Override
        public StreamExecutionEnvironment createExecutionEnvironment() {
            throw new UnsupportedOperationException("Execution Environment is already defined" + " for this shell.");
        }
    };
    initializeContextEnvironment(factory);
}
Also used : StreamExecutionEnvironmentFactory(org.apache.flink.streaming.api.environment.StreamExecutionEnvironmentFactory)

Example 5 with StreamExecutionEnvironmentFactory

use of org.apache.flink.streaming.api.environment.StreamExecutionEnvironmentFactory in project flink by apache.

the class TestStreamEnvironment method setAsContext.

// ------------------------------------------------------------------------
/**
	 * Sets the streaming context environment to a TestStreamEnvironment that runs its programs on
	 * the given cluster with the given default parallelism.
	 * 
	 * @param cluster The test cluster to run the test program on.
	 * @param parallelism The default parallelism for the test programs.
	 */
public static void setAsContext(final LocalFlinkMiniCluster cluster, final int parallelism) {
    StreamExecutionEnvironmentFactory factory = new StreamExecutionEnvironmentFactory() {

        @Override
        public StreamExecutionEnvironment createExecutionEnvironment() {
            return new TestStreamEnvironment(cluster, parallelism);
        }
    };
    initializeContextEnvironment(factory);
}
Also used : StreamExecutionEnvironmentFactory(org.apache.flink.streaming.api.environment.StreamExecutionEnvironmentFactory)

Aggregations

StreamExecutionEnvironmentFactory (org.apache.flink.streaming.api.environment.StreamExecutionEnvironmentFactory)6 Configuration (org.apache.flink.configuration.Configuration)3 StreamExecutionEnvironment (org.apache.flink.streaming.api.environment.StreamExecutionEnvironment)3 Collection (java.util.Collection)2 Collections (java.util.Collections)2 PublicEvolving (org.apache.flink.annotation.PublicEvolving)2 JobClient (org.apache.flink.core.execution.JobClient)2 StreamGraph (org.apache.flink.streaming.api.graph.StreamGraph)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 ObjectOutputStream (java.io.ObjectOutputStream)1 Serializable (java.io.Serializable)1 URL (java.net.URL)1 Duration (java.time.Duration)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 List (java.util.List)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 TimeUnit (java.util.concurrent.TimeUnit)1 Internal (org.apache.flink.annotation.Internal)1