From c7038a087ca3bc45b68005686c3647f36d1d8f8a Mon Sep 17 00:00:00 2001 From: JinyLeeChina <42576980+JinyLeeChina@users.noreply.github.com> Date: Sat, 16 Jan 2021 23:57:59 +0800 Subject: [PATCH] [Feature][JsonSplit] task and relation entity (#4475) * task and relation entity * task and relation entity * task and relation entity * task and relation entity * task and relation entity * add timeout flag Co-authored-by: JinyLeeChina <297062848@qq.com> --- .../common/enums/ConditionType.java | 51 +++ .../common/enums/TimeoutFlag.java | 49 +++ .../dao/entity/ProcessTaskRelation.java | 252 ++++++++++++ .../dao/entity/ProcessTaskRelationLog.java | 279 +++++++++++++ .../dao/entity/TaskDefinition.java | 359 ++++++++++++++++ .../dao/entity/TaskDefinitionLog.java | 385 ++++++++++++++++++ sql/dolphinscheduler_mysql.sql | 24 +- 7 files changed, 1387 insertions(+), 12 deletions(-) create mode 100644 dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/ConditionType.java create mode 100644 dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/TimeoutFlag.java create mode 100644 dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessTaskRelation.java create mode 100644 dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessTaskRelationLog.java create mode 100644 dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskDefinition.java create mode 100644 dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskDefinitionLog.java diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/ConditionType.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/ConditionType.java new file mode 100644 index 0000000000..3842aedca5 --- /dev/null +++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/ConditionType.java @@ -0,0 +1,51 @@ +/* + * 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.enums; + +import com.baomidou.mybatisplus.annotation.EnumValue; + +/** + * condition type + */ +public enum ConditionType { + /** + * 0 none + * 1 judge + * 2 delay + */ + NONE(0, "none"), + JUDGE(1, "judge"), + DELAY(2, "delay"); + + ConditionType(int code, String desc) { + this.code = code; + this.desc = desc; + } + + @EnumValue + private final int code; + private final String desc; + + public int getCode() { + return code; + } + + public String getDesc() { + return desc; + } +} diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/TimeoutFlag.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/TimeoutFlag.java new file mode 100644 index 0000000000..4449487a02 --- /dev/null +++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/TimeoutFlag.java @@ -0,0 +1,49 @@ +/* + * 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.enums; + +import com.baomidou.mybatisplus.annotation.EnumValue; + +/** + * timeout flag + */ +public enum TimeoutFlag { + /** + * 0 close + * 1 open + */ + CLOSE(0, "close"), + OPEN(1, "open"); + + + TimeoutFlag(int code, String desc){ + this.code = code; + this.desc = desc; + } + + @EnumValue + private final int code; + private final String desc; + + public int getCode() { + return code; + } + + public String getDesc() { + return desc; + } +} diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessTaskRelation.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessTaskRelation.java new file mode 100644 index 0000000000..6d1dd77902 --- /dev/null +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessTaskRelation.java @@ -0,0 +1,252 @@ +/* + * 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.dao.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; +import com.fasterxml.jackson.annotation.JsonFormat; +import org.apache.dolphinscheduler.common.enums.ConditionType; +import org.apache.dolphinscheduler.common.process.Property; +import org.apache.dolphinscheduler.common.utils.JSONUtils; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * process task relation + */ +@TableName("t_ds_process_task_relation") +public class ProcessTaskRelation { + + /** + * id + */ + @TableId(value = "id", type = IdType.AUTO) + private int id; + + /** + * name + */ + private String name; + + /** + * version + */ + private int version; + + /** + * project code + */ + private long projectCode; + + /** + * process code + */ + private long processDefinitionCode; + + /** + * pre project code + */ + private long preProjectCode; + + /** + * pre task code + */ + private long preTaskCode; + + /** + * post project code + */ + private long postProjectCode; + + /** + * post task code + */ + private long postTaskCode; + + /** + * condition type + */ + private ConditionType conditionType; + + /** + * condition parameters + */ + private String conditionParams; + + /** + * condition parameter list + */ + @TableField(exist = false) + private List conditionParamList; + + /** + * condition parameter map + */ + @TableField(exist = false) + private Map conditionParamMap; + + /** + * create time + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date createTime; + + /** + * update time + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date updateTime; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + + public String getConditionParams() { + return conditionParams; + } + + public void setConditionParams(String conditionParams) { + if (conditionParams == null) { + this.conditionParamList = new ArrayList<>(); + } else { + this.conditionParamList = JSONUtils.toList(conditionParams, Property.class); + } + this.conditionParams = conditionParams; + } + + public List getConditionParamList() { + return conditionParamList; + } + + public void setConditionParamList(List conditionParamList) { + this.conditionParams = JSONUtils.toJsonString(conditionParamList); + this.conditionParamList = conditionParamList; + } + + public Map getConditionParamMap() { + if (conditionParamMap == null && StringUtils.isNotEmpty(conditionParams)) { + List propList = JSONUtils.toList(conditionParams, Property.class); + conditionParamMap = propList.stream().collect(Collectors.toMap(Property::getProp, Property::getValue)); + } + + return conditionParamMap; + } + + public void setConditionParamMap(Map conditionParamMap) { + this.conditionParamMap = conditionParamMap; + } + + public int getVersion() { + return version; + } + + public void setVersion(int version) { + this.version = version; + } + + public long getProjectCode() { + return projectCode; + } + + public void setProjectCode(long projectCode) { + this.projectCode = projectCode; + } + + public long getProcessDefinitionCode() { + return processDefinitionCode; + } + + public void setProcessDefinitionCode(long processDefinitionCode) { + this.processDefinitionCode = processDefinitionCode; + } + + public long getPreProjectCode() { + return preProjectCode; + } + + public void setPreProjectCode(long preProjectCode) { + this.preProjectCode = preProjectCode; + } + + public long getPreTaskCode() { + return preTaskCode; + } + + public void setPreTaskCode(long preTaskCode) { + this.preTaskCode = preTaskCode; + } + + public long getPostProjectCode() { + return postProjectCode; + } + + public void setPostProjectCode(long postProjectCode) { + this.postProjectCode = postProjectCode; + } + + public long getPostTaskCode() { + return postTaskCode; + } + + public void setPostTaskCode(long postTaskCode) { + this.postTaskCode = postTaskCode; + } + + public ConditionType getConditionType() { + return conditionType; + } + + public void setConditionType(ConditionType conditionType) { + this.conditionType = conditionType; + } +} diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessTaskRelationLog.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessTaskRelationLog.java new file mode 100644 index 0000000000..27f156cb8f --- /dev/null +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessTaskRelationLog.java @@ -0,0 +1,279 @@ +/* + * 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.dao.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; +import com.fasterxml.jackson.annotation.JsonFormat; +import org.apache.dolphinscheduler.common.enums.ConditionType; +import org.apache.dolphinscheduler.common.process.Property; +import org.apache.dolphinscheduler.common.utils.JSONUtils; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * process task relation log + */ +@TableName("t_ds_process_task_relation_log") +public class ProcessTaskRelationLog { + + /** + * id + */ + @TableId(value = "id", type = IdType.AUTO) + private int id; + + /** + * name + */ + private String name; + + /** + * version + */ + private int version; + + /** + * project code + */ + private long projectCode; + + /** + * process code + */ + private long processDefinitionCode; + + /** + * pre project code + */ + private long preProjectCode; + + /** + * pre task code + */ + private long preTaskCode; + + /** + * post project code + */ + private long postProjectCode; + + /** + * post task code + */ + private long postTaskCode; + + /** + * condition type + */ + private ConditionType conditionType; + + /** + * condition parameters + */ + private String conditionParams; + + /** + * condition parameter list + */ + @TableField(exist = false) + private List conditionParamList; + + /** + * condition parameter map + */ + @TableField(exist = false) + private Map conditionParamMap; + + /** + * operator user id + */ + private int operator; + + /** + * operate time + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date operateTime; + + /** + * create time + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date createTime; + + /** + * update time + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date updateTime; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + + public String getConditionParams() { + return conditionParams; + } + + public void setConditionParams(String conditionParams) { + if (conditionParams == null) { + this.conditionParamList = new ArrayList<>(); + } else { + this.conditionParamList = JSONUtils.toList(conditionParams, Property.class); + } + this.conditionParams = conditionParams; + } + + public List getConditionParamList() { + return conditionParamList; + } + + public void setConditionParamList(List conditionParamList) { + this.conditionParams = JSONUtils.toJsonString(conditionParamList); + this.conditionParamList = conditionParamList; + } + + public Map getConditionParamMap() { + if (conditionParamMap == null && StringUtils.isNotEmpty(conditionParams)) { + List propList = JSONUtils.toList(conditionParams, Property.class); + conditionParamMap = propList.stream().collect(Collectors.toMap(Property::getProp, Property::getValue)); + } + + return conditionParamMap; + } + + public void setConditionParamMap(Map conditionParamMap) { + this.conditionParamMap = conditionParamMap; + } + + public int getVersion() { + return version; + } + + public void setVersion(int version) { + this.version = version; + } + + public long getProjectCode() { + return projectCode; + } + + public void setProjectCode(long projectCode) { + this.projectCode = projectCode; + } + + public long getProcessDefinitionCode() { + return processDefinitionCode; + } + + public void setProcessDefinitionCode(long processDefinitionCode) { + this.processDefinitionCode = processDefinitionCode; + } + + public long getPreProjectCode() { + return preProjectCode; + } + + public void setPreProjectCode(long preProjectCode) { + this.preProjectCode = preProjectCode; + } + + public long getPreTaskCode() { + return preTaskCode; + } + + public void setPreTaskCode(long preTaskCode) { + this.preTaskCode = preTaskCode; + } + + public long getPostProjectCode() { + return postProjectCode; + } + + public void setPostProjectCode(long postProjectCode) { + this.postProjectCode = postProjectCode; + } + + public long getPostTaskCode() { + return postTaskCode; + } + + public void setPostTaskCode(long postTaskCode) { + this.postTaskCode = postTaskCode; + } + + public ConditionType getConditionType() { + return conditionType; + } + + public void setConditionType(ConditionType conditionType) { + this.conditionType = conditionType; + } + + public int getOperator() { + return operator; + } + + public void setOperator(int operator) { + this.operator = operator; + } + + public Date getOperateTime() { + return operateTime; + } + + public void setOperateTime(Date operateTime) { + this.operateTime = operateTime; + } +} diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskDefinition.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskDefinition.java new file mode 100644 index 0000000000..3789fed38b --- /dev/null +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskDefinition.java @@ -0,0 +1,359 @@ +/* + * 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.dao.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; +import com.fasterxml.jackson.annotation.JsonFormat; +import org.apache.dolphinscheduler.common.enums.*; +import org.apache.dolphinscheduler.common.process.Property; +import org.apache.dolphinscheduler.common.utils.JSONUtils; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + + +/** + * task definition + */ +@TableName("t_ds_task_definition") +public class TaskDefinition { + + /** + * id + */ + @TableId(value = "id", type = IdType.AUTO) + private int id; + + /** + * code + */ + private long code; + + /** + * name + */ + private String name; + + /** + * version + */ + private int version; + + /** + * description + */ + private String description; + + /** + * project code + */ + private long projectCode; + + /** + * task user id + */ + private int userId; + + /** + * task type + */ + private TaskType taskType; + + /** + * user defined parameters + */ + private String taskParams; + + /** + * user defined parameter list + */ + @TableField(exist = false) + private List taskParamList; + + /** + * user define parameter map + */ + @TableField(exist = false) + private Map taskParamMap; + + /** + * task is valid: yes/no + */ + private Flag flag; + + /** + * task priority + */ + private Priority taskPriority; + + /** + * user name + */ + @TableField(exist = false) + private String userName; + + /** + * project name + */ + @TableField(exist = false) + private String projectName; + + /** + * worker group + */ + private String workerGroup; + + /** + * fail retry times + */ + private int failRetryTimes; + + /** + * fail retry interval + */ + private int failRetryInterval; + + /** + * timeout flag + */ + private TimeoutFlag timeoutFlag; + + /** + * timeout notify strategy + */ + private TaskTimeoutStrategy taskTimeoutStrategy; + + /** + * task warning time out. unit: minute + */ + private int timeout; + + /** + * create time + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date createTime; + + /** + * update time + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date updateTime; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + + public Flag getFlag() { + return flag; + } + + public void setFlag(Flag flag) { + this.flag = flag; + } + + public int getUserId() { + return userId; + } + + public void setUserId(int userId) { + this.userId = userId; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getProjectName() { + return projectName; + } + + public void setProjectName(String projectName) { + this.projectName = projectName; + } + + public String getTaskParams() { + return taskParams; + } + + public void setTaskParams(String taskParams) { + if (taskParams == null) { + this.taskParamList = new ArrayList<>(); + } else { + this.taskParamList = JSONUtils.toList(taskParams, Property.class); + } + this.taskParams = taskParams; + } + + public List getTaskParamList() { + return taskParamList; + } + + public void setTaskParamList(List taskParamList) { + this.taskParams = JSONUtils.toJsonString(taskParamList); + this.taskParamList = taskParamList; + } + + public Map getTaskParamMap() { + if (taskParamMap == null && StringUtils.isNotEmpty(taskParams)) { + List propList = JSONUtils.toList(taskParams, Property.class); + taskParamMap = propList.stream().collect(Collectors.toMap(Property::getProp, Property::getValue)); + } + + return taskParamMap; + } + + public void setTaskParamMap(Map taskParamMap) { + this.taskParamMap = taskParamMap; + } + + public int getTimeout() { + return timeout; + } + + public void setTimeout(int timeout) { + this.timeout = timeout; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public long getCode() { + return code; + } + + public void setCode(long code) { + this.code = code; + } + + public int getVersion() { + return version; + } + + public void setVersion(int version) { + this.version = version; + } + + public long getProjectCode() { + return projectCode; + } + + public void setProjectCode(long projectCode) { + this.projectCode = projectCode; + } + + public TaskType getTaskType() { + return taskType; + } + + public void setTaskType(TaskType taskType) { + this.taskType = taskType; + } + + public Priority getTaskPriority() { + return taskPriority; + } + + public void setTaskPriority(Priority taskPriority) { + this.taskPriority = taskPriority; + } + + public String getWorkerGroup() { + return workerGroup; + } + + public void setWorkerGroup(String workerGroup) { + this.workerGroup = workerGroup; + } + + public int getFailRetryTimes() { + return failRetryTimes; + } + + public void setFailRetryTimes(int failRetryTimes) { + this.failRetryTimes = failRetryTimes; + } + + public int getFailRetryInterval() { + return failRetryInterval; + } + + public void setFailRetryInterval(int failRetryInterval) { + this.failRetryInterval = failRetryInterval; + } + + public TaskTimeoutStrategy getTaskTimeoutStrategy() { + return taskTimeoutStrategy; + } + + public void setTaskTimeoutStrategy(TaskTimeoutStrategy taskTimeoutStrategy) { + this.taskTimeoutStrategy = taskTimeoutStrategy; + } + + public TimeoutFlag getTimeoutFlag() { + return timeoutFlag; + } + + public void setTimeoutFlag(TimeoutFlag timeoutFlag) { + this.timeoutFlag = timeoutFlag; + } +} diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskDefinitionLog.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskDefinitionLog.java new file mode 100644 index 0000000000..d9dd8a41af --- /dev/null +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskDefinitionLog.java @@ -0,0 +1,385 @@ +/* + * 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.dao.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; +import com.fasterxml.jackson.annotation.JsonFormat; +import org.apache.dolphinscheduler.common.enums.*; +import org.apache.dolphinscheduler.common.process.Property; +import org.apache.dolphinscheduler.common.utils.JSONUtils; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * task definition log + */ +@TableName("t_ds_task_definition_log") +public class TaskDefinitionLog { + + /** + * id + */ + @TableId(value = "id", type = IdType.AUTO) + private int id; + + /** + * code + */ + private long code; + + /** + * name + */ + private String name; + + /** + * version + */ + private int version; + + /** + * description + */ + private String description; + + /** + * project code + */ + private long projectCode; + + /** + * task user id + */ + private int userId; + + /** + * task type + */ + private TaskType taskType; + + /** + * user defined parameters + */ + private String taskParams; + + /** + * user defined parameter list + */ + @TableField(exist = false) + private List taskParamList; + + /** + * user define parameter map + */ + @TableField(exist = false) + private Map taskParamMap; + + /** + * task is valid: yes/no + */ + private Flag flag; + + /** + * task priority + */ + private Priority taskPriority; + + /** + * user name + */ + @TableField(exist = false) + private String userName; + + /** + * project name + */ + @TableField(exist = false) + private String projectName; + + /** + * worker group + */ + private String workerGroup; + + /** + * fail retry times + */ + private int failRetryTimes; + + /** + * fail retry interval + */ + private int failRetryInterval; + + /** + * timeout flag + */ + private TimeoutFlag timeoutFlag; + + /** + * timeout notify strategy + */ + private TaskTimeoutStrategy taskTimeoutStrategy; + + /** + * task warning time out. unit: minute + */ + private int timeout; + + /** + * operator user id + */ + private int operator; + + /** + * operate time + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date operateTime; + + /** + * create time + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date createTime; + + /** + * update time + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date updateTime; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + + public Flag getFlag() { + return flag; + } + + public void setFlag(Flag flag) { + this.flag = flag; + } + + public int getUserId() { + return userId; + } + + public void setUserId(int userId) { + this.userId = userId; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getProjectName() { + return projectName; + } + + public void setProjectName(String projectName) { + this.projectName = projectName; + } + + public String getTaskParams() { + return taskParams; + } + + public void setTaskParams(String taskParams) { + if (taskParams == null) { + this.taskParamList = new ArrayList<>(); + } else { + this.taskParamList = JSONUtils.toList(taskParams, Property.class); + } + this.taskParams = taskParams; + } + + public List getTaskParamList() { + return taskParamList; + } + + public void setTaskParamList(List taskParamList) { + this.taskParams = JSONUtils.toJsonString(taskParamList); + this.taskParamList = taskParamList; + } + + public Map getTaskParamMap() { + if (taskParamMap == null && StringUtils.isNotEmpty(taskParams)) { + List propList = JSONUtils.toList(taskParams, Property.class); + taskParamMap = propList.stream().collect(Collectors.toMap(Property::getProp, Property::getValue)); + } + + return taskParamMap; + } + + public void setTaskParamMap(Map taskParamMap) { + this.taskParamMap = taskParamMap; + } + + public int getTimeout() { + return timeout; + } + + public void setTimeout(int timeout) { + this.timeout = timeout; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public long getCode() { + return code; + } + + public void setCode(long code) { + this.code = code; + } + + public int getVersion() { + return version; + } + + public void setVersion(int version) { + this.version = version; + } + + public long getProjectCode() { + return projectCode; + } + + public void setProjectCode(long projectCode) { + this.projectCode = projectCode; + } + + public TaskType getTaskType() { + return taskType; + } + + public void setTaskType(TaskType taskType) { + this.taskType = taskType; + } + + public Priority getTaskPriority() { + return taskPriority; + } + + public void setTaskPriority(Priority taskPriority) { + this.taskPriority = taskPriority; + } + + public String getWorkerGroup() { + return workerGroup; + } + + public void setWorkerGroup(String workerGroup) { + this.workerGroup = workerGroup; + } + + public int getFailRetryTimes() { + return failRetryTimes; + } + + public void setFailRetryTimes(int failRetryTimes) { + this.failRetryTimes = failRetryTimes; + } + + public int getFailRetryInterval() { + return failRetryInterval; + } + + public void setFailRetryInterval(int failRetryInterval) { + this.failRetryInterval = failRetryInterval; + } + + public TaskTimeoutStrategy getTaskTimeoutStrategy() { + return taskTimeoutStrategy; + } + + public void setTaskTimeoutStrategy(TaskTimeoutStrategy taskTimeoutStrategy) { + this.taskTimeoutStrategy = taskTimeoutStrategy; + } + + public int getOperator() { + return operator; + } + + public void setOperator(int operator) { + this.operator = operator; + } + + public Date getOperateTime() { + return operateTime; + } + + public void setOperateTime(Date operateTime) { + this.operateTime = operateTime; + } + + public TimeoutFlag getTimeoutFlag() { + return timeoutFlag; + } + + public void setTimeoutFlag(TimeoutFlag timeoutFlag) { + this.timeoutFlag = timeoutFlag; + } +} diff --git a/sql/dolphinscheduler_mysql.sql b/sql/dolphinscheduler_mysql.sql index e900632a92..da6bfa2395 100644 --- a/sql/dolphinscheduler_mysql.sql +++ b/sql/dolphinscheduler_mysql.sql @@ -407,7 +407,7 @@ CREATE TABLE `t_ds_process_definition` ( `flag` tinyint(4) DEFAULT NULL COMMENT '0 not available, 1 available', `receivers` text COMMENT 'receivers', `receivers_cc` text COMMENT 'cc', - `timeout` int(11) DEFAULT '0' COMMENT 'time out', + `timeout` int(11) DEFAULT '0' COMMENT 'time out, unit: minute', `tenant_id` int(11) NOT NULL DEFAULT '-1' COMMENT 'tenant id', `create_time` datetime NOT NULL COMMENT 'create time', `update_time` datetime DEFAULT NULL COMMENT 'update time', @@ -436,7 +436,7 @@ CREATE TABLE `t_ds_process_definition_log` ( `flag` tinyint(4) DEFAULT NULL COMMENT '0 not available, 1 available', `receivers` text COMMENT 'receivers', `receivers_cc` text COMMENT 'cc', - `timeout` int(11) DEFAULT '0' COMMENT 'time out', + `timeout` int(11) DEFAULT '0' COMMENT 'time out,unit: minute', `tenant_id` int(11) NOT NULL DEFAULT '-1' COMMENT 'tenant id', `operator` int(11) DEFAULT NULL COMMENT 'operator user id', `operate_time` datetime DEFAULT NULL COMMENT 'operate time', @@ -456,16 +456,16 @@ CREATE TABLE `t_ds_task_definition` ( `description` text COMMENT 'description', `project_code` bigint(20) NOT NULL COMMENT 'project code', `user_id` int(11) DEFAULT NULL COMMENT 'task definition creator id', - `task_type` varchar(30) DEFAULT NULL COMMENT 'job type', + `task_type` tinyint(4) DEFAULT NULL COMMENT '0 shell,1 sql,2 sub_process,3 procedure,4 mr,5 spark,6 python,7 dependent,8 flink,9 http,10 datax,11 conditions,12 sqoop,13 waterdrop', `task_params` text COMMENT 'job custom parameters', - `run_flag` tinyint(2) DEFAULT NULL COMMENT '0 not available, 1 available', + `flag` tinyint(2) DEFAULT NULL COMMENT '0 not available, 1 available', `task_priority` tinyint(4) DEFAULT NULL COMMENT 'job priority', `worker_group` varchar(200) DEFAULT NULL COMMENT 'worker grouping', `fail_retry_times` int(11) DEFAULT NULL COMMENT 'number of failed retries', `fail_retry_interval` int(11) DEFAULT NULL COMMENT 'failed retry interval', `timeout_flag` tinyint(1) DEFAULT '0' COMMENT 'timeout flag:0 close, 1 open', `timeout_notify_strategy` tinyint(4) DEFAULT NULL COMMENT 'timeout notification policy: 0 warning, 1 fail', - `timeout_duration` int(11) DEFAULT '0' COMMENT 'timeout length', + `timeout` int(11) DEFAULT '0' COMMENT 'timeout length,unit: minute', `create_time` datetime NOT NULL COMMENT 'create time', `update_time` datetime DEFAULT NULL COMMENT 'update time', PRIMARY KEY (`id`,`code`), @@ -483,16 +483,16 @@ CREATE TABLE `t_ds_task_definition_log` ( `description` text COMMENT 'description', `project_code` bigint(20) NOT NULL COMMENT 'project code', `user_id` int(11) DEFAULT NULL COMMENT 'task definition creator id', - `task_type` varchar(30) DEFAULT NULL COMMENT 'job type', + `task_type` tinyint(4) DEFAULT NULL COMMENT '0 shell,1 sql,2 sub_process,3 procedure,4 mr,5 spark,6 python,7 dependent,8 flink,9 http,10 datax,11 conditions,12 sqoop,13 waterdrop', `task_params` text COMMENT 'job custom parameters', - `run_flag` tinyint(2) DEFAULT NULL COMMENT '0 not available, 1 available', + `flag` tinyint(2) DEFAULT NULL COMMENT '0 not available, 1 available', `task_priority` tinyint(4) DEFAULT NULL COMMENT 'job priority', `worker_group` varchar(200) DEFAULT NULL COMMENT 'worker grouping', `fail_retry_times` int(11) DEFAULT NULL COMMENT 'number of failed retries', `fail_retry_interval` int(11) DEFAULT NULL COMMENT 'failed retry interval', `timeout_flag` tinyint(1) DEFAULT '0' COMMENT 'timeout flag:0 close, 1 open', `timeout_notify_strategy` tinyint(4) DEFAULT NULL COMMENT 'timeout notification policy: 0 warning, 1 fail', - `timeout_duration` int(11) DEFAULT '0' COMMENT 'timeout length', + `timeout` int(11) DEFAULT '0' COMMENT 'timeout length,unit: minute', `operator` int(11) DEFAULT NULL COMMENT 'operator user id', `operate_time` datetime DEFAULT NULL COMMENT 'operate time', `create_time` datetime NOT NULL COMMENT 'create time', @@ -511,10 +511,10 @@ CREATE TABLE `t_ds_process_task_relation` ( `process_definition_code` bigint(20) NOT NULL COMMENT 'process code', `pre_project_code` bigint(20) NOT NULL COMMENT 'pre process code', `pre_task_code` bigint(20) NOT NULL COMMENT 'pre task code', - `condition_type` tinyint(2) DEFAULT NULL COMMENT 'condition type : 0 none, 1 judge 2 delay', - `condition_params` text COMMENT 'condition params(json)', `post_project_code` bigint(20) NOT NULL COMMENT 'post process code', `post_task_code` bigint(20) NOT NULL COMMENT 'post task code', + `condition_type` tinyint(2) DEFAULT NULL COMMENT 'condition type : 0 none, 1 judge 2 delay', + `condition_params` text COMMENT 'condition params(json)', `create_time` datetime NOT NULL COMMENT 'create time', `update_time` datetime DEFAULT NULL COMMENT 'update time', PRIMARY KEY (`id`) @@ -531,10 +531,10 @@ CREATE TABLE `t_ds_process_task_relation_log` ( `process_definition_code` bigint(20) NOT NULL COMMENT 'process code', `pre_project_code` bigint(20) NOT NULL COMMENT 'pre process code', `pre_task_code` bigint(20) NOT NULL COMMENT 'pre task code', - `condition_type` tinyint(2) DEFAULT NULL COMMENT 'condition type : 0 none, 1 judge 2 delay', - `condition_params` text COMMENT 'condition params(json)', `post_project_code` bigint(20) NOT NULL COMMENT 'post process code', `post_task_code` bigint(20) NOT NULL COMMENT 'post task code', + `condition_type` tinyint(2) DEFAULT NULL COMMENT 'condition type : 0 none, 1 judge 2 delay', + `condition_params` text COMMENT 'condition params(json)', `operator` int(11) DEFAULT NULL COMMENT 'operator user id', `operate_time` datetime DEFAULT NULL COMMENT 'operate time', `create_time` datetime NOT NULL COMMENT 'create time',