Search in sources :

Example 6 with TestingLeaderRetrievalService

use of org.apache.flink.runtime.leaderelection.TestingLeaderRetrievalService in project flink by apache.

the class SlotProtocolTest method configureHA.

private static TestingLeaderElectionService configureHA(TestingHighAvailabilityServices testingHA, JobID jobID, String rmAddress, UUID rmID, String jmAddress, UUID jmID) {
    final TestingLeaderElectionService rmLeaderElectionService = new TestingLeaderElectionService();
    testingHA.setResourceManagerLeaderElectionService(rmLeaderElectionService);
    final TestingLeaderRetrievalService rmLeaderRetrievalService = new TestingLeaderRetrievalService(rmAddress, rmID);
    testingHA.setResourceManagerLeaderRetriever(rmLeaderRetrievalService);
    final TestingLeaderElectionService jmLeaderElectionService = new TestingLeaderElectionService();
    testingHA.setJobMasterLeaderElectionService(jobID, jmLeaderElectionService);
    final TestingLeaderRetrievalService jmLeaderRetrievalService = new TestingLeaderRetrievalService(jmAddress, jmID);
    testingHA.setJobMasterLeaderRetriever(jobID, jmLeaderRetrievalService);
    return rmLeaderElectionService;
}
Also used : TestingLeaderElectionService(org.apache.flink.runtime.leaderelection.TestingLeaderElectionService) TestingLeaderRetrievalService(org.apache.flink.runtime.leaderelection.TestingLeaderRetrievalService)

Example 7 with TestingLeaderRetrievalService

use of org.apache.flink.runtime.leaderelection.TestingLeaderRetrievalService in project flink by apache.

the class JobLeaderIdServiceTest 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 UUID leaderId = UUID.randomUUID();
    TestingHighAvailabilityServices highAvailabilityServices = new TestingHighAvailabilityServices();
    TestingLeaderRetrievalService leaderRetrievalService = new TestingLeaderRetrievalService();
    highAvailabilityServices.setJobMasterLeaderRetriever(jobId, leaderRetrievalService);
    ScheduledExecutor scheduledExecutor = mock(ScheduledExecutor.class);
    Time timeout = Time.milliseconds(5000L);
    JobLeaderIdActions jobLeaderIdActions = mock(JobLeaderIdActions.class);
    JobLeaderIdService jobLeaderIdService = new JobLeaderIdService(highAvailabilityServices, scheduledExecutor, timeout);
    jobLeaderIdService.start(jobLeaderIdActions);
    jobLeaderIdService.addJob(jobId);
    Future<UUID> leaderIdFuture = jobLeaderIdService.getLeaderId(jobId);
    // notify the leader id service about the new leader
    leaderRetrievalService.notifyListener(address, leaderId);
    assertEquals(leaderId, leaderIdFuture.get());
    assertTrue(jobLeaderIdService.containsJob(jobId));
}
Also used : TestingHighAvailabilityServices(org.apache.flink.runtime.highavailability.TestingHighAvailabilityServices) TestingLeaderRetrievalService(org.apache.flink.runtime.leaderelection.TestingLeaderRetrievalService) Time(org.apache.flink.api.common.time.Time) UUID(java.util.UUID) JobID(org.apache.flink.api.common.JobID) ScheduledExecutor(org.apache.flink.runtime.concurrent.ScheduledExecutor) Test(org.junit.Test)

Example 8 with TestingLeaderRetrievalService

use of org.apache.flink.runtime.leaderelection.TestingLeaderRetrievalService in project flink by apache.

the class ResourceManagerJobMasterTest method testRegisterJobMasterWithUnmatchedLeaderSessionId1.

/**
	 * Test receive registration with unmatched leadershipId from job master
	 */
@Test
public void testRegisterJobMasterWithUnmatchedLeaderSessionId1() throws Exception {
    String jobMasterAddress = "/jobMasterAddress1";
    JobID jobID = mockJobMaster(jobMasterAddress);
    TestingLeaderElectionService resourceManagerLeaderElectionService = new TestingLeaderElectionService();
    UUID jmLeaderID = UUID.randomUUID();
    TestingLeaderRetrievalService jobMasterLeaderRetrievalService = new TestingLeaderRetrievalService(jobMasterAddress, jmLeaderID);
    TestingFatalErrorHandler testingFatalErrorHandler = new TestingFatalErrorHandler();
    final ResourceManager resourceManager = createAndStartResourceManager(resourceManagerLeaderElectionService, jobID, jobMasterLeaderRetrievalService, testingFatalErrorHandler);
    final UUID rmLeaderSessionId = grantResourceManagerLeadership(resourceManagerLeaderElectionService);
    // test throw exception when receive a registration from job master which takes unmatched leaderSessionId
    UUID differentLeaderSessionID = UUID.randomUUID();
    Future<RegistrationResponse> unMatchedLeaderFuture = resourceManager.registerJobManager(differentLeaderSessionID, jmLeaderID, jobMasterAddress, jobID);
    assertTrue(unMatchedLeaderFuture.get(5, TimeUnit.SECONDS) instanceof RegistrationResponse.Decline);
    if (testingFatalErrorHandler.hasExceptionOccurred()) {
        testingFatalErrorHandler.rethrowError();
    }
}
Also used : TestingFatalErrorHandler(org.apache.flink.runtime.util.TestingFatalErrorHandler) TestingLeaderElectionService(org.apache.flink.runtime.leaderelection.TestingLeaderElectionService) TestingLeaderRetrievalService(org.apache.flink.runtime.leaderelection.TestingLeaderRetrievalService) UUID(java.util.UUID) RegistrationResponse(org.apache.flink.runtime.registration.RegistrationResponse) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

Example 9 with TestingLeaderRetrievalService

use of org.apache.flink.runtime.leaderelection.TestingLeaderRetrievalService in project flink by apache.

the class JobClientActorTest method testRegistrationTimeout.

/** Tests that a {@link JobClientActorRegistrationTimeoutException} is thrown when the registration
	 * cannot be performed at the JobManager by the JobAttachmentClientActor. This is here the case, because the
	 * started JobManager never replies to a {@link RegisterJobClient} message.
	 */
@Test(expected = JobClientActorRegistrationTimeoutException.class)
public void testRegistrationTimeout() throws Exception {
    FiniteDuration jobClientActorTimeout = new FiniteDuration(5, TimeUnit.SECONDS);
    FiniteDuration timeout = jobClientActorTimeout.$times(2);
    UUID leaderSessionID = UUID.randomUUID();
    ActorRef jobManager = system.actorOf(Props.create(PlainActor.class, leaderSessionID));
    TestingLeaderRetrievalService testingLeaderRetrievalService = new TestingLeaderRetrievalService(jobManager.path().toString(), leaderSessionID);
    Props jobClientActorProps = JobAttachmentClientActor.createActorProps(testingLeaderRetrievalService, jobClientActorTimeout, false);
    ActorRef jobClientActor = system.actorOf(jobClientActorProps);
    Future<Object> jobExecutionResult = Patterns.ask(jobClientActor, new JobClientMessages.AttachToJobAndWait(testJobGraph.getJobID()), new Timeout(timeout));
    Await.result(jobExecutionResult, timeout);
}
Also used : AttachToJobAndWait(org.apache.flink.runtime.messages.JobClientMessages.AttachToJobAndWait) TestingLeaderRetrievalService(org.apache.flink.runtime.leaderelection.TestingLeaderRetrievalService) ActorRef(akka.actor.ActorRef) JobClientMessages(org.apache.flink.runtime.messages.JobClientMessages) Timeout(akka.util.Timeout) FiniteDuration(scala.concurrent.duration.FiniteDuration) UUID(java.util.UUID) Props(akka.actor.Props) Test(org.junit.Test)

Example 10 with TestingLeaderRetrievalService

use of org.apache.flink.runtime.leaderelection.TestingLeaderRetrievalService in project flink by apache.

the class JobClientActorTest method testConnectionTimeoutWithoutJobManagerForRegistration.

/** Tests that a {@link org.apache.flink.runtime.client.JobClientActorConnectionTimeoutException}
	 * is thrown when the JobAttachmentClientActor attach to a job at the JobManager
	 * but has not connected to a JobManager.
	 */
@Test(expected = JobClientActorConnectionTimeoutException.class)
public void testConnectionTimeoutWithoutJobManagerForRegistration() throws Exception {
    FiniteDuration jobClientActorTimeout = new FiniteDuration(5, TimeUnit.SECONDS);
    FiniteDuration timeout = jobClientActorTimeout.$times(2);
    TestingLeaderRetrievalService testingLeaderRetrievalService = new TestingLeaderRetrievalService();
    Props jobClientActorProps = JobAttachmentClientActor.createActorProps(testingLeaderRetrievalService, jobClientActorTimeout, false);
    ActorRef jobClientActor = system.actorOf(jobClientActorProps);
    Future<Object> jobExecutionResult = Patterns.ask(jobClientActor, new JobClientMessages.AttachToJobAndWait(testJobGraph.getJobID()), new Timeout(timeout));
    Await.result(jobExecutionResult, timeout);
}
Also used : AttachToJobAndWait(org.apache.flink.runtime.messages.JobClientMessages.AttachToJobAndWait) TestingLeaderRetrievalService(org.apache.flink.runtime.leaderelection.TestingLeaderRetrievalService) ActorRef(akka.actor.ActorRef) JobClientMessages(org.apache.flink.runtime.messages.JobClientMessages) Timeout(akka.util.Timeout) FiniteDuration(scala.concurrent.duration.FiniteDuration) Props(akka.actor.Props) Test(org.junit.Test)

Aggregations

TestingLeaderRetrievalService (org.apache.flink.runtime.leaderelection.TestingLeaderRetrievalService)22 Test (org.junit.Test)21 UUID (java.util.UUID)17 ActorRef (akka.actor.ActorRef)13 JobID (org.apache.flink.api.common.JobID)11 FiniteDuration (scala.concurrent.duration.FiniteDuration)10 Props (akka.actor.Props)7 Timeout (akka.util.Timeout)7 TestingHighAvailabilityServices (org.apache.flink.runtime.highavailability.TestingHighAvailabilityServices)7 Time (org.apache.flink.api.common.time.Time)6 ScheduledExecutor (org.apache.flink.runtime.concurrent.ScheduledExecutor)5 JobClientMessages (org.apache.flink.runtime.messages.JobClientMessages)5 LinkedBlockingQueue (java.util.concurrent.LinkedBlockingQueue)4 Configuration (org.apache.flink.configuration.Configuration)4 JobVertexID (org.apache.flink.runtime.jobgraph.JobVertexID)4 LookupKvStateLocation (org.apache.flink.runtime.query.KvStateMessage.LookupKvStateLocation)4 TestingFatalErrorHandler (org.apache.flink.runtime.util.TestingFatalErrorHandler)4 ResourceID (org.apache.flink.runtime.clusterframework.types.ResourceID)3 HeartbeatServices (org.apache.flink.runtime.heartbeat.HeartbeatServices)3 TestingLeaderElectionService (org.apache.flink.runtime.leaderelection.TestingLeaderElectionService)3