task execution

Hi Lars

Took a bit longer than expected fitting things in with Xmas but I’ve created a new task execution service based on Spring wrapper of java.util.concurrent and uploaded to lp:~dhis2-devs-core/+junk/dhis2-xml-ng. Not much documentation yet but you can get a good idea from the unit tests. There’s probably a few things to add and refactor but I must push on now (rather than try and get the world’s best task executor). If you look at the beans you can see that the concurrency strategy is configurable there. For the moment spawning new thread per task is the most straightforward, but for highly scalable applications we might want to use threadpool. Both work but in the latter case we do need to cater for tasks being refused and determine optimal size of pool.

The idea is that any class implementing Task (like import or datamart or what have you) must provide a setter for a message queue and a call() method. Task execution is then managed by the TaskExecutor. Tasks “belong” to users. A user can at any time check whether the task has emitted any messages and display them. For example the getStatus ajax arrangement as we have currently, with small modification can display these messages periodically as the task executes. Will need to implement a watchdog task to clean up stale tasks later. Haven’t decided the best strategy for this yet.

If you (or anyone else) gets a chance you might want to look this over. There may be some functionality from amplecode cave process which is missing, but for the most part this seems reasonably clean and robust.

Now back to the xml framework stuff …