use of org.apache.flink.runtime.leaderretrieval.SettableLeaderRetrievalService in project flink by apache.
the class DefaultJobLeaderIdServiceTest method testRemovingJob.
/**
* Tests that removing a job completes the job leader id future exceptionally.
*/
@Test(timeout = 10000)
public void testRemovingJob() throws Exception {
final JobID jobId = new JobID();
TestingHighAvailabilityServices highAvailabilityServices = new TestingHighAvailabilityServices();
SettableLeaderRetrievalService leaderRetrievalService = new SettableLeaderRetrievalService(null, null);
highAvailabilityServices.setJobMasterLeaderRetriever(jobId, leaderRetrievalService);
ScheduledExecutor scheduledExecutor = mock(ScheduledExecutor.class);
Time timeout = Time.milliseconds(5000L);
JobLeaderIdActions jobLeaderIdActions = mock(JobLeaderIdActions.class);
JobLeaderIdService jobLeaderIdService = new DefaultJobLeaderIdService(highAvailabilityServices, scheduledExecutor, timeout);
jobLeaderIdService.start(jobLeaderIdActions);
jobLeaderIdService.addJob(jobId);
CompletableFuture<JobMasterId> leaderIdFuture = jobLeaderIdService.getLeaderId(jobId);
// remove the job before we could find a leader
jobLeaderIdService.removeJob(jobId);
assertFalse(jobLeaderIdService.containsJob(jobId));
try {
leaderIdFuture.get();
fail("The leader id future should be completed exceptionally.");
} catch (ExecutionException ignored) {
// expected exception
}
}
use of org.apache.flink.runtime.leaderretrieval.SettableLeaderRetrievalService in project flink by apache.
the class DefaultJobLeaderIdServiceTest method testAddingJob.
/**
* Tests adding a job and finding out its leader id.
*/
@Test(timeout = 10000)
public void testAddingJob() throws Exception {
final JobID jobId = new JobID();
final String address = "foobar";
final JobMasterId leaderId = JobMasterId.generate();
TestingHighAvailabilityServices highAvailabilityServices = new TestingHighAvailabilityServices();
SettableLeaderRetrievalService leaderRetrievalService = new SettableLeaderRetrievalService(null, null);
highAvailabilityServices.setJobMasterLeaderRetriever(jobId, leaderRetrievalService);
ScheduledExecutor scheduledExecutor = mock(ScheduledExecutor.class);
Time timeout = Time.milliseconds(5000L);
JobLeaderIdActions jobLeaderIdActions = mock(JobLeaderIdActions.class);
JobLeaderIdService jobLeaderIdService = new DefaultJobLeaderIdService(highAvailabilityServices, scheduledExecutor, timeout);
jobLeaderIdService.start(jobLeaderIdActions);
jobLeaderIdService.addJob(jobId);
CompletableFuture<JobMasterId> leaderIdFuture = jobLeaderIdService.getLeaderId(jobId);
// notify the leader id service about the new leader
leaderRetrievalService.notifyListener(address, leaderId.toUUID());
assertEquals(leaderId, leaderIdFuture.get());
assertTrue(jobLeaderIdService.containsJob(jobId));
}
use of org.apache.flink.runtime.leaderretrieval.SettableLeaderRetrievalService in project flink by apache.
the class ResourceManagerJobMasterTest method createAndRegisterJobMasterGateway.
private void createAndRegisterJobMasterGateway() {
jobMasterGateway = new TestingJobMasterGatewayBuilder().build();
rpcService.registerGateway(jobMasterGateway.getAddress(), jobMasterGateway);
jobMasterLeaderRetrievalService = new SettableLeaderRetrievalService(jobMasterGateway.getAddress(), jobMasterGateway.getFencingToken().toUUID());
}
use of org.apache.flink.runtime.leaderretrieval.SettableLeaderRetrievalService in project flink by apache.
the class TaskManagerRunnerStartupTest method setupTest.
@Before
public void setupTest() {
highAvailabilityServices = new TestingHighAvailabilityServices();
highAvailabilityServices.setResourceManagerLeaderRetriever(new SettableLeaderRetrievalService());
}
use of org.apache.flink.runtime.leaderretrieval.SettableLeaderRetrievalService in project flink by apache.
the class ManualLeaderService method createLeaderRetrievalService.
public LeaderRetrievalService createLeaderRetrievalService() {
final SettableLeaderRetrievalService settableLeaderRetrievalService = new SettableLeaderRetrievalService(getLeaderAddress(currentLeaderIndex), currentLeaderId);
leaderRetrievalServices.add(settableLeaderRetrievalService);
return settableLeaderRetrievalService;
}
Aggregations