Skip to content

Commit

Permalink
[Feature] timed scheduler Improvement (#15449) (#15450)
Browse files Browse the repository at this point in the history
  • Loading branch information
ly109974 authored Jan 11, 2024
1 parent 309c8c9 commit 0f7081b
Show file tree
Hide file tree
Showing 16 changed files with 125 additions and 59 deletions.
11 changes: 8 additions & 3 deletions docs/docs/en/guide/project/workflow-definition.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,12 @@ Click `Project Management -> Workflow -> Workflow Definition` to enter the workf
### Actions Supported by a Single Workflow

- **Edit:** Only "Offline" workflow definitions can be edited. Workflow DAG editing is the same as [Create Workflow Definition](#create-workflow-definition)
- **Run:** Only workflow in the online state can run. See [Run Workflow](#run-the-workflow) for the operation steps.
- **Online:** When the workflow status is "Offline", used to make workflow online. Only the workflow in the "Online" state can run, but cannot edit.
- **Offline:** When the workflow status is "Online", used to make workflow offline. Only the workflow in the "Offline" state can be edited, but cannot run.
- **Run:** Only workflow in the online state can run. See [Run Workflow](#run-the-workflow) for the operation steps.
- **Timing:** Timing can only set to online workflows, and the system automatically schedules to run the workflow on time. The status after creating a timing setting is "offline", and the timing must set online on the timing management page to make effect. See [Workflow Timing](#workflow-schedule) for timing operation steps.
- **Timing:** Timing can only set to online workflows, and the system automatically schedules to run the workflow on time. The status after creating a timing setting is "offline", You need to click the <img src="../../../../img/scheduler_online.png" width="20"/>button on the right to go online to take effect. See [Workflow Timing](#workflow-schedule) for timing operation steps.
- **Timing Online:** Scheduled online, schedule can only be clicked after the schedule is created and the workflow status is "online".
- **Timing Offline:** Scheduled offline.
- **Timing Management:** The timing management page can edit, online or offline and delete timing.
- **Delete:** Delete the workflow definition. In the same project, only the workflow definition created by yourself can be deleted, and the workflow definition of other users cannot be deleted. If you need to delete it, please contact the user who created it or the administrator.
- **Download:** Download workflow definition to local.
Expand Down Expand Up @@ -179,10 +181,13 @@ Description of workflow operating parameters:

- Click the "Create" button to create the timing. Now the timing status is "**Offline**" and the timing needs to be **Online** to make effect.

- Schedule online: Click the `Timing Management` button <img src="../../../../img/timeManagement.png" width="35"/>, enter the timing management page, click the `online` button, the timing status will change to `online`, as shown in the below figure, the workflow makes effect regularly.
- Schedule online: Click the `Timing online` button <img src="../../../../img/scheduler_online.png" width="30"/>, click the `online` button, the timing status will change to `online`, as shown in the below figure, the workflow makes effect regularly.

![workflow-time03](../../../../img/new_ui/dev/project/workflow-time03.png)

- View the Schedule Timing:After the scheduled time goes online, you can check the current timing situation through the "Timing" button<img src="../../../../img/timing.png" width="35"/>. But it cannot be modified, as shown in the below figure.
![workflow-time04](../../../../img/new_ui/dev/project/workflow-time04.png)

## Import Workflow

Click `Project Management -> Workflow -> Workflow Definition` to enter the workflow definition page, click the `Import Workflow` button to import the local workflow file, the workflow definition list displays the imported workflow and the status is offline.
13 changes: 8 additions & 5 deletions docs/docs/zh/guide/project/workflow-definition.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,12 @@
### 单个工作流支持的操作

- **编辑:** 只能编辑"下线"的工作流定义。工作流DAG编辑同创建工作流定义。
- **运行:** 只有上线的工作流能运行。运行操作步骤见运行工作流
- **上线:** 工作流状态为"下线"时,上线工作流,只有"上线"状态的工作流能运行,但不能编辑。
- **下线:** 工作流状态为"上线"时,下线工作流,下线状态的工作流可以编辑,但不能运行。
- **运行** 只有上线的工作流能运行。运行操作步骤见运行工作流
- **定时** 只有上线的工作流能设置定时,系统自动定时调度工作流运行。创建定时后的状态为"下线",需在定时管理页面上线定时才生效。定时操作步骤见工作流定时
- **定时管理** 定时管理页面可编辑、上线/下线、删除定时
- **定时** 工作流设置定时,系统自动定时调度工作流运行。创建定时后的状态为"下线",需要点击右边<img src="../../../../img/scheduler_online.png" width="20"/>按钮上线定时才生效。定时操作步骤见[工作流定时](#工作流定时)
- **定时上线** 定时调度上线,只能定时创建后且工作流状态为"上线"时才可点击。
- **定时下线** 定时调度下线
- **删除:** 删除工作流定义。在同一个项目中,只能删除自己创建的工作流定义,其他用户的工作流定义不能进行删除,如果需要删除请联系创建用户或者管理员。
- **下载:** 下载工作流定义到本地。
- **复制:** 在当前项目下,根据当前工作流复制出一个新的工作流,新工作流的名称会在原工作流名称的基础上加上后缀`_copy_<date>`
Expand Down Expand Up @@ -163,10 +164,12 @@

- 点击"创建"按钮,创建定时成功,此时定时状态为"**下线**",定时需**上线**才生效。

- 定时上线:点击"定时管理"按钮<img src="../../../../img/timeManagement.png" width="35"/>,进入定时管理页面,点击"上线"按钮,定时状态变为"上线",如下图所示,工作流定时生效。

- 定时上线:点击"定时上线"按钮<img src="../../../../img/scheduler_online.png" width="30"/>,点击"上线"按钮,定时状态变为"上线",如下图选中所示,工作流定时生效。
![workflow-time03](../../../../img/new_ui/dev/project/workflow-time03.png)

- 查看定时:定时上线后可以通过"定时"按钮<img src="../../../../img/timing.png" width="35"/>,查看当前定时情况。但是不可修改,如图所示。
![workflow-time04](../../../../img/new_ui/dev/project/workflow-time04.png)

## 导入工作流

点击项目管理->工作流->工作流定义,进入工作流定义页面,点击"导入工作流"按钮,导入本地工作流文件,工作流定义列表显示导入的工作流,状态为下线。
Binary file modified docs/img/new_ui/dev/project/workflow-list.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/img/new_ui/dev/project/workflow-time03.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/new_ui/dev/project/workflow-time04.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/scheduler_online.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/img/timeManagement.png
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,7 @@ public PageInfo<ProcessDefinition> queryProcessDefinitionListPaging(@NonNull Use
});
Schedule schedule = scheduleMap.get(pd.getCode());
pd.setScheduleReleaseState(schedule == null ? null : schedule.getReleaseState());
pd.setSchedule(schedule);
}

PageInfo<ProcessDefinition> pageInfo = new PageInfo<>(pageNo, pageSize);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ public class ProcessDefinition {
@TableField(exist = false)
private ReleaseState scheduleReleaseState;

@TableField(exist = false)
private Schedule schedule;

/**
* process warning time out. unit: minute
*/
Expand Down
4 changes: 4 additions & 0 deletions dolphinscheduler-ui/src/locales/en_US/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ export default {
timezone: 'Timezone',
up_line: 'Online',
down_line: 'Offline',
time_up_line: 'Scheduler Online',
time_down_line: 'Scheduler Offline',
copy_workflow: 'Copy Workflow',
copy_workflow_name: 'Copy workflow name',
visit_workflow_instances: 'Visit workflow instances',
Expand Down Expand Up @@ -233,6 +235,8 @@ export default {
want_to_set_timing: 'Would you like to set the workflow timing?',
confirm_to_online: 'Confirm to make the workflow online?',
confirm_to_offline: 'Confirm to make the workflow offline?',
time_to_online: 'Confirm to make the Scheduler online?',
time_to_offline: 'Confirm to make the Scheduler offline?',
},
task: {
on_line: 'Online',
Expand Down
4 changes: 4 additions & 0 deletions dolphinscheduler-ui/src/locales/zh_CN/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ export default {
timezone: '时区',
up_line: '上线',
down_line: '下线',
time_up_line: '定时上线',
time_down_line: '定时下线',
copy_workflow: '复制工作流',
copy_workflow_name: '复制工作流名称',
visit_workflow_instances: '查看工作流实例',
Expand Down Expand Up @@ -231,6 +233,8 @@ export default {
want_to_set_timing: '现在想去配置该工作流定时?',
confirm_to_online: '是否确定上线该工作流?',
confirm_to_offline: '是否确定下线该工作流?',
time_to_online: '是否确定上线该定时?',
time_to_offline: '是否确定下线该定时?',
},
task: {
on_line: '线上',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ import {
PlayCircleOutlined,
ClockCircleOutlined,
CopyOutlined,
FieldTimeOutlined,
ExportOutlined,
ApartmentOutlined,
UploadOutlined
UploadOutlined,
ArrowUpOutlined,
ArrowDownOutlined
} from '@vicons/antd'
import { useI18n } from 'vue-i18n'
import { IDefinitionData } from '../types'

const props = {
row: {
type: Object as PropType<IDefinitionData>
Expand All @@ -50,9 +50,9 @@ export default defineComponent({
'versionWorkflow',
'deleteWorkflow',
'releaseWorkflow',
'releaseScheduler',
'copyWorkflow',
'exportWorkflow',
'gotoTimingManage',
'gotoWorkflowTree'
],
setup(props, ctx) {
Expand Down Expand Up @@ -88,14 +88,13 @@ export default defineComponent({
ctx.emit('exportWorkflow')
}

const handleGotoTimingManage = () => {
ctx.emit('gotoTimingManage')
}

const handleGotoWorkflowTree = () => {
ctx.emit('gotoWorkflowTree')
}

const handleReleaseScheduler = () => {
ctx.emit('releaseScheduler')
}
return {
handleEditWorkflow,
handleStartWorkflow,
Expand All @@ -105,16 +104,16 @@ export default defineComponent({
handleReleaseWorkflow,
handleCopyWorkflow,
handleExportWorkflow,
handleGotoTimingManage,
handleGotoWorkflowTree,
handleReleaseScheduler,
...toRefs(props)
}
},
render() {
const { t } = useI18n()
const releaseState = this.row?.releaseState
const scheduleReleaseState = this.row?.scheduleReleaseState

const schedule = this.row?.schedule
return (
<NSpace>
<NTooltip trigger={'hover'}>
Expand Down Expand Up @@ -158,25 +157,6 @@ export default defineComponent({
)
}}
</NTooltip>
<NTooltip trigger={'hover'}>
{{
default: () => t('project.workflow.timing'),
trigger: () => (
<NButton
size='small'
type='info'
tag='div'
circle
onClick={this.handleTimingWorkflow}
disabled={releaseState !== 'ONLINE' || !!scheduleReleaseState}
>
<NIcon>
<ClockCircleOutlined />
</NIcon>
</NButton>
)
}}
</NTooltip>
<NTooltip trigger={'hover'}>
{{
default: () =>
Expand Down Expand Up @@ -214,36 +194,73 @@ export default defineComponent({
</NTooltip>
<NTooltip trigger={'hover'}>
{{
default: () => t('project.workflow.copy_workflow'),
default: () => t('project.workflow.timing'),
trigger: () => (
<NButton
size='small'
type='info'
tag='div'
circle
onClick={this.handleCopyWorkflow}
onClick={this.handleTimingWorkflow}
>
<NIcon>
<CopyOutlined />
<ClockCircleOutlined />
</NIcon>
</NButton>
)
}}
</NTooltip>
<NTooltip trigger={'hover'}>
{{
default: () => t('project.workflow.cron_manage'),
default: () =>
scheduleReleaseState === 'ONLINE'
? t('project.workflow.time_down_line')
: t('project.workflow.time_up_line'),
trigger: () => (
<NPopconfirm onPositiveClick={this.handleReleaseScheduler}>
{{
default: () =>
scheduleReleaseState === 'ONLINE'
? t('project.workflow.time_to_offline')
: t('project.workflow.time_to_online'),
trigger: () => (
<NButton
size='small'
type={
scheduleReleaseState === 'ONLINE' ? 'warning' : 'error'
}
tag='div'
circle
class='btn-publish'
disabled={!schedule || releaseState !== 'ONLINE'}
>
<NIcon>
{scheduleReleaseState === 'ONLINE' ? (
<ArrowDownOutlined />
) : (
<ArrowUpOutlined />
)}
</NIcon>
</NButton>
)
}}
</NPopconfirm>
)
}}
</NTooltip>
<NTooltip trigger={'hover'}>
{{
default: () => t('project.workflow.copy_workflow'),
trigger: () => (
<NButton
size='small'
type='info'
tag='div'
circle
disabled={releaseState === 'OFFLINE'}
onClick={this.handleGotoTimingManage}
onClick={this.handleCopyWorkflow}
>
<NIcon>
<FieldTimeOutlined />
<CopyOutlined />
</NIcon>
</NButton>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ const props = {
type: {
type: String as PropType<String>,
default: 'create'
},
state: {
type: String as PropType<String>,
default: 'OFFLINE'
}
}

Expand Down Expand Up @@ -331,8 +335,13 @@ export default defineComponent({
onCancel={this.hideModal}
onConfirm={this.handleTiming}
confirmLoading={this.saving}
confirmDisabled={this.$props.state === 'ONLINE'}
>
<NForm ref='timingFormRef' rules={this.rules}>
<NForm
ref='timingFormRef'
rules={this.rules}
disabled={this.$props.state === 'ONLINE'}
>
<NFormItem
label={t('project.workflow.start_and_stop_time')}
path='startEndTime'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ export default defineComponent({
getTableData,
batchDeleteWorkflow,
batchExportWorkflow,
batchCopyWorkflow,
gotoTimingManage
batchCopyWorkflow
} = useTable()

const requestData = () => {
Expand All @@ -82,7 +81,7 @@ export default defineComponent({
}

const confirmToSetWorkflowTiming = () => {
gotoTimingManage(variables.row)
variables.timingShowRef = true
}

const handleSearch = () => {
Expand Down Expand Up @@ -295,6 +294,8 @@ export default defineComponent({
<TimingModal
v-model:row={this.row}
v-model:show={this.timingShowRef}
v-model:type={this.timingType}
v-model:state={this.timingState}
onUpdateList={this.handleUpdateList}
/>
<VersionModal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export interface IDefinitionData {
projectName: any
releaseState: string
scheduleReleaseState: any
schedule: any
tenantCode: any
tenantId: number
timeout: number
Expand Down
Loading

0 comments on commit 0f7081b

Please sign in to comment.