Skip to content

acquire task workflow

Michael Kamm edited this page May 16, 2017 · 1 revision

Aquire_Task_Workflow

Before acquiring a Task a DeployInfo was provided. This DeployInfo contains a version string - each Task from one specific .jar file has been tagged with this string. In order to get a suitable Task (a Task that requires a specific version) the target needs to provide its version string. To do that you need to include the version string into the GetTask(version: String) message and send that message to the InstanceActor.

The InstanceActor then searches for an suitable instance (an instance that contains Tasks that have been tagged with the corresponding version string). If a suitable instance is found, the message is being forwarded to that instance. If not, the InstanceActor responds with a NoMoreTasks message, which allows the target to e.g. shutdown its VM and to request a new DeployInfo.

Every suitable TaskActor receives the GetTask(version : String) message - if the Task has not been executed yet the TaskActor offers its Task through a SendTask(task : Task) message. The target therefore will receive many offers - usually the first Task that is offered will be the chosen one; all other Tasks should be rejected through a Failure(new Exception()) message (It is important that there is an Exception in the Failure message, otherwise Akka does weird stuff on the TaskActor side [soemthing like Success(Failure(...))], which would result in unexpected behaviour).

If the target is happy with one of the offers, it should request an executor from the TaskActor through a AcquireExecutor(vmActorRef : ActorRef) message. This message contains the reference of the target since this information is relevant to the TaskExecutorActor (the executor needs to know where the requests of the task should be send to).

The TaskActor then tries to create a new TaskExecutorActor - if the creation was successful the reference of the TaskExecutorActor is send to the target through a Executor(executor : ActorRef) message; if the creation was not successful, than the target is informed about that through a CannotGetExecutor message. In this case the target can again acquire a new task through GetTask(version : String).

The target must supervise the TaskExecutorActor through context.watch(ActorRef of executor) in order to get informed once the task execution is done.

Once the target receives a Terminated message it can request a new Task through GetTask(version : String)

Clone this wiki locally