Search in sources :

Example 11 with Timeout

use of akka.util.Timeout 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 12 with Timeout

use of akka.util.Timeout 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)

Example 13 with Timeout

use of akka.util.Timeout in project flink by apache.

the class JobClientActorTest method testConnectionTimeoutAfterJobRegistration.

/** Tests that a {@link JobClientActorConnectionTimeoutException}
	 * is thrown after a successful registration of the client at the JobManager.
	 */
@Test(expected = JobClientActorConnectionTimeoutException.class)
public void testConnectionTimeoutAfterJobRegistration() throws Exception {
    FiniteDuration jobClientActorTimeout = new FiniteDuration(5, TimeUnit.SECONDS);
    FiniteDuration timeout = jobClientActorTimeout.$times(2);
    UUID leaderSessionID = UUID.randomUUID();
    ActorRef jobManager = system.actorOf(Props.create(JobAcceptingActor.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 AttachToJobAndWait(testJobGraph.getJobID()), new Timeout(timeout));
    Future<Object> waitFuture = Patterns.ask(jobManager, new RegisterTest(), new Timeout(timeout));
    Await.result(waitFuture, timeout);
    jobManager.tell(PoisonPill.getInstance(), ActorRef.noSender());
    Await.result(jobExecutionResult, timeout);
}
Also used : TestingLeaderRetrievalService(org.apache.flink.runtime.leaderelection.TestingLeaderRetrievalService) ActorRef(akka.actor.ActorRef) Timeout(akka.util.Timeout) FiniteDuration(scala.concurrent.duration.FiniteDuration) UUID(java.util.UUID) Props(akka.actor.Props) AttachToJobAndWait(org.apache.flink.runtime.messages.JobClientMessages.AttachToJobAndWait) Test(org.junit.Test)

Example 14 with Timeout

use of akka.util.Timeout in project flink by apache.

the class JobClientActorTest method testGuaranteedAnswerIfJobClientDies.

/** Tests that JobClient throws an Exception if the JobClientActor dies and can't answer to
	 * {@link akka.actor.Identify} message anymore.
	 */
@Test
public void testGuaranteedAnswerIfJobClientDies() throws Exception {
    FiniteDuration timeout = new FiniteDuration(2, TimeUnit.SECONDS);
    UUID leaderSessionID = UUID.randomUUID();
    ActorRef jobManager = system.actorOf(Props.create(JobAcceptingActor.class, leaderSessionID));
    TestingLeaderRetrievalService testingLeaderRetrievalService = new TestingLeaderRetrievalService(jobManager.path().toString(), leaderSessionID);
    JobListeningContext jobListeningContext = JobClient.submitJob(system, clientConfig, testingLeaderRetrievalService, testJobGraph, timeout, false, getClass().getClassLoader());
    Future<Object> waitFuture = Patterns.ask(jobManager, new RegisterTest(), new Timeout(timeout));
    Await.result(waitFuture, timeout);
    // kill the job client actor which has been registered at the JobManager
    jobListeningContext.getJobClientActor().tell(PoisonPill.getInstance(), ActorRef.noSender());
    try {
        // should not block but return an error
        JobClient.awaitJobResult(jobListeningContext);
        Assert.fail();
    } catch (JobExecutionException e) {
    // this is what we want
    }
}
Also used : TestingLeaderRetrievalService(org.apache.flink.runtime.leaderelection.TestingLeaderRetrievalService) ActorRef(akka.actor.ActorRef) Timeout(akka.util.Timeout) FiniteDuration(scala.concurrent.duration.FiniteDuration) UUID(java.util.UUID) Test(org.junit.Test)

Example 15 with Timeout

use of akka.util.Timeout in project flink by apache.

the class JobClientActorTest method testConnectionTimeoutWithoutJobManagerForSubmission.

/** Tests that a {@link org.apache.flink.runtime.client.JobClientActorConnectionTimeoutException}
	 * is thrown when the JobSubmissionClientActor wants to submit a job but has not connected to a JobManager.
	 *
	 * @throws Exception
	 */
@Test(expected = JobClientActorConnectionTimeoutException.class)
public void testConnectionTimeoutWithoutJobManagerForSubmission() throws Exception {
    FiniteDuration jobClientActorTimeout = new FiniteDuration(5, TimeUnit.SECONDS);
    FiniteDuration timeout = jobClientActorTimeout.$times(2);
    TestingLeaderRetrievalService testingLeaderRetrievalService = new TestingLeaderRetrievalService();
    Props jobClientActorProps = JobSubmissionClientActor.createActorProps(testingLeaderRetrievalService, jobClientActorTimeout, false, clientConfig);
    ActorRef jobClientActor = system.actorOf(jobClientActorProps);
    Future<Object> jobExecutionResult = Patterns.ask(jobClientActor, new JobClientMessages.SubmitJobAndWait(testJobGraph), new Timeout(timeout));
    Await.result(jobExecutionResult, timeout);
}
Also used : 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

Timeout (akka.util.Timeout)18 ActorRef (akka.actor.ActorRef)11 FiniteDuration (scala.concurrent.duration.FiniteDuration)11 Props (akka.actor.Props)8 TestingLeaderRetrievalService (org.apache.flink.runtime.leaderelection.TestingLeaderRetrievalService)7 JobClientMessages (org.apache.flink.runtime.messages.JobClientMessages)7 Test (org.junit.Test)7 UUID (java.util.UUID)5 IOException (java.io.IOException)4 ProgramInvocationException (org.apache.flink.client.program.ProgramInvocationException)4 TimeoutException (java.util.concurrent.TimeoutException)3 AttachToJobAndWait (org.apache.flink.runtime.messages.JobClientMessages.AttachToJobAndWait)3 ArrayList (java.util.ArrayList)2 JobStatusMessage (org.apache.flink.runtime.client.JobStatusMessage)2 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)2 ActorSelection (akka.actor.ActorSelection)1 JavaTestKit (akka.testkit.JavaTestKit)1 File (java.io.File)1 JobID (org.apache.flink.api.common.JobID)1 Configuration (org.apache.flink.configuration.Configuration)1