Skip to content

Commit 444c2d2

Browse files
ajbozarthMarcelo Vanzin
authored andcommitted
[SPARK-10541][WEB UI] Allow ApplicationHistoryProviders to provide their own text when there aren't any complete apps
## What changes were proposed in this pull request? I've added a method to `ApplicationHistoryProvider` that returns the html paragraph to display when there are no applications. This allows providers other than `FsHistoryProvider` to determine what is printed. The current hard coded text is now moved into `FsHistoryProvider` since it assumed that's what was being used before. I chose to make the function return html rather than text because the current text block had inline html in it and it allows a new implementation of `ApplicationHistoryProvider` more versatility. I did not see any security issues with this since injecting html here requires implementing `ApplicationHistoryProvider` and can't be done outside of code. ## How was this patch tested? Manual testing and dev/run-tests No visible changes to the UI Author: Alex Bozarth <[email protected]> Closes #15490 from ajbozarth/spark10541.
1 parent 9540357 commit 444c2d2

File tree

4 files changed

+27
-7
lines changed

4 files changed

+27
-7
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ package org.apache.spark.deploy.history
1919

2020
import java.util.zip.ZipOutputStream
2121

22+
import scala.xml.Node
23+
2224
import org.apache.spark.SparkException
2325
import org.apache.spark.ui.SparkUI
2426

@@ -114,4 +116,8 @@ private[history] abstract class ApplicationHistoryProvider {
114116
*/
115117
def getApplicationInfo(appId: String): Option[ApplicationHistoryInfo]
116118

119+
/**
120+
* @return html text to display when the application list is empty
121+
*/
122+
def getEmptyListingHtml(): Seq[Node] = Seq.empty
117123
}

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import java.util.concurrent.{Executors, ExecutorService, TimeUnit}
2323
import java.util.zip.{ZipEntry, ZipOutputStream}
2424

2525
import scala.collection.mutable
26+
import scala.xml.Node
2627

2728
import com.google.common.io.ByteStreams
2829
import com.google.common.util.concurrent.{MoreExecutors, ThreadFactoryBuilder}
@@ -262,6 +263,17 @@ private[history] class FsHistoryProvider(conf: SparkConf, clock: Clock)
262263
}
263264
}
264265

266+
override def getEmptyListingHtml(): Seq[Node] = {
267+
<p>
268+
Did you specify the correct logging directory? Please verify your setting of
269+
<span style="font-style:italic">spark.history.fs.logDirectory</span>
270+
listed above and whether you have the permissions to access it.
271+
<br/>
272+
It is also possible that your application did not run to
273+
completion or did not stop the SparkContext.
274+
</p>
275+
}
276+
265277
override def getConfig(): Map[String, String] = {
266278
val safeMode = if (isFsInSafeMode()) {
267279
Map("HDFS State" -> "In safe mode, application logs not available.")

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,7 @@ private[history] class HistoryPage(parent: HistoryServer) extends WebUIPage("")
4747
} else if (requestedIncomplete) {
4848
<h4>No incomplete applications found!</h4>
4949
} else {
50-
<h4>No completed applications found!</h4> ++
51-
<p>Did you specify the correct logging directory?
52-
Please verify your setting of <span style="font-style:italic">
53-
spark.history.fs.logDirectory</span> and whether you have the permissions to
54-
access it.<br /> It is also possible that your application did not run to
55-
completion or did not stop the SparkContext.
56-
</p>
50+
<h4>No completed applications found!</h4> ++ parent.emptyListingHtml
5751
}
5852
}
5953

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import java.util.zip.ZipOutputStream
2222
import javax.servlet.http.{HttpServlet, HttpServletRequest, HttpServletResponse}
2323

2424
import scala.util.control.NonFatal
25+
import scala.xml.Node
2526

2627
import org.eclipse.jetty.servlet.{ServletContextHandler, ServletHolder}
2728

@@ -193,6 +194,13 @@ class HistoryServer(
193194
provider.writeEventLogs(appId, attemptId, zipStream)
194195
}
195196

197+
/**
198+
* @return html text to display when the application list is empty
199+
*/
200+
def emptyListingHtml(): Seq[Node] = {
201+
provider.getEmptyListingHtml()
202+
}
203+
196204
/**
197205
* Returns the provider configuration to show in the listing page.
198206
*

0 commit comments

Comments
 (0)