Skip to content
Closed
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
13 changes: 9 additions & 4 deletions core/src/main/scala/org/apache/spark/status/LiveEntity.scala
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,15 @@ private class LiveTask(
}

override protected def doUpdate(): Any = {
val duration = if (info.finished) {
info.duration
var duration: Long = 0
var executorRunTime: Long = 0

if (info.finished) {
Copy link
Contributor

Choose a reason for hiding this comment

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

vars are not very cool in scala... how about something like this?

val (duration, executorRunTime) = if (info.finished) {
      (info.duration, metrics.executorRunTime)
    } else {
      val timeRunning = info.timeRunning(lastUpdateTime.getOrElse(System.currentTimeMillis()))
      (timeRunning, timeRunning)
    }

duration = info.duration
executorRunTime = metrics.executorRunTime
} else {
info.timeRunning(lastUpdateTime.getOrElse(System.currentTimeMillis()))
duration = info.timeRunning(lastUpdateTime.getOrElse(System.currentTimeMillis()))
executorRunTime = duration
}

new TaskDataWrapper(
Expand All @@ -198,7 +203,7 @@ private class LiveTask(

metrics.executorDeserializeTime,
metrics.executorDeserializeCpuTime,
metrics.executorRunTime,
executorRunTime,
metrics.executorCpuTime,
metrics.resultSize,
metrics.jvmGcTime,
Expand Down