Search in sources :

Example 1 with PlanExecutor

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;
}
Also used : JobExecutionResult(org.apache.flink.api.common.JobExecutionResult) PlanExecutor(org.apache.flink.api.common.PlanExecutor) Plan(org.apache.flink.api.common.Plan)

Example 2 with PlanExecutor

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;
    }
}
Also used : PlanExecutor(org.apache.flink.api.common.PlanExecutor) Plan(org.apache.flink.api.common.Plan)

Example 3 with PlanExecutor

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.");
    }
}
Also used : PlanExecutor(org.apache.flink.api.common.PlanExecutor) MalformedURLException(java.net.MalformedURLException) InvalidProgramException(org.apache.flink.api.common.InvalidProgramException)

Example 4 with PlanExecutor

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);
}
Also used : StreamExecutionEnvironment(org.apache.flink.streaming.api.environment.StreamExecutionEnvironment) Configuration(org.apache.flink.configuration.Configuration) PlanExecutor(org.apache.flink.api.common.PlanExecutor) FlinkILoop(org.apache.flink.api.scala.FlinkILoop) InvocationOnMock(org.mockito.invocation.InvocationOnMock) List(java.util.List) MutableSettings(scala.tools.nsc.settings.MutableSettings) Settings(scala.tools.nsc.Settings) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

PlanExecutor (org.apache.flink.api.common.PlanExecutor)4 Plan (org.apache.flink.api.common.Plan)2 MalformedURLException (java.net.MalformedURLException)1 List (java.util.List)1 InvalidProgramException (org.apache.flink.api.common.InvalidProgramException)1 JobExecutionResult (org.apache.flink.api.common.JobExecutionResult)1 FlinkILoop (org.apache.flink.api.scala.FlinkILoop)1 Configuration (org.apache.flink.configuration.Configuration)1 StreamExecutionEnvironment (org.apache.flink.streaming.api.environment.StreamExecutionEnvironment)1 Test (org.junit.Test)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1 Settings (scala.tools.nsc.Settings)1 MutableSettings (scala.tools.nsc.settings.MutableSettings)1