Browse Source

[BUG][WORKER-9349]fix param priority (#9379)

* fix param priority

* fix params priority code logic
3.0.0/version-upgrade
Tq 3 years ago committed by GitHub
parent
commit
2a4fa9cdb1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parameters/AbstractParameters.java
  2. 20
      dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parser/ParamUtils.java

10
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parameters/AbstractParameters.java

@ -75,15 +75,14 @@ public abstract class AbstractParameters implements IParameters {
* @return parameters map * @return parameters map
*/ */
public Map<String, Property> getLocalParametersMap() { public Map<String, Property> getLocalParametersMap() {
if (localParams != null) {
Map<String, Property> localParametersMaps = new LinkedHashMap<>(); Map<String, Property> localParametersMaps = new LinkedHashMap<>();
if (localParams != null) {
for (Property property : localParams) { for (Property property : localParams) {
localParametersMaps.put(property.getProp(),property); localParametersMaps.put(property.getProp(),property);
} }
return localParametersMaps;
} }
return null; return localParametersMaps;
} }
/** /**
@ -92,14 +91,13 @@ public abstract class AbstractParameters implements IParameters {
* @return parameters map * @return parameters map
*/ */
public Map<String, Property> getVarPoolMap() { public Map<String, Property> getVarPoolMap() {
if (varPool != null) {
Map<String, Property> varPoolMap = new LinkedHashMap<>(); Map<String, Property> varPoolMap = new LinkedHashMap<>();
if (varPool != null) {
for (Property property : varPool) { for (Property property : varPool) {
varPoolMap.put(property.getProp(), property); varPoolMap.put(property.getProp(), property);
} }
return varPoolMap;
} }
return null; return varPoolMap;
} }
public List<Property> getVarPool() { public List<Property> getVarPool() {

20
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parser/ParamUtils.java

@ -63,9 +63,10 @@ public class ParamUtils {
// combining local and global parameters // combining local and global parameters
Map<String, Property> localParams = parameters.getLocalParametersMap(); Map<String, Property> localParams = parameters.getLocalParametersMap();
//stream pass params
Map<String, Property> varParams = parameters.getVarPoolMap(); Map<String, Property> varParams = parameters.getVarPoolMap();
if (globalParams == null && localParams == null) { if (globalParams.size() == 0 && localParams.size() == 0 && varParams.size() == 0) {
return null; return null;
} }
// if it is a complement, // if it is a complement,
@ -85,15 +86,13 @@ public class ParamUtils {
} }
params.put(PARAMETER_TASK_INSTANCE_ID, Integer.toString(taskExecutionContext.getTaskInstanceId())); params.put(PARAMETER_TASK_INSTANCE_ID, Integer.toString(taskExecutionContext.getTaskInstanceId()));
if (globalParams != null && localParams != null) { if (varParams.size() != 0) {
globalParams.putAll(localParams); globalParams.putAll(varParams);
} else if (globalParams == null && localParams != null) {
globalParams = localParams;
} }
if (varParams != null) { if (localParams.size() != 0) {
varParams.putAll(globalParams); globalParams.putAll(localParams);
globalParams = varParams;
} }
Iterator<Map.Entry<String, Property>> iter = globalParams.entrySet().iterator(); Iterator<Map.Entry<String, Property>> iter = globalParams.entrySet().iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
Map.Entry<String, Property> en = iter.next(); Map.Entry<String, Property> en = iter.next();
@ -143,16 +142,15 @@ public class ParamUtils {
* @return parameters map * @return parameters map
*/ */
public static Map<String, Property> getUserDefParamsMap(Map<String, String> definedParams) { public static Map<String, Property> getUserDefParamsMap(Map<String, String> definedParams) {
if (definedParams != null) {
Map<String, Property> userDefParamsMaps = new HashMap<>(); Map<String, Property> userDefParamsMaps = new HashMap<>();
if (definedParams != null) {
Iterator<Map.Entry<String, String>> iter = definedParams.entrySet().iterator(); Iterator<Map.Entry<String, String>> iter = definedParams.entrySet().iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
Map.Entry<String, String> en = iter.next(); Map.Entry<String, String> en = iter.next();
Property property = new Property(en.getKey(), Direct.IN, DataType.VARCHAR, en.getValue()); Property property = new Property(en.getKey(), Direct.IN, DataType.VARCHAR, en.getValue());
userDefParamsMaps.put(property.getProp(),property); userDefParamsMaps.put(property.getProp(),property);
} }
return userDefParamsMaps;
} }
return null; return userDefParamsMaps;
} }
} }
Loading…
Cancel
Save