Skip to content

Commit 4da3a52

Browse files
author
Marcelo Vanzin
committed
Remove UI from ApplicationHistoryInfo.
This reduces the needed memory when lots of applications are listed, since there were 2 pointers wasted per entry to hold UI-specific information.
1 parent 2a7f68d commit 4da3a52

File tree

3 files changed

+23
-25
lines changed

3 files changed

+23
-25
lines changed

core/src/main/scala/org/apache/spark/deploy/history/ApplicationHistoryProvider.scala

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ private[spark] case class ApplicationHistoryInfo(
2525
startTime: Long,
2626
endTime: Long,
2727
lastUpdated: Long,
28-
sparkUser: String,
29-
viewAcls: String,
30-
ui: SparkUI) {
28+
sparkUser: String) {
3129
}
3230

3331
private[spark] abstract class ApplicationHistoryProvider {
@@ -41,12 +39,12 @@ private[spark] abstract class ApplicationHistoryProvider {
4139
def getListing(): Seq[ApplicationHistoryInfo]
4240

4341
/**
44-
* This method should return the application information, including a rendered SparkUI.
42+
* This method should return the application UI.
4543
*
4644
* @param appId The application ID.
47-
* @return The app info, or null if not found.
45+
* @return The application's UI, or null if application is not found.
4846
*/
49-
def getAppInfo(appId: String): ApplicationHistoryInfo
47+
def getAppUI(appId: String): SparkUI
5048

5149
/**
5250
* Called when the server is shutting down.

core/src/main/scala/org/apache/spark/deploy/history/FsHistoryProvider.scala

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ private[history] class FsHistoryProvider(conf: SparkConf) extends ApplicationHis
8989

9090
override def getListing() = appList
9191

92-
override def getAppInfo(appId: String): ApplicationHistoryInfo = {
92+
override def getAppUI(appId: String): SparkUI = {
9393
try {
9494
val appLogDir = fs.getFileStatus(new Path(logDir, appId))
95-
loadAppInfo(appLogDir, true)
95+
loadAppInfo(appLogDir, true)._2
9696
} catch {
9797
case e: FileNotFoundException => null
9898
}
@@ -128,7 +128,7 @@ private[history] class FsHistoryProvider(conf: SparkConf) extends ApplicationHis
128128
val curr = currentApps.getOrElse(dir.getPath().getName(), null)
129129
if (curr == null || curr.lastUpdated < getModificationTime(dir)) {
130130
try {
131-
newApps += loadAppInfo(dir, false)
131+
newApps += loadAppInfo(dir, false)._1
132132
} catch {
133133
case e: Exception => logError(s"Failed to load app info from directory $dir.")
134134
}
@@ -152,10 +152,10 @@ private[history] class FsHistoryProvider(conf: SparkConf) extends ApplicationHis
152152
* clicks on a specific application.
153153
*
154154
* @param logDir Directory with application's log files.
155-
* @param renderUI Whether to create the SparkUI for the application. If false, the "ui"
156-
* attribute of the returned object will be null.
155+
* @param renderUI Whether to create the SparkUI for the application.
156+
* @return A 2-tuple `(app info, ui)`. `ui` will be null if `renderUI` is false.
157157
*/
158-
private def loadAppInfo(logDir: FileStatus, renderUI: Boolean): ApplicationHistoryInfo = {
158+
private def loadAppInfo(logDir: FileStatus, renderUI: Boolean) = {
159159
val elogInfo = EventLoggingListener.parseLoggingInfo(logDir.getPath(), fs)
160160
val path = logDir.getPath
161161
val appId = path.getName
@@ -173,14 +173,19 @@ private[history] class FsHistoryProvider(conf: SparkConf) extends ApplicationHis
173173
}
174174

175175
replayBus.replay()
176-
ApplicationHistoryInfo(appId,
176+
val appInfo = ApplicationHistoryInfo(appId,
177177
appListener.appName,
178178
appListener.startTime,
179179
appListener.endTime,
180180
getModificationTime(logDir),
181-
appListener.sparkUser,
182-
if (renderUI) appListener.viewAcls else null,
183-
ui)
181+
appListener.sparkUser)
182+
183+
if (ui != null) {
184+
val uiAclsEnabled = conf.getBoolean("spark.history.ui.acls.enable", false)
185+
ui.getSecurityManager.setUIAcls(uiAclsEnabled)
186+
ui.getSecurityManager.setViewAcls(appListener.sparkUser, appListener.viewAcls)
187+
}
188+
(appInfo, ui)
184189
}
185190

186191
/** Return when this directory was last modified. */

core/src/main/scala/org/apache/spark/deploy/history/HistoryServer.scala

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,21 +50,16 @@ class HistoryServer(
5050
// How many applications to retain
5151
private val retainedApplications = conf.getInt("spark.history.retainedApplications", 50)
5252

53-
// set whether to enable or disable view acls for all applications
54-
private val uiAclsEnabled = conf.getBoolean("spark.history.ui.acls.enable", false)
55-
5653
private val localHost = Utils.localHostName()
5754

5855
private val appLoader = new CacheLoader[String, SparkUI] {
5956
override def load(key: String): SparkUI = {
60-
val info = provider.getAppInfo(key)
61-
if (info == null) {
57+
val ui = provider.getAppUI(key)
58+
if (ui == null) {
6259
throw new NoSuchElementException()
6360
}
64-
info.ui.getSecurityManager.setUIAcls(uiAclsEnabled)
65-
info.ui.getSecurityManager.setViewAcls(info.sparkUser, info.viewAcls)
66-
attachSparkUI(info.ui)
67-
info.ui
61+
attachSparkUI(ui)
62+
ui
6863
}
6964
}
7065

0 commit comments

Comments
 (0)