use of org.apache.flink.runtime.highavailability.TestingHighAvailabilityServicesBuilder in project flink by apache.
the class DefaultJobLeaderServiceTest method rejectedJobManagerRegistrationCallsJobLeaderListener.
@Test
public void rejectedJobManagerRegistrationCallsJobLeaderListener() throws Exception {
final SettableLeaderRetrievalService leaderRetrievalService = new SettableLeaderRetrievalService();
final TestingHighAvailabilityServices haServices = new TestingHighAvailabilityServicesBuilder().setJobMasterLeaderRetrieverFunction(ignored -> leaderRetrievalService).build();
final JobID jobId = new JobID();
final CompletableFuture<JobID> rejectedRegistrationFuture = new CompletableFuture<>();
final TestingJobLeaderListener testingJobLeaderListener = new TestingJobLeaderListener(ignored -> {
}, rejectedRegistrationFuture::complete);
final JobLeaderService jobLeaderService = createAndStartJobLeaderService(haServices, testingJobLeaderListener);
final TestingJobMasterGateway jobMasterGateway = new TestingJobMasterGatewayBuilder().setRegisterTaskManagerFunction((jobID, taskManagerRegistrationInformation) -> CompletableFuture.completedFuture(new JMTMRegistrationRejection("foobar"))).build();
rpcServiceResource.getTestingRpcService().registerGateway(jobMasterGateway.getAddress(), jobMasterGateway);
try {
jobLeaderService.addJob(jobId, "foobar");
leaderRetrievalService.notifyListener(jobMasterGateway.getAddress(), jobMasterGateway.getFencingToken().toUUID());
assertThat(rejectedRegistrationFuture.get(), is(jobId));
} finally {
jobLeaderService.stop();
}
}
Aggregations