@Test public void testCheckStatusWithEmptyJobId() throws IOException { Job job = Job.getInstance(new Configuration(false)); StringBuilder stringBuilder = new StringBuilder(); JobStepStatusEnum jobStepStatusEnum = HadoopJobStatusChecker.checkStatus(job, stringBuilder); assertEquals(JobStepStatusEnum.WAITING, jobStepStatusEnum); assertEquals("Skip status check with empty job id..\n", stringBuilder.toString()); assertFalse(jobStepStatusEnum.isRunable()); assertEquals(32, jobStepStatusEnum.getCode()); assertFalse(jobStepStatusEnum.isComplete()); }
public static JobStepStatusEnum checkStatus(Job job, StringBuilder output) { if (job == null || job.getJobID() == null) { output.append("Skip status check with empty job id..\n"); return JobStepStatusEnum.WAITING; } JobStepStatusEnum status = null; try { switch (job.getStatus().getState()) { case SUCCEEDED: status = JobStepStatusEnum.FINISHED; break; case FAILED: status = JobStepStatusEnum.ERROR; break; case KILLED: status = JobStepStatusEnum.KILLED; break; case RUNNING: status = JobStepStatusEnum.RUNNING; break; case PREP: status = JobStepStatusEnum.WAITING; break; default: throw new IllegalStateException(); } } catch (Exception e) { logger.error("error check status", e); output.append("Exception: ").append(e.getLocalizedMessage()).append("\n"); status = JobStepStatusEnum.ERROR; } return status; }
HadoopJobStatusChecker { public static JobStepStatusEnum checkStatus(Job job, StringBuilder output) { if (job == null || job.getJobID() == null) { output.append("Skip status check with empty job id..\n"); return JobStepStatusEnum.WAITING; } JobStepStatusEnum status = null; try { switch (job.getStatus().getState()) { case SUCCEEDED: status = JobStepStatusEnum.FINISHED; break; case FAILED: status = JobStepStatusEnum.ERROR; break; case KILLED: status = JobStepStatusEnum.KILLED; break; case RUNNING: status = JobStepStatusEnum.RUNNING; break; case PREP: status = JobStepStatusEnum.WAITING; break; default: throw new IllegalStateException(); } } catch (Exception e) { logger.error("error check status", e); output.append("Exception: ").append(e.getLocalizedMessage()).append("\n"); status = JobStepStatusEnum.ERROR; } return status; } }
HadoopJobStatusChecker { public static JobStepStatusEnum checkStatus(Job job, StringBuilder output) { if (job == null || job.getJobID() == null) { output.append("Skip status check with empty job id..\n"); return JobStepStatusEnum.WAITING; } JobStepStatusEnum status = null; try { switch (job.getStatus().getState()) { case SUCCEEDED: status = JobStepStatusEnum.FINISHED; break; case FAILED: status = JobStepStatusEnum.ERROR; break; case KILLED: status = JobStepStatusEnum.KILLED; break; case RUNNING: status = JobStepStatusEnum.RUNNING; break; case PREP: status = JobStepStatusEnum.WAITING; break; default: throw new IllegalStateException(); } } catch (Exception e) { logger.error("error check status", e); output.append("Exception: ").append(e.getLocalizedMessage()).append("\n"); status = JobStepStatusEnum.ERROR; } return status; }  }
HadoopJobStatusChecker { public static JobStepStatusEnum checkStatus(Job job, StringBuilder output) { if (job == null || job.getJobID() == null) { output.append("Skip status check with empty job id..\n"); return JobStepStatusEnum.WAITING; } JobStepStatusEnum status = null; try { switch (job.getStatus().getState()) { case SUCCEEDED: status = JobStepStatusEnum.FINISHED; break; case FAILED: status = JobStepStatusEnum.ERROR; break; case KILLED: status = JobStepStatusEnum.KILLED; break; case RUNNING: status = JobStepStatusEnum.RUNNING; break; case PREP: status = JobStepStatusEnum.WAITING; break; default: throw new IllegalStateException(); } } catch (Exception e) { logger.error("error check status", e); output.append("Exception: ").append(e.getLocalizedMessage()).append("\n"); status = JobStepStatusEnum.ERROR; } return status; }  static JobStepStatusEnum checkStatus(Job job, StringBuilder output); }
HadoopJobStatusChecker { public static JobStepStatusEnum checkStatus(Job job, StringBuilder output) { if (job == null || job.getJobID() == null) { output.append("Skip status check with empty job id..\n"); return JobStepStatusEnum.WAITING; } JobStepStatusEnum status = null; try { switch (job.getStatus().getState()) { case SUCCEEDED: status = JobStepStatusEnum.FINISHED; break; case FAILED: status = JobStepStatusEnum.ERROR; break; case KILLED: status = JobStepStatusEnum.KILLED; break; case RUNNING: status = JobStepStatusEnum.RUNNING; break; case PREP: status = JobStepStatusEnum.WAITING; break; default: throw new IllegalStateException(); } } catch (Exception e) { logger.error("error check status", e); output.append("Exception: ").append(e.getLocalizedMessage()).append("\n"); status = JobStepStatusEnum.ERROR; } return status; }  static JobStepStatusEnum checkStatus(Job job, StringBuilder output);  }