diff options
author | Devaraj K <devaraj@apache.org> | 2016-06-03 13:03:28 -0700 |
---|---|---|
committer | Marcelo Vanzin <vanzin@cloudera.com> | 2016-06-03 13:03:28 -0700 |
commit | efd3b11a47ec553f68ab6aa714167f3aee2ecf56 (patch) | |
tree | 76b12d3b293bd2156f0f1990c6fe90c505065396 /launcher/src/main/java/org | |
parent | 9e2eb13ca59fc7ac66c6accd49469f339700b23b (diff) | |
download | spark-efd3b11a47ec553f68ab6aa714167f3aee2ecf56.tar.gz spark-efd3b11a47ec553f68ab6aa714167f3aee2ecf56.tar.bz2 spark-efd3b11a47ec553f68ab6aa714167f3aee2ecf56.zip |
[SPARK-15665][CORE] spark-submit --kill and --status are not working
## What changes were proposed in this pull request?
--kill and --status were not considered while handling in OptionParser and due to that it was failing. Now handling the --kill and --status options as part of OptionParser.handle.
## How was this patch tested?
Added a test org.apache.spark.launcher.SparkSubmitCommandBuilderSuite.testCliKillAndStatus() and also I have verified these manually by running --kill and --status commands.
Author: Devaraj K <devaraj@apache.org>
Closes #13407 from devaraj-kavali/SPARK-15665.
Diffstat (limited to 'launcher/src/main/java/org')
-rw-r--r-- | launcher/src/main/java/org/apache/spark/launcher/SparkSubmitCommandBuilder.java | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/launcher/src/main/java/org/apache/spark/launcher/SparkSubmitCommandBuilder.java b/launcher/src/main/java/org/apache/spark/launcher/SparkSubmitCommandBuilder.java index 824500d980..b3ccc4805f 100644 --- a/launcher/src/main/java/org/apache/spark/launcher/SparkSubmitCommandBuilder.java +++ b/launcher/src/main/java/org/apache/spark/launcher/SparkSubmitCommandBuilder.java @@ -89,7 +89,7 @@ class SparkSubmitCommandBuilder extends AbstractCommandBuilder { } final List<String> sparkArgs; - private final boolean printInfo; + private final boolean isAppResourceReq; private final boolean isExample; /** @@ -101,7 +101,7 @@ class SparkSubmitCommandBuilder extends AbstractCommandBuilder { SparkSubmitCommandBuilder() { this.sparkArgs = new ArrayList<>(); - this.printInfo = false; + this.isAppResourceReq = true; this.isExample = false; } @@ -133,19 +133,19 @@ class SparkSubmitCommandBuilder extends AbstractCommandBuilder { this.isExample = isExample; OptionParser parser = new OptionParser(); parser.parse(submitArgs); - this.printInfo = parser.infoRequested; + this.isAppResourceReq = parser.isAppResourceReq; } else { this.isExample = isExample; - this.printInfo = true; + this.isAppResourceReq = false; } } @Override public List<String> buildCommand(Map<String, String> env) throws IOException, IllegalArgumentException { - if (PYSPARK_SHELL.equals(appResource) && !printInfo) { + if (PYSPARK_SHELL.equals(appResource) && isAppResourceReq) { return buildPySparkShellCommand(env); - } else if (SPARKR_SHELL.equals(appResource) && !printInfo) { + } else if (SPARKR_SHELL.equals(appResource) && isAppResourceReq) { return buildSparkRCommand(env); } else { return buildSparkSubmitCommand(env); @@ -156,7 +156,7 @@ class SparkSubmitCommandBuilder extends AbstractCommandBuilder { List<String> args = new ArrayList<>(); SparkSubmitOptionParser parser = new SparkSubmitOptionParser(); - if (!allowsMixedArguments && !printInfo) { + if (!allowsMixedArguments && isAppResourceReq) { checkArgument(appResource != null, "Missing application resource."); } @@ -208,7 +208,7 @@ class SparkSubmitCommandBuilder extends AbstractCommandBuilder { args.add(join(",", pyFiles)); } - if (!printInfo) { + if (isAppResourceReq) { checkArgument(!isExample || mainClass != null, "Missing example class name."); } if (mainClass != null) { @@ -388,7 +388,7 @@ class SparkSubmitCommandBuilder extends AbstractCommandBuilder { private class OptionParser extends SparkSubmitOptionParser { - boolean infoRequested = false; + boolean isAppResourceReq = true; @Override protected boolean handle(String opt, String value) { @@ -420,11 +420,15 @@ class SparkSubmitCommandBuilder extends AbstractCommandBuilder { allowsMixedArguments = true; appResource = specialClasses.get(value); } + } else if (opt.equals(KILL_SUBMISSION) || opt.equals(STATUS)) { + isAppResourceReq = false; + sparkArgs.add(opt); + sparkArgs.add(value); } else if (opt.equals(HELP) || opt.equals(USAGE_ERROR)) { - infoRequested = true; + isAppResourceReq = false; sparkArgs.add(opt); } else if (opt.equals(VERSION)) { - infoRequested = true; + isAppResourceReq = false; sparkArgs.add(opt); } else { sparkArgs.add(opt); |