Java Code Examples for org.apache.flink.api.java.ExecutionEnvironment#getExecutionPlan()

The following examples show how to use org.apache.flink.api.java.ExecutionEnvironment#getExecutionPlan() . 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: ExecutionPlanAfterExecutionTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@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.");
	}
}
 
Example 2
Source File: ExecutionPlanAfterExecutionTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@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());
	}
}
 
Example 3
Source File: ExecutionPlanAfterExecutionTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@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.");
	}
}
 
Example 4
Source File: ExecutionPlanAfterExecutionTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@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());
	}
}
 
Example 5
Source File: ExecutionEnvironmentTest.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Tests that verifies consecutive calls to {@link ExecutionEnvironment#getExecutionPlan()} do
 * not cause any exceptions. {@link ExecutionEnvironment#getExecutionPlan()} must not modify
 * the
 * state of the plan
 */
@Test
public void testExecuteAfterGetExecutionPlanContextEnvironment() {
	ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	DataSet<Integer> baseSet = env.fromElements(1, 2);

	DataSet<Integer> result = baseSet.map((MapFunction<Integer, Integer>) value -> value * 2);
	result.output(new DiscardingOutputFormat<>());

	try {
		env.getExecutionPlan();
		env.getExecutionPlan();
	} catch (Exception e) {
		fail("Consecutive #getExecutionPlan calls caused an exception.");
	}
}
 
Example 6
Source File: ExecutionPlanAfterExecutionTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testExecuteAfterGetExecutionPlan() {
	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.execute();
	}
	catch (Exception e) {
		e.printStackTrace();
		fail("Cannot run both #getExecutionPlan and #execute.");
	}
}
 
Example 7
Source File: ExecutionPlanAfterExecutionTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@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());
	}
}
 
Example 8
Source File: ExecutionPlanAfterExecutionTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetExecutionPlanOfRangePartition() {
	ExecutionEnvironment env = new LocalEnvironment();

	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.");
	}
}
 
Example 9
Source File: ExecutionPlanAfterExecutionTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@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.");
	}
}
 
Example 10
Source File: ExecutionPlanAfterExecutionTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@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.");
	}
}