Unverified Commit 0df7c671 authored by bao liang's avatar bao liang Committed by GitHub
Browse files

[New Feature] add conditions task #205 (#2003)

* add funtion conditions task

* update conditions tasks

* update conditions for ui

* update conditions

* update

* revert

* update
parent 84409b57
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -34,7 +34,8 @@ public enum TaskType {
     * 8 FLINK
     * 9 HTTP
     * 10 DATAX
     * 11 SQOOP
     * 11 CONDITIONS
     * 12 SQOOP
     */
    SHELL(0, "shell"),
    SQL(1, "sql"),
@@ -47,7 +48,8 @@ public enum TaskType {
    FLINK(8, "flink"),
    HTTP(9, "http"),
    DATAX(10, "datax"),
    SQOOP(11, "sqoop");
    CONDITIONS(11, "conditions"),
    SQOOP(12, "sqoop");

    TaskType(int code, String descp){
        this.code = code;
+10 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package org.apache.dolphinscheduler.common.model;

import org.apache.dolphinscheduler.common.enums.DependResult;
import org.apache.dolphinscheduler.common.enums.ExecutionStatus;

/**
 * dependent item
@@ -28,6 +29,7 @@ public class DependentItem {
    private String cycle;
    private String dateValue;
    private DependResult dependResult;
    private ExecutionStatus status;


    public String getKey(){
@@ -77,4 +79,12 @@ public class DependentItem {
    public void setDependResult(DependResult dependResult) {
        this.dependResult = dependResult;
    }

    public ExecutionStatus getStatus() {
        return status;
    }

    public void setStatus(ExecutionStatus status) {
        this.status = status;
    }
}
+19 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package org.apache.dolphinscheduler.common.model;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.enums.Priority;
import org.apache.dolphinscheduler.common.enums.TaskTimeoutStrategy;
import org.apache.dolphinscheduler.common.enums.TaskType;
import org.apache.dolphinscheduler.common.task.TaskTimeoutParameter;
import org.apache.dolphinscheduler.common.utils.CollectionUtils;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
@@ -108,6 +109,11 @@ public class TaskNode {
  @JsonSerialize(using = JSONUtils.JsonDataSerializer.class)
  private String dependence;


  @JsonDeserialize(using = JSONUtils.JsonDataDeserializer.class)
  @JsonSerialize(using = JSONUtils.JsonDataSerializer.class)
  private String conditionResult;

  /**
   *  task instance priority
   */
@@ -230,6 +236,7 @@ public class TaskNode {
            Objects.equals(extras, taskNode.extras) &&
            Objects.equals(runFlag, taskNode.runFlag) &&
            Objects.equals(dependence, taskNode.dependence) &&
            Objects.equals(conditionResult, taskNode.conditionResult) &&
            Objects.equals(workerGroupId, taskNode.workerGroupId) &&
            CollectionUtils.equalLists(depList, taskNode.depList);
  }
@@ -292,6 +299,10 @@ public class TaskNode {
    return new TaskTimeoutParameter(false);
  }

  public boolean isConditionsTask(){
    return this.getType().toUpperCase().equals(TaskType.CONDITIONS.toString());
  }

  @Override
  public String toString() {
    return "TaskNode{" +
@@ -321,4 +332,12 @@ public class TaskNode {
  public void setWorkerGroupId(int workerGroupId) {
    this.workerGroupId = workerGroupId;
  }

  public String getConditionResult() {
    return conditionResult;
  }

  public void setConditionResult(String conditionResult) {
    this.conditionResult = conditionResult;
  }
}
+79 −0
Original line number Diff line number Diff line
/*
 * 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.
 */
package org.apache.dolphinscheduler.common.task.conditions;

import org.apache.dolphinscheduler.common.enums.DependentRelation;
import org.apache.dolphinscheduler.common.model.DependentTaskModel;
import org.apache.dolphinscheduler.common.task.AbstractParameters;

import java.util.List;

public class ConditionsParameters extends AbstractParameters {

    //depend node list and state, only need task name
    private List<DependentTaskModel> dependTaskList;
    private DependentRelation dependRelation;

    // node list to run when success
    private List<String> successNode;

    // node list to run when failed
    private List<String> failedNode;


    @Override
    public boolean checkParameters() {
        return true;
    }

    @Override
    public List<String> getResourceFilesList() {
        return null;
    }

    public List<DependentTaskModel> getDependTaskList() {
        return dependTaskList;
    }

    public void setDependTaskList(List<DependentTaskModel> dependTaskList) {
        this.dependTaskList = dependTaskList;
    }

    public DependentRelation getDependRelation() {
        return dependRelation;
    }

    public void setDependRelation(DependentRelation dependRelation) {
        this.dependRelation = dependRelation;
    }

    public List<String> getSuccessNode() {
        return successNode;
    }

    public void setSuccessNode(List<String> successNode) {
        this.successNode = successNode;
    }

    public List<String> getFailedNode() {
        return failedNode;
    }

    public void setFailedNode(List<String> failedNode) {
        this.failedNode = failedNode;
    }
}
+3 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package org.apache.dolphinscheduler.common.utils;

import org.apache.dolphinscheduler.common.enums.TaskType;
import org.apache.dolphinscheduler.common.task.AbstractParameters;
import org.apache.dolphinscheduler.common.task.conditions.ConditionsParameters;
import org.apache.dolphinscheduler.common.task.dependent.DependentParameters;
import org.apache.dolphinscheduler.common.task.datax.DataxParameters;
import org.apache.dolphinscheduler.common.task.flink.FlinkParameters;
@@ -72,6 +73,8 @@ public class TaskParametersUtils {
          return JSONUtils.parseObject(parameter, HttpParameters.class);
        case DATAX:
          return JSONUtils.parseObject(parameter, DataxParameters.class);
        case CONDITIONS:
          return JSONUtils.parseObject(parameter, ConditionsParameters.class);
        case SQOOP:
          return JSONUtils.parseObject(parameter, SqoopParameters.class);
        default:
Loading