コード例 #1
0
 private boolean testUberDecision(Configuration conf) {
   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 = getInitTransition(2);
   JobEvent mockJobEvent = mock(JobEvent.class);
   initTransition.transition(job, mockJobEvent);
   boolean isUber = job.isUber();
   return isUber;
 }
コード例 #2
0
  @Test
  public void testReportDiagnostics() throws Exception {
    JobID jobID = JobID.forName("job_1234567890000_0001");
    JobId jobId = TypeConverter.toYarn(jobID);
    final String diagMsg = "some diagnostic message";
    final JobDiagnosticsUpdateEvent diagUpdateEvent = new JobDiagnosticsUpdateEvent(jobId, diagMsg);
    MRAppMetrics mrAppMetrics = MRAppMetrics.create();
    AppContext mockContext = mock(AppContext.class);
    when(mockContext.hasSuccessfullyUnregistered()).thenReturn(true);
    JobImpl job =
        new JobImpl(
            jobId,
            Records.newRecord(ApplicationAttemptId.class),
            new Configuration(),
            mock(EventHandler.class),
            null,
            mock(JobTokenSecretManager.class),
            null,
            new SystemClock(),
            null,
            mrAppMetrics,
            null,
            true,
            null,
            0,
            null,
            mockContext,
            null,
            null);
    job.handle(diagUpdateEvent);
    String diagnostics = job.getReport().getDiagnostics();
    Assert.assertNotNull(diagnostics);
    Assert.assertTrue(diagnostics.contains(diagMsg));

    job =
        new JobImpl(
            jobId,
            Records.newRecord(ApplicationAttemptId.class),
            new Configuration(),
            mock(EventHandler.class),
            null,
            mock(JobTokenSecretManager.class),
            null,
            new SystemClock(),
            null,
            mrAppMetrics,
            null,
            true,
            null,
            0,
            null,
            mockContext,
            null,
            null);
    job.handle(new JobEvent(jobId, JobEventType.JOB_KILL));
    job.handle(diagUpdateEvent);
    diagnostics = job.getReport().getDiagnostics();
    Assert.assertNotNull(diagnostics);
    Assert.assertTrue(diagnostics.contains(diagMsg));
  }
コード例 #3
0
    public StubbedJob(
        JobId jobId,
        ApplicationAttemptId applicationAttemptId,
        Configuration conf,
        EventHandler eventHandler,
        boolean newApiCommitter,
        String user,
        int numSplits,
        AppContext appContext) {
      super(
          jobId,
          applicationAttemptId,
          conf,
          eventHandler,
          null,
          new JobTokenSecretManager(),
          new Credentials(),
          new SystemClock(),
          Collections.<TaskId, TaskInfo>emptyMap(),
          MRAppMetrics.create(),
          null,
          newApiCommitter,
          user,
          System.currentTimeMillis(),
          null,
          appContext,
          null,
          null);

      initTransition = getInitTransition(numSplits);
      localFactory =
          stateMachineFactory.addTransition(
              JobStateInternal.NEW,
              EnumSet.of(JobStateInternal.INITED, JobStateInternal.FAILED),
              JobEventType.JOB_INIT,
              // This is abusive.
              initTransition);

      // This "this leak" is okay because the retained pointer is in an
      //  instance variable.
      localStateMachine = localFactory.make(this);
    }