如何为一系列任务设计执行引擎 [英] How to design an execution engine for a sequence of tasks

查看:249
本文介绍了如何为一系列任务设计执行引擎的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试用Java编写一个问题,其中我必须执行一堆任务。

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

问题

执行包含多个任务的任务,这些任务具有

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. 它配置为在部分执行其前任任务时执行。在这种情况下,前任任务将通知它已部分完成,我的后继任务可以开始

  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

前任任务成功完成。

示例

具有两个初始任务A的工作A具有2个后续任务M和N。B具有1个后续任务P。P具有2个后续任务Y和Z。

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可以在部分完成M它的前任任务A。
Z可以在其前任任务P的部分完成后开始。
N,P和Y只能分别在其前任任务A,B和P完成后开始。

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.

我必须设计这种工作流程/作业的执行方式。在设计中,我们必须确认前任任务发送的部分完成事件,以便可以启动其后继任务。我应该怎么做?

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?

推荐答案

看看akka- http://akka.io

使用akka创建角色(事件驱动的并发实体)

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)

这篇关于如何为一系列任务设计执行引擎的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆