TisonKun commented on a change in pull request #10526: [FLINK-15090][build]
Reverse the dependency from flink-streaming-java to flink-client
URL: https://github.com/apache/flink/pull/10526#discussion_r390812271
##########
File path:
flink-clients/src/main/java/org/apache/flink/client/program/OptimizerPlanEnvironment.java
##########
@@ -22,143 +22,39 @@
import org.apache.flink.api.java.ExecutionEnvironment;
import org.apache.flink.api.java.ExecutionEnvironmentFactory;
import org.apache.flink.core.execution.JobClient;
-import org.apache.flink.util.Preconditions;
-
-import javax.annotation.Nullable;
-
-import java.io.ByteArrayOutputStream;
-import java.io.PrintStream;
/**
- * An {@link ExecutionEnvironment} that never executes a job but only extracts
the {@link
- * org.apache.flink.api.dag.Pipeline}.
+ * An {@link ExecutionEnvironment} that never executes a job but only extracts
the {@link Pipeline}.
*/
public class OptimizerPlanEnvironment extends ExecutionEnvironment {
- private Pipeline pipeline;
+ private static Pipeline pipeline;
Review comment:
What if users write code
```java
ExecutionEnvironment env[1..n] =
ExecutionEnvironment.getExecutionEnvironment();
parallel-n {
env[i].execute();
}
```
In this case, the whole function is not thread transparent. And even with
master branch we might miss the exception. Here, already we make some
assumption that user calls `env.execute` in the same thread he runs `main` and
doesn't caught `ProgramAbortException`.
If we keep `OptimizerPlanEnvironment` as is, then we go into the problem you
mention above for ContextEnvironment. What if
```java
ExecutionEnvironment env1 = ExecutionEnvironment.getExecutionEnvironment();
ExecutionEnvironment env2 = ExecutionEnvironment.getExecutionEnvironment();
env1 ...
env2 ...
env1.execute()
```
Actually `env1` & `env2` is the same environment.
Either way, we make some implications. And if you compare master
`OptimizerPlanEnvironment` and `StreamPlanEnvironment`, you will find that they
are different.
- `OptimizerPlanEnvironment.setAsContext` always set the same instance
- `StreamPlanEnvironment.setAsContext` always set a new instance, though it
finally set StreamGraph to the single `OptimizerPlanEnvironment`, but different
`StreamPlanEnvironment` instance has different configuration and the first one
call `execute()` wins. If you put it in multi-threaded environment, the one
runs as the same thread of `main` and first call `execute()` wins.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services