use of org.apache.flink.runtime.dispatcher.SingleJobJobGraphStore in project flink by apache.
the class DefaultDispatcherRunnerITCase method leaderChange_withBlockingJobManagerTermination_doesNotAffectNewLeader.
/**
* See FLINK-11843. This is a probabilistic test which needs to be executed several times to
* fail.
*/
@Test
public void leaderChange_withBlockingJobManagerTermination_doesNotAffectNewLeader() throws Exception {
final TestingJobMasterServiceLeadershipRunnerFactory jobManagerRunnerFactory = new TestingJobMasterServiceLeadershipRunnerFactory(1);
final TestingCleanupRunnerFactory cleanupRunnerFactory = new TestingCleanupRunnerFactory();
dispatcherRunnerFactory = DefaultDispatcherRunnerFactory.createSessionRunner(new TestingDispatcherFactory(jobManagerRunnerFactory, cleanupRunnerFactory));
jobGraphStore = new SingleJobJobGraphStore(jobGraph);
try (final DispatcherRunner dispatcherRunner = createDispatcherRunner()) {
// initial run
dispatcherLeaderElectionService.isLeader(UUID.randomUUID()).get();
final TestingJobManagerRunner testingJobManagerRunner = jobManagerRunnerFactory.takeCreatedJobManagerRunner();
dispatcherLeaderElectionService.notLeader();
LOG.info("Re-grant leadership first time.");
dispatcherLeaderElectionService.isLeader(UUID.randomUUID());
// give the Dispatcher some time to recover jobs
Thread.sleep(1L);
dispatcherLeaderElectionService.notLeader();
LOG.info("Re-grant leadership second time.");
final UUID leaderSessionId = UUID.randomUUID();
final CompletableFuture<UUID> leaderFuture = dispatcherLeaderElectionService.isLeader(leaderSessionId);
assertThat(leaderFuture.isDone(), is(false));
LOG.info("Complete the termination of the first job manager runner.");
testingJobManagerRunner.completeTerminationFuture();
assertThat(leaderFuture.get(TIMEOUT.toMilliseconds(), TimeUnit.MILLISECONDS), is(equalTo(leaderSessionId)));
// Wait for job to recover...
final DispatcherGateway leaderGateway = rpcServiceResource.getTestingRpcService().connect(dispatcherLeaderElectionService.getAddress(), DispatcherId.fromUuid(leaderSessionId), DispatcherGateway.class).get();
assertEquals(jobGraph.getJobID(), Iterables.getOnlyElement(leaderGateway.listJobs(TIMEOUT).get()));
}
}
Aggregations