Github user squito commented on a diff in the pull request:
https://github.com/apache/spark/pull/19681#discussion_r150091458
--- Diff:
sql/core/src/main/scala/org/apache/spark/sql/execution/ui/SQLAppStatusStore.scala
---
@@ -0,0 +1,172 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.sql.execution.ui
+
+import java.lang.{Long => JLong}
+import java.util.Date
+
+import scala.collection.JavaConverters._
+import scala.collection.mutable.ArrayBuffer
+
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize
+
+import org.apache.spark.{JobExecutionStatus, SparkConf}
+import org.apache.spark.scheduler.SparkListener
+import org.apache.spark.status.AppStatusPlugin
+import org.apache.spark.status.KVUtils.KVIndexParam
+import org.apache.spark.ui.SparkUI
+import org.apache.spark.util.Utils
+import org.apache.spark.util.kvstore.KVStore
+
+/**
+ * Provides a view of a KVStore with methods that make it easy to query
SQL-specific state. There's
+ * no state kept in this class, so it's ok to have multiple instances of
it in an application.
+ */
+private[sql] class SQLAppStatusStore(
+ store: KVStore,
+ listener: Option[SQLAppStatusListener] = None) {
+
+ def executionsList(): Seq[SQLExecutionUIData] = {
+ store.view(classOf[SQLExecutionUIData]).asScala.toSeq
+ }
+
+ def execution(executionId: Long): Option[SQLExecutionUIData] = {
+ try {
+ Some(store.read(classOf[SQLExecutionUIData], executionId))
+ } catch {
+ case _: NoSuchElementException => None
+ }
+ }
+
+ def executionsCount(): Long = {
+ store.count(classOf[SQLExecutionUIData])
+ }
+
+ def executionMetrics(executionId: Long): Map[Long, String] = {
+ val exec = store.read(classOf[SQLExecutionUIData], executionId)
+ Option(exec.metricValues)
+ .orElse(listener.map(_.executionMetrics(executionId)))
+ .getOrElse(Map())
--- End diff --
is there a race here when the execution ends?
- T1 (UI thread, calling this method): execution hasn't ended, so
`exec.metricValues` is null
- T2 (listener): execution ends, drops execution from `liveExecutions`
- T1: `_.executionMetrics(executionId)` throws an exception because its
dropped from the `liveExecutions`
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]