[SPARK-8862][SQL]Support multiple SQLContexts in Web UI

This is a follow-up PR to solve the UI issue when there are multiple SQLContexts. Each SQLContext has a separate tab and contains queries which are executed by this SQLContext.

<img width="1366" alt="multiple sqlcontexts" src="https://cloud.githubusercontent.com/assets/1000778/9088391/54584434-3bc2-11e5-9caf-94c2b0da528e.png">

Author: zsxwing <zsxwing@gmail.com>

Closes #7962 from zsxwing/multi-sqlcontext-ui and squashes the following commits:

cf661e1 [zsxwing] sql -> SQL
39b0c97 [zsxwing] Support multiple SQLContexts in Web UI
This commit is contained in:
zsxwing 2015-08-06 22:52:23 -07:00 committed by Reynold Xin
parent f0cda587fb
commit 7aaed1b114
2 changed files with 11 additions and 3 deletions

View file

@ -178,7 +178,7 @@ private[ui] abstract class ExecutionTable(
"%s/jobs/job?id=%s".format(UIUtils.prependBaseUri(parent.basePath), jobId)
private def executionURL(executionID: Long): String =
"%s/sql/execution?id=%s".format(UIUtils.prependBaseUri(parent.basePath), executionID)
s"${UIUtils.prependBaseUri(parent.basePath)}/${parent.prefix}/execution?id=$executionID"
}
private[ui] class RunningExecutionTable(

View file

@ -17,13 +17,14 @@
package org.apache.spark.sql.ui
import java.util.concurrent.atomic.AtomicInteger
import org.apache.spark.Logging
import org.apache.spark.sql.SQLContext
import org.apache.spark.ui.{SparkUI, SparkUITab}
private[sql] class SQLTab(sqlContext: SQLContext, sparkUI: SparkUI)
extends SparkUITab(sparkUI, "sql") with Logging {
extends SparkUITab(sparkUI, SQLTab.nextTabName) with Logging {
val parent = sparkUI
val listener = sqlContext.listener
@ -38,4 +39,11 @@ private[sql] class SQLTab(sqlContext: SQLContext, sparkUI: SparkUI)
private[sql] object SQLTab {
private val STATIC_RESOURCE_DIR = "org/apache/spark/sql/ui/static"
private val nextTabId = new AtomicInteger(0)
private def nextTabName: String = {
val nextId = nextTabId.getAndIncrement()
if (nextId == 0) "SQL" else s"SQL${nextId}"
}
}