| 1 | <%@ page |
|---|
| 2 | contentType="application/json; charset=UTF-8" |
|---|
| 3 | import="javax.servlet.*" |
|---|
| 4 | import="javax.servlet.http.*" |
|---|
| 5 | import="java.io.*" |
|---|
| 6 | import="java.util.*" |
|---|
| 7 | import="java.text.DecimalFormat" |
|---|
| 8 | import="org.apache.hadoop.http.HtmlQuoting" |
|---|
| 9 | import="org.apache.hadoop.mapred.*" |
|---|
| 10 | import="org.apache.hadoop.util.*" |
|---|
| 11 | %> |
|---|
| 12 | <% |
|---|
| 13 | JobTracker tracker = (JobTracker) application.getAttribute("job.tracker"); |
|---|
| 14 | String trackerName = |
|---|
| 15 | StringUtils.simpleHostname(tracker.getJobTrackerMachine()); |
|---|
| 16 | JobQueueInfo[] queues = tracker.getQueues(); |
|---|
| 17 | Vector<JobInProgress> runningJobs = tracker.runningJobs(); |
|---|
| 18 | Vector<JobInProgress> completedJobs = tracker.completedJobs(); |
|---|
| 19 | Vector<JobInProgress> failedJobs = tracker.failedJobs(); |
|---|
| 20 | %> |
|---|
| 21 | <% |
|---|
| 22 | StringBuffer sb = new StringBuffer(); |
|---|
| 23 | int rowId = 0; |
|---|
| 24 | sb.append("{\"data\":["); |
|---|
| 25 | for (Iterator<JobInProgress> it = completedJobs.iterator(); it.hasNext(); ++rowId) { |
|---|
| 26 | JobInProgress job = it.next(); |
|---|
| 27 | JobProfile profile = job.getProfile(); |
|---|
| 28 | JobStatus status = job.getStatus(); |
|---|
| 29 | JobID jobid = profile.getJobID(); |
|---|
| 30 | |
|---|
| 31 | String name = HtmlQuoting.quoteHtmlChars(profile.getJobName()); |
|---|
| 32 | String schedulingInfo = |
|---|
| 33 | HtmlQuoting.quoteHtmlChars(job.getStatus().getSchedulingInfo()); |
|---|
| 34 | if (rowId != 0) sb.append(","); |
|---|
| 35 | sb.append("{\"id\":\"" + jobid + |
|---|
| 36 | "\",\"priority\":\"" + job.getPriority().toString() + |
|---|
| 37 | "\",\"user\":\"" + profile.getUser() + |
|---|
| 38 | "\",\"name\":\"" + ("".equals(name) ? "" : name) + |
|---|
| 39 | "\",\"mapProgress\":" + status.mapProgress() + |
|---|
| 40 | ",\"desiredMaps\":" + job.desiredMaps() + |
|---|
| 41 | ",\"completedMaps\":" + job.finishedMaps() + |
|---|
| 42 | ",\"reduceProgress\":" + status.reduceProgress() + |
|---|
| 43 | ",\"desiredReduces\":" + job.desiredReduces() + |
|---|
| 44 | ",\"completedReduces\":" + job.finishedReduces() + |
|---|
| 45 | ",\"startTime\":" + job.getStartTime() + |
|---|
| 46 | ",\"finishTime\":" + job.getFinishTime() + |
|---|
| 47 | ",\"schedulingInfo\":\"" + schedulingInfo + |
|---|
| 48 | "\",\"status\":\"" + status.getJobRunState(status.getRunState()) + |
|---|
| 49 | "\"}"); |
|---|
| 50 | } |
|---|
| 51 | sb.append("]}"); |
|---|
| 52 | out.println(sb.toString()); |
|---|
| 53 | %> |
|---|