use of org.apache.flink.api.common.PlanExecutor in project flink by apache.
the class RemoteEnvironment method execute.
// ------------------------------------------------------------------------
@Override
public JobExecutionResult execute(String jobName) throws Exception {
PlanExecutor executor = getExecutor();
Plan p = createProgramPlan(jobName);
// Session management is disabled, revert this commit to enable
//p.setJobId(jobID);
//p.setSessionTimeout(sessionTimeout);
JobExecutionResult result = executor.executePlan(p);
this.lastJobExecutionResult = result;
return result;
}
use of org.apache.flink.api.common.PlanExecutor in project flink by apache.
the class RemoteEnvironment method getExecutionPlan.
@Override
public String getExecutionPlan() throws Exception {
Plan p = createProgramPlan("plan", false);
// generate the plan
if (executor != null) {
return executor.getOptimizerPlanAsJSON(p);
} else {
PlanExecutor le = PlanExecutor.createLocalExecutor(null);
String plan = le.getOptimizerPlanAsJSON(p);
le.stop();
return plan;
}
}
use of org.apache.flink.api.common.PlanExecutor in project flink by apache.
the class RemoteEnvironment method dispose.
// ------------------------------------------------------------------------
// Dispose
// ------------------------------------------------------------------------
protected void dispose() {
// shutdown hook itself
if (shutdownHook != null && shutdownHook != Thread.currentThread()) {
try {
Runtime.getRuntime().removeShutdownHook(shutdownHook);
} catch (IllegalStateException e) {
// race, JVM is in shutdown already, we can safely ignore this
} catch (Throwable t) {
LOG.warn("Exception while unregistering the cleanup shutdown hook.");
}
}
try {
PlanExecutor executor = this.executor;
if (executor != null) {
executor.endSession(jobID);
executor.stop();
}
} catch (Exception e) {
throw new RuntimeException("Failed to dispose the session shutdown hook.");
}
}
use of org.apache.flink.api.common.PlanExecutor in project flink by apache.
the class FlinkILoopTest method testConfigurationForwarding.
@Test
public void testConfigurationForwarding() throws Exception {
Configuration configuration = new Configuration();
configuration.setString("foobar", "foobar");
FlinkILoop flinkILoop = new FlinkILoop("localhost", 6123, configuration, Option.<String[]>empty());
final TestPlanExecutor testPlanExecutor = new TestPlanExecutor();
PowerMockito.mockStatic(PlanExecutor.class);
BDDMockito.given(PlanExecutor.createRemoteExecutor(Matchers.anyString(), Matchers.anyInt(), Matchers.any(Configuration.class), Matchers.any(java.util.List.class), Matchers.any(java.util.List.class))).willAnswer(new Answer<PlanExecutor>() {
@Override
public PlanExecutor answer(InvocationOnMock invocation) throws Throwable {
testPlanExecutor.setHost((String) invocation.getArguments()[0]);
testPlanExecutor.setPort((Integer) invocation.getArguments()[1]);
testPlanExecutor.setConfiguration((Configuration) invocation.getArguments()[2]);
testPlanExecutor.setJars((List<String>) invocation.getArguments()[3]);
testPlanExecutor.setGlobalClasspaths((List<String>) invocation.getArguments()[4]);
return testPlanExecutor;
}
});
Settings settings = new Settings();
((MutableSettings.BooleanSetting) settings.usejavacp()).value_$eq(true);
flinkILoop.settings_$eq(settings);
flinkILoop.createInterpreter();
ExecutionEnvironment env = flinkILoop.scalaBenv().getJavaEnv();
env.fromElements(1).output(new DiscardingOutputFormat<Integer>());
env.execute("Test job");
Configuration forwardedConfiguration = testPlanExecutor.getConfiguration();
assertEquals(configuration, forwardedConfiguration);
}
Aggregations