|
|
|
@ -14,18 +14,27 @@
|
|
|
|
|
* See the License for the specific language governing permissions and |
|
|
|
|
* limitations under the License. |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
package org.apache.dolphinscheduler.dao.entity; |
|
|
|
|
|
|
|
|
|
import org.apache.dolphinscheduler.common.enums.CommandType; |
|
|
|
|
import org.apache.dolphinscheduler.common.enums.ExecutionStatus; |
|
|
|
|
import org.apache.dolphinscheduler.common.enums.FailureStrategy; |
|
|
|
|
import org.apache.dolphinscheduler.common.enums.Flag; |
|
|
|
|
import org.apache.dolphinscheduler.common.enums.Priority; |
|
|
|
|
import org.apache.dolphinscheduler.common.enums.TaskDependType; |
|
|
|
|
import org.apache.dolphinscheduler.common.enums.WarningType; |
|
|
|
|
import org.apache.dolphinscheduler.common.utils.DateUtils; |
|
|
|
|
|
|
|
|
|
import java.util.Date; |
|
|
|
|
import java.util.Objects; |
|
|
|
|
|
|
|
|
|
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 java.util.Date; |
|
|
|
|
import java.util.Objects; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* process instance |
|
|
|
@ -36,7 +45,7 @@ public class ProcessInstance {
|
|
|
|
|
/** |
|
|
|
|
* id |
|
|
|
|
*/ |
|
|
|
|
@TableId(value="id", type=IdType.AUTO) |
|
|
|
|
@TableId(value = "id", type = IdType.AUTO) |
|
|
|
|
private int id; |
|
|
|
|
/** |
|
|
|
|
* process definition id |
|
|
|
@ -53,13 +62,13 @@ public class ProcessInstance {
|
|
|
|
|
/** |
|
|
|
|
* start time |
|
|
|
|
*/ |
|
|
|
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8") |
|
|
|
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
|
|
|
|
private Date startTime; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* end time |
|
|
|
|
*/ |
|
|
|
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8") |
|
|
|
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
|
|
|
|
private Date endTime; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -120,13 +129,13 @@ public class ProcessInstance {
|
|
|
|
|
/** |
|
|
|
|
* schedule time |
|
|
|
|
*/ |
|
|
|
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8") |
|
|
|
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
|
|
|
|
private Date scheduleTime; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* command start time |
|
|
|
|
*/ |
|
|
|
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8") |
|
|
|
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
|
|
|
|
private Date commandStartTime; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -189,6 +198,7 @@ public class ProcessInstance {
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* process duration |
|
|
|
|
* |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@TableField(exist = false) |
|
|
|
@ -226,19 +236,24 @@ public class ProcessInstance {
|
|
|
|
|
@TableField(exist = false) |
|
|
|
|
private String receiversCc; |
|
|
|
|
|
|
|
|
|
public ProcessInstance(){ |
|
|
|
|
public ProcessInstance() { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* set the process name with process define version and timestamp |
|
|
|
|
* |
|
|
|
|
* @param processDefinition processDefinition |
|
|
|
|
*/ |
|
|
|
|
public ProcessInstance(ProcessDefinition processDefinition){ |
|
|
|
|
public ProcessInstance(ProcessDefinition processDefinition) { |
|
|
|
|
this.processDefinition = processDefinition; |
|
|
|
|
this.name = processDefinition.getName() + "-" + |
|
|
|
|
processDefinition.getVersion() + "-" + |
|
|
|
|
System.currentTimeMillis(); |
|
|
|
|
this.name = processDefinition.getName() |
|
|
|
|
+ "-" |
|
|
|
|
+ |
|
|
|
|
processDefinition.getVersion() |
|
|
|
|
+ "-" |
|
|
|
|
+ |
|
|
|
|
DateUtils.getCurrentTimeStamp(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public ProcessDefinition getProcessDefinition() { |
|
|
|
@ -313,7 +328,6 @@ public class ProcessInstance {
|
|
|
|
|
this.name = name; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String getHost() { |
|
|
|
|
return host; |
|
|
|
|
} |
|
|
|
@ -322,7 +336,6 @@ public class ProcessInstance {
|
|
|
|
|
this.host = host; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public CommandType getCommandType() { |
|
|
|
|
return commandType; |
|
|
|
|
} |
|
|
|
@ -347,7 +360,6 @@ public class ProcessInstance {
|
|
|
|
|
this.taskDependType = taskDependType; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public int getMaxTryTimes() { |
|
|
|
|
return maxTryTimes; |
|
|
|
|
} |
|
|
|
@ -364,8 +376,7 @@ public class ProcessInstance {
|
|
|
|
|
this.failureStrategy = failureStrategy; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public boolean isProcessInstanceStop(){ |
|
|
|
|
public boolean isProcessInstanceStop() { |
|
|
|
|
return this.state.typeIsFinished(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -441,7 +452,6 @@ public class ProcessInstance {
|
|
|
|
|
this.executorId = executorId; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Flag getIsSubProcess() { |
|
|
|
|
return isSubProcess; |
|
|
|
|
} |
|
|
|
@ -457,6 +467,7 @@ public class ProcessInstance {
|
|
|
|
|
public void setProcessInstancePriority(Priority processInstancePriority) { |
|
|
|
|
this.processInstancePriority = processInstancePriority; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public String getLocations() { |
|
|
|
|
return locations; |
|
|
|
|
} |
|
|
|
@ -477,6 +488,10 @@ public class ProcessInstance {
|
|
|
|
|
return historyCmd; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void setHistoryCmd(String historyCmd) { |
|
|
|
|
this.historyCmd = historyCmd; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public String getExecutorName() { |
|
|
|
|
return executorName; |
|
|
|
|
} |
|
|
|
@ -485,28 +500,26 @@ public class ProcessInstance {
|
|
|
|
|
this.executorName = executorName; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void setHistoryCmd(String historyCmd) { |
|
|
|
|
this.historyCmd = historyCmd; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* add command to history |
|
|
|
|
* |
|
|
|
|
* @param cmd cmd |
|
|
|
|
*/ |
|
|
|
|
public void addHistoryCmd(CommandType cmd){ |
|
|
|
|
if(StringUtils.isNotEmpty(this.historyCmd)){ |
|
|
|
|
public void addHistoryCmd(CommandType cmd) { |
|
|
|
|
if (StringUtils.isNotEmpty(this.historyCmd)) { |
|
|
|
|
this.historyCmd = String.format("%s,%s", this.historyCmd, cmd.toString()); |
|
|
|
|
}else{ |
|
|
|
|
} else { |
|
|
|
|
this.historyCmd = cmd.toString(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* check this process is start complement data |
|
|
|
|
* |
|
|
|
|
* @return whether complement data |
|
|
|
|
*/ |
|
|
|
|
public boolean isComplementData(){ |
|
|
|
|
if(StringUtils.isEmpty(this.historyCmd)){ |
|
|
|
|
public boolean isComplementData() { |
|
|
|
|
if (StringUtils.isEmpty(this.historyCmd)) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
return historyCmd.startsWith(CommandType.COMPLEMENT_DATA.toString()); |
|
|
|
@ -515,10 +528,11 @@ public class ProcessInstance {
|
|
|
|
|
/** |
|
|
|
|
* get current command type, |
|
|
|
|
* if start with complement data,return complement |
|
|
|
|
* |
|
|
|
|
* @return CommandType |
|
|
|
|
*/ |
|
|
|
|
public CommandType getCmdTypeIfComplement(){ |
|
|
|
|
if(isComplementData()){ |
|
|
|
|
public CommandType getCmdTypeIfComplement() { |
|
|
|
|
if (isComplementData()) { |
|
|
|
|
return CommandType.COMPLEMENT_DATA; |
|
|
|
|
} |
|
|
|
|
return commandType; |
|
|
|
@ -556,15 +570,14 @@ public class ProcessInstance {
|
|
|
|
|
this.timeout = timeout; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public int getTenantId() { |
|
|
|
|
return this.tenantId; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void setTenantId(int tenantId) { |
|
|
|
|
this.tenantId = tenantId; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public int getTenantId() { |
|
|
|
|
return this.tenantId ; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public String getReceivers() { |
|
|
|
|
return receivers; |
|
|
|
|
} |
|
|
|
@ -583,44 +596,83 @@ public class ProcessInstance {
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public String toString() { |
|
|
|
|
return "ProcessInstance{" + |
|
|
|
|
"id=" + id + |
|
|
|
|
", processDefinitionId=" + processDefinitionId + |
|
|
|
|
", state=" + state + |
|
|
|
|
", recovery=" + recovery + |
|
|
|
|
", startTime=" + startTime + |
|
|
|
|
", endTime=" + endTime + |
|
|
|
|
", runTimes=" + runTimes + |
|
|
|
|
", name='" + name + '\'' + |
|
|
|
|
", host='" + host + '\'' + |
|
|
|
|
", processDefinition=" + processDefinition + |
|
|
|
|
", commandType=" + commandType + |
|
|
|
|
", commandParam='" + commandParam + '\'' + |
|
|
|
|
", taskDependType=" + taskDependType + |
|
|
|
|
", maxTryTimes=" + maxTryTimes + |
|
|
|
|
", failureStrategy=" + failureStrategy + |
|
|
|
|
", warningType=" + warningType + |
|
|
|
|
", warningGroupId=" + warningGroupId + |
|
|
|
|
", scheduleTime=" + scheduleTime + |
|
|
|
|
", commandStartTime=" + commandStartTime + |
|
|
|
|
", globalParams='" + globalParams + '\'' + |
|
|
|
|
", processInstanceJson='" + processInstanceJson + '\'' + |
|
|
|
|
", executorId=" + executorId + |
|
|
|
|
", tenantCode='" + tenantCode + '\'' + |
|
|
|
|
", queue='" + queue + '\'' + |
|
|
|
|
", isSubProcess=" + isSubProcess + |
|
|
|
|
", locations='" + locations + '\'' + |
|
|
|
|
", connects='" + connects + '\'' + |
|
|
|
|
", historyCmd='" + historyCmd + '\'' + |
|
|
|
|
", dependenceScheduleTimes='" + dependenceScheduleTimes + '\'' + |
|
|
|
|
", duration=" + duration + |
|
|
|
|
", processInstancePriority=" + processInstancePriority + |
|
|
|
|
", workerGroup='" + workerGroup + '\'' + |
|
|
|
|
", timeout=" + timeout + |
|
|
|
|
", tenantId=" + tenantId + |
|
|
|
|
", receivers='" + receivers + '\'' + |
|
|
|
|
", receiversCc='" + receiversCc + '\'' + |
|
|
|
|
'}'; |
|
|
|
|
return "ProcessInstance{" |
|
|
|
|
+ "id=" + id |
|
|
|
|
+ ", processDefinitionId=" + processDefinitionId |
|
|
|
|
+ ", state=" + state |
|
|
|
|
+ ", recovery=" + recovery |
|
|
|
|
+ ", startTime=" + startTime |
|
|
|
|
+ ", endTime=" + endTime |
|
|
|
|
+ ", runTimes=" + runTimes |
|
|
|
|
+ ", name='" + name + '\'' |
|
|
|
|
+ ", host='" + host + '\'' |
|
|
|
|
+ ", processDefinition=" |
|
|
|
|
+ processDefinition |
|
|
|
|
+ ", commandType=" |
|
|
|
|
+ commandType |
|
|
|
|
+ ", commandParam='" |
|
|
|
|
+ commandParam |
|
|
|
|
+ '\'' |
|
|
|
|
+ ", taskDependType=" |
|
|
|
|
+ taskDependType |
|
|
|
|
+ ", maxTryTimes=" |
|
|
|
|
+ maxTryTimes |
|
|
|
|
+ ", failureStrategy=" |
|
|
|
|
+ failureStrategy |
|
|
|
|
+ ", warningType=" |
|
|
|
|
+ warningType |
|
|
|
|
+ ", warningGroupId=" |
|
|
|
|
+ warningGroupId |
|
|
|
|
+ ", scheduleTime=" |
|
|
|
|
+ scheduleTime |
|
|
|
|
+ ", commandStartTime=" |
|
|
|
|
+ commandStartTime |
|
|
|
|
+ ", globalParams='" |
|
|
|
|
+ globalParams |
|
|
|
|
+ '\'' |
|
|
|
|
+ ", processInstanceJson='" |
|
|
|
|
+ processInstanceJson |
|
|
|
|
+ '\'' |
|
|
|
|
+ ", executorId=" |
|
|
|
|
+ executorId |
|
|
|
|
+ ", tenantCode='" |
|
|
|
|
+ tenantCode |
|
|
|
|
+ '\'' |
|
|
|
|
+ ", queue='" |
|
|
|
|
+ queue |
|
|
|
|
+ '\'' |
|
|
|
|
+ ", isSubProcess=" |
|
|
|
|
+ isSubProcess |
|
|
|
|
+ ", locations='" |
|
|
|
|
+ locations |
|
|
|
|
+ '\'' |
|
|
|
|
+ ", connects='" |
|
|
|
|
+ connects |
|
|
|
|
+ '\'' |
|
|
|
|
+ ", historyCmd='" |
|
|
|
|
+ historyCmd |
|
|
|
|
+ '\'' |
|
|
|
|
+ ", dependenceScheduleTimes='" |
|
|
|
|
+ dependenceScheduleTimes |
|
|
|
|
+ '\'' |
|
|
|
|
+ ", duration=" |
|
|
|
|
+ duration |
|
|
|
|
+ ", processInstancePriority=" |
|
|
|
|
+ processInstancePriority |
|
|
|
|
+ ", workerGroup='" |
|
|
|
|
+ workerGroup |
|
|
|
|
+ '\'' |
|
|
|
|
+ ", timeout=" |
|
|
|
|
+ timeout |
|
|
|
|
+ ", tenantId=" |
|
|
|
|
+ tenantId |
|
|
|
|
+ ", receivers='" |
|
|
|
|
+ receivers |
|
|
|
|
+ '\'' |
|
|
|
|
+ ", receiversCc='" |
|
|
|
|
+ receiversCc |
|
|
|
|
+ '\'' |
|
|
|
|
+ '}'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|