Skip to content

Commit

Permalink
Update ExecuteJarOperation.java
Browse files Browse the repository at this point in the history
  • Loading branch information
Pandas886 authored Mar 12, 2024
1 parent af931a8 commit 3ba46ca
Showing 1 changed file with 29 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@

package org.dinky.trans.dml;

import org.apache.commons.lang.StringUtils;
import org.dinky.executor.CustomTableEnvironment;
import org.dinky.trans.AbstractOperation;
import org.dinky.trans.ExtendOperation;
import org.dinky.trans.parse.ExecuteJarParseStrategy;
import org.dinky.utils.RunTimeUtil;
import org.dinky.utils.URLUtils;

import org.apache.flink.api.dag.Pipeline;
Expand All @@ -37,7 +37,10 @@

import java.io.File;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Optional;

Expand Down Expand Up @@ -99,7 +102,7 @@ public static StreamGraph getStreamGraph(
.setEntryPointClassName(submitParam.getMainClass())
.setConfiguration(configuration)
.setSavepointRestoreSettings(savepointRestoreSettings)
.setArguments(RunTimeUtil.handleCmds(submitParam.getArgs()))
.setArguments(extractArgs(submitParam.getArgs().trim()).toArray(new String[0]))
.setUserClassPaths(classpaths)
.build();
int parallelism = StrUtil.isNumeric(submitParam.getParallelism())
Expand All @@ -114,6 +117,30 @@ public static StreamGraph getStreamGraph(
}
}

public static List<String> extractArgs(String args) {
List<String> programArgs = new ArrayList<>();
if (StringUtils.isNotEmpty(args)) {
String[] array = args.split("\\s+");
Iterator<String> iter = Arrays.asList(array).iterator();
while (iter.hasNext()) {
String v = iter.next();
String p = v.substring(0, 1);
if (p.equals("'") || p.equals("\"")) {
String value = v;
if (!v.endsWith(p)) {
while (!value.endsWith(p) && iter.hasNext()) {
value += " " + iter.next();
}
}
programArgs.add(value.substring(1, value.length() - 1));
} else {
programArgs.add(v);
}
}
}
return programArgs;
}

@Override
public String asSummaryString() {
return statement;
Expand Down Expand Up @@ -142,7 +169,6 @@ protected JarSubmitParam() {}
public static JarSubmitParam build(String statement) {
JarSubmitParam submitParam = ExecuteJarParseStrategy.getInfo(statement);
Assert.notBlank(submitParam.getUri());
Assert.notBlank(submitParam.getMainClass());
return submitParam;
}
}
Expand Down

0 comments on commit 3ba46ca

Please sign in to comment.