Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to design an execution engine for a sequence of tasks

I am trying to code a problem in Java where I have to execute a bunch of tasks.

Problem

Execute a job which consists of multiple tasks and those tasks have dependencies among them.

A job will have a list of tasks and each such task will further have a list of successor tasks (Each successor task will have its own successor tasks - you can see the recursive nature here). Each successor task can start its execution if -

  1. It is configured to be executed on partial execution of its predecessor task. In this case, predecessor task will notify that it has completed partially and my successor tasks can start

  2. Successful completion of its predecessor task.

Example

Job having 2 initial tasks A and B. A has 2 successor tasks M and N. B has 1 successor task P. P has 2 successor tasks Y and Z.

M can start on partial completion of its predecessor task A. Z can start on partial completion of its predecessor task P. N, P and Y can start only on completion of their predecessor tasks A, B and P respectively.

Tasks Hierarchy (A and B can start in parallel)

I have to design the execution of such a workflow/job. In the design we have to acknowledge the partial completion event sent by a predecessor task so that its successor task can be started. How should I go about it? Is there any design pattern which suits this problem in concurrency?

like image 819
user1522820 Avatar asked Dec 08 '14 13:12

user1522820


Video Answer


1 Answers

Take a look at akka - http://akka.io

using akka you create actors (event driven, concurrent entities that process messages asynchronously)

each task can be represented as an actor (you choose when to fire it up)

you can trigger other actors (tasks) on partial complete or full complete (actually you can trigger them whenever you want)

like image 127
Nimrod007 Avatar answered Oct 21 '22 09:10

Nimrod007