aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authoruncleGen <hustyugm@gmail.com>2015-02-13 09:43:10 -0800
committerAndrew Or <andrew@databricks.com>2015-02-13 09:44:13 -0800
commitc0ccd2564182695ea5771524840bf1a99d5aa842 (patch)
tree5af385b811b42a793896168b74b289d5aa63415c /core
parent1768bd51438670c493ca3ca02988aee3ae31e87e (diff)
downloadspark-c0ccd2564182695ea5771524840bf1a99d5aa842.tar.gz
spark-c0ccd2564182695ea5771524840bf1a99d5aa842.tar.bz2
spark-c0ccd2564182695ea5771524840bf1a99d5aa842.zip
[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
Diffstat (limited to 'core')
-rw-r--r--core/src/main/scala/org/apache/spark/deploy/SparkSubmit.scala18
-rw-r--r--core/src/main/scala/org/apache/spark/deploy/SparkSubmitArguments.scala4
2 files changed, 19 insertions, 3 deletions
diff --git a/core/src/main/scala/org/apache/spark/deploy/SparkSubmit.scala b/core/src/main/scala/org/apache/spark/deploy/SparkSubmit.scala
index 80cc058728..54399e99c9 100644
--- a/core/src/main/scala/org/apache/spark/deploy/SparkSubmit.scala
+++ b/core/src/main/scala/org/apache/spark/deploy/SparkSubmit.scala
@@ -37,6 +37,7 @@ import org.apache.ivy.core.settings.IvySettings
import org.apache.ivy.plugins.matcher.GlobPatternMatcher
import org.apache.ivy.plugins.resolver.{ChainResolver, IBiblioResolver}
+import org.apache.spark.SPARK_VERSION
import org.apache.spark.deploy.rest._
import org.apache.spark.executor._
import org.apache.spark.util.{ChildFirstURLClassLoader, MutableURLClassLoader, Utils}
@@ -83,14 +84,25 @@ object SparkSubmit {
// Exposed for testing
private[spark] var exitFn: () => Unit = () => System.exit(1)
private[spark] var printStream: PrintStream = System.err
- private[spark] def printWarning(str: String) = printStream.println("Warning: " + str)
- private[spark] def printErrorAndExit(str: String) = {
+ private[spark] def printWarning(str: String): Unit = printStream.println("Warning: " + str)
+ private[spark] def printErrorAndExit(str: String): Unit = {
printStream.println("Error: " + str)
printStream.println("Run with --help for usage help or --verbose for debug output")
exitFn()
}
+ private[spark] def printVersionAndExit(): Unit = {
+ printStream.println("""Welcome to
+ ____ __
+ / __/__ ___ _____/ /__
+ _\ \/ _ \/ _ `/ __/ '_/
+ /___/ .__/\_,_/_/ /_/\_\ version %s
+ /_/
+ """.format(SPARK_VERSION))
+ printStream.println("Type --help for more information.")
+ exitFn()
+ }
- def main(args: Array[String]) {
+ def main(args: Array[String]): Unit = {
val appArgs = new SparkSubmitArguments(args)
if (appArgs.verbose) {
printStream.println(appArgs)
diff --git a/core/src/main/scala/org/apache/spark/deploy/SparkSubmitArguments.scala b/core/src/main/scala/org/apache/spark/deploy/SparkSubmitArguments.scala
index fa38070c6f..82e66a3742 100644
--- a/core/src/main/scala/org/apache/spark/deploy/SparkSubmitArguments.scala
+++ b/core/src/main/scala/org/apache/spark/deploy/SparkSubmitArguments.scala
@@ -417,6 +417,9 @@ private[spark] class SparkSubmitArguments(args: Seq[String], env: Map[String, St
verbose = true
parse(tail)
+ case ("--version") :: tail =>
+ SparkSubmit.printVersionAndExit()
+
case EQ_SEPARATED_OPT(opt, value) :: tail =>
parse(opt :: value :: tail)
@@ -485,6 +488,7 @@ private[spark] class SparkSubmitArguments(args: Seq[String], env: Map[String, St
|
| --help, -h Show this help message and exit
| --verbose, -v Print additional debug output
+ | --version, Print the version of current Spark
|
| Spark standalone with cluster deploy mode only:
| --driver-cores NUM Cores for driver (Default: 1).