Search in sources :

Example 1 with LeaderElectionService

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));
}
Also used : HeartbeatServices(org.apache.flink.runtime.heartbeat.HeartbeatServices) SubmittedJobGraphStore(org.apache.flink.runtime.jobmanager.SubmittedJobGraphStore) MetricRegistryConfiguration(org.apache.flink.runtime.metrics.MetricRegistryConfiguration) Configuration(org.apache.flink.configuration.Configuration) MetricRegistry(org.apache.flink.runtime.metrics.MetricRegistry) JobGraph(org.apache.flink.runtime.jobgraph.JobGraph) JobVertex(org.apache.flink.runtime.jobgraph.JobVertex) HighAvailabilityServices(org.apache.flink.runtime.highavailability.HighAvailabilityServices) RpcService(org.apache.flink.runtime.rpc.RpcService) LeaderElectionService(org.apache.flink.runtime.leaderelection.LeaderElectionService) BlobStore(org.apache.flink.runtime.blob.BlobStore) JobID(org.apache.flink.api.common.JobID) Before(org.junit.Before)

Example 2 with LeaderElectionService

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));
    }
}
Also used : Configuration(org.apache.flink.configuration.Configuration) LeaderRetrievalService(org.apache.flink.runtime.leaderretrieval.LeaderRetrievalService) LeaderContender(org.apache.flink.runtime.leaderelection.LeaderContender) LeaderElectionService(org.apache.flink.runtime.leaderelection.LeaderElectionService) LeaderRetrievalListener(org.apache.flink.runtime.leaderretrieval.LeaderRetrievalListener) UUID(java.util.UUID) Test(org.junit.Test)

Aggregations

Configuration (org.apache.flink.configuration.Configuration)2 LeaderElectionService (org.apache.flink.runtime.leaderelection.LeaderElectionService)2 UUID (java.util.UUID)1 JobID (org.apache.flink.api.common.JobID)1 BlobStore (org.apache.flink.runtime.blob.BlobStore)1 HeartbeatServices (org.apache.flink.runtime.heartbeat.HeartbeatServices)1 HighAvailabilityServices (org.apache.flink.runtime.highavailability.HighAvailabilityServices)1 JobGraph (org.apache.flink.runtime.jobgraph.JobGraph)1 JobVertex (org.apache.flink.runtime.jobgraph.JobVertex)1 SubmittedJobGraphStore (org.apache.flink.runtime.jobmanager.SubmittedJobGraphStore)1 LeaderContender (org.apache.flink.runtime.leaderelection.LeaderContender)1 LeaderRetrievalListener (org.apache.flink.runtime.leaderretrieval.LeaderRetrievalListener)1 LeaderRetrievalService (org.apache.flink.runtime.leaderretrieval.LeaderRetrievalService)1 MetricRegistry (org.apache.flink.runtime.metrics.MetricRegistry)1 MetricRegistryConfiguration (org.apache.flink.runtime.metrics.MetricRegistryConfiguration)1 RpcService (org.apache.flink.runtime.rpc.RpcService)1 Before (org.junit.Before)1 Test (org.junit.Test)1