dolphinscheduler节点二次开发需要改动的部分

dolphinscheduler节点二次开发需要改动的部分

前端

  1. dolphinscheduler-ui/public/images/task-icons/目录下新增两个节点的logo图片,一个为激活状态的一个为非激活状态的,如下。

  1. 修改文件dolphinscheduler-ui/src/views/projects/task/constants/task-type.ts

    • 给TaskType新增可取的类型,如下

    • 给TASK_TYPES_MAP增加新节点的映射信息,如下

    修改完成之后,新节点的名字就会在dolphin组件的侧边栏显示出来啦。

  2. 修改文件dolphinscheduler-ui/src/views/projects/workflow/components/dag/dag.module.scss

    • .draggable样式下的.sidebar-icon样式中分别添加图标激活和没激活的路径。取名规范必须为.icon-后面接先前在TASK_TYPES_MAP中新增的内容的小写。

    修改完成之后,新节点的logo就会在dolphin组件的侧边栏显示出来啦。

  3. 在目录dolphinscheduler-ui/src/views/projects/task/components/node/fields下新增节点字段的ts文件

    如下所示:期间需要新增国际化文件中的字段信息。

    /*
     * Licensed to the Apache Software Foundation (ASF) under one or more
     * contributor license agreements.  See the NOTICE file distributed with
     * this work for additional information regarding copyright ownership.
     * The ASF licenses this file to You under the Apache License, Version 2.0
     * (the "License"); you may not use this file except in compliance with
     * the License.  You may obtain a copy of the License at
     *
     *    http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     */
    import {useI18n} from 'vue-i18n'
    import {useCustomParams, useResources} from '.'
    import type {IJsonItem} from '../types'
    import { ref, onMounted, watch } from 'vue'
    
    export function useEmailSender(model: { [field: string]: any }): IJsonItem[] {
        const otherStatementSpan = ref(22)
    
        const {t} = useI18n()
        return [
            {
              type: 'input',
              field: 'subject',
              name: t('project.node.email_sender_subject')
            },
            {
                type: 'editor',
                field: 'messageTemplate',
                name: t('project.node.email_sender_message_template'),
            },
            {
                type: 'multi-input',
                field: 'emails',
                name: t('project.node.email_sender_emails'),
                span: otherStatementSpan,
                props: {
                    placeholder: t('project.node.email_sender_emails'),
                    type: 'textarea',
                    autosize: { minRows: 1 }
                }
            },
            useResources(),
            ...useCustomParams({model, field: 'localParams', isSimple: false})
        ]
    }
    
  4. 在目录dolphinscheduler-ui/src/views/projects/task/components/node/tasks下新增节点字段的ts文件

    如下所示:

    /*
     * Licensed to the Apache Software Foundation (ASF) under one or more
     * contributor license agreements.  See the NOTICE file distributed with
     * this work for additional information regarding copyright ownership.
     * The ASF licenses this file to You under the Apache License, Version 2.0
     * (the "License"); you may not use this file except in compliance with
     * the License.  You may obtain a copy of the License at
     *
     *    http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     */
    
    import { reactive } from 'vue'
    import * as Fields from '../fields/index'
    import type { IJsonItem, INodeData } from '../types'
    import { ITaskData } from '../types'
    
    export function useEmailSender({
      projectCode,
      from = 0,
      readonly,
      data
    }: {
      projectCode: number
      from?: number
      readonly?: boolean
      data?: ITaskData
    }) {
      const model = reactive({
        name: '',
        taskType: 'EMAIL_SENDER',
        flag: 'YES',
        description: '',
        timeoutFlag: false,
        timeoutNotifyStrategy: ['WARN'],
        localParams: [],
        environmentCode: null,
        failRetryInterval: 1,
        failRetryTimes: 0,
        workerGroup: 'default',
        delayTime: 0,
        timeout: 30,
        messageTemplate: '',
        emails: [],
        subject: ''
      } as INodeData)
    
      return {
        json: [
          Fields.useName(from),
          ...Fields.useTaskDefinition({ projectCode, from, readonly, data, model }),
          Fields.useRunFlag(),
          Fields.useDescription(),
          Fields.useTaskPriority(),
          Fields.useWorkerGroup(),
          Fields.useEnvironmentName(model, !data?.id),
          ...Fields.useTaskGroup(model, projectCode),
          ...Fields.useFailed(),
          Fields.useDelayTime(model),
          ...Fields.useTimeoutAlarm(model),
          ...Fields.useEmailSender(model),
          Fields.usePreTasks()
        ] as IJsonItem[],
        model
      }
    }
    

    ps: 这里存在不容易察觉到的细节,尤其注意。

这个地方一定要跟着改,不然页面上显示的字段,还是之前复制的那个节点的字段。

  1. 修改文件dolphinscheduler-ui/src/views/projects/task/components/node/fields/index.ts

    新增一个export导出就好了

  2. 修改文件dolphinscheduler-ui/src/views/projects/task/components/node/tasks/index.ts

    新增一个映射关系,如下:

    前面这个部分必须和第二步时候的TASK_TYPES_MAP这个map中的alias一致。

  3. 修改文件dolphinscheduler-ui/src/views/projects/task/components/node/format-data.ts

    formatParams方法中增加新增节点的表单赋值代码,不加的话,页面上填的值,提交执行的时候,后端是拿不到的。

    如下所示:

  4. 修改文件dolphinscheduler-ui/src/views/projects/task/components/node/types.ts

    在这个文件中添加,我们在5步时候新增的字段在interface ITaskParams这个实体里面添加就好了。

至此,前端基本上改的就差不多了,下面是后端。


后端

  1. 在目录dolphinscheduler-task-plugin/dolphinscheduler-task-patsnap/src/main/java/org/apache/dolphinscheduler/plugin/task下新增节点对应的文件夹。

  2. 新增类XXXParameters继承CustomBaseParameters

    注意点如下:

    • 如果其中有字段的内容可能是占位符,运行时需要替换,可以标上@ReplacePlaceholders这个注解,目前这个注解支持String类型和List类型的字段的占位符自动替换。
    • 一定要重写checkParameters这个方法,不然到时候填完表单信息保存的时候会报错,节点信息无效的。
  3. 新增类XXXChannel继承 CustomBaseChannel

    重写一下createTask和parseParameters方法。

  4. 新增类XXXChannelFactory,需要继承CustomBaseChannelFactory

    重写getNamecreate方法。

    getName的内容必须和前端第二步中改的TASK_TYPES_MAP中的alias的名字一致。

  5. 新增类XXXTask继承CustomBaseTask

    需要重写方法handlePatsnapTask,这个节点想做什么事情,都在这个方法里面实现。

    注意点如下:

    • 节点正常运行完成之后一定要加setExitStatusCode(TaskConstants.EXIT_CODE_SUCCESS);这行代码,告知节点运行success
    • 节点运行异常一定要执行setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);这行代码。
    • 运行完成之后需要调用releaseResource();来释放资源。
    • 如果想要实现取消逻辑,需要重写方法cancel,前端点击取消的时候,会执行到这个方法里面。
  • 20
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
DolphinScheduler是一款开源的分布式任务调度系统,可以实现自动化地调度和执行各种任务。如果需要DolphinScheduler进行二次开发,并进行打包,需要按照以下步骤进行: 1. 克隆DolphinScheduler的源代码:在Github上找到DolphinScheduler的仓库并将其克隆到本地。 2. 将开发代码添加到源代码中:根据自己的需求,在克隆的源代码中添加新的功能或修改现有功能。可以根据实际情况修改调度器、执行器、调度API等。 3. 配置、编译和打包:根据二次开发所需的配置信息,修改`conf`目录下的相关配置文件。使用maven对代码进行编译,可以运行`mvn clean package -Dmaven.test.skip=true`命令进行打包,该命令会在`target`目录下生成打包结果。 4. 部署和运行:将打包的结果部署到服务器上,包括调度服务器和执行器节点。根据DolphinScheduler的部署文档将相关的配置文件、依赖库、打包结果等拷贝到相应的位置。运行DolphinScheduler的启动脚本以启动调度服务器和执行器节点。 5. 测试和验证:根据自己的需求进行相应的测试和验证,确保二次开发的功能能够正常运行。进行功能测试、性能测试、兼容性测试等,确保系统的稳定性和可靠性。 需要注意的是,二次开发需要DolphinScheduler的源代码有一定的了解和熟悉。在进行二次开发之前,可以先阅读官方文档、源代码以及相关的社区讨论,这样能更好地理解整个系统的架构和设计理念,更方便进行二次开发和定制。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值