org.apache.flink.client.program.ContextEnvironment Java Examples

The following examples show how to use org.apache.flink.client.program.ContextEnvironment. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StreamExecutionEnvironment.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
/**
 * Creates an execution environment that represents the context in which the
 * program is currently executed. If the program is invoked standalone, this
 * method returns a local execution environment, as returned by
 * {@link #createLocalEnvironment()}.
 *
 * @return The execution environment of the context in which the program is
 * executed.
 */
public static StreamExecutionEnvironment getExecutionEnvironment() {
	if (contextEnvironmentFactory != null) {
		return contextEnvironmentFactory.createExecutionEnvironment();
	}

	// because the streaming project depends on "flink-clients" (and not the other way around)
	// we currently need to intercept the data set environment and create a dependent stream env.
	// this should be fixed once we rework the project dependencies

	ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	if (env instanceof ContextEnvironment) {
		return new StreamContextEnvironment((ContextEnvironment) env);
	} else if (env instanceof OptimizerPlanEnvironment || env instanceof PreviewPlanEnvironment) {
		return new StreamPlanEnvironment(env);
	} else {
		return createLocalEnvironment();
	}
}
 
Example #2
Source File: StreamExecutionEnvironment.java    From flink with Apache License 2.0 5 votes vote down vote up
private static StreamExecutionEnvironment createStreamExecutionEnvironment() {
	// because the streaming project depends on "flink-clients" (and not the other way around)
	// we currently need to intercept the data set environment and create a dependent stream env.
	// this should be fixed once we rework the project dependencies

	ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	if (env instanceof ContextEnvironment) {
		return new StreamContextEnvironment((ContextEnvironment) env);
	} else if (env instanceof OptimizerPlanEnvironment || env instanceof PreviewPlanEnvironment) {
		return new StreamPlanEnvironment(env);
	} else {
		return createLocalEnvironment();
	}
}
 
Example #3
Source File: StreamContextEnvironment.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
protected StreamContextEnvironment(ContextEnvironment ctx) {
	this.ctx = ctx;
	if (ctx.getParallelism() > 0) {
		setParallelism(ctx.getParallelism());
	}
}
 
Example #4
Source File: StreamContextEnvironment.java    From flink with Apache License 2.0 4 votes vote down vote up
protected StreamContextEnvironment(ContextEnvironment ctx) {
	this.ctx = ctx;
	if (ctx.getParallelism() > 0) {
		setParallelism(ctx.getParallelism());
	}
}
 
Example #5
Source File: FlinkFlowStepJob.java    From cascading-flink with Apache License 2.0 4 votes vote down vote up
@Override
protected boolean isRemoteExecution() {
	return env instanceof ContextEnvironment;
}