aboutsummaryrefslogtreecommitdiff
path: root/launcher/src/main
diff options
context:
space:
mode:
authorwm624@hotmail.com <wm624@hotmail.com>2016-05-20 10:27:41 -0700
committerMarcelo Vanzin <vanzin@cloudera.com>2016-05-20 10:28:24 -0700
commitfe2fcb48039ac897242e2cfaed31703fa6116db7 (patch)
treee0f31b117931375cd2dca700d442e59a9d9209d8 /launcher/src/main
parent2cbe96e64d5f84474b2eb59bed9ce3ab543d8aff (diff)
downloadspark-fe2fcb48039ac897242e2cfaed31703fa6116db7.tar.gz
spark-fe2fcb48039ac897242e2cfaed31703fa6116db7.tar.bz2
spark-fe2fcb48039ac897242e2cfaed31703fa6116db7.zip
[SPARK-15360][SPARK-SUBMIT] Should print spark-submit usage when no arguments is specified
(Please fill in changes proposed in this fix) In 2.0, ./bin/spark-submit doesn't print out usage, but it raises an exception. In this PR, an exception handling is added in the Main.java when the exception is thrown. In the handling code, if there is no additional argument, it prints out usage. (Please explain how this patch was tested. E.g. unit tests, integration tests, manual tests) Manually tested. ./bin/spark-submit Usage: spark-submit [options] <app jar | python file> [app arguments] Usage: spark-submit --kill [submission ID] --master [spark://...] Usage: spark-submit --status [submission ID] --master [spark://...] Usage: spark-submit run-example [options] example-class [example args] Options: --master MASTER_URL spark://host:port, mesos://host:port, yarn, or local. --deploy-mode DEPLOY_MODE Whether to launch the driver program locally ("client") or on one of the worker machines inside the cluster ("cluster") (Default: client). --class CLASS_NAME Your application's main class (for Java / Scala apps). --name NAME A name of your application. --jars JARS Comma-separated list of local jars to include on the driver and executor classpaths. --packages Comma-separated list of maven coordinates of jars to include on the driver and executor classpaths. Will search the local maven repo, then maven central and any additional remote repositories given by --repositories. The format for the coordinates should be groupId:artifactId:version. Author: wm624@hotmail.com <wm624@hotmail.com> Closes #13163 from wangmiao1981/submit.
Diffstat (limited to 'launcher/src/main')
-rw-r--r--launcher/src/main/java/org/apache/spark/launcher/SparkSubmitCommandBuilder.java47
1 files changed, 28 insertions, 19 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 76897c4f75..824500d980 100644
--- a/launcher/src/main/java/org/apache/spark/launcher/SparkSubmitCommandBuilder.java
+++ b/launcher/src/main/java/org/apache/spark/launcher/SparkSubmitCommandBuilder.java
@@ -107,28 +107,37 @@ class SparkSubmitCommandBuilder extends AbstractCommandBuilder {
SparkSubmitCommandBuilder(List<String> args) {
this.allowsMixedArguments = false;
-
+ this.sparkArgs = new ArrayList<>();
boolean isExample = false;
List<String> submitArgs = args;
- if (args.size() > 0 && args.get(0).equals(PYSPARK_SHELL)) {
- this.allowsMixedArguments = true;
- appResource = PYSPARK_SHELL;
- submitArgs = args.subList(1, args.size());
- } else if (args.size() > 0 && args.get(0).equals(SPARKR_SHELL)) {
- this.allowsMixedArguments = true;
- appResource = SPARKR_SHELL;
- submitArgs = args.subList(1, args.size());
- } else if (args.size() > 0 && args.get(0).equals(RUN_EXAMPLE)) {
- isExample = true;
- submitArgs = args.subList(1, args.size());
- }
- this.sparkArgs = new ArrayList<>();
- this.isExample = isExample;
+ if (args.size() > 0) {
+ switch (args.get(0)) {
+ case PYSPARK_SHELL:
+ this.allowsMixedArguments = true;
+ appResource = PYSPARK_SHELL;
+ submitArgs = args.subList(1, args.size());
+ break;
+
+ case SPARKR_SHELL:
+ this.allowsMixedArguments = true;
+ appResource = SPARKR_SHELL;
+ submitArgs = args.subList(1, args.size());
+ break;
+
+ case RUN_EXAMPLE:
+ isExample = true;
+ submitArgs = args.subList(1, args.size());
+ }
- OptionParser parser = new OptionParser();
- parser.parse(submitArgs);
- this.printInfo = parser.infoRequested;
+ this.isExample = isExample;
+ OptionParser parser = new OptionParser();
+ parser.parse(submitArgs);
+ this.printInfo = parser.infoRequested;
+ } else {
+ this.isExample = isExample;
+ this.printInfo = true;
+ }
}
@Override
@@ -147,7 +156,7 @@ class SparkSubmitCommandBuilder extends AbstractCommandBuilder {
List<String> args = new ArrayList<>();
SparkSubmitOptionParser parser = new SparkSubmitOptionParser();
- if (!allowsMixedArguments) {
+ if (!allowsMixedArguments && !printInfo) {
checkArgument(appResource != null, "Missing application resource.");
}