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

    https://github.com/apache/spark/pull/4525#discussion_r25013864
  
    --- Diff: 
core/src/main/scala/org/apache/spark/deploy/history/FsHistoryProvider.scala ---
    @@ -187,47 +201,78 @@ private[history] class FsHistoryProvider(conf: 
SparkConf) extends ApplicationHis
             }
             .flatMap { entry =>
               try {
    -            Some(replay(entry, new ReplayListenerBus()))
    +            Some((getModificationTime(entry).get, entry))
               } catch {
                 case e: Exception =>
                   logError(s"Failed to load application log data from 
$entry.", e)
                   None
               }
             }
    -        .sortWith(compareAppInfo)
    +        .sortWith(_._1 >= _._1)
    +        .map(_._2)
    +
    +      val itor = logInfos.iterator
    +      while (itor.hasNext) {
    +        val batchSize = 20
    +        val batch = itor.take(batchSize)
    +        replayExecutor.submit(new Runnable {
    +          override def run(): Unit = replay(batch)
    +        })
    +        for (i <- 1 to batchSize) {
    +          if(itor.hasNext) {
    +            itor.next()
    +          }
    +        }
    +      }
     
           lastModifiedTime = newLastModifiedTime
    +    } catch {
    +      case e: Exception => logError("Exception in checking for event log 
updates", e)
    +    }
    +  }
     
    -      // When there are new logs, merge the new list with the existing 
one, maintaining
    -      // the expected ordering (descending end time). Maintaining the 
order is important
    -      // to avoid having to sort the list every time there is a request 
for the log list.
    -      if (!logInfos.isEmpty) {
    -        val newApps = new mutable.LinkedHashMap[String, 
FsApplicationHistoryInfo]()
    -        def addIfAbsent(info: FsApplicationHistoryInfo) = {
    -          if (!newApps.contains(info.id) ||
    -              
newApps(info.id).logPath.endsWith(EventLoggingListener.IN_PROGRESS) &&
    -              !info.logPath.endsWith(EventLoggingListener.IN_PROGRESS)) {
    -            newApps += (info.id -> info)
    -          }
    -        }
    +  /**
    +   * Fetch and Parse the log files
    +   */
    +  private def replay(logs: Iterator[FileStatus]) {
    +    def addIfAbsent(newApps: mutable.LinkedHashMap[String, 
FsApplicationHistoryInfo],
    +                    info: FsApplicationHistoryInfo) {
    +      if (!newApps.contains(info.id) ||
    +        
newApps(info.id).logPath.endsWith(EventLoggingListener.IN_PROGRESS) &&
    +          !info.logPath.endsWith(EventLoggingListener.IN_PROGRESS)) {
    +        newApps += (info.id -> info)
    +      }
    +    }
     
    -        val newIterator = logInfos.iterator.buffered
    -        val oldIterator = applications.values.iterator.buffered
    -        while (newIterator.hasNext && oldIterator.hasNext) {
    -          if (compareAppInfo(newIterator.head, oldIterator.head)) {
    -            addIfAbsent(newIterator.next)
    -          } else {
    -            addIfAbsent(oldIterator.next)
    -          }
    -        }
    -        newIterator.foreach(addIfAbsent)
    -        oldIterator.foreach(addIfAbsent)
    +    def mergeApps(list: Seq[FsApplicationHistoryInfo]) {
    --- End diff --
    
    need `: Unit` return type here and other places, see 
https://cwiki.apache.org/confluence/display/SPARK/Spark+Code+Style+Guide.


---
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