@GET @Path("/mapreduce/jobs/{jobid}") @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public JobInfo getJob(@Context HttpServletRequest hsr, @PathParam("jobid") String jid) { init(); Job job = AMWebServices.getJobFromJobIdString(jid, ctx); checkAccess(job, hsr); return new JobInfo(job); }
@GET @Path("/mapreduce/jobs/{jobid}") @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public JobInfo getJob(@PathParam("jobid") String jid) { init(); Job job = AMWebServices.getJobFromJobIdString(jid, ctx); return new JobInfo(job); }
public static JobsInfo getPartialJobs(Collection<Job> jobs, Long offset, Long count, String user, String queue, Long sBegin, Long sEnd, Long fBegin, Long fEnd, JobState jobState) { JobsInfo allJobs = new JobsInfo(); if (sBegin == null || sBegin < 0) sBegin = 0l; if (sEnd == null) sEnd = Long.MAX_VALUE; if (fBegin == null || fBegin < 0) fBegin = 0l; if (fEnd == null) fEnd = Long.MAX_VALUE; if (offset == null || offset < 0) offset = 0l; if (count == null) count = Long.MAX_VALUE; if (offset > jobs.size()) { return allJobs; } long at = 0; long end = offset + count - 1; if (end < 0) { // due to overflow end = Long.MAX_VALUE; } for (Job job : jobs) { if (at > end) { break; } // can't really validate queue is a valid one since queues could change if (queue != null && !queue.isEmpty()) { if (!job.getQueueName().equals(queue)) { continue; } } if (user != null && !user.isEmpty()) { if (!job.getUserName().equals(user)) { continue; } } JobReport report = job.getReport(); if (report.getStartTime() < sBegin || report.getStartTime() > sEnd) { continue; } if (report.getFinishTime() < fBegin || report.getFinishTime() > fEnd) { continue; } if (jobState != null && jobState != report.getJobState()) { continue; } at++; if ((at - 1) < offset) { continue; } JobInfo jobInfo = new JobInfo(job); allJobs.add(jobInfo); } return allJobs; }
@Override protected void render(Block html) { TBODY<TABLE<Hamlet>> tbody = html. h2("Retired Jobs"). table("#jobs"). thead(). tr(). th("Submit Time"). th("Start Time"). th("Finish Time"). th(".id", "Job ID"). th(".name", "Name"). th("User"). th("Queue"). th(".state", "State"). th("Maps Total"). th("Maps Completed"). th("Reduces Total"). th("Reduces Completed")._()._(). tbody(); LOG.info("Getting list of all Jobs."); // Write all the data into a JavaScript array of arrays for JQuery // DataTables to display StringBuilder jobsTableData = new StringBuilder("[\n"); for (Job j : appContext.getAllJobs().values()) { JobInfo job = new JobInfo(j); jobsTableData.append("[\"") .append(dateFormat.format(new Date(job.getSubmitTime()))).append("\",\"") .append(dateFormat.format(new Date(job.getStartTime()))).append("\",\"") .append(dateFormat.format(new Date(job.getFinishTime()))).append("\",\"") .append("<a target='_blank' href='").append(url("job", job.getId())).append("'>") .append(job.getId()).append("</a>\",\"") .append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml( job.getName()))).append("\",\"") .append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml( job.getUserName()))).append("\",\"") .append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml( job.getQueueName()))).append("\",\"") .append(job.getState()).append("\",\"") .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"); } //Remove the last comma and close off the array of arrays if(jobsTableData.charAt(jobsTableData.length() - 2) == ',') { jobsTableData.delete(jobsTableData.length()-2, jobsTableData.length()-1); } jobsTableData.append("]"); html.script().$type("text/javascript"). _("var jobsTableData=" + jobsTableData)._(); 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")._()._(). _(). _(). _(); }
@Override protected void render(Block html) { TBODY<TABLE<Hamlet>> tbody = html. h2("Retired Jobs"). table("#jobs"). thead(). tr(). th("Submit Time"). th("Start Time"). th("Finish Time"). th(".id", "Job ID"). th(".name", "Name"). th("User"). th("Queue"). th(".state", "State"). th("Maps Total"). th("Maps Completed"). th("Reduces Total"). th("Reduces Completed")._()._(). tbody(); LOG.info("Getting list of all Jobs."); // Write all the data into a JavaScript array of arrays for JQuery // DataTables to display StringBuilder jobsTableData = new StringBuilder("[\n"); for (Job j : appContext.getAllJobs().values()) { JobInfo job = new JobInfo(j); jobsTableData.append("[\"") .append(dateFormat.format(new Date(job.getSubmitTime()))).append("\",\"") .append(dateFormat.format(new Date(job.getStartTime()))).append("\",\"") .append(dateFormat.format(new Date(job.getFinishTime()))).append("\",\"") .append("<a href='").append(url("job", job.getId())).append("'>") .append(job.getId()).append("</a>\",\"") .append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml( job.getName()))).append("\",\"") .append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml( job.getUserName()))).append("\",\"") .append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml( job.getQueueName()))).append("\",\"") .append(job.getState()).append("\",\"") .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"); } //Remove the last comma and close off the array of arrays if(jobsTableData.charAt(jobsTableData.length() - 2) == ',') { jobsTableData.delete(jobsTableData.length()-2, jobsTableData.length()-1); } jobsTableData.append("]"); html.script().$type("text/javascript"). _("var jobsTableData=" + jobsTableData)._(); 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")._()._(). _(). _(). _(); }
@Override protected void render(Block html) { TBODY<TABLE<Hamlet>> tbody = html. h2("Retired Jobs"). table("#jobs"). thead(). tr(). th("Start Time"). th("Finish Time"). th(".id", "Job ID"). th(".name", "Name"). th("User"). th("Queue"). th(".state", "State"). th("Maps Total"). th("Maps Completed"). th("Reduces Total"). th("Reduces Completed")._()._(). tbody(); LOG.info("Getting list of all Jobs."); // Write all the data into a JavaScript array of arrays for JQuery // DataTables to display StringBuilder jobsTableData = new StringBuilder("[\n"); for (Job j : appContext.getAllJobs().values()) { JobInfo job = new JobInfo(j); jobsTableData.append("[\"") .append(dateFormat.format(new Date(job.getStartTime()))).append("\",\"") .append(dateFormat.format(new Date(job.getFinishTime()))).append("\",\"") .append("<a href='").append(url("job", job.getId())).append("'>") .append(job.getId()).append("</a>\",\"") .append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml( job.getName()))).append("\",\"") .append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml( job.getUserName()))).append("\",\"") .append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml( job.getQueueName()))).append("\",\"") .append(job.getState()).append("\",\"") .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"); } //Remove the last comma and close off the array of arrays if(jobsTableData.charAt(jobsTableData.length() - 2) == ',') { jobsTableData.delete(jobsTableData.length()-2, jobsTableData.length()-1); } jobsTableData.append("]"); html.script().$type("text/javascript"). _("var jobsTableData=" + jobsTableData)._(); tbody._(). tfoot(). tr(). 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")._()._(). _(). _(). _(); }