kezhenxu94
2 years ago
committed by
GitHub
132 changed files with 702 additions and 1125 deletions
@ -1,83 +0,0 @@ |
|||||||
/* |
|
||||||
* 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.utils.placeholder; |
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.common.utils.DateUtils; |
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.parser.TimePlaceholderUtils; |
|
||||||
|
|
||||||
import java.util.Date; |
|
||||||
import java.util.TimeZone; |
|
||||||
|
|
||||||
import org.junit.Assert; |
|
||||||
import org.junit.Before; |
|
||||||
import org.junit.BeforeClass; |
|
||||||
import org.junit.Test; |
|
||||||
|
|
||||||
public class TimePlaceholderUtilsTest { |
|
||||||
|
|
||||||
private Date date; |
|
||||||
|
|
||||||
@BeforeClass |
|
||||||
public static void setup() { |
|
||||||
TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")); |
|
||||||
} |
|
||||||
|
|
||||||
@Before |
|
||||||
public void init() { |
|
||||||
date = DateUtils.parse("20170101010101", "yyyyMMddHHmmss", null); |
|
||||||
} |
|
||||||
|
|
||||||
@Test |
|
||||||
public void replacePlaceholdersT() { |
|
||||||
Assert.assertEquals("2017test12017:***2016-12-31,20170102,20170130,20161227,20161231", TimePlaceholderUtils |
|
||||||
.replacePlaceholders("$[yyyy]test1$[yyyy:***]$[yyyy-MM-dd-1],$[month_begin(yyyyMMdd, 1)],$[month_end(yyyyMMdd, -1)],$[week_begin(yyyyMMdd, 1)],$[week_end(yyyyMMdd, -1)]", |
|
||||||
date, true)); |
|
||||||
|
|
||||||
Assert.assertEquals("1483200061,1483290061,1485709261,1482771661,1483113600,1483203661", TimePlaceholderUtils.replacePlaceholders("$[timestamp(yyyyMMdd00mmss)]," |
|
||||||
+ "$[timestamp(month_begin(yyyyMMddHHmmss, 1))]," |
|
||||||
+ "$[timestamp(month_end(yyyyMMddHHmmss, -1))]," |
|
||||||
+ "$[timestamp(week_begin(yyyyMMddHHmmss, 1))]," |
|
||||||
+ "$[timestamp(week_end(yyyyMMdd000000, -1))]," |
|
||||||
+ "$[timestamp(yyyyMMddHHmmss)]", |
|
||||||
date, true)); |
|
||||||
} |
|
||||||
|
|
||||||
@Test |
|
||||||
public void calcMinutesT() { |
|
||||||
Assert.assertEquals("Sun Jan 01 01:01:01 CST 2017=yyyy", TimePlaceholderUtils.calcMinutes("yyyy", date).toString()); |
|
||||||
Assert.assertEquals("Sun Jan 08 01:01:01 CST 2017=yyyyMMdd", TimePlaceholderUtils.calcMinutes("yyyyMMdd+7*1", date).toString()); |
|
||||||
Assert.assertEquals("Sun Dec 25 01:01:01 CST 2016=yyyyMMdd", TimePlaceholderUtils.calcMinutes("yyyyMMdd-7*1", date).toString()); |
|
||||||
Assert.assertEquals("Mon Jan 02 01:01:01 CST 2017=yyyyMMdd", TimePlaceholderUtils.calcMinutes("yyyyMMdd+1", date).toString()); |
|
||||||
Assert.assertEquals("Sat Dec 31 01:01:01 CST 2016=yyyyMMdd", TimePlaceholderUtils.calcMinutes("yyyyMMdd-1", date).toString()); |
|
||||||
Assert.assertEquals("Sun Jan 01 02:01:01 CST 2017=yyyyMMddHH", TimePlaceholderUtils.calcMinutes("yyyyMMddHH+1/24", date).toString()); |
|
||||||
Assert.assertEquals("Sun Jan 01 00:01:01 CST 2017=yyyyMMddHH", TimePlaceholderUtils.calcMinutes("yyyyMMddHH-1/24", date).toString()); |
|
||||||
} |
|
||||||
|
|
||||||
@Test |
|
||||||
public void calcMonthsT() { |
|
||||||
Assert.assertEquals("Mon Jan 01 01:01:01 CST 2018=yyyyMMdd", TimePlaceholderUtils.calcMonths("add_months(yyyyMMdd,12*1)", date).toString()); |
|
||||||
Assert.assertEquals("Fri Jan 01 01:01:01 CST 2016=yyyyMMdd", TimePlaceholderUtils.calcMonths("add_months(yyyyMMdd,-12*1)", date).toString()); |
|
||||||
} |
|
||||||
|
|
||||||
@Test |
|
||||||
public void testGetPlaceHolderTime() { |
|
||||||
|
|
||||||
Assert.assertEquals("20170101", TimePlaceholderUtils.getPlaceHolderTime("yyyyMMdd", date)); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
@ -1,115 +0,0 @@ |
|||||||
/* |
|
||||||
* 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 org.apache.dolphinscheduler.common.model.TaskNode; |
|
||||||
import org.apache.dolphinscheduler.common.utils.CollectionUtils; |
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.model.Property; |
|
||||||
|
|
||||||
import java.util.List; |
|
||||||
|
|
||||||
/** |
|
||||||
* definition json data structure |
|
||||||
*/ |
|
||||||
public class ProcessData { |
|
||||||
/** |
|
||||||
* task list |
|
||||||
*/ |
|
||||||
private List<TaskNode> tasks; |
|
||||||
|
|
||||||
/** |
|
||||||
* global parameters |
|
||||||
*/ |
|
||||||
private List<Property> globalParams; |
|
||||||
|
|
||||||
|
|
||||||
private int timeout; |
|
||||||
|
|
||||||
private int tenantId; |
|
||||||
|
|
||||||
|
|
||||||
public ProcessData() { |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* |
|
||||||
* @param tasks tasks |
|
||||||
* @param globalParams globalParams |
|
||||||
*/ |
|
||||||
public ProcessData(List<TaskNode> tasks, List<Property> globalParams) { |
|
||||||
this.tasks = tasks; |
|
||||||
this.globalParams = globalParams; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public boolean equals(Object o) { |
|
||||||
if (this == o) { |
|
||||||
return true; |
|
||||||
} |
|
||||||
|
|
||||||
if (o == null || getClass() != o.getClass()) { |
|
||||||
return false; |
|
||||||
} |
|
||||||
|
|
||||||
ProcessData that = (ProcessData) o; |
|
||||||
|
|
||||||
return CollectionUtils.equalLists(tasks, that.tasks) && |
|
||||||
CollectionUtils.equalLists(globalParams, that.globalParams); |
|
||||||
} |
|
||||||
|
|
||||||
public List<TaskNode> getTasks() { |
|
||||||
return tasks; |
|
||||||
} |
|
||||||
|
|
||||||
public void setTasks(List<TaskNode> tasks) { |
|
||||||
this.tasks = tasks; |
|
||||||
} |
|
||||||
|
|
||||||
public List<Property> getGlobalParams() { |
|
||||||
return globalParams; |
|
||||||
} |
|
||||||
|
|
||||||
public void setGlobalParams(List<Property> globalParams) { |
|
||||||
this.globalParams = globalParams; |
|
||||||
} |
|
||||||
|
|
||||||
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; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String toString() { |
|
||||||
return "ProcessData{" + |
|
||||||
"tasks=" + tasks + |
|
||||||
", globalParams=" + globalParams + |
|
||||||
", timeout=" + timeout + |
|
||||||
", tenantId=" + tenantId + |
|
||||||
'}'; |
|
||||||
} |
|
||||||
} |
|
@ -0,0 +1,44 @@ |
|||||||
|
/* |
||||||
|
* 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.service.utils; |
||||||
|
|
||||||
|
import org.apache.dolphinscheduler.common.enums.WorkflowExecutionStatus; |
||||||
|
import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus; |
||||||
|
|
||||||
|
import lombok.experimental.UtilityClass; |
||||||
|
|
||||||
|
@UtilityClass |
||||||
|
public final class Constants { |
||||||
|
|
||||||
|
public static final int[] NOT_TERMINATED_STATES = new int[]{ |
||||||
|
WorkflowExecutionStatus.SUBMITTED_SUCCESS.getCode(), |
||||||
|
TaskExecutionStatus.DISPATCH.getCode(), |
||||||
|
WorkflowExecutionStatus.RUNNING_EXECUTION.getCode(), |
||||||
|
WorkflowExecutionStatus.DELAY_EXECUTION.getCode(), |
||||||
|
WorkflowExecutionStatus.READY_PAUSE.getCode(), |
||||||
|
WorkflowExecutionStatus.READY_STOP.getCode(), |
||||||
|
TaskExecutionStatus.NEED_FAULT_TOLERANCE.getCode(), |
||||||
|
}; |
||||||
|
|
||||||
|
public static final int[] RUNNING_PROCESS_STATE = new int[]{ |
||||||
|
TaskExecutionStatus.RUNNING_EXECUTION.getCode(), |
||||||
|
TaskExecutionStatus.SUBMITTED_SUCCESS.getCode(), |
||||||
|
TaskExecutionStatus.DISPATCH.getCode(), |
||||||
|
WorkflowExecutionStatus.SERIAL_WAIT.getCode() |
||||||
|
}; |
||||||
|
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue