Browse Source

[Feature] timed scheduler Improvement (#15449) (#15450)

3.2.1-prepare
liyou 11 months ago committed by GitHub
parent
commit
0f7081be10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      docs/docs/en/guide/project/workflow-definition.md
  2. 13
      docs/docs/zh/guide/project/workflow-definition.md
  3. BIN
      docs/img/new_ui/dev/project/workflow-list.png
  4. BIN
      docs/img/new_ui/dev/project/workflow-time03.png
  5. BIN
      docs/img/new_ui/dev/project/workflow-time04.png
  6. BIN
      docs/img/scheduler_online.png
  7. BIN
      docs/img/timeManagement.png
  8. 1
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
  9. 3
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessDefinition.java
  10. 4
      dolphinscheduler-ui/src/locales/en_US/project.ts
  11. 4
      dolphinscheduler-ui/src/locales/zh_CN/project.ts
  12. 89
      dolphinscheduler-ui/src/views/projects/workflow/definition/components/table-action.tsx
  13. 11
      dolphinscheduler-ui/src/views/projects/workflow/definition/components/timing-modal.tsx
  14. 7
      dolphinscheduler-ui/src/views/projects/workflow/definition/index.tsx
  15. 1
      dolphinscheduler-ui/src/views/projects/workflow/definition/types.ts
  16. 40
      dolphinscheduler-ui/src/views/projects/workflow/definition/use-table.ts

11
docs/docs/en/guide/project/workflow-definition.md

@ -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.
@ -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
docs/docs/zh/guide/project/workflow-definition.md

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

BIN
docs/img/new_ui/dev/project/workflow-list.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 140 KiB

After

Width:  |  Height:  |  Size: 152 KiB

BIN
docs/img/new_ui/dev/project/workflow-time03.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 61 KiB

After

Width:  |  Height:  |  Size: 169 KiB

BIN
docs/img/new_ui/dev/project/workflow-time04.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 KiB

BIN
docs/img/scheduler_online.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
docs/img/timeManagement.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

1
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java

@ -591,6 +591,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
});
Schedule schedule = scheduleMap.get(pd.getCode());
pd.setScheduleReleaseState(schedule == null ? null : schedule.getReleaseState());
pd.setSchedule(schedule);
}
PageInfo<ProcessDefinition> pageInfo = new PageInfo<>(pageNo, pageSize);

3
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessDefinition.java

@ -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
*/

4
dolphinscheduler-ui/src/locales/en_US/project.ts

@ -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',
@ -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',

4
dolphinscheduler-ui/src/locales/zh_CN/project.ts

@ -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: '查看工作流实例',
@ -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: '线上',

89
dolphinscheduler-ui/src/views/projects/workflow/definition/components/table-action.tsx

@ -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>
@ -50,9 +50,9 @@ export default defineComponent({
'versionWorkflow',
'deleteWorkflow',
'releaseWorkflow',
'releaseScheduler',
'copyWorkflow',
'exportWorkflow',
'gotoTimingManage',
'gotoWorkflowTree'
],
setup(props, ctx) {
@ -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,
@ -105,8 +104,8 @@ export default defineComponent({
handleReleaseWorkflow,
handleCopyWorkflow,
handleExportWorkflow,
handleGotoTimingManage,
handleGotoWorkflowTree,
handleReleaseScheduler,
...toRefs(props)
}
},
@ -114,7 +113,7 @@ export default defineComponent({
const { t } = useI18n()
const releaseState = this.row?.releaseState
const scheduleReleaseState = this.row?.scheduleReleaseState
const schedule = this.row?.schedule
return (
<NSpace>
<NTooltip trigger={'hover'}>
@ -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: () =>
@ -214,17 +194,17 @@ 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>
)
@ -232,18 +212,55 @@ export default defineComponent({
</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>
)

11
dolphinscheduler-ui/src/views/projects/workflow/definition/components/timing-modal.tsx

@ -65,6 +65,10 @@ const props = {
type: {
type: String as PropType<String>,
default: 'create'
},
state: {
type: String as PropType<String>,
default: 'OFFLINE'
}
}
@ -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'

7
dolphinscheduler-ui/src/views/projects/workflow/definition/index.tsx

@ -60,8 +60,7 @@ export default defineComponent({
getTableData,
batchDeleteWorkflow,
batchExportWorkflow,
batchCopyWorkflow,
gotoTimingManage
batchCopyWorkflow
} = useTable()
const requestData = () => {
@ -82,7 +81,7 @@ export default defineComponent({
}
const confirmToSetWorkflowTiming = () => {
gotoTimingManage(variables.row)
variables.timingShowRef = true
}
const handleSearch = () => {
@ -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

1
dolphinscheduler-ui/src/views/projects/workflow/definition/types.ts

@ -38,6 +38,7 @@ export interface IDefinitionData {
projectName: any
releaseState: string
scheduleReleaseState: any
schedule: any
tenantCode: any
tenantId: number
timeout: number

40
dolphinscheduler-ui/src/views/projects/workflow/definition/use-table.ts

@ -29,6 +29,7 @@ import {
queryListPaging,
release
} from '@/service/modules/process-definition'
import { offline, online } from '@/service/modules/schedules'
import TableAction from './components/table-action'
import styles from './index.module.scss'
import { NTag, NSpace, NIcon, NButton, NEllipsis, NTooltip } from 'naive-ui'
@ -58,6 +59,8 @@ export function useTable() {
pageSize: ref(10),
searchVal: ref(),
totalPage: ref(1),
timingType: ref('create'),
timingState: ref('OFFLINE'),
showRef: ref(false),
startShowRef: ref(false),
timingShowRef: ref(false),
@ -260,9 +263,9 @@ export function useTable() {
onVersionWorkflow: () => versionWorkflow(row),
onDeleteWorkflow: () => deleteWorkflow(row),
onReleaseWorkflow: () => releaseWorkflow(row),
onReleaseScheduler: () => releaseScheduler(row),
onCopyWorkflow: () => copyWorkflow(row),
onExportWorkflow: () => exportWorkflow(row),
onGotoTimingManage: () => gotoTimingManage(row),
onGotoWorkflowTree: () => gotoWorkflowTree(row)
})
}
@ -287,7 +290,13 @@ export function useTable() {
const timingWorkflow = (row: any) => {
variables.timingShowRef = true
variables.row = row
if (row?.schedule) {
variables.row = row.schedule
variables.timingType = 'update'
variables.timingState = row.scheduleReleaseState
} else {
variables.row = row
}
}
const versionWorkflow = (row: any) => {
@ -368,6 +377,23 @@ export function useTable() {
})
}
const releaseScheduler = (row: any) => {
if (row.schedule) {
let handle = online
if (row.schedule.releaseState === 'ONLINE') {
handle = offline
}
handle(variables.projectCode, row.schedule.id).then(() => {
window.$message.success(t('project.workflow.success'))
getTableData({
pageSize: variables.pageSize,
pageNo: variables.page,
searchVal: variables.searchVal
})
})
}
}
const copyWorkflow = (row: any) => {
const data = {
codes: String(row.code),
@ -419,13 +445,6 @@ export function useTable() {
})
}
const gotoTimingManage = (row: any) => {
router.push({
name: 'workflow-definition-timing',
params: { projectCode: variables.projectCode, definitionCode: row.code }
})
}
const gotoWorkflowTree = (row: any) => {
router.push({
name: 'workflow-definition-tree',
@ -455,7 +474,6 @@ export function useTable() {
getTableData,
batchDeleteWorkflow,
batchExportWorkflow,
batchCopyWorkflow,
gotoTimingManage
batchCopyWorkflow
}
}

Loading…
Cancel
Save