Github user ryan-williams commented on a diff in the pull request:

    https://github.com/apache/spark/pull/4525#discussion_r24613618
  
    --- Diff: 
core/src/main/scala/org/apache/spark/deploy/history/FsHistoryProvider.scala ---
    @@ -119,14 +138,79 @@ private[history] class FsHistoryProvider(conf: 
SparkConf) extends ApplicationHis
         if (!conf.contains("spark.testing")) {
           logCheckingThread.setDaemon(true)
           logCheckingThread.start()
    +      logLazyReplayThread.setDaemon(true)
    +      logLazyReplayThread.start()
    +    } else {
    +      logLazyReplay()
         }
       }
     
    -  override def getListing() = applications.values
    +  /**
    +   * Fetch and Parse the log files
    +   */
    +  private[history] def logLazyReplay() {
    +    if(lazyApplications.isEmpty) return
    +
    +    logDebug("start doLazyReplay")
    +    val mergeSize = 20
    +    val bufferedApps = new ArrayBuffer[FsApplicationHistoryInfo](mergeSize)
    +
    +    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)
    +      }
    +    }
    +
    +    def mergeApps(): mutable.LinkedHashMap[String, 
FsApplicationHistoryInfo] = {
    +      val newApps = new mutable.LinkedHashMap[String, 
FsApplicationHistoryInfo]()
    +      bufferedApps.sortWith(compareAppInfo)
    +
    +      val newIterator = bufferedApps.iterator.buffered
    +      val oldIterator = applications.values.iterator.buffered
    +      while (newIterator.hasNext && oldIterator.hasNext) {
    +        if (compareAppInfo(newIterator.head, oldIterator.head)) {
    +          addIfAbsent(newApps, newIterator.next())
    +        } else {
    +          addIfAbsent(newApps, oldIterator.next())
    +        }
    +      }
    +      newIterator.foreach(addIfAbsent(newApps, _))
    +      oldIterator.foreach(addIfAbsent(newApps, _))
    +
    +      newApps
    +    }
    +
    +    val bus = new ReplayListenerBus()
    +    while(lazyApplications.nonEmpty){
    +      lazyApplications.iterator.take(mergeSize).foreach(keyValue => {
    +        try{
    +          val lazyInfo = keyValue._2
    +          val info = replay(lazyInfo.eventLog, bus)
    +          bufferedApps += info
    +          logDebug("replay application " + lazyInfo.id + " successfully")
    +        } catch {
    +          case e: Exception =>
    +        }
    +      })
    +      applications = mergeApps()
    +      for(i <- 1 to bufferedApps.size) 
lazyApplications.remove(lazyApplications.head._1)
    +      bufferedApps.clear()
    +    }
    +    logDebug("finish doLazyReplay")
    --- End diff --
    
    ditto


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