From 375ec125c5cc50a9634fac120a9936ccfc2807c7 Mon Sep 17 00:00:00 2001 From: BoYiZhang <39816903+BoYiZhang@users.noreply.github.com> Date: Tue, 22 Sep 2020 17:38:17 +0800 Subject: [PATCH] [Feature-3773][processInstance, taskInstance] Change title name : Replacement System.currentTimeMillis () (#3774) * fix bug Delete invalid field: executorcores Modify verification prompt * fix bug Delete invalid field: executorcores Modify verification prompt * fix bug Delete invalid field: executorcores Modify verification prompt * dag add close button * reset last version * reset last version * dag add close buttion dag add close buttion * update CLICK_SAVE_WORKFLOW_BUTTON xpath * updae CLICK_SAVE_WORKFLOW_BUTTON xpath * updae CLICK_SAVE_WORKFLOW_BUTTON xpath * updae CLICK_SAVE_WORKFLOW_BUTTON xpath * Update CreateWorkflowLocator.java modify submit workflow button * Update CreateWorkflowLocator.java * Update CreateWorkflowLocator.java modify CLICK_ADD_BUTTON * Update CreateWorkflowLocator.java delete print * Update CreateWorkflowLocator.java 1 * Update CreateWorkflowLocator.java 1 * Setting '-XX:+DisableExplicitGC ' causes netty memory leaks in addition update '- XX: largepagesizeinbytes = 128M' to '- XX: largepagesizeinbytes = 10M' * Update dag.vue * Update dag.vue * Update dag.vue * Update CreateWorkflowLocator.java * Revert "Setting '-XX:+DisableExplicitGC ' causes netty memory leaks" This reverts commit 3a2cba7a * Setting '-XX:+DisableExplicitGC ' causes netty memory leaks in addition update '- XX: largepagesizeinbytes = 128M' to '- XX: largepagesizeinbytes = 10M' * Update dolphinscheduler-daemon.sh * Replacement System.currentTimeMillis () to DateUtils.getCurrentTimeStamp() * update checkstyle * update checkstyle Co-authored-by: dailidong Co-authored-by: xingchun-chen <55787491+xingchun-chen@users.noreply.github.com> --- .../impl/ProcessDefinitionServiceImpl.java | 4 +- .../dolphinscheduler/common/Constants.java | 4 + .../common/utils/DateUtils.java | 10 + .../common/utils/DateUtilsTest.java | 19 +- .../dao/entity/ProcessInstance.java | 200 +++++++++++------- 5 files changed, 155 insertions(+), 82 deletions(-) diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java index a5e297072c..f4ea1bf065 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java @@ -845,7 +845,7 @@ public class ProcessDefinitionServiceImpl extends BaseService implements try { createProcessResult = createProcessDefinition(loginUser , currentProjectName, - processDefinitionName + "_import_" + System.currentTimeMillis(), + processDefinitionName + "_import_" + DateUtils.getCurrentTimeStamp(), importProcessParam, processMeta.getProcessDefinitionDescription(), processMeta.getProcessDefinitionLocations(), @@ -1433,7 +1433,7 @@ public class ProcessDefinitionServiceImpl extends BaseService implements return createProcessDefinition( loginUser, targetProject.getName(), - processDefinition.getName() + "_copy_" + System.currentTimeMillis(), + processDefinition.getName() + "_copy_" + DateUtils.getCurrentTimeStamp(), processDefinition.getProcessDefinitionJson(), processDefinition.getDescription(), processDefinition.getLocations(), diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java index ba8b0c4921..85066cc55a 100644 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java +++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java @@ -266,6 +266,10 @@ public final class Constants { */ public static final String YYYYMMDDHHMMSS = "yyyyMMddHHmmss"; + /** + * date format of yyyyMMddHHmmssSSS + */ + public static final String YYYYMMDDHHMMSSSSS = "yyyyMMddHHmmssSSS"; /** * http connect time out */ diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/DateUtils.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/DateUtils.java index 283b4e7f80..80c0ed411c 100644 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/DateUtils.java +++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/DateUtils.java @@ -444,4 +444,14 @@ public class DateUtils { long usedTime = (System.currentTimeMillis() - baseTime.getTime()) / 1000; return intervalSeconds - usedTime; } + + /** + * get current time stamp : yyyyMMddHHmmssSSS + * + * @return date string + */ + public static String getCurrentTimeStamp() { + return getCurrentTime(Constants.YYYYMMDDHHMMSSSSS); + } + } diff --git a/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/DateUtilsTest.java b/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/DateUtilsTest.java index 6800f6b542..fa16446cd8 100644 --- a/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/DateUtilsTest.java +++ b/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/DateUtilsTest.java @@ -14,14 +14,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.dolphinscheduler.common.utils; -import org.junit.Assert; -import org.junit.Test; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; +import org.junit.Assert; +import org.junit.Test; + public class DateUtilsTest { @Test public void format2Readable() throws ParseException { @@ -38,10 +40,8 @@ public class DateUtilsTest { Assert.assertEquals("01 09:23:08", readableDate); } - @Test - public void testWeek(){ - + public void testWeek() { Date curr = DateUtils.stringToDate("2019-02-01 00:00:00"); Date monday1 = DateUtils.stringToDate("2019-01-28 00:00:00"); Date sunday1 = DateUtils.stringToDate("2019-02-03 00:00:00"); @@ -54,7 +54,7 @@ public class DateUtilsTest { } @Test - public void diffHours(){ + public void diffHours() { Date d1 = DateUtils.stringToDate("2019-01-28 00:00:00"); Date d2 = DateUtils.stringToDate("2019-01-28 20:00:00"); Assert.assertEquals(DateUtils.diffHours(d1, d2), 20); @@ -150,4 +150,11 @@ public class DateUtilsTest { Date curr = DateUtils.getEndOfHour(d1); Assert.assertEquals(DateUtils.dateToString(curr), "2019-01-31 11:59:59"); } + + @Test + public void getCurrentTimeStamp() { + String timeStamp = DateUtils.getCurrentTimeStamp(); + Assert.assertNotNull(timeStamp); + } + } diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessInstance.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessInstance.java index 28f1eba975..3d1a756d25 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessInstance.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessInstance.java @@ -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; /** @@ -108,7 +117,7 @@ public class ProcessInstance { private FailureStrategy failureStrategy; /** - * warning type + * warning type */ private WarningType warningType; @@ -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