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

    https://github.com/apache/spark/pull/1222#discussion_r18534683
  
    --- Diff: 
core/src/main/scala/org/apache/spark/deploy/history/FsHistoryProvider.scala ---
    @@ -142,48 +151,56 @@ private[history] class FsHistoryProvider(conf: 
SparkConf) extends ApplicationHis
        * Tries to reuse as much of the data already in memory as possible, by 
not reading
        * applications that haven't been updated since last time the logs were 
checked.
        */
    -  private def checkForLogs() = {
    +  private[history] def checkForLogs() = {
         lastLogCheckTimeMs = getMonotonicTimeMs()
         logDebug("Checking for logs. Time is now 
%d.".format(lastLogCheckTimeMs))
    -    try {
    -      val logStatus = fs.listStatus(new Path(resolvedLogDir))
    -      val logDirs = if (logStatus != null) logStatus.filter(_.isDir).toSeq 
else Seq[FileStatus]()
     
    -      // Load all new logs from the log directory. Only directories that 
have a modification time
    -      // later than the last known log directory will be loaded.
    +    def getModificationTime(fsEntry: FileStatus) = {
    +      if (fsEntry.isDir) {
    +        fs.listStatus(fsEntry.getPath).map(_.getModificationTime()).max
    +      } else {
    +        fsEntry.getModificationTime()
    +      }
    +    }
    +
    +    try {
           var newLastModifiedTime = lastModifiedTime
    -      val logInfos = logDirs
    -        .filter { dir =>
    -          if (fs.isFile(new Path(dir.getPath(), 
EventLoggingListener.APPLICATION_COMPLETE))) {
    -            val modTime = getModificationTime(dir)
    +      val logInfos = fs.listStatus(new Path(logDir))
    +        .filter { entry =>
    +          val isLogEntry =
    +            if (entry.isDir()) {
    +              fs.exists(new Path(entry.getPath(), APPLICATION_COMPLETE))
    +            } else {
    +              
!entry.getPath().getName().endsWith(EventLoggingListener.IN_PROGRESS)
    +            }
    +
    +          if (isLogEntry) {
    +            val modTime = getModificationTime(entry)
                 newLastModifiedTime = math.max(newLastModifiedTime, modTime)
    -            modTime > lastModifiedTime
    +            modTime >= lastModifiedTime
               } else {
                 false
               }
             }
    -        .flatMap { dir =>
    +        .flatMap { entry =>
               try {
    -            val (replayBus, appListener) = createReplayBus(dir)
    -            replayBus.replay()
    +            val appListener = replay(entry, new ReplayListenerBus())
                 Some(new FsApplicationHistoryInfo(
    -              dir.getPath().getName(),
    -              appListener.appId.getOrElse(dir.getPath().getName()),
    +              entry.getPath().getName(),
    +              appListener.appId.getOrElse(entry.getPath().getName()),
                   appListener.appName.getOrElse(NOT_STARTED),
                   appListener.startTime.getOrElse(-1L),
                   appListener.endTime.getOrElse(-1L),
    -              getModificationTime(dir),
    +              getModificationTime(entry),
                   appListener.sparkUser.getOrElse(NOT_STARTED)))
               } catch {
                 case e: Exception =>
    -              logInfo(s"Failed to load application log data from $dir.", e)
    +              logInfo(s"Failed to load application log data from $entry.", 
e)
                   None
               }
             }
             .sortBy { info => -info.endTime }
     
    -      lastModifiedTime = newLastModifiedTime
    --- End diff --
    
    Oops.


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to