use of akka.actor.ActorRef in project flink by apache.
the class JobClientActorTest method testConnectionTimeoutAfterJobSubmission.
/** Tests that a {@link org.apache.flink.runtime.client.JobClientActorConnectionTimeoutException}
* is thrown after a successful job submission if the JobManager dies.
*
* @throws Exception
*/
@Test(expected = JobClientActorConnectionTimeoutException.class)
public void testConnectionTimeoutAfterJobSubmission() 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 = JobSubmissionClientActor.createActorProps(testingLeaderRetrievalService, jobClientActorTimeout, false, clientConfig);
ActorRef jobClientActor = system.actorOf(jobClientActorProps);
Future<Object> jobExecutionResult = Patterns.ask(jobClientActor, new JobClientMessages.SubmitJobAndWait(testJobGraph), 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);
}
use of akka.actor.ActorRef in project flink by apache.
the class JobClientActorTest method testSubmissionTimeout.
/** Tests that a {@link JobClientActorSubmissionTimeoutException} is thrown when the job cannot
* be submitted by the JobSubmissionClientActor. This is here the case, because the started JobManager
* never replies to a {@link SubmitJob} message.
*
* @throws Exception
*/
@Test(expected = JobClientActorSubmissionTimeoutException.class)
public void testSubmissionTimeout() 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 = 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);
}
use of akka.actor.ActorRef in project flink by apache.
the class AkkaKvStateLocationLookupServiceTest method testLeaderSessionIdChange.
/**
* Tests that messages are properly decorated with the leader session ID.
*/
@Test
public void testLeaderSessionIdChange() throws Exception {
TestingLeaderRetrievalService leaderRetrievalService = new TestingLeaderRetrievalService();
Queue<LookupKvStateLocation> received = new LinkedBlockingQueue<>();
AkkaKvStateLocationLookupService lookupService = new AkkaKvStateLocationLookupService(leaderRetrievalService, testActorSystem, TIMEOUT, new AkkaKvStateLocationLookupService.DisabledLookupRetryStrategyFactory());
lookupService.start();
// Create test actors with random leader session IDs
KvStateLocation expected1 = new KvStateLocation(new JobID(), new JobVertexID(), 8282, "salt");
UUID leaderSessionId1 = UUID.randomUUID();
ActorRef testActor1 = LookupResponseActor.create(received, leaderSessionId1, expected1);
String testActorAddress1 = AkkaUtils.getAkkaURL(testActorSystem, testActor1);
KvStateLocation expected2 = new KvStateLocation(new JobID(), new JobVertexID(), 22321, "pepper");
UUID leaderSessionId2 = UUID.randomUUID();
ActorRef testActor2 = LookupResponseActor.create(received, leaderSessionId1, expected2);
String testActorAddress2 = AkkaUtils.getAkkaURL(testActorSystem, testActor2);
JobID jobId = new JobID();
//
// Notify about first leader
//
leaderRetrievalService.notifyListener(testActorAddress1, leaderSessionId1);
KvStateLocation location = Await.result(lookupService.getKvStateLookupInfo(jobId, "rock"), TIMEOUT);
assertEquals(expected1, location);
assertEquals(1, received.size());
verifyLookupMsg(received.poll(), jobId, "rock");
//
// Notify about second leader
//
leaderRetrievalService.notifyListener(testActorAddress2, leaderSessionId2);
location = Await.result(lookupService.getKvStateLookupInfo(jobId, "roll"), TIMEOUT);
assertEquals(expected2, location);
assertEquals(1, received.size());
verifyLookupMsg(received.poll(), jobId, "roll");
}
use of akka.actor.ActorRef in project flink by apache.
the class AkkaKvStateLocationLookupServiceTest method testUnexpectedResponseType.
@Test
public void testUnexpectedResponseType() throws Exception {
TestingLeaderRetrievalService leaderRetrievalService = new TestingLeaderRetrievalService();
Queue<LookupKvStateLocation> received = new LinkedBlockingQueue<>();
AkkaKvStateLocationLookupService lookupService = new AkkaKvStateLocationLookupService(leaderRetrievalService, testActorSystem, TIMEOUT, new AkkaKvStateLocationLookupService.DisabledLookupRetryStrategyFactory());
lookupService.start();
// Create test actors with random leader session IDs
String expected = "unexpected-response-type";
ActorRef testActor = LookupResponseActor.create(received, null, expected);
String testActorAddress = AkkaUtils.getAkkaURL(testActorSystem, testActor);
leaderRetrievalService.notifyListener(testActorAddress, null);
try {
Await.result(lookupService.getKvStateLookupInfo(new JobID(), "spicy"), TIMEOUT);
fail("Did not throw expected Exception");
} catch (Throwable ignored) {
// Expected
}
}
use of akka.actor.ActorRef in project flink by apache.
the class WebRuntimeMonitorITCase method startWebRuntimeMonitor.
private WebRuntimeMonitor startWebRuntimeMonitor(TestingCluster flink) throws Exception {
ActorSystem jmActorSystem = flink.jobManagerActorSystems().get().head();
ActorRef jmActor = flink.jobManagerActors().get().head();
// Needs to match the leader address from the leader retrieval service
String jobManagerAddress = AkkaUtils.getAkkaURL(jmActorSystem, jmActor);
File logDir = temporaryFolder.newFolder("log");
Path logFile = Files.createFile(new File(logDir, "jobmanager.log").toPath());
Files.createFile(new File(logDir, "jobmanager.out").toPath());
// Web frontend on random port
Configuration config = new Configuration();
config.setInteger(ConfigConstants.JOB_MANAGER_WEB_PORT_KEY, 0);
config.setString(ConfigConstants.JOB_MANAGER_WEB_LOG_PATH_KEY, logFile.toString());
WebRuntimeMonitor webMonitor = new WebRuntimeMonitor(config, flink.createLeaderRetrievalService(), jmActorSystem);
webMonitor.start(jobManagerAddress);
flink.waitForActorsToBeAlive();
return webMonitor;
}
Aggregations