You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kyuubi.apache.org by GitBox <gi...@apache.org> on 2022/02/09 02:06:07 UTC

[GitHub] [incubator-kyuubi] wForget commented on a change in pull request #1820: [KYUUBI #1816] Implement KyuubiHistoryServerPlugin

wForget commented on a change in pull request #1820:
URL: https://github.com/apache/incubator-kyuubi/pull/1820#discussion_r802210586



##########
File path: externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/spark/ui/EngineTab.scala
##########
@@ -24,25 +24,42 @@ import scala.util.control.NonFatal
 import org.apache.kyuubi.{Logging, Utils}
 import org.apache.kyuubi.config.KyuubiConf
 import org.apache.kyuubi.engine.spark.SparkSQLEngine
+import org.apache.kyuubi.engine.spark.events.EngineEventsStore
 import org.apache.kyuubi.service.ServiceState
 
 /**
  * Note that [[SparkUITab]] is private for Spark
  */
-case class EngineTab(engine: SparkSQLEngine)
-  extends SparkUITab(engine.spark.sparkContext.ui.orNull, "kyuubi") with Logging {
+case class EngineTab(
+    engine: Option[SparkSQLEngine],
+    sparkUI: Option[SparkUI],
+    store: EngineEventsStore,
+    kyuubiConf: KyuubiConf)
+  extends SparkUITab(sparkUI.orNull, "kyuubi") with Logging {
 
   override val name: String = "Kyuubi Query Engine"
-  val killEnabled = engine.getConf.get(KyuubiConf.ENGINE_UI_STOP_ENABLED)
+  val killEnabled = kyuubiConf.get(KyuubiConf.ENGINE_UI_STOP_ENABLED)
 
-  engine.spark.sparkContext.ui.foreach { ui =>
+  val startTime = engine.map(_.getStartTime).getOrElse {
+    sparkUI
+      .map(ui => ui.store.applicationInfo().attempts.head.startTime.getTime)
+      .getOrElse(0L)
+  }
+
+  def endTime(): Long = engine.map(_ => System.currentTimeMillis()).getOrElse {
+    sparkUI
+      .map(ui => ui.store.applicationInfo().attempts.head.endTime.getTime)

Review comment:
       I see that the spark source code also uses `attempts.head` to get attempt.
   like: https://github.com/apache/spark/blob/2a9416abd5c8d83901c09a08433bf91e649dc43f/core/src/main/scala/org/apache/spark/ui/jobs/AllJobsPage.scala#L277




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org