Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions core/src/main/scala/org/apache/spark/ui/WebUI.scala
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,25 @@ private[spark] abstract class WebUI(
}
}

/**
* Add a handler for static content.
*
* @param resourceBase Root of where to find resources to serve.
* @param path Path in UI where to mount the resources.
*/
def addStaticHandler(resourceBase: String, path: String): Unit = {
attachHandler(JettyUtils.createStaticHandler(resourceBase, path))
}

/**
* Remove a static content handler.
*
* @param path Path in UI to unmount.
*/
def removeStaticHandler(path: String): Unit = {
handlers.find(_.getContextPath() == path).foreach(detachHandler)
}

/** Initialize all components of the server. */
def initialize()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@

package org.apache.spark.streaming.ui

import org.eclipse.jetty.servlet.ServletContextHandler

import org.apache.spark.{Logging, SparkException}
import org.apache.spark.streaming.StreamingContext
import org.apache.spark.ui.{JettyUtils, SparkUI, SparkUITab}
import org.apache.spark.ui.{SparkUI, SparkUITab}

import StreamingTab._

Expand All @@ -42,18 +40,14 @@ private[spark] class StreamingTab(val ssc: StreamingContext)
attachPage(new StreamingPage(this))
attachPage(new BatchPage(this))

var staticHandler: ServletContextHandler = null

def attach() {
getSparkUI(ssc).attachTab(this)
staticHandler = JettyUtils.createStaticHandler(STATIC_RESOURCE_DIR, "/static/streaming")
getSparkUI(ssc).attachHandler(staticHandler)
getSparkUI(ssc).addStaticHandler(STATIC_RESOURCE_DIR, "/static/streaming")
}

def detach() {
getSparkUI(ssc).detachTab(this)
getSparkUI(ssc).detachHandler(staticHandler)
staticHandler = null
getSparkUI(ssc).removeStaticHandler("/static/streaming")
}
}

Expand Down