Search in sources :

Example 1 with TerminalJobStatusListener

use of org.apache.flink.runtime.executiongraph.TerminalJobStatusListener in project flink by apache.

the class LeaderChangeJobRecoveryTest method testNotRestartedWhenLosingLeadership.

/**
	 * Tests that the job is not restarted or at least terminates eventually in case that the
	 * JobManager loses its leadership.
	 *
	 * @throws Exception
	 */
@Test
public void testNotRestartedWhenLosingLeadership() throws Exception {
    UUID leaderSessionID = UUID.randomUUID();
    cluster.grantLeadership(0, leaderSessionID);
    cluster.notifyRetrievalListeners(0, leaderSessionID);
    cluster.waitForTaskManagersToBeRegistered(timeout);
    cluster.submitJobDetached(job);
    ActorGateway jm = cluster.getLeaderGateway(timeout);
    Future<Object> wait = jm.ask(new TestingJobManagerMessages.WaitForAllVerticesToBeRunningOrFinished(job.getJobID()), timeout);
    Await.ready(wait, timeout);
    Future<Object> futureExecutionGraph = jm.ask(new TestingJobManagerMessages.RequestExecutionGraph(job.getJobID()), timeout);
    TestingJobManagerMessages.ResponseExecutionGraph responseExecutionGraph = (TestingJobManagerMessages.ResponseExecutionGraph) Await.result(futureExecutionGraph, timeout);
    assertTrue(responseExecutionGraph instanceof TestingJobManagerMessages.ExecutionGraphFound);
    ExecutionGraph executionGraph = (ExecutionGraph) ((TestingJobManagerMessages.ExecutionGraphFound) responseExecutionGraph).executionGraph();
    TerminalJobStatusListener testListener = new TerminalJobStatusListener();
    executionGraph.registerJobStatusListener(testListener);
    cluster.revokeLeadership();
    testListener.waitForTerminalState(30000);
}
Also used : TestingJobManagerMessages(org.apache.flink.runtime.testingUtils.TestingJobManagerMessages) TerminalJobStatusListener(org.apache.flink.runtime.executiongraph.TerminalJobStatusListener) ActorGateway(org.apache.flink.runtime.instance.ActorGateway) ExecutionGraph(org.apache.flink.runtime.executiongraph.ExecutionGraph) UUID(java.util.UUID) Test(org.junit.Test)

Aggregations

UUID (java.util.UUID)1 ExecutionGraph (org.apache.flink.runtime.executiongraph.ExecutionGraph)1 TerminalJobStatusListener (org.apache.flink.runtime.executiongraph.TerminalJobStatusListener)1 ActorGateway (org.apache.flink.runtime.instance.ActorGateway)1 TestingJobManagerMessages (org.apache.flink.runtime.testingUtils.TestingJobManagerMessages)1 Test (org.junit.Test)1