JobImpl implements org.apache.hadoop.mapreduce.v2.app.job.Job, 
  EventHandler<JobEvent> { @Override public List<String> getDiagnostics() { readLock.lock(); try { return diagnostics; } finally { readLock.unlock(); } } JobImpl(JobId jobId, ApplicationAttemptId applicationAttemptId,
      Configuration conf, EventHandler eventHandler,
      TaskAttemptListener taskAttemptListener,
      JobTokenSecretManager jobTokenSecretManager,
      Credentials jobCredentials, Clock clock,
      Map<TaskId, TaskInfo> completedTasksFromPreviousRun, MRAppMetrics metrics,
      OutputCommitter committer, boolean newApiCommitter, String userName,
      long appSubmitTime, List<AMInfo> amInfos, AppContext appContext,
      JobStateInternal forcedState, String forcedDiagnostic); @Override JobId getID(); @Override boolean checkAccess(UserGroupInformation callerUGI, 
      JobACL jobOperation); @Override Task getTask(TaskId taskID); @Override int getCompletedMaps(); @Override int getCompletedReduces(); @Override boolean isUber(); @Override Counters getAllCounters(); static Counters incrTaskCounters(
      Counters counters, Collection<Task> tasks); @Override TaskAttemptCompletionEvent[] getTaskAttemptCompletionEvents(
      int fromEventId, int maxEvents); @Override TaskCompletionEvent[] getMapAttemptCompletionEvents(
      int startIndex, int maxEvents); @Override List<String> getDiagnostics(); @Override JobReport getReport(); @Override float getProgress(); @Override Map<TaskId, Task> getTasks(); @Override Map<TaskId,Task> getTasks(TaskType taskType); @Override JobState getState(); @Override /** * The only entry point to change the Job. */ void handle(JobEvent event); @Private JobStateInternal getInternalState(); @Override String getUserName(); @Override String getQueueName(); @Override void setQueueName(String queueName); @Override Path getConfFile(); @Override String getName(); @Override int getTotalMaps(); @Override int getTotalReduces(); @Override Map<JobACL, AccessControlList> getJobACLs(); @Override List<AMInfo> getAMInfos(); static String escapeString(String data); @Private void constructFinalFullcounters(); @Override Configuration loadConfFile(); float getMaxAllowedFetchFailuresFraction(); int getMaxFetchFailuresNotifications(); @Override void setJobPriority(Priority priority); static final String JOB_KILLED_DIAG; public JobConf conf; public Path remoteJobConfFile; }
@Test public void testMetaInfoSizeOverMax() throws Exception { Configuration conf = new Configuration(); JobID jobID = JobID.forName("job_1234567890000_0001"); JobId jobId = TypeConverter.toYarn(jobID); MRAppMetrics mrAppMetrics = MRAppMetrics.create(); JobImpl job = new JobImpl(jobId, ApplicationAttemptId.newInstance( ApplicationId.newInstance(0, 0), 0), conf, mock(EventHandler.class), null, new JobTokenSecretManager(), new Credentials(), null, null, mrAppMetrics, null, true, null, 0, null, null, null, null); InitTransition initTransition = new InitTransition() { @Override protected TaskSplitMetaInfo[] createSplits(JobImpl job, JobId jobId) { throw new YarnRuntimeException(EXCEPTIONMSG); } }; JobEvent mockJobEvent = mock(JobEvent.class); JobStateInternal jobSI = initTransition.transition(job, mockJobEvent); Assert.assertTrue("When init fails, return value from InitTransition.transition should equal NEW.", jobSI.equals(JobStateInternal.NEW)); Assert.assertTrue("Job diagnostics should contain YarnRuntimeException", job.getDiagnostics().toString().contains("YarnRuntimeException")); Assert.assertTrue("Job diagnostics should contain " + EXCEPTIONMSG, job.getDiagnostics().toString().contains(EXCEPTIONMSG)); }