use of org.apache.flink.runtime.instance.AkkaActorGateway in project flink by apache.
the class JobManagerRetriever method notifyLeaderAddress.
@Override
public void notifyLeaderAddress(final String leaderAddress, final UUID leaderSessionID) {
if (leaderAddress != null && !leaderAddress.equals("")) {
try {
final Promise<Tuple2<ActorGateway, Integer>> leaderGatewayPortPromise = new scala.concurrent.impl.Promise.DefaultPromise<>();
synchronized (waitLock) {
leaderGatewayPortFuture = leaderGatewayPortPromise.future();
waitLock.notifyAll();
}
LOG.info("New leader reachable under {}:{}.", leaderAddress, leaderSessionID);
AkkaUtils.getActorRefFuture(leaderAddress, actorSystem, lookupTimeout).flatMap(new Mapper<ActorRef, Future<Tuple2<ActorGateway, Object>>>() {
@Override
public Future<Tuple2<ActorGateway, Object>> apply(ActorRef jobManagerRef) {
ActorGateway leaderGateway = new AkkaActorGateway(jobManagerRef, leaderSessionID);
Future<Object> webMonitorPort = leaderGateway.ask(JobManagerMessages.getRequestWebMonitorPort(), timeout);
return Futures.successful(leaderGateway).zip(webMonitorPort);
}
}, actorSystem.dispatcher()).onComplete(new OnComplete<Tuple2<ActorGateway, Object>>() {
@Override
public void onComplete(Throwable failure, Tuple2<ActorGateway, Object> success) throws Throwable {
if (failure == null) {
if (success._2() instanceof ResponseWebMonitorPort) {
int webMonitorPort = ((ResponseWebMonitorPort) success._2()).port();
leaderGatewayPortPromise.success(new Tuple2<>(success._1(), webMonitorPort));
} else {
leaderGatewayPortPromise.failure(new Exception("Received the message " + success._2() + " as response to " + JobManagerMessages.getRequestWebMonitorPort() + ". But a message of type " + ResponseWebMonitorPort.class + " was expected."));
}
} else {
LOG.warn("Failed to retrieve leader gateway and port.", failure);
leaderGatewayPortPromise.failure(failure);
}
}
}, actorSystem.dispatcher());
} catch (Exception e) {
handleError(e);
}
}
}
use of org.apache.flink.runtime.instance.AkkaActorGateway in project flink by apache.
the class JobSubmissionClientActor method tryToSubmitJob.
private void tryToSubmitJob() {
LOG.info("Sending message to JobManager {} to submit job {} ({}) and wait for progress", jobManager.path().toString(), jobGraph.getName(), jobGraph.getJobID());
Futures.future(new Callable<Object>() {
@Override
public Object call() throws Exception {
ActorGateway jobManagerGateway = new AkkaActorGateway(jobManager, leaderSessionID);
LOG.info("Upload jar files to job manager {}.", jobManager.path());
try {
jobGraph.uploadUserJars(jobManagerGateway, timeout, clientConfig);
} catch (IOException exception) {
getSelf().tell(decorateMessage(new JobManagerMessages.JobResultFailure(new SerializedThrowable(new JobSubmissionException(jobGraph.getJobID(), "Could not upload the jar files to the job manager.", exception)))), ActorRef.noSender());
}
LOG.info("Submit job to the job manager {}.", jobManager.path());
jobManager.tell(decorateMessage(new JobManagerMessages.SubmitJob(jobGraph, ListeningBehaviour.EXECUTION_RESULT_AND_STATE_CHANGES)), getSelf());
// issue a SubmissionTimeout message to check that we submit the job within
// the given timeout
getContext().system().scheduler().scheduleOnce(timeout, getSelf(), decorateMessage(JobClientMessages.getSubmissionTimeout()), getContext().dispatcher(), ActorRef.noSender());
return null;
}
}, getContext().dispatcher());
}
use of org.apache.flink.runtime.instance.AkkaActorGateway in project flink by apache.
the class TaskManagerTest method testUpdateTaskInputPartitionsFailure.
/**
* Tests that the TaskManager sends a proper exception back to the sender if the trigger stack
* trace message fails.
*/
@Test
public void testUpdateTaskInputPartitionsFailure() throws Exception {
ActorGateway jobManager = null;
ActorGateway taskManager = null;
try {
final ExecutionAttemptID executionAttemptId = new ExecutionAttemptID();
ActorRef jm = system.actorOf(Props.create(SimpleJobManager.class, leaderSessionID));
jobManager = new AkkaActorGateway(jm, leaderSessionID);
taskManager = TestingUtils.createTaskManager(system, jobManager, new Configuration(), true, true);
TaskDeploymentDescriptor tdd = createTaskDeploymentDescriptor(new JobID(), "test job", new JobVertexID(), executionAttemptId, new SerializedValue<>(new ExecutionConfig()), "test task", 1, 0, 1, 0, new Configuration(), new Configuration(), BlockingNoOpInvokable.class.getName(), Collections.<ResultPartitionDeploymentDescriptor>emptyList(), Collections.<InputGateDeploymentDescriptor>emptyList(), Collections.<BlobKey>emptyList(), Collections.<URL>emptyList(), 0);
Future<Object> submitResponse = taskManager.ask(new SubmitTask(tdd), timeout);
Await.result(submitResponse, timeout);
Future<Object> partitionUpdateResponse = taskManager.ask(new TaskMessages.UpdateTaskSinglePartitionInfo(executionAttemptId, new IntermediateDataSetID(), new InputChannelDeploymentDescriptor(new ResultPartitionID(), ResultPartitionLocation.createLocal())), timeout);
try {
Await.result(partitionUpdateResponse, timeout);
fail("The update task input partitions message should have failed.");
} catch (Exception e) {
// expected
}
} finally {
TestingUtils.stopActor(jobManager);
TestingUtils.stopActor(taskManager);
}
}
use of org.apache.flink.runtime.instance.AkkaActorGateway in project flink by apache.
the class TaskManagerTest method testGateChannelEdgeMismatch.
@Test
public void testGateChannelEdgeMismatch() {
new JavaTestKit(system) {
{
ActorGateway jobManager = null;
ActorGateway taskManager = null;
final ActorGateway testActorGateway = new AkkaActorGateway(getTestActor(), leaderSessionID);
try {
ActorRef jm = system.actorOf(Props.create(SimpleJobManager.class, leaderSessionID));
jobManager = new AkkaActorGateway(jm, leaderSessionID);
taskManager = TestingUtils.createTaskManager(system, jobManager, new Configuration(), true, true);
final ActorGateway tm = taskManager;
final JobID jid = new JobID();
JobVertexID vid1 = new JobVertexID();
JobVertexID vid2 = new JobVertexID();
final ExecutionAttemptID eid1 = new ExecutionAttemptID();
final ExecutionAttemptID eid2 = new ExecutionAttemptID();
final TaskDeploymentDescriptor tdd1 = createTaskDeploymentDescriptor(jid, "TestJob", vid1, eid1, new SerializedValue<>(new ExecutionConfig()), "Sender", 1, 0, 1, 0, new Configuration(), new Configuration(), Tasks.Sender.class.getName(), Collections.<ResultPartitionDeploymentDescriptor>emptyList(), Collections.<InputGateDeploymentDescriptor>emptyList(), new ArrayList<BlobKey>(), Collections.<URL>emptyList(), 0);
final TaskDeploymentDescriptor tdd2 = createTaskDeploymentDescriptor(jid, "TestJob", vid2, eid2, new SerializedValue<>(new ExecutionConfig()), "Receiver", 7, 2, 7, 0, new Configuration(), new Configuration(), Tasks.Receiver.class.getName(), Collections.<ResultPartitionDeploymentDescriptor>emptyList(), Collections.<InputGateDeploymentDescriptor>emptyList(), new ArrayList<BlobKey>(), Collections.<URL>emptyList(), 0);
new Within(d) {
@Override
protected void run() {
try {
tm.tell(new SubmitTask(tdd1), testActorGateway);
tm.tell(new SubmitTask(tdd2), testActorGateway);
expectMsgEquals(Acknowledge.get());
expectMsgEquals(Acknowledge.get());
tm.tell(new TestingTaskManagerMessages.NotifyWhenTaskRemoved(eid1), testActorGateway);
tm.tell(new TestingTaskManagerMessages.NotifyWhenTaskRemoved(eid2), testActorGateway);
expectMsgEquals(true);
expectMsgEquals(true);
tm.tell(TestingTaskManagerMessages.getRequestRunningTasksMessage(), testActorGateway);
Map<ExecutionAttemptID, Task> tasks = expectMsgClass(TestingTaskManagerMessages.ResponseRunningTasks.class).asJava();
assertEquals(0, tasks.size());
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
};
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
} finally {
// shut down the actors
TestingUtils.stopActor(taskManager);
TestingUtils.stopActor(jobManager);
}
}
};
}
use of org.apache.flink.runtime.instance.AkkaActorGateway in project flink by apache.
the class TaskManagerTest method testStackTraceSampleFailure.
/**
* Tests that the TaskManager sends a proper exception back to the sender if the trigger stack
* trace message fails.
*/
@Test
public void testStackTraceSampleFailure() throws Exception {
ActorGateway jobManager = null;
ActorGateway taskManager = null;
try {
ActorRef jm = system.actorOf(Props.create(SimpleJobManager.class, leaderSessionID));
jobManager = new AkkaActorGateway(jm, leaderSessionID);
taskManager = TestingUtils.createTaskManager(system, jobManager, new Configuration(), true, true);
Future<Object> stackTraceResponse = taskManager.ask(new TriggerStackTraceSample(0, new ExecutionAttemptID(), 0, Time.milliseconds(1L), 0), timeout);
try {
Await.result(stackTraceResponse, timeout);
fail("The trigger stack trace message should have failed.");
} catch (IllegalStateException e) {
// expected
}
} finally {
TestingUtils.stopActor(jobManager);
TestingUtils.stopActor(taskManager);
}
}
Aggregations