예제 #1
0
 @Override
 protected Job createJob(Configuration conf, JobStateInternal forcedState, String diagnostic) {
   JobImpl jobImpl = mock(JobImpl.class);
   when(jobImpl.getInternalState()).thenReturn(this.jobStateInternal);
   JobID jobID = JobID.forName("job_1234567890000_0001");
   JobId jobId = TypeConverter.toYarn(jobID);
   when(jobImpl.getID()).thenReturn(jobId);
   ((AppContext) getContext()).getAllJobs().put(jobImpl.getID(), jobImpl);
   return jobImpl;
 }
예제 #2
0
 @Test
 public void testCountersOnJobFinish() throws Exception {
   MRAppWithSpiedJob app = new MRAppWithSpiedJob(1, 1, true, this.getClass().getName(), true);
   JobImpl job = (JobImpl) app.submit(new Configuration());
   app.waitForState(job, JobState.SUCCEEDED);
   app.verifyCompleted();
   System.out.println(job.getAllCounters());
   // Just call getCounters
   job.getAllCounters();
   job.getAllCounters();
   // Should be called only once
   verify(job, times(1)).constructFinalFullcounters();
 }
예제 #3
0
  protected void unregister() {
    try {
      FinalApplicationStatus finishState = FinalApplicationStatus.UNDEFINED;
      JobImpl jobImpl = (JobImpl) job;
      if (jobImpl.getInternalState() == JobStateInternal.SUCCEEDED) {
        finishState = FinalApplicationStatus.SUCCEEDED;
      } else if (jobImpl.getInternalState() == JobStateInternal.KILLED
          || (jobImpl.getInternalState() == JobStateInternal.RUNNING && isSignalled)) {
        finishState = FinalApplicationStatus.KILLED;
      } else if (jobImpl.getInternalState() == JobStateInternal.FAILED
          || jobImpl.getInternalState() == JobStateInternal.ERROR) {
        finishState = FinalApplicationStatus.FAILED;
      }
      StringBuffer sb = new StringBuffer();
      for (String s : job.getDiagnostics()) {
        sb.append(s).append("\n");
      }
      LOG.info("Setting job diagnostics to " + sb.toString());

      String historyUrl = JobHistoryUtils.getHistoryUrl(getConfig(), context.getApplicationID());
      LOG.info("History url is " + historyUrl);

      FinishApplicationMasterRequest request =
          FinishApplicationMasterRequest.newInstance(finishState, sb.toString(), historyUrl);
      scheduler.finishApplicationMaster(request);
    } catch (Exception are) {
      LOG.error("Exception while unregistering ", are);
    }
  }
예제 #4
0
 @Override
 protected Job createJob(Configuration conf) {
   spiedJob = spy((JobImpl) super.createJob(conf));
   ((AppContext) getContext()).getAllJobs().put(spiedJob.getID(), spiedJob);
   return spiedJob;
 }