Skip to content

Commit

Permalink
After code review (scaladoc + explicit Unit for the return type + met…
Browse files Browse the repository at this point in the history
…hod rename)
  • Loading branch information
jaceklaskowski committed Jun 15, 2018
1 parent 3ab14a1 commit 1a29c65
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
40 changes: 20 additions & 20 deletions core/src/main/scala/org/apache/spark/ui/WebUI.scala
Expand Up @@ -61,24 +61,24 @@ private[spark] abstract class WebUI(
def getSecurityManager: SecurityManager = securityManager

/** Attaches a tab to this UI, along with all of its attached pages. */
def attachTab(tab: WebUITab) {
def attachTab(tab: WebUITab): Unit = {
tab.pages.foreach(attachPage)
tabs += tab
}

/** Detaches a tab from this UI. */
def detachTab(tab: WebUITab) {
/** Detaches a tab from this UI, along with all of its attached pages. */
def detachTab(tab: WebUITab): Unit = {
tab.pages.foreach(detachPage)
tabs -= tab
}

/** Detaches a page from this UI. */
def detachPage(page: WebUIPage) {
/** Detaches a page from this UI, along with all of its attached handlers. */
def detachPage(page: WebUIPage): Unit = {
pageToHandlers.remove(page).foreach(_.foreach(detachHandler))
}

/** Attaches a page to this UI. */
def attachPage(page: WebUIPage) {
def attachPage(page: WebUIPage): Unit = {
val pagePath = "/" + page.prefix
val renderHandler = createServletHandler(pagePath,
(request: HttpServletRequest) => page.render(request), securityManager, conf, basePath)
Expand All @@ -91,17 +91,26 @@ private[spark] abstract class WebUI(
}

/** Attaches a handler to this UI. */
def attachHandler(handler: ServletContextHandler) {
def attachHandler(handler: ServletContextHandler): Unit = {
handlers += handler
serverInfo.foreach(_.addHandler(handler))
}

/** Detaches a handler from this UI. */
def detachHandler(handler: ServletContextHandler) {
def detachHandler(handler: ServletContextHandler): Unit = {
handlers -= handler
serverInfo.foreach(_.removeHandler(handler))
}

/**
* Detaches the content handler at `path` URI.
*
* @param path Path in UI to unmount.
*/
def detachHandler(path: String): Unit = {
handlers.find(_.getContextPath() == path).foreach(detachHandler)
}

/**
* Adds a handler for static content.
*
Expand All @@ -112,16 +121,7 @@ private[spark] abstract class WebUI(
attachHandler(JettyUtils.createStaticHandler(resourceBase, path))
}

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

/** Initializes all components of the server. */
/** A hook to initialize components of the UI */
def initialize(): Unit

/** Binds to the HTTP server behind this web interface. */
Expand All @@ -141,14 +141,14 @@ private[spark] abstract class WebUI(
/** @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(). */
/** @return The actual port to which this server is bound. Only valid after [[bind]]. */
def boundPort: Int = serverInfo.map(_.boundPort).getOrElse(-1)

/** Stops the server behind this web interface. Only valid after [[bind]]. */
def stop(): Unit = {
assert(serverInfo.isDefined,
s"Attempted to stop $className before binding to a server!")
serverInfo.get.stop()
serverInfo.foreach(_.stop())
}
}

Expand Down
Expand Up @@ -49,7 +49,7 @@ private[spark] class StreamingTab(val ssc: StreamingContext)

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

Expand Down

0 comments on commit 1a29c65

Please sign in to comment.