xuanyuanking commented on a change in pull request #28781:
URL: https://github.com/apache/spark/pull/28781#discussion_r440937299



##########
File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/ui/StreamingQueryStatusStore.scala
##########
@@ -0,0 +1,61 @@
+/*
+ * 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 org.apache.spark.sql.streaming.ui.{StreamingQueryProgressWrapper, 
StreamingQuerySummary, StreamingQueryUIData}
+import org.apache.spark.status.{ElementTrackingStore, KVUtils}
+
+/**
+ * Provides a view of a KVStore with methods that make it easy to query 
Streaming Query state.
+ * There's no state kept in this class, so it's ok to have multiple instances 
of it in an
+ * application.
+ */
+class StreamingQueryStatusStore(store: ElementTrackingStore) {
+
+  def queriesCount(): Long = store.count(classOf[StreamingQuerySummary])

Review comment:
       No usage for `queriesCount`? Do you plan to use it in 
`StreamingQueryHistoryServerPlugin`?

##########
File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/ui/StreamingQueryStatusStore.scala
##########
@@ -0,0 +1,61 @@
+/*
+ * 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 org.apache.spark.sql.streaming.ui.{StreamingQueryProgressWrapper, 
StreamingQuerySummary, StreamingQueryUIData}
+import org.apache.spark.status.{ElementTrackingStore, KVUtils}
+
+/**
+ * Provides a view of a KVStore with methods that make it easy to query 
Streaming Query state.
+ * There's no state kept in this class, so it's ok to have multiple instances 
of it in an
+ * application.
+ */
+class StreamingQueryStatusStore(store: ElementTrackingStore) {

Review comment:
       Forget to address this comment 
https://github.com/apache/spark/pull/28781#discussion_r438704385? I think 
using` store: KVStore` here is enough.

##########
File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/StreamingQueryListenerBus.scala
##########
@@ -95,7 +95,11 @@ class StreamingQueryListenerBus(sparkListenerBus: 
LiveListenerBus)
         // synchronously and the ones attached to LiveListenerBus 
asynchronously. Therefore,
         // we need to ignore QueryStartedEvent if this method is called within 
SparkListenerBus
         // thread
-        if (!LiveListenerBus.withinListenerThread.value || 
!e.isInstanceOf[QueryStartedEvent]) {
+        //
+        // When loaded by Spark History Server, we should process all event 
coming from replay
+        // listener bus.
+        if (!live || !LiveListenerBus.withinListenerThread.value ||
+          !e.isInstanceOf[QueryStartedEvent])  {

Review comment:
       nit: add 2 more space here.

##########
File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/ui/StreamingQueryHistoryServerPlugin.scala
##########
@@ -0,0 +1,42 @@
+/*
+ * 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 org.apache.spark.SparkConf
+import org.apache.spark.scheduler.SparkListener
+import org.apache.spark.sql.execution.streaming.StreamingQueryListenerBus
+import org.apache.spark.sql.streaming.ui.{StreamingQueryStatusListener, 
StreamingQueryTab}
+import org.apache.spark.status.{AppHistoryServerPlugin, ElementTrackingStore}
+import org.apache.spark.ui.SparkUI
+
+class StreamingQueryHistoryServerPlugin extends AppHistoryServerPlugin {
+
+  override def createListeners(conf: SparkConf, store: ElementTrackingStore): 
Seq[SparkListener] = {
+    val listenerBus = new StreamingQueryListenerBus(None, live = false)
+    listenerBus.addListener(new StreamingQueryStatusListener(conf, store))
+    Seq(listenerBus)
+  }
+
+  override def setupUI(ui: SparkUI): Unit = {
+    val trackingStore = new ElementTrackingStore(ui.store.store, ui.conf)

Review comment:
       Ditto, don't need to new ElementTrackingStore here?




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

For queries about this service, please contact Infrastructure at:
[email protected]



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

Reply via email to