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

    https://github.com/apache/spark/pull/18887#discussion_r141125410
  
    --- Diff: 
core/src/main/scala/org/apache/spark/deploy/history/FsHistoryProvider.scala ---
    @@ -424,208 +459,105 @@ private[history] class FsHistoryProvider(conf: 
SparkConf, clock: Clock)
           }
         }
     
    -    applications.get(appId) match {
    -      case Some(appInfo) =>
    -        try {
    -          // If no attempt is specified, or there is no attemptId for 
attempts, return all attempts
    -          appInfo.attempts.filter { attempt =>
    -            attempt.attemptId.isEmpty || attemptId.isEmpty || 
attempt.attemptId.get == attemptId.get
    -          }.foreach { attempt =>
    -            val logPath = new Path(logDir, attempt.logPath)
    -            zipFileToStream(logPath, attempt.logPath, zipStream)
    -          }
    -        } finally {
    -          zipStream.close()
    +    val app = try {
    +      load(appId)
    +    } catch {
    +      case _: NoSuchElementException =>
    +        throw new SparkException(s"Logs for $appId not found.")
    +    }
    +
    +    try {
    +      // If no attempt is specified, or there is no attemptId for 
attempts, return all attempts
    +      attemptId
    +        .map { id => app.attempts.filter(_.info.attemptId == Some(id)) }
    +        .getOrElse(app.attempts)
    +        .map(_.logPath)
    +        .foreach { log =>
    +          zipFileToStream(new Path(logDir, log), log, zipStream)
             }
    -      case None => throw new SparkException(s"Logs for $appId not found.")
    +    } finally {
    +      zipStream.close()
         }
       }
     
       /**
    -   * Replay the log files in the list and merge the list of old 
applications with new ones
    +   * Replay the given log file, saving the application in the listing db.
    --- End diff --
    
    No. If you look at the old code it did a "merge sort" kinda thing to create 
an updated listing. `KVStore` sorts things internally so there's no need for 
that code anymore - you just write something to it, and it's sorted magically.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to