/** * Get job corresponding to jobid. * * @param jobId * @return object of {@link Job} * @throws IOException * @throws InterruptedException */ public Job getJob(JobID jobId) throws IOException, InterruptedException { JobStatus status = client.getJobStatus(jobId); if (status != null) { return Job.getInstance(this, status, new JobConf(status.getJobFile())); } return null; }
public void getTaskDiagnostics(String job) { try { String errinfo[]; StringBuilder sb = new StringBuilder(); JobID jobid = JobID.forName(job); JobStatus status = client.getJobStatus(jobid); System.out.println(status.getTrackingUrl()); System.out.println(status.getJobFile()); System.out.println(status.getHistoryFile()); System.out.println(status.getQueue()); System.out.println(status.toString()); System.out.println("#### QueueAclsInfo ####"); QueueAclsInfo[] qais = client.getQueueAclsForCurrentUser(); for (int i = 0; i < qais.length; i++) { QueueAclsInfo qai = qais[i]; System.out.println(qai.getQueueName().toString()); String[] ops = qai.getOperations(); for (int j = 0; j < ops.length; j++) { System.out.println(ops[j]); } } System.out.println("#### QueueInfo ####"); QueueInfo[] qis = client.getRootQueues(); for (int i = 0; i < qis.length; i++) { QueueInfo qi = qis[i]; System.out.println(qi.getQueueName()); System.out.println(qi.getSchedulingInfo()); System.out.println(qi.getState()); System.out.println(qi.getProperties()); } int mapnum = client.getTaskReports(jobid, TaskType.MAP).length; int rednum = client.getTaskReports(jobid, TaskType.REDUCE).length; float progress = status.getMapProgress(); sb.append( String.format( "m %4d %6s", mapnum, progress == 1 ? "100%" : String.format("%.2f%%", progress * 100))); sb.append("|"); progress = status.getReduceProgress(); sb.append( String.format( "r %4d %6s", rednum, progress == 1 ? "100%" : String.format("%.2f%%", progress * 100))); System.out.println(sb.toString()); printTaskAttempt(client.getTaskReports(jobid, TaskType.MAP)); printTaskAttempt(client.getTaskReports(jobid, TaskType.REDUCE)); System.out.println(sb.toString()); } catch (Exception e) { System.out.println(e); } }
/** * Get job corresponding to jobid. * * @param jobId * @return object of {@link Job} * @throws IOException * @throws InterruptedException */ public Job getJob(JobID jobId) throws IOException, InterruptedException { JobStatus status = client.getJobStatus(jobId); if (status != null) { JobConf conf; try { conf = new JobConf(status.getJobFile()); } catch (RuntimeException ex) { // If job file doesn't exist it means we can't find the job if (ex.getCause() instanceof FileNotFoundException) { return null; } else { throw ex; } } return Job.getInstance(this, status, conf); } return null; }