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

    https://github.com/apache/spark/pull/10284#discussion_r47562711
  
    --- Diff: core/src/main/scala/org/apache/spark/deploy/master/Master.scala 
---
    @@ -924,49 +939,74 @@ private[deploy] class Master(
        * Return the UI if successful, else None
        */
       private[master] def rebuildSparkUI(app: ApplicationInfo): 
Option[SparkUI] = {
    +    val futureUI = asyncRebuildSparkUI(app)
    +
    +    // Wait until the UI is rebuilt or cancelled, log status occasionally 
for apps with many events
    +    var waitSec = 2
    +    do {
    +      try {
    +        val ui = Await.result(futureUI, Duration(waitSec, 
TimeUnit.SECONDS))
    +        return Some(ui)
    +      } catch {
    +        case te: TimeoutException =>
    +          waitSec *= 2
    +          logInfo(s"Application UI is rebuilding, will continue to wait 
$waitSec seconds")
    +        case NonFatal(_) | _: InterruptedException =>
    +          waitSec = 0
    +      }
    +    } while (waitSec > 0)
    +    None
    +  }
    +
    +  /** Rebuild a new SparkUI asynchronously to not block RPC event loop */
    +  private[master] def asyncRebuildSparkUI(app: ApplicationInfo): 
Future[SparkUI] = {
         val appName = app.desc.name
         val notFoundBasePath = HistoryServer.UI_PATH_PREFIX + "/not-found"
    -    try {
    -      val eventLogDir = app.desc.eventLogDir
    -        .getOrElse {
    -          // Event logging is not enabled for this application
    -          app.appUIUrlAtHistoryServer = Some(notFoundBasePath)
    -          return None
    -        }
    +    val futureUI = Future {
    +
    +      // Fail the future immediately if event logging is not enabled for 
this application
    +      val eventLogDir = app.desc.eventLogDir.getOrElse(throw new 
RebuildUINoEventLogException)
    --- End diff --
    
    we don't have to do this in the future since it's quick. Then we don't need 
to introduce the custom exception. I would actually just wrap the original code 
in a `Future[Option[SparkUI]`, and then `onSuccess` tell the RPC loop to attach 
it to the web UI.


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

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

Reply via email to