Skip to content

Commit

Permalink
review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
squito committed Apr 28, 2015
1 parent 14ac3ed commit befff0c
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,15 @@

package org.apache.spark.status.api.v1;

import org.apache.spark.annotation.DeveloperApi;
import org.apache.spark.util.EnumUtil;

import java.util.HashSet;
import java.util.Set;

// exposed for jersey
@DeveloperApi
public enum TaskSorting {
ID,
IncreasingRuntime("runtime"),
DecreasingRuntime("-runtime");
INCREASING_RUNTIME("runtime"),
DECREASING_RUNTIME("-runtime");

private final Set<String> alternateNames;
private TaskSorting(String... names) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,12 +294,16 @@ private[v1] abstract class MetricHelper[I,O](
quantiles: Array[Double]) {

def getSubmetrics(raw: InternalTaskMetrics): Option[I]

def build: O

val data: Seq[I] = rawMetrics.flatMap(getSubmetrics)

/** applies the given function to all input metrics, and returns the quantiles */
def submetricQuantiles(f: I => Double): IndexedSeq[Double] = {
Distribution(data.map { d => f(d) }).get.getQuantiles(quantiles)
}

def metricOption: Option[O] = {
if (data.isEmpty) {
None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ object OneStageResource {
val extractor: (TaskData => Long) = td =>
taskSorting match {
case ID => td.taskId
case IncreasingRuntime => td.taskMetrics.map{_.executorRunTime}.getOrElse(-1L)
case DecreasingRuntime => -td.taskMetrics.map{_.executorRunTime}.getOrElse(-1L)
case INCREASING_RUNTIME => td.taskMetrics.map{_.executorRunTime}.getOrElse(-1L)
case DECREASING_RUNTIME => -td.taskMetrics.map{_.executorRunTime}.getOrElse(-1L)
}
Ordering.by(extractor)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class HistoryServerSuite extends FunSuite with BeforeAndAfter with Matchers with
"stage task list w/ offset & length" ->
"applications/local-1427397477963/stages/20/0/taskList?offset=10&length=50",
"stage task list w/ sortBy" ->
"applications/local-1427397477963/stages/20/0/taskList?sortBy=DecreasingRuntime",
"applications/local-1427397477963/stages/20/0/taskList?sortBy=DECREASING_RUNTIME",
"stage task list w/ sortBy short names: -runtime" ->
"applications/local-1427397477963/stages/20/0/taskList?sortBy=-runtime",
"stage task list w/ sortBy short names: runtime" ->
Expand Down

0 comments on commit befff0c

Please sign in to comment.