Skip to content
Snippets Groups Projects
Commit 36d8b278 authored by Jeff Zhang's avatar Jeff Zhang Committed by Marcelo Vanzin
Browse files

[SPARK-10531] [CORE] AppId is set as AppName in status rest api

Verify it manually.

Author: Jeff Zhang <zjffdu@apache.org>

Closes #8688 from zjffdu/SPARK-10531.
parent 81b4db37
No related branches found
No related tags found
No related merge requests found
...@@ -521,6 +521,7 @@ class SparkContext(config: SparkConf) extends Logging with ExecutorAllocationCli ...@@ -521,6 +521,7 @@ class SparkContext(config: SparkConf) extends Logging with ExecutorAllocationCli
_applicationId = _taskScheduler.applicationId() _applicationId = _taskScheduler.applicationId()
_applicationAttemptId = taskScheduler.applicationAttemptId() _applicationAttemptId = taskScheduler.applicationAttemptId()
_conf.set("spark.app.id", _applicationId) _conf.set("spark.app.id", _applicationId)
_ui.foreach(_.setAppId(_applicationId))
_env.blockManager.initialize(_applicationId) _env.blockManager.initialize(_applicationId)
// The metrics system for Driver need to be set spark.app.id to app ID. // The metrics system for Driver need to be set spark.app.id to app ID.
......
...@@ -146,16 +146,15 @@ private[history] class FsHistoryProvider(conf: SparkConf, clock: Clock) ...@@ -146,16 +146,15 @@ private[history] class FsHistoryProvider(conf: SparkConf, clock: Clock)
val ui = { val ui = {
val conf = this.conf.clone() val conf = this.conf.clone()
val appSecManager = new SecurityManager(conf) val appSecManager = new SecurityManager(conf)
SparkUI.createHistoryUI(conf, replayBus, appSecManager, appId, SparkUI.createHistoryUI(conf, replayBus, appSecManager, appInfo.name,
HistoryServer.getAttemptURI(appId, attempt.attemptId), attempt.startTime) HistoryServer.getAttemptURI(appId, attempt.attemptId), attempt.startTime)
// Do not call ui.bind() to avoid creating a new server for each application // Do not call ui.bind() to avoid creating a new server for each application
} }
val appListener = new ApplicationEventListener() val appListener = new ApplicationEventListener()
replayBus.addListener(appListener) replayBus.addListener(appListener)
val appInfo = replay(fs.getFileStatus(new Path(logDir, attempt.logPath)), replayBus) val appAttemptInfo = replay(fs.getFileStatus(new Path(logDir, attempt.logPath)),
appInfo.map { info => replayBus)
ui.setAppName(s"${info.name} ($appId)") appAttemptInfo.map { info =>
val uiAclsEnabled = conf.getBoolean("spark.history.ui.acls.enable", false) val uiAclsEnabled = conf.getBoolean("spark.history.ui.acls.enable", false)
ui.getSecurityManager.setAcls(uiAclsEnabled) ui.getSecurityManager.setAcls(uiAclsEnabled)
// make sure to set admin acls before view acls so they are properly picked up // make sure to set admin acls before view acls so they are properly picked up
......
...@@ -944,7 +944,7 @@ private[deploy] class Master( ...@@ -944,7 +944,7 @@ private[deploy] class Master(
val logInput = EventLoggingListener.openEventLog(new Path(eventLogFile), fs) val logInput = EventLoggingListener.openEventLog(new Path(eventLogFile), fs)
val replayBus = new ReplayListenerBus() val replayBus = new ReplayListenerBus()
val ui = SparkUI.createHistoryUI(new SparkConf, replayBus, new SecurityManager(conf), val ui = SparkUI.createHistoryUI(new SparkConf, replayBus, new SecurityManager(conf),
appName + status, HistoryServer.UI_PATH_PREFIX + s"/${app.id}", app.startTime) appName, HistoryServer.UI_PATH_PREFIX + s"/${app.id}", app.startTime)
val maybeTruncated = eventLogFile.endsWith(EventLoggingListener.IN_PROGRESS) val maybeTruncated = eventLogFile.endsWith(EventLoggingListener.IN_PROGRESS)
try { try {
replayBus.replay(logInput, eventLogFile, maybeTruncated) replayBus.replay(logInput, eventLogFile, maybeTruncated)
......
...@@ -56,6 +56,8 @@ private[spark] class SparkUI private ( ...@@ -56,6 +56,8 @@ private[spark] class SparkUI private (
val stagesTab = new StagesTab(this) val stagesTab = new StagesTab(this)
var appId: String = _
/** Initialize all components of the server. */ /** Initialize all components of the server. */
def initialize() { def initialize() {
attachTab(new JobsTab(this)) attachTab(new JobsTab(this))
...@@ -75,9 +77,8 @@ private[spark] class SparkUI private ( ...@@ -75,9 +77,8 @@ private[spark] class SparkUI private (
def getAppName: String = appName def getAppName: String = appName
/** Set the app name for this UI. */ def setAppId(id: String): Unit = {
def setAppName(name: String) { appId = id
appName = name
} }
/** Stop the server behind this web interface. Only valid after bind(). */ /** Stop the server behind this web interface. Only valid after bind(). */
...@@ -94,12 +95,12 @@ private[spark] class SparkUI private ( ...@@ -94,12 +95,12 @@ private[spark] class SparkUI private (
private[spark] def appUIAddress = s"http://$appUIHostPort" private[spark] def appUIAddress = s"http://$appUIHostPort"
def getSparkUI(appId: String): Option[SparkUI] = { def getSparkUI(appId: String): Option[SparkUI] = {
if (appId == appName) Some(this) else None if (appId == this.appId) Some(this) else None
} }
def getApplicationInfoList: Iterator[ApplicationInfo] = { def getApplicationInfoList: Iterator[ApplicationInfo] = {
Iterator(new ApplicationInfo( Iterator(new ApplicationInfo(
id = appName, id = appId,
name = appName, name = appName,
attempts = Seq(new ApplicationAttemptInfo( attempts = Seq(new ApplicationAttemptInfo(
attemptId = None, attemptId = None,
......
...@@ -658,6 +658,6 @@ class UISeleniumSuite extends SparkFunSuite with WebBrowser with Matchers with B ...@@ -658,6 +658,6 @@ class UISeleniumSuite extends SparkFunSuite with WebBrowser with Matchers with B
} }
def apiUrl(ui: SparkUI, path: String): URL = { def apiUrl(ui: SparkUI, path: String): URL = {
new URL(ui.appUIAddress + "/api/v1/applications/test/" + path) new URL(ui.appUIAddress + "/api/v1/applications/" + ui.sc.get.applicationId + "/" + path)
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment