use of org.apache.flink.runtime.leaderelection.LeaderElectionService in project flink by apache.
the class JobManagerRunnerMockTest method setUp.
@Before
public void setUp() throws Exception {
RpcService mockRpc = mock(RpcService.class);
when(mockRpc.getAddress()).thenReturn("localhost");
jobManager = mock(JobMaster.class);
jobManagerGateway = mock(JobMasterGateway.class);
when(jobManager.getSelf()).thenReturn(jobManagerGateway);
when(jobManager.getRpcService()).thenReturn(mockRpc);
PowerMockito.whenNew(JobMaster.class).withAnyArguments().thenReturn(jobManager);
jobCompletion = new TestingOnCompletionActions();
leaderElectionService = mock(LeaderElectionService.class);
when(leaderElectionService.hasLeadership()).thenReturn(true);
SubmittedJobGraphStore submittedJobGraphStore = mock(SubmittedJobGraphStore.class);
blobStore = mock(BlobStore.class);
HighAvailabilityServices haServices = mock(HighAvailabilityServices.class);
when(haServices.getJobManagerLeaderElectionService(any(JobID.class))).thenReturn(leaderElectionService);
when(haServices.getSubmittedJobGraphStore()).thenReturn(submittedJobGraphStore);
when(haServices.createBlobStore()).thenReturn(blobStore);
when(haServices.getRunningJobsRegistry()).thenReturn(runningJobsRegistry);
HeartbeatServices heartbeatServices = mock(HeartbeatServices.class);
runner = PowerMockito.spy(new JobManagerRunner(ResourceID.generate(), new JobGraph("test", new JobVertex("vertex")), mock(Configuration.class), mockRpc, haServices, heartbeatServices, JobManagerServices.fromConfiguration(new Configuration(), haServices), new MetricRegistry(MetricRegistryConfiguration.defaultMetricRegistryConfiguration()), jobCompletion, jobCompletion));
}
use of org.apache.flink.runtime.leaderelection.LeaderElectionService in project flink by apache.
the class YarnIntraNonHaMasterServicesTest method testClosingReportsToLeader.
@Test
public void testClosingReportsToLeader() throws Exception {
final Configuration flinkConfig = new Configuration();
try (YarnHighAvailabilityServices services = new YarnIntraNonHaMasterServices(flinkConfig, hadoopConfig)) {
final LeaderElectionService elector = services.getResourceManagerLeaderElectionService();
final LeaderRetrievalService retrieval = services.getResourceManagerLeaderRetriever();
final LeaderContender contender = mockContender(elector);
final LeaderRetrievalListener listener = mock(LeaderRetrievalListener.class);
elector.start(contender);
retrieval.start(listener);
// wait until the contender has become the leader
verify(listener, timeout(1000L).times(1)).notifyLeaderAddress(anyString(), any(UUID.class));
// now we can close the election service
services.close();
verify(contender, timeout(1000L).times(1)).handleError(any(Exception.class));
}
}
Aggregations