Browse Source

fixbug: varPool value is error (#7724)

3.0.0/version-upgrade
Ivan0626 3 years ago committed by GitHub
parent
commit
60ddede6a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/TaskConstants.java
  2. 20
      dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/AbstractCommandExecutor.java

3
dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/TaskConstants.java

@ -24,6 +24,8 @@ public class TaskConstants {
}
public static final String APPLICATION_REGEX = "application_\\d+_\\d+";
public static final String SETVALUE_REGEX = "\\$\\{setValue\\(([^)]*)\\)}";
/**
* string false
@ -369,4 +371,5 @@ public class TaskConstants {
* data.quality.error.output.path
*/
public static final String DATA_QUALITY_ERROR_OUTPUT_PATH = "data-quality.error.output.path";
}

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

@ -60,6 +60,11 @@ public abstract class AbstractCommandExecutor {
* rules for extracting application ID
*/
protected static final Pattern APPLICATION_REGEX = Pattern.compile(TaskConstants.APPLICATION_REGEX);
/**
* rules for extracting Var Pool
*/
protected static final Pattern SETVALUE_REGEX = Pattern.compile(TaskConstants.SETVALUE_REGEX);
protected StringBuilder varPool = new StringBuilder();
/**
@ -318,7 +323,7 @@ public abstract class AbstractCommandExecutor {
String line;
while ((line = inReader.readLine()) != null) {
if (line.startsWith("${setValue(")) {
varPool.append(line, "${setValue(".length(), line.length() - 2);
varPool.append(findVarPool(line));
varPool.append("$VarPool$");
} else {
logBuffer.add(line);
@ -403,6 +408,19 @@ public abstract class AbstractCommandExecutor {
return lineList;
}
/**
* find var pool
* @param line
* @return
*/
private String findVarPool(String line){
Matcher matcher = SETVALUE_REGEX.matcher(line);
if (matcher.find()) {
return matcher.group(1);
}
return null;
}
/**
* find app id

Loading…
Cancel
Save