Java Code Examples for org.apache.flink.client.program.OptimizerPlanEnvironment#ProgramAbortException

The following examples show how to use org.apache.flink.client.program.OptimizerPlanEnvironment#ProgramAbortException . 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: DumpCompiledPlanTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void dumpIterativeKMeans() {
	// prepare the test environment
	PreviewPlanEnvironment env = new PreviewPlanEnvironment();
	env.setAsContext();
	try {
		KMeans.main(new String[] {
			"--points ", IN_FILE,
			"--centroids ", IN_FILE,
			"--output ", OUT_FILE,
			"--iterations", "123"});
	} catch (OptimizerPlanEnvironment.ProgramAbortException pae) {
		// all good.
	} catch (Exception e) {
		e.printStackTrace();
		Assert.fail("KMeans failed with an exception");
	}
	dump(env.getPlan());
}
 
Example 2
Source File: PreviewPlanDumpTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void dumpWordCount() {
	// prepare the test environment
	PreviewPlanEnvironment env = new PreviewPlanEnvironment();
	env.setAsContext();
	try {
		WordCount.main(new String[] {
				"--input", IN_FILE,
				"--output", OUT_FILE});
	} catch (OptimizerPlanEnvironment.ProgramAbortException pae) {
		// all good.
	} catch (Exception e) {
		e.printStackTrace();
		Assert.fail("WordCount failed with an exception");
	}
	dump(env.getPlan());
}
 
Example 3
Source File: PreviewPlanDumpTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void dumpTPCH3() {
	// prepare the test environment
	PreviewPlanEnvironment env = new PreviewPlanEnvironment();
	env.setAsContext();
	try {
		TPCHQuery3.main(new String[] {
				"--lineitem", IN_FILE,
				"--customer", IN_FILE,
				"--orders", OUT_FILE,
				"--output", "123"});
	} catch (OptimizerPlanEnvironment.ProgramAbortException pae) {
		// all good.
	} catch (Exception e) {
		e.printStackTrace();
		Assert.fail("TPCH3 failed with an exception");
	}
	dump(env.getPlan());
}
 
Example 4
Source File: FlinkFlow.java    From cascading-flink with Apache License 2.0 6 votes vote down vote up
@Override
@ProcessComplete
public void complete() {
	try {
		super.complete();
	}
	catch(FlowException fe) {
		// check if we need to unwrap a ProgramAbortException
		Throwable t = fe.getCause();
		if (t instanceof OptimizerPlanEnvironment.ProgramAbortException) {
			throw (OptimizerPlanEnvironment.ProgramAbortException)t;
		}
		else {
			throw fe;
		}
	}
}
 
Example 5
Source File: StreamPlanEnvironment.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Override
public JobExecutionResult execute(String jobName) throws Exception {

	StreamGraph streamGraph = getStreamGraph();
	streamGraph.setJobName(jobName);

	transformations.clear();

	if (env instanceof OptimizerPlanEnvironment) {
		((OptimizerPlanEnvironment) env).setPlan(streamGraph);
	} else if (env instanceof PreviewPlanEnvironment) {
		((PreviewPlanEnvironment) env).setPreview(streamGraph.getStreamingPlanAsJSON());
	}

	throw new OptimizerPlanEnvironment.ProgramAbortException();
}
 
Example 6
Source File: DumpCompiledPlanTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void dumpWebLogAnalysis() {
	// prepare the test environment
	PreviewPlanEnvironment env = new PreviewPlanEnvironment();
	env.setAsContext();
	try {
		WebLogAnalysis.main(new String[] {
				"--documents", IN_FILE,
				"--ranks", IN_FILE,
				"--visits", OUT_FILE,
				"--output", "123"});
	} catch (OptimizerPlanEnvironment.ProgramAbortException pae) {
		// all good.
	} catch (Exception e) {
		e.printStackTrace();
		Assert.fail("WebLogAnalysis failed with an exception");
	}
	dump(env.getPlan());
}
 
Example 7
Source File: DumpCompiledPlanTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void dumpBulkIterationKMeans() {
	// prepare the test environment
	PreviewPlanEnvironment env = new PreviewPlanEnvironment();
	env.setAsContext();
	try {
		ConnectedComponents.main(new String[] {
				"--vertices", IN_FILE,
				"--edges", IN_FILE,
				"--output", OUT_FILE,
				"--iterations", "123"});
	} catch (OptimizerPlanEnvironment.ProgramAbortException pae) {
		// all good.
	} catch (Exception e) {
		e.printStackTrace();
		Assert.fail("ConnectedComponents failed with an exception");
	}
	dump(env.getPlan());
}
 
Example 8
Source File: DumpCompiledPlanTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void dumpWebLogAnalysis() {
	// prepare the test environment
	PreviewPlanEnvironment env = new PreviewPlanEnvironment();
	env.setAsContext();
	try {
		WebLogAnalysis.main(new String[] {
				"--documents", IN_FILE,
				"--ranks", IN_FILE,
				"--visits", OUT_FILE,
				"--output", "123"});
	} catch (OptimizerPlanEnvironment.ProgramAbortException pae) {
		// all good.
	} catch (Exception e) {
		e.printStackTrace();
		Assert.fail("WebLogAnalysis failed with an exception");
	}
	dump(env.getPlan());
}
 
Example 9
Source File: DumpCompiledPlanTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void dumpTPCH3() {
	// prepare the test environment
	PreviewPlanEnvironment env = new PreviewPlanEnvironment();
	env.setAsContext();
	try {
		TPCHQuery3.main(new String[] {
				"--lineitem", IN_FILE,
				"--customer", IN_FILE,
				"--orders", OUT_FILE,
				"--output", "123"});
	} catch (OptimizerPlanEnvironment.ProgramAbortException pae) {
		// all good.
	} catch (Exception e) {
		e.printStackTrace();
		Assert.fail("TPCH3 failed with an exception");
	}
	dump(env.getPlan());
}
 
Example 10
Source File: DumpCompiledPlanTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void dumpPageRank() {
	// prepare the test environment
	PreviewPlanEnvironment env = new PreviewPlanEnvironment();
	env.setAsContext();
	try {
		PageRank.main(new String[]{
				"--pages", IN_FILE,
				"--links", IN_FILE,
				"--output", OUT_FILE,
				"--numPages", "10",
				"--iterations", "123"});
	} catch (OptimizerPlanEnvironment.ProgramAbortException pae) {
		// all good.
	} catch (Exception e) {
		e.printStackTrace();
		Assert.fail("PageRank failed with an exception");
	}
	dump(env.getPlan());
}
 
Example 11
Source File: DumpCompiledPlanTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void dumpBulkIterationKMeans() {
	// prepare the test environment
	PreviewPlanEnvironment env = new PreviewPlanEnvironment();
	env.setAsContext();
	try {
		ConnectedComponents.main(new String[] {
				"--vertices", IN_FILE,
				"--edges", IN_FILE,
				"--output", OUT_FILE,
				"--iterations", "123"});
	} catch (OptimizerPlanEnvironment.ProgramAbortException pae) {
		// all good.
	} catch (Exception e) {
		e.printStackTrace();
		Assert.fail("ConnectedComponents failed with an exception");
	}
	dump(env.getPlan());
}
 
Example 12
Source File: PreviewPlanDumpTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void dumpWebLogAnalysis() {
	// prepare the test environment
	PreviewPlanEnvironment env = new PreviewPlanEnvironment();
	env.setAsContext();
	try {
		org.apache.flink.examples.java.relational.WebLogAnalysis.main(new String[] {
				"--documents", IN_FILE,
				"--ranks", IN_FILE,
				"--visits", OUT_FILE,
				"--output", "123"});
	} catch (OptimizerPlanEnvironment.ProgramAbortException pae) {
		// all good.
	} catch (Exception e) {
		e.printStackTrace();
		Assert.fail("WebLogAnalysis failed with an exception");
	}
	dump(env.getPlan());
}
 
Example 13
Source File: DumpCompiledPlanTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void dumpWordCount() {
	// prepare the test environment
	PreviewPlanEnvironment env = new PreviewPlanEnvironment();
	env.setAsContext();
	try {
		WordCount.main(new String[] {
				"--input", IN_FILE,
				"--output", OUT_FILE});
	} catch (OptimizerPlanEnvironment.ProgramAbortException pae) {
		// all good.
	} catch (Exception e) {
		e.printStackTrace();
		Assert.fail("WordCount failed with an exception");
	}
	dump(env.getPlan());
}
 
Example 14
Source File: PreviewPlanDumpTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void dumpTPCH3() {
	// prepare the test environment
	PreviewPlanEnvironment env = new PreviewPlanEnvironment();
	env.setAsContext();
	try {
		TPCHQuery3.main(new String[] {
				"--lineitem", IN_FILE,
				"--customer", IN_FILE,
				"--orders", OUT_FILE,
				"--output", "123"});
	} catch (OptimizerPlanEnvironment.ProgramAbortException pae) {
		// all good.
	} catch (Exception e) {
		e.printStackTrace();
		Assert.fail("TPCH3 failed with an exception");
	}
	dump(env.getPlan());
}
 
Example 15
Source File: PreviewPlanDumpTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void dumpWordCount() {
	// prepare the test environment
	PreviewPlanEnvironment env = new PreviewPlanEnvironment();
	env.setAsContext();
	try {
		WordCount.main(new String[] {
				"--input", IN_FILE,
				"--output", OUT_FILE});
	} catch (OptimizerPlanEnvironment.ProgramAbortException pae) {
		// all good.
	} catch (Exception e) {
		e.printStackTrace();
		Assert.fail("WordCount failed with an exception");
	}
	dump(env.getPlan());
}
 
Example 16
Source File: PreviewPlanDumpTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void dumpPageRank() {
	// prepare the test environment
	PreviewPlanEnvironment env = new PreviewPlanEnvironment();
	env.setAsContext();
	try {
		// --pages <path> --links <path> --output <path> --numPages <n> --iterations <n>
		PageRank.main(new String[]{
				"--pages", IN_FILE,
				"--links", IN_FILE,
				"--output", OUT_FILE,
				"--numPages", "10",
				"--iterations", "123"});
	} catch (OptimizerPlanEnvironment.ProgramAbortException pae) {
		// all good.
	} catch (Exception e) {
		e.printStackTrace();
		Assert.fail("PageRank failed with an exception");
	}
	dump(env.getPlan());
}
 
Example 17
Source File: StreamPlanEnvironment.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public JobExecutionResult execute(StreamGraph streamGraph) throws Exception {
	transformations.clear();

	if (env instanceof OptimizerPlanEnvironment) {
		((OptimizerPlanEnvironment) env).setPlan(streamGraph);
	} else if (env instanceof PreviewPlanEnvironment) {
		((PreviewPlanEnvironment) env).setPreview(streamGraph.getStreamingPlanAsJSON());
	}

	throw new OptimizerPlanEnvironment.ProgramAbortException();
}
 
Example 18
Source File: FlinkFlowStepJob.java    From cascading-flink with Apache License 2.0 5 votes vote down vote up
@Override
public Throwable call()
{
	if (env instanceof OptimizerPlanEnvironment) {
		// We have an OptimizerPlanEnvironment.
		//   This environment is only used to to fetch the Flink execution plan.
		try {
			// OptimizerPlanEnvironment does not execute but only build the execution plan.
			env.execute("plan generation");
		}
		// execute() throws a ProgramAbortException if everything goes well
		catch(OptimizerPlanEnvironment.ProgramAbortException pae) {
			// Forward call() to get Cascading's internal job stats right.
			//   The job will be skipped due to the overridden isSkipFlowStep method.
			super.call();
			// forward expected ProgramAbortException
			return pae;
		}
		//
		catch(Exception e) {
			// forward unexpected exception
			return e;
		}
	}
	// forward to call() if we have a regular ExecutionEnvironment
	return super.call();

}
 
Example 19
Source File: RelationalQueryCompilerTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
public static Plan getTPCH3Plan() {
	// prepare the test environment
	PreviewPlanEnvironment env = new PreviewPlanEnvironment();
	env.setAsContext();
	try {
		tcph3(new String[]{DEFAULT_PARALLELISM_STRING, IN_FILE, IN_FILE, OUT_FILE});
	} catch (OptimizerPlanEnvironment.ProgramAbortException pae) {
		// all good.
	} catch (Exception e) {
		e.printStackTrace();
		Assert.fail("tcph3 failed with an exception");
	}
	return env.getPlan();
}
 
Example 20
Source File: LargePlanTest.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Test(expected = OptimizerPlanEnvironment.ProgramAbortException.class, timeout = 30_000)
public void testPlanningOfLargePlan() throws Exception {
	runProgram(new PreviewPlanEnvironment(), 10, 20);
}