Skip to content
Snippets Groups Projects
Commit e849285d authored by Alex Bozarth's avatar Alex Bozarth Committed by Andrew Or
Browse files

[SPARK-15868][WEB UI] Executors table in Executors tab should sort Executor IDs in numerical order

## What changes were proposed in this pull request?

Currently the Executors table sorts by id using a string sort (since that's what it is stored as). Since  the id is a number (other than the driver) we should be sorting numerically. I have changed both the initial sort on page load as well as the table sort to sort on id numerically, treating non-numeric strings (like the driver) as "-1"

## How was this patch tested?

Manually tested and dev/run-tests

![pageload](https://cloud.githubusercontent.com/assets/13952758/16027882/d32edd0a-318e-11e6-9faf-fc972b7c36ab.png)
![sorted](https://cloud.githubusercontent.com/assets/13952758/16027883/d34541c6-318e-11e6-9ed7-6bfc0cd4152e.png)

Author: Alex Bozarth <ajbozart@us.ibm.com>

Closes #13654 from ajbozarth/spark15868.
parent 2d27eb1e
No related branches found
No related tags found
No related merge requests found
......@@ -20,6 +20,7 @@ package org.apache.spark.ui.exec
import java.net.URLEncoder
import javax.servlet.http.HttpServletRequest
import scala.util.Try
import scala.xml.Node
import org.apache.spark.status.api.v1.ExecutorSummary
......@@ -53,6 +54,9 @@ private[ui] class ExecutorsPage(
// When GCTimePercent is edited change ToolTips.TASK_TIME to match
private val GCTimePercent = 0.1
// a safe String to Int for sorting ids (converts non-numeric Strings to -1)
private def idStrToInt(str: String) : Int = Try(str.toInt).getOrElse(-1)
def render(request: HttpServletRequest): Seq[Node] = {
val (activeExecutorInfo, deadExecutorInfo) = listener.synchronized {
// The follow codes should be protected by `listener` to make sure no executors will be
......@@ -69,13 +73,14 @@ private[ui] class ExecutorsPage(
}
val execInfo = activeExecutorInfo ++ deadExecutorInfo
implicit val idOrder = Ordering[Int].on((s: String) => idStrToInt(s)).reverse
val execInfoSorted = execInfo.sortBy(_.id)
val logsExist = execInfo.filter(_.executorLogs.nonEmpty).nonEmpty
val execTable = {
<table class={UIUtils.TABLE_CLASS_STRIPED_SORTABLE}>
<thead>
<th>Executor ID</th>
<th class="sorttable_numeric">Executor ID</th>
<th>Address</th>
<th>Status</th>
<th>RDD Blocks</th>
......@@ -136,7 +141,7 @@ private[ui] class ExecutorsPage(
}
<tr>
<td>{info.id}</td>
<td sorttable_customkey={idStrToInt(info.id).toString}>{info.id}</td>
<td>{info.hostPort}</td>
<td sorttable_customkey={executorStatus.toString}>
{executorStatus}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment