Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/718#discussion_r13618737
  
    --- Diff: 
core/src/main/scala/org/apache/spark/deploy/history/HistoryServer.scala ---
    @@ -38,56 +39,70 @@ import org.apache.spark.util.Utils
      * application's event logs are maintained in the application's own 
sub-directory. This
      * is the same structure as maintained in the event log write code path in
      * EventLoggingListener.
    - *
    - * @param baseLogDir The base directory in which event logs are found
      */
     class HistoryServer(
    -    val baseLogDir: String,
    +    conf: SparkConf,
    +    provider: ApplicationHistoryProvider,
         securityManager: SecurityManager,
    -    conf: SparkConf)
    -  extends WebUI(securityManager, HistoryServer.WEB_UI_PORT, conf) with 
Logging {
    +    port: Int)
    +  extends WebUI(securityManager, port, conf) with Logging {
     
    -  import HistoryServer._
    +  // How many applications to retain
    +  private val retainedApplications = 
conf.getInt("spark.history.retainedApplications", 50)
     
    -  private val fileSystem = Utils.getHadoopFileSystem(baseLogDir)
       private val localHost = Utils.localHostName()
    -  private val publicHost = 
Option(System.getenv("SPARK_PUBLIC_DNS")).getOrElse(localHost)
     
    -  // A timestamp of when the disk was last accessed to check for log 
updates
    -  private var lastLogCheckTime = -1L
    +  private val appLoader = new CacheLoader[String, SparkUI] {
    +    override def load(key: String): SparkUI = {
    +      val ui = provider.getAppUI(key)
    +      if (ui == null) {
    +        throw new NoSuchElementException()
    +      }
    +      attachSparkUI(ui)
    +      ui
    +    }
    +  }
     
    -  // Number of completed applications found in this directory
    -  private var numCompletedApplications = 0
    +  private val appCache = CacheBuilder.newBuilder()
    +    .maximumSize(retainedApplications)
    +    .removalListener(new RemovalListener[String, SparkUI] {
    +      override def onRemoval(rm: RemovalNotification[String, SparkUI]) = {
    +        detachSparkUI(rm.getValue())
    +      }
    +    })
    +    .build(appLoader)
    +
    +  private val loaderServlet = new HttpServlet {
    +    protected override def doGet(req: HttpServletRequest, res: 
HttpServletResponse): Unit = {
    +      val parts = Option(req.getPathInfo()).getOrElse("").split("/")
    +      if (parts.length < 2) {
    +        res.sendError(HttpServletResponse.SC_BAD_REQUEST,
    +          s"Unexpected path info in request (URI = ${req.getRequestURI()}")
    --- End diff --
    
    I'd rather not make user errors show up in the log. It makes it too easy to 
flood the log.
    
    With this, the user that caused the error will be able to see the message.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to