use of org.apache.flink.api.java.LocalEnvironment in project flink by apache.
the class ExecutionPlanAfterExecutionTest method testGetExecutionPlanOfRangePartition.
@Test
public void testGetExecutionPlanOfRangePartition() {
ExecutionEnvironment env = new LocalEnvironment();
env.getConfig().disableSysoutLogging();
DataSet<Integer> baseSet = env.fromElements(1, 2);
DataSet<Tuple2<Integer, Integer>> result = baseSet.map(new MapFunction<Integer, Tuple2<Integer, Integer>>() {
@Override
public Tuple2<Integer, Integer> map(Integer value) throws Exception {
return new Tuple2(value, value * 2);
}
}).partitionByRange(0).aggregate(Aggregations.MAX, 1);
result.output(new DiscardingOutputFormat<Tuple2<Integer, Integer>>());
try {
env.getExecutionPlan();
env.execute();
} catch (Exception e) {
e.printStackTrace();
fail("Cannot run both #getExecutionPlan and #execute.");
}
}
use of org.apache.flink.api.java.LocalEnvironment in project flink by apache.
the class ExecutionPlanAfterExecutionTest method testExecuteAfterGetExecutionPlan.
@Test
public void testExecuteAfterGetExecutionPlan() {
ExecutionEnvironment env = new LocalEnvironment();
env.getConfig().disableSysoutLogging();
DataSet<Integer> baseSet = env.fromElements(1, 2);
DataSet<Integer> result = baseSet.map(new MapFunction<Integer, Integer>() {
@Override
public Integer map(Integer value) throws Exception {
return value * 2;
}
});
result.output(new DiscardingOutputFormat<Integer>());
try {
env.getExecutionPlan();
env.execute();
} catch (Exception e) {
e.printStackTrace();
fail("Cannot run both #getExecutionPlan and #execute.");
}
}
use of org.apache.flink.api.java.LocalEnvironment in project flink by apache.
the class ExecutionPlanAfterExecutionTest method testCreatePlanAfterGetExecutionPlan.
@Test
public void testCreatePlanAfterGetExecutionPlan() {
ExecutionEnvironment env = new LocalEnvironment();
DataSet<Integer> baseSet = env.fromElements(1, 2);
DataSet<Integer> result = baseSet.map(new MapFunction<Integer, Integer>() {
@Override
public Integer map(Integer value) throws Exception {
return value * 2;
}
});
result.output(new DiscardingOutputFormat<Integer>());
try {
env.getExecutionPlan();
env.createProgramPlan();
} catch (Exception e) {
e.printStackTrace();
fail("Cannot run both #getExecutionPlan and #execute. Message: " + e.getMessage());
}
}
use of org.apache.flink.api.java.LocalEnvironment in project flink by apache.
the class PythonPlanBinder method runPlan.
private void runPlan(String[] args) throws Exception {
env = ExecutionEnvironment.getExecutionEnvironment();
int split = 0;
for (int x = 0; x < args.length; x++) {
if (args[x].compareTo("-") == 0) {
split = x;
}
}
try {
String tmpPath = FLINK_PYTHON_FILE_PATH + r.nextInt();
prepareFiles(tmpPath, Arrays.copyOfRange(args, 0, split == 0 ? args.length : split));
startPython(tmpPath, Arrays.copyOfRange(args, split == 0 ? args.length : split + 1, args.length));
receivePlan();
if (env instanceof LocalEnvironment) {
FLINK_HDFS_PATH = "file:" + System.getProperty("java.io.tmpdir") + File.separator + "flink";
}
distributeFiles(tmpPath, env);
JobExecutionResult jer = env.execute();
sendResult(jer);
close();
} catch (Exception e) {
close();
throw e;
}
}
Aggregations