aboutsummaryrefslogtreecommitdiff
path: root/launcher/src
diff options
context:
space:
mode:
authorDevaraj K <devaraj@apache.org>2016-06-03 13:03:28 -0700
committerMarcelo Vanzin <vanzin@cloudera.com>2016-06-03 13:03:28 -0700
commitefd3b11a47ec553f68ab6aa714167f3aee2ecf56 (patch)
tree76b12d3b293bd2156f0f1990c6fe90c505065396 /launcher/src
parent9e2eb13ca59fc7ac66c6accd49469f339700b23b (diff)
downloadspark-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')
-rw-r--r--launcher/src/main/java/org/apache/spark/launcher/SparkSubmitCommandBuilder.java26
-rw-r--r--launcher/src/test/java/org/apache/spark/launcher/SparkSubmitCommandBuilderSuite.java14
2 files changed, 29 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);
diff --git a/launcher/src/test/java/org/apache/spark/launcher/SparkSubmitCommandBuilderSuite.java b/launcher/src/test/java/org/apache/spark/launcher/SparkSubmitCommandBuilderSuite.java
index d451651555..16e5a22401 100644
--- a/launcher/src/test/java/org/apache/spark/launcher/SparkSubmitCommandBuilderSuite.java
+++ b/launcher/src/test/java/org/apache/spark/launcher/SparkSubmitCommandBuilderSuite.java
@@ -73,6 +73,12 @@ public class SparkSubmitCommandBuilderSuite extends BaseSuite {
}
@Test
+ public void testCliKillAndStatus() throws Exception {
+ testCLIOpts(parser.STATUS);
+ testCLIOpts(parser.KILL_SUBMISSION);
+ }
+
+ @Test
public void testCliParser() throws Exception {
List<String> sparkSubmitArgs = Arrays.asList(
parser.MASTER,
@@ -326,4 +332,12 @@ public class SparkSubmitCommandBuilderSuite extends BaseSuite {
return newCommandBuilder(args).buildCommand(env);
}
+ private void testCLIOpts(String opt) throws Exception {
+ List<String> helpArgs = Arrays.asList(opt, "driver-20160531171222-0000");
+ Map<String, String> env = new HashMap<>();
+ List<String> cmd = buildCommand(helpArgs, env);
+ assertTrue(opt + " should be contained in the final cmd.",
+ cmd.contains(opt));
+ }
+
}