[SPARK-20966][WEB-UI][SQL] Table data is not sorted by startTime time desc, time is not formatted and redundant code in JDBC/ODBC Server page.

## What changes were proposed in this pull request?

1. Question 1 : Table data is not sorted by startTime time desc in JDBC/ODBC Server page.

fix before :
![2](https://cloud.githubusercontent.com/assets/26266482/26718483/bf4a0fa8-47b3-11e7-9a27-dc6a67165b16.png)

fix after :
![21](https://cloud.githubusercontent.com/assets/26266482/26718544/eb7376c8-47b3-11e7-9117-1bc68dfec92c.png)

2. Question 2 :  time is not formatted in JDBC/ODBC Server page.

fix before :
![1](https://cloud.githubusercontent.com/assets/26266482/26718573/0497d86a-47b4-11e7-945b-582aaa103949.png)

fix after :
![11](https://cloud.githubusercontent.com/assets/26266482/26718602/21371ad0-47b4-11e7-9587-c5114d10ab2c.png)

3. Question 3 :  Redundant code in the ThriftServerSessionPage.scala.
The function of 'generateSessionStatsTable'  has not been used

## How was this patch tested?

manual tests

Please review http://spark.apache.org/contributing.html before opening a pull request.

Author: guoxiaolong <guo.xiaolong1@zte.com.cn>
Author: 郭小龙 10207633 <guo.xiaolong1@zte.com.cn>
Author: guoxiaolongzte <guo.xiaolong1@zte.com.cn>

Closes #18186 from guoxiaolongzte/SPARK-20966.
This commit is contained in:
guoxiaolong 2017-06-07 10:18:40 +01:00 committed by Sean Owen
parent 3218505a0b
commit 0ca69c4ccf
2 changed files with 3 additions and 39 deletions

View file

@ -72,7 +72,7 @@ private[ui] class ThriftServerPage(parent: ThriftServerTab) extends WebUIPage(""
val table = if (numStatement > 0) {
val headerRow = Seq("User", "JobID", "GroupID", "Start Time", "Finish Time", "Duration",
"Statement", "State", "Detail")
val dataRows = listener.getExecutionList
val dataRows = listener.getExecutionList.sortBy(_.startTimestamp).reverse
def generateDataRow(info: ExecutionInfo): Seq[Node] = {
val jobLink = info.jobId.map { id: String =>
@ -142,7 +142,7 @@ private[ui] class ThriftServerPage(parent: ThriftServerTab) extends WebUIPage(""
val sessionList = listener.getSessionList
val numBatches = sessionList.size
val table = if (numBatches > 0) {
val dataRows = sessionList
val dataRows = sessionList.sortBy(_.startTimestamp).reverse
val headerRow = Seq("User", "IP", "Session ID", "Start Time", "Finish Time", "Duration",
"Total Execute")
def generateDataRow(session: SessionInfo): Seq[Node] = {

View file

@ -66,7 +66,7 @@ private[ui] class ThriftServerSessionPage(parent: ThriftServerTab)
val timeSinceStart = System.currentTimeMillis() - startTime.getTime
<ul class ="unstyled">
<li>
<strong>Started at: </strong> {startTime.toString}
<strong>Started at: </strong> {formatDate(startTime)}
</li>
<li>
<strong>Time since start: </strong>{formatDurationVerbose(timeSinceStart)}
@ -147,42 +147,6 @@ private[ui] class ThriftServerSessionPage(parent: ThriftServerTab)
<td>{errorSummary}{details}</td>
}
/** Generate stats of batch sessions of the thrift server program */
private def generateSessionStatsTable(): Seq[Node] = {
val sessionList = listener.getSessionList
val numBatches = sessionList.size
val table = if (numBatches > 0) {
val dataRows =
sessionList.sortBy(_.startTimestamp).reverse.map ( session =>
Seq(
session.userName,
session.ip,
session.sessionId,
formatDate(session.startTimestamp),
formatDate(session.finishTimestamp),
formatDurationOption(Some(session.totalTime)),
session.totalExecution.toString
)
).toSeq
val headerRow = Seq("User", "IP", "Session ID", "Start Time", "Finish Time", "Duration",
"Total Execute")
Some(listingTable(headerRow, dataRows))
} else {
None
}
val content =
<h5>Session Statistics</h5> ++
<div>
<ul class="unstyled">
{table.getOrElse("No statistics have been generated yet.")}
</ul>
</div>
content
}
/**
* Returns a human-readable string representing a duration such as "5 second 35 ms"
*/