ron8hu commented on a change in pull request #31204:
URL: https://github.com/apache/spark/pull/31204#discussion_r578915684
##########
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:
We need a unit test case to validate the logic here in listing multiple
taskStatus values. For example, a REST API call to show all the FAILED tasks
and KILLED tasks :
/application/{app-id}/stages?details=true&taskStatus=FAILED&taskStatus=KILLED
----------------------------------------------------------------
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]