diff options
author | Ergin Seyfe <eseyfe@fb.com> | 2016-04-28 16:16:28 +0100 |
---|---|---|
committer | Sean Owen <sowen@cloudera.com> | 2016-04-28 16:16:28 +0100 |
commit | 23256be0d0846d4eb188a4d1cae6e3f261248153 (patch) | |
tree | 5c59f00bcfc0a97e56fc948b7107e232495bc1e1 /core | |
parent | 7c6937a8859ebd3c971116dea54ef380c1636999 (diff) | |
download | spark-23256be0d0846d4eb188a4d1cae6e3f261248153.tar.gz spark-23256be0d0846d4eb188a4d1cae6e3f261248153.tar.bz2 spark-23256be0d0846d4eb188a4d1cae6e3f261248153.zip |
[SPARK-14576][WEB UI] Spark console should display Web UI url
## What changes were proposed in this pull request?
This is a proposal to print the Spark Driver UI link when spark-shell is launched.
## How was this patch tested?
Launched spark-shell in local mode and cluster mode. Spark-shell console output included following line:
"Spark context Web UI available at <Spark web url>"
Author: Ergin Seyfe <eseyfe@fb.com>
Closes #12341 from seyfe/spark_console_display_webui_link.
Diffstat (limited to 'core')
-rw-r--r-- | core/src/main/scala/org/apache/spark/SparkContext.scala | 2 | ||||
-rw-r--r-- | core/src/main/scala/org/apache/spark/ui/WebUI.scala | 14 |
2 files changed, 10 insertions, 6 deletions
diff --git a/core/src/main/scala/org/apache/spark/SparkContext.scala b/core/src/main/scala/org/apache/spark/SparkContext.scala index 865989aee0..ed4408cc5a 100644 --- a/core/src/main/scala/org/apache/spark/SparkContext.scala +++ b/core/src/main/scala/org/apache/spark/SparkContext.scala @@ -280,6 +280,8 @@ class SparkContext(config: SparkConf) extends Logging with ExecutorAllocationCli private[spark] def ui: Option[SparkUI] = _ui + def uiWebUrl: Option[String] = _ui.map(_.webUrl) + /** * A default Hadoop Configuration for the Hadoop code (e.g. file systems) that we reuse. * diff --git a/core/src/main/scala/org/apache/spark/ui/WebUI.scala b/core/src/main/scala/org/apache/spark/ui/WebUI.scala index 2b0bc32cf6..2c40e72699 100644 --- a/core/src/main/scala/org/apache/spark/ui/WebUI.scala +++ b/core/src/main/scala/org/apache/spark/ui/WebUI.scala @@ -133,26 +133,28 @@ private[spark] abstract class WebUI( /** Bind to the HTTP server behind this web interface. */ def bind() { - assert(!serverInfo.isDefined, "Attempted to bind %s more than once!".format(className)) + assert(!serverInfo.isDefined, s"Attempted to bind $className more than once!") try { - var host = Option(conf.getenv("SPARK_LOCAL_IP")).getOrElse("0.0.0.0") + val host = Option(conf.getenv("SPARK_LOCAL_IP")).getOrElse("0.0.0.0") serverInfo = Some(startJettyServer(host, port, sslOptions, handlers, conf, name)) - logInfo("Bound %s to %s, and started at http://%s:%d".format(className, host, - publicHostName, boundPort)) + logInfo(s"Bound $className to $host, and started at $webUrl") } catch { case e: Exception => - logError("Failed to bind %s".format(className), e) + logError(s"Failed to bind $className", e) System.exit(1) } } + /** Return the url of web interface. Only valid after bind(). */ + def webUrl: String = s"http://$publicHostName:$boundPort" + /** Return the actual port to which this server is bound. Only valid after bind(). */ def boundPort: Int = serverInfo.map(_.boundPort).getOrElse(-1) /** Stop the server behind this web interface. Only valid after bind(). */ def stop() { assert(serverInfo.isDefined, - "Attempted to stop %s before binding to a server!".format(className)) + s"Attempted to stop $className before binding to a server!") serverInfo.get.stop() } } |