Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions core/src/main/java/org/apache/spark/status/api/v1/TaskStatus.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* 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.status.api.v1;

import org.apache.spark.util.EnumUtil;

public enum TaskStatus {
RUNNING,
KILLED,
FAILED,
SUCCESS,
UNKNOWN;

public static TaskStatus fromString(String str) {
return EnumUtil.parseIgnoreCase(TaskStatus.class, str);
}
}
16 changes: 12 additions & 4 deletions core/src/main/scala/org/apache/spark/status/AppStatusStore.scala
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,8 @@ private[spark] class AppStatusStore(
stageAttemptId: Int,
offset: Int,
length: Int,
sortBy: v1.TaskSorting): Seq[v1.TaskData] = {
sortBy: v1.TaskSorting,
statuses: JList[v1.TaskStatus]): Seq[v1.TaskData] = {
val (indexName, ascending) = sortBy match {
case v1.TaskSorting.ID =>
(None, true)
Expand All @@ -395,7 +396,7 @@ private[spark] class AppStatusStore(
case v1.TaskSorting.DECREASING_RUNTIME =>
(Some(TaskIndexNames.EXEC_RUN_TIME), false)
}
taskList(stageId, stageAttemptId, offset, length, indexName, ascending)
taskList(stageId, stageAttemptId, offset, length, indexName, ascending, statuses)
}

def taskList(
Expand All @@ -404,7 +405,8 @@ private[spark] class AppStatusStore(
offset: Int,
length: Int,
sortBy: Option[String],
ascending: Boolean): Seq[v1.TaskData] = {
ascending: Boolean,
statuses: JList[v1.TaskStatus] = List().asJava): Seq[v1.TaskData] = {
val stageKey = Array(stageId, stageAttemptId)
val base = store.view(classOf[TaskDataWrapper])
val indexed = sortBy match {
Expand All @@ -417,7 +419,13 @@ private[spark] class AppStatusStore(
}

val ordered = if (ascending) indexed else indexed.reverse()
val taskDataWrapperIter = ordered.skip(offset).max(length).asScala
val taskDataWrapperIter = if (statuses != null && !statuses.isEmpty) {
val statusesStr = statuses.asScala.map(_.toString).toSet
ordered.asScala.filter(s => statusesStr.contains(s.status)).slice(offset, offset + length)
} else {
ordered.skip(offset).max(length).asScala
}

constructTaskDataList(taskDataWrapperIter)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@ private[v1] class StagesResource extends BaseAppResource {
@PathParam("stageAttemptId") stageAttemptId: Int,
@DefaultValue("0") @QueryParam("offset") offset: Int,
@DefaultValue("20") @QueryParam("length") length: Int,
@DefaultValue("ID") @QueryParam("sortBy") sortBy: TaskSorting): Seq[TaskData] = {
withUI(_.store.taskList(stageId, stageAttemptId, offset, length, sortBy))
@DefaultValue("ID") @QueryParam("sortBy") sortBy: TaskSorting,
@QueryParam("status") statuses: JList[TaskStatus]): Seq[TaskData] = {
Copy link
Member

@gengliangwang gengliangwang Jul 1, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to make it as JList here? How about just TaskStatus?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I'm also considering using TaskStatus. The reason I use JList is to make it consistent with stageList as below:

  @GET
  def stageList(@QueryParam("status") statuses: JList[StageStatus]): Seq[StageData] = {
    withUI(_.store.stageList(statuses))
  }

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, sorry I was not aware of this. Please change it back to JList to make it consistent.

withUI(_.store.taskList(stageId, stageAttemptId, offset, length, sortBy, statuses))
}

// This api needs to stay formatted exactly as it is below, since, it is being used by the
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
[ {
"taskId" : 1,
"index" : 1,
"attempt" : 0,
"launchTime" : "2015-05-06T13:03:06.502GMT",
"duration" : 421,
"executorId" : "driver",
"host" : "localhost",
"status" : "SUCCESS",
"taskLocality" : "PROCESS_LOCAL",
"speculative" : false,
"accumulatorUpdates" : [ ],
"taskMetrics" : {
"executorDeserializeTime" : 31,
"executorDeserializeCpuTime" : 0,
"executorRunTime" : 350,
"executorCpuTime" : 0,
"resultSize" : 2010,
"jvmGcTime" : 7,
"resultSerializationTime" : 0,
"memoryBytesSpilled" : 0,
"diskBytesSpilled" : 0,
"peakExecutionMemory" : 0,
"inputMetrics" : {
"bytesRead" : 60488,
"recordsRead" : 10000
},
"outputMetrics" : {
"bytesWritten" : 0,
"recordsWritten" : 0
},
"shuffleReadMetrics" : {
"remoteBlocksFetched" : 0,
"localBlocksFetched" : 0,
"fetchWaitTime" : 0,
"remoteBytesRead" : 0,
"remoteBytesReadToDisk" : 0,
"localBytesRead" : 0,
"recordsRead" : 0
},
"shuffleWriteMetrics" : {
"bytesWritten" : 1710,
"writeTime" : 3934399,
"recordsWritten" : 10
}
},
"executorLogs" : { },
"schedulerDelay" : 40,
"gettingResultTime" : 0
}, {
"taskId" : 2,
"index" : 2,
"attempt" : 0,
"launchTime" : "2015-05-06T13:03:06.503GMT",
"duration" : 419,
"executorId" : "driver",
"host" : "localhost",
"status" : "SUCCESS",
"taskLocality" : "PROCESS_LOCAL",
"speculative" : false,
"accumulatorUpdates" : [ ],
"taskMetrics" : {
"executorDeserializeTime" : 32,
"executorDeserializeCpuTime" : 0,
"executorRunTime" : 348,
"executorCpuTime" : 0,
"resultSize" : 2010,
"jvmGcTime" : 7,
"resultSerializationTime" : 2,
"memoryBytesSpilled" : 0,
"diskBytesSpilled" : 0,
"peakExecutionMemory" : 0,
"inputMetrics" : {
"bytesRead" : 60488,
"recordsRead" : 10000
},
"outputMetrics" : {
"bytesWritten" : 0,
"recordsWritten" : 0
},
"shuffleReadMetrics" : {
"remoteBlocksFetched" : 0,
"localBlocksFetched" : 0,
"fetchWaitTime" : 0,
"remoteBytesRead" : 0,
"remoteBytesReadToDisk" : 0,
"localBytesRead" : 0,
"recordsRead" : 0
},
"shuffleWriteMetrics" : {
"bytesWritten" : 1710,
"writeTime" : 89885,
"recordsWritten" : 10
}
},
"executorLogs" : { },
"schedulerDelay" : 37,
"gettingResultTime" : 0
} ]
Loading