You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/03/30 15:27:57 UTC

[GitHub] [spark] srowen commented on a change in pull request #31204: [SPARK-26399][WEBUI][CORE] Add new stage-level REST APIs and parameters

srowen commented on a change in pull request #31204:
URL: https://github.com/apache/spark/pull/31204#discussion_r604203453



##########
File path: core/src/main/scala/org/apache/spark/status/api/v1/StagesResource.scala
##########
@@ -28,8 +31,33 @@ import org.apache.spark.util.Utils
 private[v1] class StagesResource extends BaseAppResource {
 
   @GET
-  def stageList(@QueryParam("status") statuses: JList[StageStatus]): Seq[StageData] = {
-    withUI(_.store.stageList(statuses))
+  def stageList(
+      @QueryParam("status") statuses: JList[StageStatus],
+      @QueryParam("details") @DefaultValue("false") details: Boolean,
+      @QueryParam("withSummaries") @DefaultValue("false") withSummaries: Boolean,
+      @QueryParam("quantiles") @DefaultValue("0.0,0.25,0.5,0.75,1.0") quantileString: String,
+      @QueryParam("taskStatus") taskStatus: JList[TaskStatus])
+  : Seq[StageData] = {

Review comment:
       Nit: pull this onto the previous line.

##########
File path: core/src/main/scala/org/apache/spark/status/api/v1/StagesResource.scala
##########
@@ -28,17 +31,50 @@ import org.apache.spark.util.Utils
 private[v1] class StagesResource extends BaseAppResource {
 
   @GET
-  def stageList(@QueryParam("status") statuses: JList[StageStatus]): Seq[StageData] = {
-    withUI(_.store.stageList(statuses))
+  def stageList(
+      @QueryParam("status") statuses: JList[StageStatus],
+      @QueryParam("details") @DefaultValue("false") details: Boolean,
+      @QueryParam("withSummaries") @DefaultValue("false") withSummaries: Boolean,
+      @QueryParam("quantiles") @DefaultValue("0.0,0.25,0.5,0.75,1.0") quantileString: String,
+      @QueryParam("taskStatus") taskStatus: JList[TaskStatus])
+  : Seq[StageData] = {
+    withUI {
+      val quantiles = quantileString.split(",").map { s =>
+        try {
+          s.toDouble
+        } catch {
+          case nfe: NumberFormatException =>
+            throw new BadParameterException("quantiles", "double", s)
+        }
+      }
+      ui => {
+        ui.store.stageList(statuses, details, withSummaries, Option(quantiles), taskStatus)
+          .filter { stage =>
+            if (details) {
+              taskStatus.asScala.exists {
+                case FAILED => stage.numFailedTasks > 0
+                case KILLED => stage.numKilledTasks > 0
+                case RUNNING => stage.numActiveTasks > 0
+                case SUCCESS => stage.numCompleteTasks > 0
+                case UNKNOWN => stage.numTasks - stage.numFailedTasks - stage.numKilledTasks -
+                  stage.numActiveTasks - stage.numCompleteTasks > 0
+              }
+            } else {
+              true
+            }
+          }
+      }
+    }
   }

Review comment:
       Do we still need a simple test here?

##########
File path: docs/monitoring.md
##########
@@ -473,6 +473,10 @@ can be identified by their `[attempt-id]`. In the API listed below, when running
     <td>
       A list of all stages for a given application.
       <br><code>?status=[active|complete|pending|failed]</code> list only stages in the state.
+      <br><code>?details=true</code> lists stages with the task data.

Review comment:
       Just checking, these docs are now up to date given the PRs that have been merged?




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org