Browse Source

[Fix-6707][common] Fix complement data error because of global variables (#6759)

* [Fix-6707][common] Fix complement data error because of global variables

* [Fix-6707][common] Fix complement data error because of global variables

* [Fix-6707][common] Fix complement data error because of global variables

* [Fix-6707][common] Fix complement data error because of global variables

Co-authored-by: shangeyao <sgy960921>
Co-authored-by: OS <29528966+lenboo@users.noreply.github.com>
3.0.0/version-upgrade
Assert 3 years ago committed by GitHub
parent
commit
089f73ebe4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/ParameterUtils.java
  2. 81
      dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/placeholder/BusinessTimeUtils.java

4
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/ParameterUtils.java

@ -99,8 +99,8 @@ public class ParameterUtils {
} }
Map<String, String> allParamMap = new HashMap<>(); Map<String, String> allParamMap = new HashMap<>();
//If it is a complement, a complement time needs to be passed in, according to the task type //If it is a complement, a complement time needs to be passed in, according to the task type
Map<String, String> timeParams = BusinessTimeUtils Map<String, String> timeParams = BusinessTimeUtils.
.getBusinessTime(commandType, scheduleTime); getBusinessTime(commandType, scheduleTime);
if (timeParams != null) { if (timeParams != null) {
allParamMap.putAll(timeParams); allParamMap.putAll(timeParams);

81
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 * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.dolphinscheduler.common.utils.placeholder; package org.apache.dolphinscheduler.common.utils.placeholder;
import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.Constants;
@ -33,43 +34,47 @@ import static org.apache.commons.lang.time.DateUtils.addDays;
* business time utils * business time utils
*/ */
public class BusinessTimeUtils { public class BusinessTimeUtils {
private BusinessTimeUtils() { private BusinessTimeUtils() {
throw new IllegalStateException("BusinessTimeUtils class"); throw new IllegalStateException("BusinessTimeUtils class");
} }
/**
* get business time in parameters by different command types /**
* * get business time in parameters by different command types
* @param commandType command type *
* @param runTime run time or schedule time * @param commandType command type
* @return business time * @param runTime run time or schedule time
*/ * @return business time
public static Map<String, String> getBusinessTime(CommandType commandType, Date runTime) { */
Date businessDate = runTime; public static Map<String, String> getBusinessTime(CommandType commandType, Date runTime) {
switch (commandType) { Date businessDate = runTime;
case COMPLEMENT_DATA: Map<String, String> result = new HashMap<>();
break; switch (commandType) {
case START_PROCESS: case COMPLEMENT_DATA:
case START_CURRENT_TASK_PROCESS: if (runTime == null) {
case RECOVER_TOLERANCE_FAULT_PROCESS: return result;
case RECOVER_SUSPENDED_PROCESS: }
case START_FAILURE_TASK_PROCESS: break;
case REPEAT_RUNNING: case START_PROCESS:
case SCHEDULER: case START_CURRENT_TASK_PROCESS:
default: case RECOVER_TOLERANCE_FAULT_PROCESS:
businessDate = addDays(new Date(), -1); case RECOVER_SUSPENDED_PROCESS:
if (runTime != null){ case START_FAILURE_TASK_PROCESS:
/** case REPEAT_RUNNING:
* If there is a scheduled time, take the scheduling time. Recovery from failed nodes, suspension of recovery, re-run for scheduling case SCHEDULER:
*/ default:
businessDate = addDays(runTime, -1); businessDate = addDays(new Date(), -1);
} if (runTime != null) {
break; /**
* 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;
}
} }

Loading…
Cancel
Save