You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by ki...@apache.org on 2021/11/14 01:36:51 UTC
[dolphinscheduler] branch 2.0.0-release-prepare updated: [Fix-6707][common] Fix complement data error because of global variables (#6759) (#6839)
This is an automated email from the ASF dual-hosted git repository.
kirs pushed a commit to branch 2.0.0-release-prepare
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git
The following commit(s) were added to refs/heads/2.0.0-release-prepare by this push:
new ae08769 [Fix-6707][common] Fix complement data error because of global variables (#6759) (#6839)
ae08769 is described below
commit ae087699af87839159500dc26c3c32ad56c4a151
Author: OS <29...@users.noreply.github.com>
AuthorDate: Sun Nov 14 09:36:43 2021 +0800
[Fix-6707][common] Fix complement data error because of global variables (#6759) (#6839)
---
.../common/utils/ParameterUtils.java | 4 +-
.../utils/placeholder/BusinessTimeUtils.java | 81 ++++++++++++----------
2 files changed, 45 insertions(+), 40 deletions(-)
diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/ParameterUtils.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/ParameterUtils.java
index 8aa6f80..c7e6e14 100644
--- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/ParameterUtils.java
+++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/ParameterUtils.java
@@ -173,8 +173,8 @@ public class ParameterUtils {
}
Map<String, String> allParamMap = new HashMap<>();
//If it is a complement, a complement time needs to be passed in, according to the task type
- Map<String, String> timeParams = BusinessTimeUtils
- .getBusinessTime(commandType, scheduleTime);
+ Map<String, String> timeParams = BusinessTimeUtils.
+ getBusinessTime(commandType, scheduleTime);
if (timeParams != null) {
allParamMap.putAll(timeParams);
diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/placeholder/BusinessTimeUtils.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/placeholder/BusinessTimeUtils.java
index 23db4b6..3c220f9 100644
--- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/placeholder/BusinessTimeUtils.java
+++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/placeholder/BusinessTimeUtils.java
@@ -14,6 +14,7 @@
* 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.Constants;
@@ -33,43 +34,47 @@ import static org.apache.commons.lang.time.DateUtils.addDays;
* business time utils
*/
public class BusinessTimeUtils {
- private BusinessTimeUtils() {
- throw new IllegalStateException("BusinessTimeUtils class");
- }
- /**
- * get business time in parameters by different command types
- *
- * @param commandType command type
- * @param runTime run time or schedule time
- * @return business time
- */
- public static Map<String, String> getBusinessTime(CommandType commandType, Date runTime) {
- Date businessDate = runTime;
- switch (commandType) {
- case COMPLEMENT_DATA:
- break;
- case START_PROCESS:
- case START_CURRENT_TASK_PROCESS:
- case RECOVER_TOLERANCE_FAULT_PROCESS:
- case RECOVER_SUSPENDED_PROCESS:
- case START_FAILURE_TASK_PROCESS:
- case REPEAT_RUNNING:
- case SCHEDULER:
- default:
- businessDate = addDays(new Date(), -1);
- if (runTime != null){
- /**
- * If there is a scheduled time, take the scheduling time. Recovery from failed nodes, suspension of recovery, re-run for scheduling
- */
- businessDate = addDays(runTime, -1);
- }
- break;
+ private BusinessTimeUtils() {
+ throw new IllegalStateException("BusinessTimeUtils class");
+ }
+
+ /**
+ * get business time in parameters by different command types
+ *
+ * @param commandType command type
+ * @param runTime run time or schedule time
+ * @return business time
+ */
+ public static Map<String, String> getBusinessTime(CommandType commandType, Date runTime) {
+ Date businessDate = runTime;
+ Map<String, String> result = new HashMap<>();
+ switch (commandType) {
+ case COMPLEMENT_DATA:
+ if (runTime == null) {
+ return result;
+ }
+ break;
+ case START_PROCESS:
+ case START_CURRENT_TASK_PROCESS:
+ case RECOVER_TOLERANCE_FAULT_PROCESS:
+ case RECOVER_SUSPENDED_PROCESS:
+ case START_FAILURE_TASK_PROCESS:
+ case REPEAT_RUNNING:
+ case SCHEDULER:
+ default:
+ businessDate = addDays(new Date(), -1);
+ if (runTime != null) {
+ /**
+ * If there is a scheduled time, take the scheduling time. Recovery from failed nodes, suspension of recovery, re-run for scheduling
+ */
+ businessDate = addDays(runTime, -1);
+ }
+ break;
+ }
+ Date businessCurrentDate = addDays(businessDate, 1);
+ result.put(Constants.PARAMETER_CURRENT_DATE, format(businessCurrentDate, PARAMETER_FORMAT_DATE));
+ result.put(Constants.PARAMETER_BUSINESS_DATE, format(businessDate, PARAMETER_FORMAT_DATE));
+ result.put(Constants.PARAMETER_DATETIME, format(businessCurrentDate, PARAMETER_FORMAT_TIME));
+ return result;
}
- Date businessCurrentDate = addDays(businessDate, 1);
- Map<String, String> result = new HashMap<>();
- result.put(Constants.PARAMETER_CURRENT_DATE, format(businessCurrentDate, PARAMETER_FORMAT_DATE));
- result.put(Constants.PARAMETER_BUSINESS_DATE, format(businessDate, PARAMETER_FORMAT_DATE));
- result.put(Constants.PARAMETER_DATETIME, format(businessCurrentDate, PARAMETER_FORMAT_TIME));
- return result;
- }
}