Skip to content

Commit c0ccd25

Browse files
uncleGenAndrew Or
authored and
Andrew Or
committed
[SPARK-5732][CORE]:Add an option to print the spark version in spark script.
Naturally, we may need to add an option to print the spark version in spark script. It is pretty common in script tool. ![9](https://cloud.githubusercontent.com/assets/7402327/6183331/cab1b74e-b38e-11e4-9daa-e26e6015cff3.JPG) Author: uncleGen <hustyugm@gmail.com> Author: genmao.ygm <genmao.ygm@alibaba-inc.com> Closes #4522 from uncleGen/master-clean-150211 and squashes the following commits: 9f2127c [genmao.ygm] revert the behavior of "-v" 015ddee [uncleGen] minor changes 463f02c [uncleGen] minor changes
1 parent 1768bd5 commit c0ccd25

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

core/src/main/scala/org/apache/spark/deploy/SparkSubmit.scala

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import org.apache.ivy.core.settings.IvySettings
3737
import org.apache.ivy.plugins.matcher.GlobPatternMatcher
3838
import org.apache.ivy.plugins.resolver.{ChainResolver, IBiblioResolver}
3939

40+
import org.apache.spark.SPARK_VERSION
4041
import org.apache.spark.deploy.rest._
4142
import org.apache.spark.executor._
4243
import org.apache.spark.util.{ChildFirstURLClassLoader, MutableURLClassLoader, Utils}
@@ -83,14 +84,25 @@ object SparkSubmit {
8384
// Exposed for testing
8485
private[spark] var exitFn: () => Unit = () => System.exit(1)
8586
private[spark] var printStream: PrintStream = System.err
86-
private[spark] def printWarning(str: String) = printStream.println("Warning: " + str)
87-
private[spark] def printErrorAndExit(str: String) = {
87+
private[spark] def printWarning(str: String): Unit = printStream.println("Warning: " + str)
88+
private[spark] def printErrorAndExit(str: String): Unit = {
8889
printStream.println("Error: " + str)
8990
printStream.println("Run with --help for usage help or --verbose for debug output")
9091
exitFn()
9192
}
93+
private[spark] def printVersionAndExit(): Unit = {
94+
printStream.println("""Welcome to
95+
____ __
96+
/ __/__ ___ _____/ /__
97+
_\ \/ _ \/ _ `/ __/ '_/
98+
/___/ .__/\_,_/_/ /_/\_\ version %s
99+
/_/
100+
""".format(SPARK_VERSION))
101+
printStream.println("Type --help for more information.")
102+
exitFn()
103+
}
92104

93-
def main(args: Array[String]) {
105+
def main(args: Array[String]): Unit = {
94106
val appArgs = new SparkSubmitArguments(args)
95107
if (appArgs.verbose) {
96108
printStream.println(appArgs)

core/src/main/scala/org/apache/spark/deploy/SparkSubmitArguments.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,9 @@ private[spark] class SparkSubmitArguments(args: Seq[String], env: Map[String, St
417417
verbose = true
418418
parse(tail)
419419

420+
case ("--version") :: tail =>
421+
SparkSubmit.printVersionAndExit()
422+
420423
case EQ_SEPARATED_OPT(opt, value) :: tail =>
421424
parse(opt :: value :: tail)
422425

@@ -485,6 +488,7 @@ private[spark] class SparkSubmitArguments(args: Seq[String], env: Map[String, St
485488
|
486489
| --help, -h Show this help message and exit
487490
| --verbose, -v Print additional debug output
491+
| --version, Print the version of current Spark
488492
|
489493
| Spark standalone with cluster deploy mode only:
490494
| --driver-cores NUM Cores for driver (Default: 1).

0 commit comments

Comments
 (0)