MAPREDUCE-6499. Add elapsed time for retired job in JobHistoryServer WebUI. Contributed by Lin Yiqun.

(cherry picked from commit a7f776ffdf)
This commit is contained in:
Akira Ajisaka 2015-11-17 15:16:47 +09:00
parent efcaf9c28f
commit 8de7911eb3
3 changed files with 72 additions and 14 deletions

View File

@ -287,6 +287,41 @@ public class StringUtils {
buf.append("sec");
return buf.toString();
}
/**
*
* Given the time in long milliseconds, returns a String in the sortable
* format Xhrs, Ymins, Zsec. X, Y, and Z are always two-digit. If the time is
* more than 100 hours ,it is displayed as 99hrs, 59mins, 59sec.
*
* @param timeDiff The time difference to format
*/
public static String formatTimeSortable(long timeDiff) {
StringBuilder buf = new StringBuilder();
long hours = timeDiff / (60 * 60 * 1000);
long rem = (timeDiff % (60 * 60 * 1000));
long minutes = rem / (60 * 1000);
rem = rem % (60 * 1000);
long seconds = rem / 1000;
// if hours is more than 99 hours, it will be set a max value format
if (hours > 99) {
hours = 99;
minutes = 59;
seconds = 59;
}
buf.append(String.format("%02d", hours));
buf.append("hrs, ");
buf.append(String.format("%02d", minutes));
buf.append("mins, ");
buf.append(String.format("%02d", seconds));
buf.append("sec");
return buf.toString();
}
/**
* Formats time in ms and appends difference (finishTime - startTime)
* as returned by formatTimeDiff().

View File

@ -136,6 +136,9 @@ Release 2.8.0 - UNRELEASED
MAPREDUCE-5485. Allow repeating job commit by extending OutputCommitter
API. Contributed by Junping Du
MAPREDUCE-6499. Add elapsed time for retired job in JobHistoryServer WebUI.
(Lin Yiqun via aajisaka)
OPTIMIZATIONS
MAPREDUCE-6376. Add avro binary support for jhist files (Ray Chiang via

View File

@ -25,6 +25,8 @@ import org.apache.commons.lang.StringEscapeUtils;
import org.apache.hadoop.mapreduce.v2.app.AppContext;
import org.apache.hadoop.mapreduce.v2.app.job.Job;
import org.apache.hadoop.mapreduce.v2.hs.webapp.dao.JobInfo;
import org.apache.hadoop.util.StringUtils;
import org.apache.hadoop.yarn.util.Times;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TABLE;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TBODY;
@ -66,7 +68,8 @@ public class HsJobsBlock extends HtmlBlock {
th("Maps Total").
th("Maps Completed").
th("Reduces Total").
th("Reduces Completed")._()._().
th("Reduces Completed").
th("Elapsed Time")._()._().
tbody();
LOG.info("Getting list of all Jobs.");
// Write all the data into a JavaScript array of arrays for JQuery
@ -90,7 +93,10 @@ public class HsJobsBlock extends HtmlBlock {
.append(String.valueOf(job.getMapsTotal())).append("\",\"")
.append(String.valueOf(job.getMapsCompleted())).append("\",\"")
.append(String.valueOf(job.getReducesTotal())).append("\",\"")
.append(String.valueOf(job.getReducesCompleted())).append("\"],\n");
.append(String.valueOf(job.getReducesCompleted())).append("\",\"")
.append(
StringUtils.formatTimeSortable(Times.elapsed(job.getStartTime(),
job.getFinishTime(), false))).append("\"],\n");
}
//Remove the last comma and close off the array of arrays
@ -103,18 +109,32 @@ public class HsJobsBlock extends HtmlBlock {
tbody._().
tfoot().
tr().
th().input("search_init").$type(InputType.text).$name("submit_time").$value("Submit Time")._()._().
th().input("search_init").$type(InputType.text).$name("start_time").$value("Start Time")._()._().
th().input("search_init").$type(InputType.text).$name("finish_time").$value("Finish Time")._()._().
th().input("search_init").$type(InputType.text).$name("start_time").$value("Job ID")._()._().
th().input("search_init").$type(InputType.text).$name("start_time").$value("Name")._()._().
th().input("search_init").$type(InputType.text).$name("start_time").$value("User")._()._().
th().input("search_init").$type(InputType.text).$name("start_time").$value("Queue")._()._().
th().input("search_init").$type(InputType.text).$name("start_time").$value("State")._()._().
th().input("search_init").$type(InputType.text).$name("start_time").$value("Maps Total")._()._().
th().input("search_init").$type(InputType.text).$name("start_time").$value("Maps Completed")._()._().
th().input("search_init").$type(InputType.text).$name("start_time").$value("Reduces Total")._()._().
th().input("search_init").$type(InputType.text).$name("start_time").$value("Reduces Completed")._()._().
th().input("search_init").$type(InputType.text)
.$name("submit_time").$value("Submit Time")._()._().
th().input("search_init").$type(InputType.text)
.$name("start_time").$value("Start Time")._()._().
th().input("search_init").$type(InputType.text)
.$name("finish_time").$value("Finish Time")._()._().
th().input("search_init").$type(InputType.text)
.$name("job_id").$value("Job ID")._()._().
th().input("search_init").$type(InputType.text)
.$name("name").$value("Name")._()._().
th().input("search_init").$type(InputType.text)
.$name("user").$value("User")._()._().
th().input("search_init").$type(InputType.text)
.$name("queue").$value("Queue")._()._().
th().input("search_init").$type(InputType.text)
.$name("state").$value("State")._()._().
th().input("search_init").$type(InputType.text)
.$name("maps_total").$value("Maps Total")._()._().
th().input("search_init").$type(InputType.text).
$name("maps_completed").$value("Maps Completed")._()._().
th().input("search_init").$type(InputType.text).
$name("reduces_total").$value("Reduces Total")._()._().
th().input("search_init").$type(InputType.text).
$name("reduces_completed").$value("Reduces Completed")._()._().
th().input("search_init").$type(InputType.text).
$name("elapsed_time").$value("Elapsed Time")._()._().
_().
_().
_();