zhongjiajie commented on code in PR #10247:
URL: https://github.com/apache/dolphinscheduler/pull/10247#discussion_r884388341
##########
docs/docs/en/guide/task/switch.md:
##########
@@ -14,26 +15,42 @@ Drag from the toolbar <img src="/img/switch.png"
width="20"/> task node to canv
- Descriptive information: Describe the function of the node.
- Task priority: When the number of worker threads is insufficient, execute in
the order of priority from high to low, and tasks with the same priority will
execute in a first-in first-out order.
- Worker grouping: Assign tasks to the machines of the worker group to
execute. If `Default` is selected, randomly select a worker machine for
execution.
+- Environment name: The environment in Security, if not configured, it will
not be used.
+- Task group name: The group in Resources, if not configured, it will not be
used.
- Times of failed retry attempts: The number of times the task failed to
resubmit. You can select from drop-down or fill-in a number.
- Failed retry interval: The time interval for resubmitting the task after a
failed task. You can select from drop-down or fill-in a number.
+- Delay execution time: Task delay execution time.
- Timeout alarm: Check the timeout alarm and timeout failure. When the task
runs exceed the "timeout", an alarm email will send and the task execution will
fail.
- Condition: You can configure multiple conditions for the switch task. When
the conditions are satisfied, execute the configured branch. You can configure
multiple different conditions to satisfy different businesses.
- Branch flow: The default branch flow, when all the conditions are not
satisfied, execute this branch flow.
-## Detail
+## Task Example
+
+This is demonstrated using one switch task and three shell tasks.
+
+
+
+### 1. Create a workflow
Review Comment:
We should avoid using number in markdown title, the prefix `###` is for the
same function @huangchenguang123 and cc @QuakeWang
```suggestion
### Create a workflow
```
##########
docs/docs/en/guide/task/switch.md:
##########
@@ -14,26 +15,42 @@ Drag from the toolbar <img src="/img/switch.png"
width="20"/> task node to canv
- Descriptive information: Describe the function of the node.
- Task priority: When the number of worker threads is insufficient, execute in
the order of priority from high to low, and tasks with the same priority will
execute in a first-in first-out order.
- Worker grouping: Assign tasks to the machines of the worker group to
execute. If `Default` is selected, randomly select a worker machine for
execution.
+- Environment name: The environment in Security, if not configured, it will
not be used.
+- Task group name: The group in Resources, if not configured, it will not be
used.
- Times of failed retry attempts: The number of times the task failed to
resubmit. You can select from drop-down or fill-in a number.
- Failed retry interval: The time interval for resubmitting the task after a
failed task. You can select from drop-down or fill-in a number.
+- Delay execution time: Task delay execution time.
- Timeout alarm: Check the timeout alarm and timeout failure. When the task
runs exceed the "timeout", an alarm email will send and the task execution will
fail.
- Condition: You can configure multiple conditions for the switch task. When
the conditions are satisfied, execute the configured branch. You can configure
multiple different conditions to satisfy different businesses.
- Branch flow: The default branch flow, when all the conditions are not
satisfied, execute this branch flow.
-## Detail
+## Task Example
+
+This is demonstrated using one switch task and three shell tasks.
+
+
+
+### 1. Create a workflow
Review Comment:
same as others places
##########
docs/docs/zh/guide/task/switch.md:
##########
@@ -1,37 +1,57 @@
# Switch
-Switch是一个条件判断节点,依据[全局变量](../parameter/global.md)的值和用户所编写的表达式判断结果执行对应分支。
+Switch 是一个条件判断节点,依据[全局变量](../parameter/global.md)的值和用户所编写的表达式判断结果执行对应分支。
+**注意**使用 javax.script.ScriptEngine.eval 执行表达式。
## 创建任务
-
-拖动工具栏中的<img src="/img/switch.png"
width="20"/>任务节点到画板中即能完成任务创建,**注意**switch任务创建后,要先配置上下游,才能配置任务分支的参数
+点击项目管理 -> 项目名称 -> 工作流定义,点击"创建工作流"按钮,进入 DAG 编辑页面。
+拖动工具栏中的<img src="/img/switch.png" width="20"/>任务节点到画板中即能完成任务创建。
+**注意** switch 任务创建后,要先配置上下游,才能配置任务分支的参数。
## 任务参数
- 节点名称:一个工作流定义中的节点名称是唯一的。
- 运行标志:标识这个节点是否能正常调度,如果不需要执行,可以打开禁止执行开关。
- 描述信息:描述该节点的功能。
-- 任务优先级:worker线程数不足时,根据优先级从高到低依次执行,优先级一样时根据先进先出原则执行。
-- Worker分组:任务分配给worker组的机器机执行,选择Default,会随机选择一台worker机执行。
+- 任务优先级:worker 线程数不足时,根据优先级从高到低依次执行,优先级一样时根据先进先出原则执行。
+- Worker 分组:任务分配给 worker 组的机器机执行,选择 Default,会随机选择一台 worker 机执行。
+- 环境名称:安全中心中配置的环境,不配置则不使用。
+- 任务组名称:资源中心中配置的任务组,不配置则不使用。
- 失败重试次数:任务失败重新提交的次数,支持下拉和手填。
- 失败重试间隔:任务失败重新提交任务的时间间隔,支持下拉和手填。
-- 超时告警:勾选超时告警、超时失败,当任务超过"超时时长"后,会发送告警邮件并且任务执行失败.
-- 条件:可以为switch任务配置多个条件,当条件满足时,就会执行指定的分支,可以配置多个不同的条件来满足不同的业务
-- 分支流转:默认的流转内容,当**条件**中的内容为全部不符合要求时,则运行**分支流转**中指定的分支
+- 延时执行时间:任务延迟执行的时间。
+- 超时告警:勾选超时告警、超时失败,当任务超过"超时时长"后,会发送告警邮件并且任务执行失败。
+- 条件:可以为switch任务配置多个条件,当条件满足时,就会执行指定的分支,可以配置多个不同的条件来满足不同的业务,使用字符串判断时需要使用""。
+- 分支流转:默认的流转内容,当**条件**中的内容为全部不符合要求时,则运行**分支流转**中指定的分支。
+
+## 任务样例
+
+这里使用一个 switch 任务以及三个 shell 任务来演示。
+
+### 1、创建工作流
+
+新建 switch 任务,以及下游的三个 shell 任务。shell 任务没有要求。
+switch 任务需要和下游任务连线配置关系后,才可以进行下游任务的选择。
+
+
+
+### 2、设置条件
+
+配置条件和默认分支,满足条件会走指定分支,都不满足则走默认分支。
+图中如果变量的值为 "A" 则执行分支 taskA,如果变量的值为 "B" 则执行分支 taskB ,都不满足则执行 default。
+
+
-## 详细流程
+条件使用了全局变量,请参考[全局变量](../parameter/global.md)。
+这里配置全局变量的值为 A。
-假设我们三个任务,其依赖关系是 `A -> B -> [C, D]` 其中task_a是shell任务,task_b是switch任务
+
-- 任务A中通过[全局变量](../parameter/global.md)定义了名为`id`的全局变量,声明方式为`${setValue(id=1)}`
--
任务B增加条件,使用上游声明的全局变量实现条件判断(注意:只要直接、非直接上游在switch运行前对全局变量赋值,switch运行时就可以获取该全局变量)。下面我们想要实现当id为1时,运行任务C,其他运行任务D
- - 配置当全局变量`id=1`时,运行任务C。则在任务B的条件中编辑`${id} == 1`,分支流转选择`C`
- - 对于其他任务,在分支流转中选择`D`
+如果执行正确,那么 taskA 会被正确执行。
-最终switch任务的配置如下
+### 3、执行
-
+执行,并且查看是否符合预期。可以看到符合预期,执行了指定的下游任务 taskA。
-## 相关任务
+
Review Comment:
Maybe we should still using the old style start with `/img` until we merge
https://github.com/apache/dolphinscheduler-website/pull/789 WDYT
@huangchenguang123
```suggestion

```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]