Browse Source

[Feature-4417][JsonSplit] definition log extends definition (#4870)

* task definition log extends task definition

* process definition log extends process definition
process task relation log extends process task relation

* code style

* code style

* code style

* update log extends definition

* code style

* code style
pull/3/MERGE
bao liang 4 years ago committed by GitHub
parent
commit
fd7aa53fd3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 433
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessDefinitionLog.java
  2. 249
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessTaskRelationLog.java
  3. 19
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskDefinition.java
  4. 392
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskDefinitionLog.java
  5. 63
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/TaskDefinitionLogMapperTest.java
  6. 62
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/TaskDefinitionMapperTest.java
  7. 33
      dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java

433
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessDefinitionLog.java

@ -17,169 +17,16 @@
package org.apache.dolphinscheduler.dao.entity;
import org.apache.dolphinscheduler.common.enums.Flag;
import org.apache.dolphinscheduler.common.enums.ReleaseState;
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;
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;
/**
* process definition log
*/
@TableName("t_ds_process_definition_log")
public class ProcessDefinitionLog {
/**
* id
*/
@TableId(value = "id", type = IdType.AUTO)
private int id;
/**
* code
*/
private Long code;
/**
* name
*/
private String name;
/**
* version
*/
private int version;
/**
* release state : online/offline
*/
private ReleaseState releaseState;
/**
* project code
*/
private Long projectCode;
/**
* description
*/
private String description;
/**
* user defined parameters
*/
private String globalParams;
/**
* user defined parameter list
*/
@TableField(exist = false)
private List<Property> globalParamList;
/**
* user define parameter map
*/
@TableField(exist = false)
private Map<String, String> globalParamMap;
/**
* 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;
/**
* process is valid: yes/no
*/
private Flag flag;
/**
* process user id
*/
private int userId;
/**
* user name
*/
@TableField(exist = false)
private String userName;
/**
* project name
*/
@TableField(exist = false)
private String projectName;
/**
* locations array for web
*/
private String locations;
/**
* receivers
*/
private String receivers;
/**
* receivers cc
*/
private String receiversCc;
/**
* schedule release state : online/offline
*/
@TableField(exist = false)
private ReleaseState scheduleReleaseState;
/**
* process warning time out. unit: minute
*/
private int timeout;
/**
* tenant id
*/
private int tenantId;
/**
* modify user name
*/
private String modifyBy;
/**
* warningGroupId
*/
@TableField(exist = false)
private int warningGroupId;
/**
* connects array for web
*/
private String connects;
/**
* resource ids
*/
private String resourceIds;
public class ProcessDefinitionLog extends ProcessDefinition {
/**
* operator
@ -192,21 +39,37 @@ public class ProcessDefinitionLog {
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date operateTime;
public int getWarningGroupId() {
return warningGroupId;
public ProcessDefinitionLog() {
super();
}
public ProcessDefinitionLog(ProcessDefinition processDefinition) {
this.setId(processDefinition.getId());
this.setCode(processDefinition.getCode());
this.setName(processDefinition.getName());
this.setVersion(processDefinition.getVersion());
this.setReleaseState(processDefinition.getReleaseState());
this.setProjectCode(processDefinition.getProjectCode());
this.setDescription(processDefinition.getDescription());
this.setGlobalParams(processDefinition.getGlobalParams());
this.setGlobalParamList(processDefinition.getGlobalParamList());
this.setGlobalParamMap(processDefinition.getGlobalParamMap());
this.setCreateTime(processDefinition.getCreateTime());
this.setUpdateTime(processDefinition.getUpdateTime());
this.setFlag(processDefinition.getFlag());
this.setUserId(processDefinition.getUserId());
this.setUserName(processDefinition.getUserName());
this.setProjectName(processDefinition.getProjectName());
this.setLocations(processDefinition.getLocations());
this.setConnects(processDefinition.getConnects());
this.setScheduleReleaseState(processDefinition.getScheduleReleaseState());
this.setTimeout(processDefinition.getTimeout());
this.setTenantId(processDefinition.getTenantId());
this.setModifyBy(processDefinition.getModifyBy());
this.setResourceIds(processDefinition.getResourceIds());
this.setWarningGroupId(processDefinition.getWarningGroupId());
}
public void setWarningGroupId(int warningGroupId) {
this.warningGroupId = warningGroupId;
}
public String getConnects() {
return connects;
}
public void setConnects(String connects) {
this.connects = connects;
}
public int getOperator() {
return operator;
@ -224,240 +87,4 @@ public class ProcessDefinitionLog {
this.operateTime = operateTime;
}
public Long getCode() {
return code;
}
public void setCode(Long code) {
this.code = code;
}
public Long getProjectCode() {
return projectCode;
}
public void setProjectCode(Long projectCode) {
this.projectCode = projectCode;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getVersion() {
return version;
}
public void setVersion(int version) {
this.version = version;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public ReleaseState getReleaseState() {
return releaseState;
}
public void setReleaseState(ReleaseState releaseState) {
this.releaseState = releaseState;
}
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 getGlobalParams() {
return globalParams;
}
public void setGlobalParams(String globalParams) {
if (globalParams == null) {
this.globalParamList = new ArrayList<>();
} else {
this.globalParamList = JSONUtils.toList(globalParams, Property.class);
}
this.globalParams = globalParams;
}
public List<Property> getGlobalParamList() {
return globalParamList;
}
public void setGlobalParamList(List<Property> globalParamList) {
this.globalParams = JSONUtils.toJsonString(globalParamList);
this.globalParamList = globalParamList;
}
public Map<String, String> getGlobalParamMap() {
if (globalParamMap == null && StringUtils.isNotEmpty(globalParams)) {
List<Property> propList = JSONUtils.toList(globalParams, Property.class);
globalParamMap = propList.stream().collect(Collectors.toMap(Property::getProp, Property::getValue));
}
return globalParamMap;
}
public void setGlobalParamMap(Map<String, String> globalParamMap) {
this.globalParamMap = globalParamMap;
}
public String getLocations() {
return locations;
}
public void setLocations(String locations) {
this.locations = locations;
}
public String getReceivers() {
return receivers;
}
public void setReceivers(String receivers) {
this.receivers = receivers;
}
public String getReceiversCc() {
return receiversCc;
}
public void setReceiversCc(String receiversCc) {
this.receiversCc = receiversCc;
}
public ReleaseState getScheduleReleaseState() {
return scheduleReleaseState;
}
public void setScheduleReleaseState(ReleaseState scheduleReleaseState) {
this.scheduleReleaseState = scheduleReleaseState;
}
public String getResourceIds() {
return resourceIds;
}
public void setResourceIds(String resourceIds) {
this.resourceIds = resourceIds;
}
public int getTimeout() {
return timeout;
}
public void setTimeout(int timeout) {
this.timeout = timeout;
}
public int getTenantId() {
return tenantId;
}
public void setTenantId(int tenantId) {
this.tenantId = tenantId;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getModifyBy() {
return modifyBy;
}
public void setModifyBy(String modifyBy) {
this.modifyBy = modifyBy;
}
@Override
public String toString() {
return "ProcessDefinitionLog{"
+ "id=" + id
+ ", code=" + code
+ ", name='" + name + '\''
+ ", version=" + version
+ ", releaseState=" + releaseState
+ ", projectCode=" + projectCode
+ ", description='" + description + '\''
+ ", globalParams='" + globalParams + '\''
+ ", globalParamList=" + globalParamList
+ ", globalParamMap=" + globalParamMap
+ ", createTime=" + createTime
+ ", updateTime=" + updateTime
+ ", flag=" + flag
+ ", userId=" + userId
+ ", userName='" + userName + '\''
+ ", projectName='" + projectName + '\''
+ ", locations='" + locations + '\''
+ ", receivers='" + receivers + '\''
+ ", receiversCc='" + receiversCc + '\''
+ ", scheduleReleaseState=" + scheduleReleaseState
+ ", timeout=" + timeout
+ ", tenantId=" + tenantId
+ ", modifyBy='" + modifyBy + '\''
+ ", warningGroupId=" + warningGroupId
+ ", connects='" + connects + '\''
+ ", resourceIds='" + resourceIds + '\''
+ ", operator=" + operator
+ ", operateTime=" + operateTime
+ '}';
}
}

249
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessTaskRelationLog.java

@ -17,96 +17,16 @@
package org.apache.dolphinscheduler.dao.entity;
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;
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;
/**
* 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;
/**
* process version
*/
private int processDefinitionVersion;
/**
* project code
*/
private long projectCode;
/**
* process code
*/
private long processDefinitionCode;
/**
* pre task code
*/
private long preTaskCode;
/**
* pre node version
*/
private int preNodeVersion;
/**
* post task code
*/
private long postTaskCode;
/**
* post node version
*/
private int postNodeVersion;
/**
* condition type
*/
private ConditionType conditionType;
/**
* condition parameters
*/
private String conditionParams;
/**
* condition parameter list
*/
@TableField(exist = false)
private List<Property> conditionParamList;
/**
* condition parameter map
*/
@TableField(exist = false)
private Map<String, String> conditionParamMap;
public class ProcessTaskRelationLog extends ProcessTaskRelation {
/**
* operator user id
@ -119,132 +39,29 @@ public class ProcessTaskRelationLog {
@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 ProcessTaskRelationLog() {
super();
}
public int getId() {
return id;
public ProcessTaskRelationLog(ProcessTaskRelation processTaskRelation) {
super();
this.setId(processTaskRelation.getId());
this.setName(processTaskRelation.getName());
this.setProcessDefinitionCode(processTaskRelation.getProcessDefinitionCode());
this.setProcessDefinitionVersion(processTaskRelation.getProcessDefinitionVersion());
this.setProjectCode(processTaskRelation.getProjectCode());
this.setPreTaskCode(processTaskRelation.getPreTaskCode());
this.setPreNodeVersion(processTaskRelation.getPreNodeVersion());
this.setPostTaskCode(processTaskRelation.getPostTaskCode());
this.setPostNodeVersion(processTaskRelation.getPostNodeVersion());
this.setConditionType(processTaskRelation.getConditionType());
this.setConditionParams(processTaskRelation.getConditionParams());
this.setConditionParamList(processTaskRelation.getConditionParamList());
this.setConditionParamMap(processTaskRelation.getConditionParamMap());
this.setCreateTime(processTaskRelation.getCreateTime());
this.setUpdateTime(processTaskRelation.getUpdateTime());
}
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<Property> getConditionParamList() {
return conditionParamList;
}
public void setConditionParamList(List<Property> conditionParamList) {
this.conditionParams = JSONUtils.toJsonString(conditionParamList);
this.conditionParamList = conditionParamList;
}
public Map<String, String> getConditionParamMap() {
if (conditionParamMap == null && StringUtils.isNotEmpty(conditionParams)) {
List<Property> propList = JSONUtils.toList(conditionParams, Property.class);
conditionParamMap = propList.stream().collect(Collectors.toMap(Property::getProp, Property::getValue));
}
return conditionParamMap;
}
public void setConditionParamMap(Map<String, String> conditionParamMap) {
this.conditionParamMap = conditionParamMap;
}
public int getProcessDefinitionVersion() {
return processDefinitionVersion;
}
public void setProcessDefinitionVersion(int processDefinitionVersion) {
this.processDefinitionVersion = processDefinitionVersion;
}
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 getPreTaskCode() {
return preTaskCode;
}
public void setPreTaskCode(long preTaskCode) {
this.preTaskCode = preTaskCode;
}
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;
@ -262,30 +79,4 @@ public class ProcessTaskRelationLog {
this.operateTime = operateTime;
}
public void set(ProcessTaskRelation processTaskRelation) {
this.name = processTaskRelation.getName();
this.processDefinitionVersion = processTaskRelation.getProcessDefinitionVersion();
this.projectCode = processTaskRelation.getProjectCode();
this.processDefinitionCode = processTaskRelation.getProcessDefinitionCode();
this.preTaskCode = processTaskRelation.getPreTaskCode();
this.postTaskCode = processTaskRelation.getPostTaskCode();
this.conditionType = processTaskRelation.getConditionType();
this.conditionParams = processTaskRelation.getConditionParams();
}
public int getPostNodeVersion() {
return postNodeVersion;
}
public void setPostNodeVersion(int postNodeVersion) {
this.postNodeVersion = postNodeVersion;
}
public int getPreNodeVersion() {
return preNodeVersion;
}
public void setPreNodeVersion(int preNodeVersion) {
this.preNodeVersion = preNodeVersion;
}
}

19
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskDefinition.java

@ -14,16 +14,13 @@
* 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.enums.Flag;
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.enums.TimeoutFlag;
import org.apache.dolphinscheduler.common.process.Property;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
@ -33,6 +30,12 @@ import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
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;
/**
* task definition

392
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskDefinitionLog.java

@ -17,142 +17,16 @@
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<Property> taskParamList;
/**
* user define parameter map
*/
@TableField(exist = false)
private Map<String, String> 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;
/**
* resource ids
*/
private String resourceIds;
public class TaskDefinitionLog extends TaskDefinition {
/**
* operator user id
@ -165,203 +39,36 @@ public class TaskDefinitionLog {
@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<Property> getTaskParamList() {
return taskParamList;
}
public void setTaskParamList(List<Property> taskParamList) {
this.taskParams = JSONUtils.toJsonString(taskParamList);
this.taskParamList = taskParamList;
}
public Map<String, String> getTaskParamMap() {
if (taskParamMap == null && StringUtils.isNotEmpty(taskParams)) {
List<Property> propList = JSONUtils.toList(taskParams, Property.class);
taskParamMap = propList.stream().collect(Collectors.toMap(Property::getProp, Property::getValue));
}
return taskParamMap;
}
public void setTaskParamMap(Map<String, String> 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 TaskDefinitionLog() {
super();
}
public TaskDefinitionLog(TaskDefinition taskDefinition) {
super();
this.setId(taskDefinition.getId());
this.setCode(taskDefinition.getCode());
this.setVersion(taskDefinition.getVersion());
this.setName(taskDefinition.getName());
this.setDescription(taskDefinition.getDescription());
this.setUserId(taskDefinition.getUserId());
this.setUserName(taskDefinition.getUserName());
this.setWorkerGroup(taskDefinition.getWorkerGroup());
this.setProjectCode(taskDefinition.getProjectCode());
this.setProjectName(taskDefinition.getProjectName());
this.setResourceIds(taskDefinition.getResourceIds());
this.setTaskParams(taskDefinition.getTaskParams());
this.setTaskParamList(taskDefinition.getTaskParamList());
this.setTaskParamMap(taskDefinition.getTaskParamMap());
this.setTaskPriority(taskDefinition.getTaskPriority());
this.setTaskTimeoutStrategy(taskDefinition.getTaskTimeoutStrategy());
this.setTaskType(taskDefinition.getTaskType());
this.setTimeout(taskDefinition.getTimeout());
this.setTimeoutFlag(taskDefinition.getTimeoutFlag());
this.setUpdateTime(taskDefinition.getUpdateTime());
this.setCreateTime(taskDefinition.getCreateTime());
this.setFailRetryInterval(taskDefinition.getFailRetryInterval());
this.setFailRetryTimes(taskDefinition.getFailRetryTimes());
this.setFlag(taskDefinition.getFlag());
}
public int getOperator() {
@ -379,41 +86,4 @@ public class TaskDefinitionLog {
public void setOperateTime(Date operateTime) {
this.operateTime = operateTime;
}
public TimeoutFlag getTimeoutFlag() {
return timeoutFlag;
}
public void setTimeoutFlag(TimeoutFlag timeoutFlag) {
this.timeoutFlag = timeoutFlag;
}
public String getResourceIds() {
return resourceIds;
}
public void setResourceIds(String resourceIds) {
this.resourceIds = resourceIds;
}
public void set(TaskDefinition taskDefinition) {
this.code = taskDefinition.getCode();
this.name = taskDefinition.getName();
this.version = taskDefinition.getVersion();
this.description = taskDefinition.getDescription();
this.projectCode = taskDefinition.getProjectCode();
this.userId = taskDefinition.getUserId();
this.taskType = taskDefinition.getTaskType();
this.taskParams = taskDefinition.getTaskParams();
this.flag = taskDefinition.getFlag();
this.taskPriority = taskDefinition.getTaskPriority();
this.workerGroup = taskDefinition.getWorkerGroup();
this.failRetryTimes = taskDefinition.getFailRetryTimes();
this.failRetryInterval = taskDefinition.getFailRetryInterval();
this.timeoutFlag = taskDefinition.getTimeoutFlag();
this.taskTimeoutStrategy = taskDefinition.getTaskTimeoutStrategy();
this.timeout = taskDefinition.getTimeout();
this.createTime = taskDefinition.getCreateTime();
this.updateTime = taskDefinition.getUpdateTime();
}
}

63
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/TaskDefinitionLogMapperTest.java

@ -0,0 +1,63 @@
/*
* 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.mapper;
import org.apache.dolphinscheduler.common.enums.TaskType;
import org.apache.dolphinscheduler.dao.entity.TaskDefinitionLog;
import java.util.Date;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
@RunWith(SpringRunner.class)
@SpringBootTest
@Transactional
@Rollback(true)
public class TaskDefinitionLogMapperTest {
@Autowired
TaskDefinitionLogMapper taskDefinitionLogMapper;
public TaskDefinitionLog insertOne() {
TaskDefinitionLog taskDefinition = new TaskDefinitionLog();
taskDefinition.setCode(888888L);
taskDefinition.setName("unit-test");
taskDefinition.setProjectCode(111111L);
taskDefinition.setTaskType(TaskType.SHELL);
taskDefinition.setUserId(99);
taskDefinition.setVersion(1);
taskDefinition.setCreateTime(new Date());
taskDefinition.setUpdateTime(new Date());
taskDefinitionLogMapper.insert(taskDefinition);
return taskDefinition;
}
@Test
public void testInsert() {
TaskDefinitionLog taskDefinitionLog = insertOne();
Assert.assertNotEquals(taskDefinitionLog.getId(), 0);
}
}

62
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/TaskDefinitionMapperTest.java

@ -0,0 +1,62 @@
/*
* 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.mapper;
import org.apache.dolphinscheduler.common.enums.TaskType;
import org.apache.dolphinscheduler.dao.entity.TaskDefinition;
import java.util.Date;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
@RunWith(SpringRunner.class)
@SpringBootTest
@Transactional
@Rollback(true)
public class TaskDefinitionMapperTest {
@Autowired
TaskDefinitionMapper taskDefinitionMapper;
public TaskDefinition insertOne() {
TaskDefinition taskDefinition = new TaskDefinition();
taskDefinition.setCode(888888L);
taskDefinition.setName("unit-test");
taskDefinition.setProjectCode(111111L);
taskDefinition.setTaskType(TaskType.SHELL);
taskDefinition.setUserId(99);
taskDefinition.setVersion(1);
taskDefinition.setCreateTime(new Date());
taskDefinition.setUpdateTime(new Date());
taskDefinitionMapper.insert(taskDefinition);
return taskDefinition;
}
@Test
public void testInsert() {
TaskDefinition taskDefinition = insertOne();
Assert.assertNotEquals(taskDefinition.getId(), 0);
}
}

33
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java

@ -404,10 +404,7 @@ public class ProcessService {
* covert log to process definition
*/
public ProcessDefinition convertFromLog(ProcessDefinitionLog processDefinitionLog) {
ProcessDefinition definition = null;
if (null != processDefinitionLog) {
definition = JSONUtils.parseObject(JSONUtils.toJsonString(processDefinitionLog), ProcessDefinition.class);
}
ProcessDefinition definition = processDefinitionLog;
if (null != definition) {
definition.setId(0);
}
@ -2130,8 +2127,7 @@ public class ProcessService {
return Constants.EXIT_CODE_FAILURE;
}
ProcessDefinition tmpDefinition = JSONUtils.parseObject(JSONUtils.toJsonString(processDefinitionLog),
ProcessDefinition.class);
ProcessDefinition tmpDefinition = processDefinitionLog;
tmpDefinition.setId(processDefinition.getId());
tmpDefinition.setReleaseState(ReleaseState.OFFLINE);
tmpDefinition.setFlag(Flag.YES);
@ -2153,8 +2149,7 @@ public class ProcessService {
}
List<ProcessTaskRelationLog> processTaskRelationLogList = processTaskRelationLogMapper.queryByProcessCodeAndVersion(processDefinition.getCode(), processDefinition.getVersion());
for (ProcessTaskRelationLog processTaskRelationLog : processTaskRelationLogList) {
ProcessTaskRelation processTaskRelation = JSONUtils.parseObject(JSONUtils.toJsonString(processTaskRelationLog),
ProcessTaskRelation.class);
ProcessTaskRelation processTaskRelation = processTaskRelationLog;
processTaskRelationMapper.insert(processTaskRelation);
}
}
@ -2178,8 +2173,7 @@ public class ProcessService {
setTaskFromTaskNode(taskNode, taskDefinition);
int update = taskDefinitionMapper.updateById(taskDefinition);
// save task definition log
TaskDefinitionLog taskDefinitionLog = new TaskDefinitionLog();
taskDefinitionLog.set(taskDefinition);
TaskDefinitionLog taskDefinitionLog = new TaskDefinitionLog(taskDefinition);
taskDefinitionLog.setOperator(operator.getId());
taskDefinitionLog.setOperateTime(now);
int insert = taskDefinitionLogMapper.insert(taskDefinitionLog);
@ -2314,25 +2308,27 @@ public class ProcessService {
List<String> depList = taskNode.getDepList();
if (CollectionUtils.isNotEmpty(depList)) {
for (String preTaskName : depList) {
builderRelationList.add(new ProcessTaskRelation("",// todo relation name
builderRelationList.add(new ProcessTaskRelation("",
processDefinition.getVersion(),
projectCode,
processDefinition.getCode(),
taskNameAndCode.get(preTaskName),
taskNameAndCode.get(taskNode.getName()),
ConditionType.of("none"), // todo conditionType
ConditionType.of("none"),
taskNode.getConditionResult(),
now,
now));
}
} else {
builderRelationList.add(new ProcessTaskRelation("",// todo relation name
// todo relation name
builderRelationList.add(new ProcessTaskRelation("",
processDefinition.getVersion(),
projectCode,
processDefinition.getCode(),
0L,
taskNameAndCode.get(taskNode.getName()),
ConditionType.of("none"), // todo conditionType
// todo conditionType
ConditionType.of("none"),
taskNode.getConditionResult(),
now,
now));
@ -2341,8 +2337,7 @@ public class ProcessService {
for (ProcessTaskRelation processTaskRelation : builderRelationList) {
processTaskRelationMapper.insert(processTaskRelation);
// save process task relation log
ProcessTaskRelationLog processTaskRelationLog = new ProcessTaskRelationLog();
processTaskRelationLog.set(processTaskRelation);
ProcessTaskRelationLog processTaskRelationLog = new ProcessTaskRelationLog(processTaskRelation);
processTaskRelationLog.setOperator(operator.getId());
processTaskRelationLog.setOperateTime(now);
processTaskRelationLogMapper.insert(processTaskRelationLog);
@ -2359,9 +2354,7 @@ public class ProcessService {
setTaskFromTaskNode(taskNode, taskDefinition);
// save the new task definition
int insert = taskDefinitionMapper.insert(taskDefinition);
// save task definition log
TaskDefinitionLog taskDefinitionLog = new TaskDefinitionLog();
taskDefinitionLog.set(taskDefinition);
TaskDefinitionLog taskDefinitionLog = new TaskDefinitionLog(taskDefinition);
taskDefinitionLog.setOperator(operator.getId());
taskDefinitionLog.setOperateTime(now);
int logInsert = taskDefinitionLogMapper.insert(taskDefinitionLog);
@ -2410,7 +2403,7 @@ public class ProcessService {
processVersion);
List<ProcessTaskRelation> processTaskRelations = new ArrayList<>();
for (ProcessTaskRelationLog processTaskRelationLog : taskRelationLogs) {
processTaskRelations.add(JSONUtils.parseObject(JSONUtils.toJsonString(processTaskRelationLog), ProcessTaskRelation.class));
processTaskRelations.add(processTaskRelationLog);
}
return processTaskRelations;
}

Loading…
Cancel
Save