Search in sources :

Example 16 with MRAppMaster

use of org.apache.hadoop.mapreduce.v2.app.MRAppMaster in project hadoop by apache.

the class TestStagingCleanup method testPreservePatternMatchedAndFailedStaging.

@Test
public void testPreservePatternMatchedAndFailedStaging() throws IOException {
    conf.set(MRJobConfig.MAPREDUCE_JOB_DIR, stagingJobDir);
    // When RESERVE_FILES_PATTERN and PRESERVE_FAILED_TASK_FILES are set,
    // files in staging dir are always kept.
    conf.set(MRJobConfig.PRESERVE_FILES_PATTERN, "JobDir");
    conf.setBoolean(MRJobConfig.PRESERVE_FAILED_TASK_FILES, true);
    fs = mock(FileSystem.class);
    when(fs.delete(any(Path.class), anyBoolean())).thenReturn(true);
    //Staging Dir exists
    String user = UserGroupInformation.getCurrentUser().getShortUserName();
    Path stagingDir = MRApps.getStagingAreaDir(conf, user);
    when(fs.exists(stagingDir)).thenReturn(true);
    ApplicationId appId = ApplicationId.newInstance(System.currentTimeMillis(), 0);
    ApplicationAttemptId attemptId = ApplicationAttemptId.newInstance(appId, 1);
    JobId jobid = recordFactory.newRecordInstance(JobId.class);
    jobid.setAppId(appId);
    ContainerAllocator mockAlloc = mock(ContainerAllocator.class);
    Assert.assertTrue(MRJobConfig.DEFAULT_MR_AM_MAX_ATTEMPTS > 1);
    MRAppMaster appMaster = new TestMRApp(attemptId, mockAlloc, JobStateInternal.RUNNING, MRJobConfig.DEFAULT_MR_AM_MAX_ATTEMPTS);
    appMaster.init(conf);
    appMaster.start();
    appMaster.shutDownJob();
    //test whether notifyIsLastAMRetry called
    Assert.assertEquals(true, ((TestMRApp) appMaster).getTestIsLastAMRetry());
    verify(fs, times(0)).delete(stagingJobPath, true);
}
Also used : Path(org.apache.hadoop.fs.Path) FileSystem(org.apache.hadoop.fs.FileSystem) ApplicationAttemptId(org.apache.hadoop.yarn.api.records.ApplicationAttemptId) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) JobId(org.apache.hadoop.mapreduce.v2.api.records.JobId) ContainerAllocator(org.apache.hadoop.mapreduce.v2.app.rm.ContainerAllocator) Test(org.junit.Test)

Aggregations

FileSystem (org.apache.hadoop.fs.FileSystem)13 Path (org.apache.hadoop.fs.Path)13 ApplicationAttemptId (org.apache.hadoop.yarn.api.records.ApplicationAttemptId)12 Test (org.junit.Test)11 JobId (org.apache.hadoop.mapreduce.v2.api.records.JobId)10 ContainerAllocator (org.apache.hadoop.mapreduce.v2.app.rm.ContainerAllocator)10 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)9 IOException (java.io.IOException)4 JobConf (org.apache.hadoop.mapred.JobConf)4 ContainerId (org.apache.hadoop.yarn.api.records.ContainerId)3 JobHistoryEvent (org.apache.hadoop.mapreduce.jobhistory.JobHistoryEvent)2 JobEvent (org.apache.hadoop.mapreduce.v2.app.job.event.JobEvent)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Configuration (org.apache.hadoop.conf.Configuration)1 HttpServer2 (org.apache.hadoop.http.HttpServer2)1 LocalContainerLauncher (org.apache.hadoop.mapred.LocalContainerLauncher)1 AMStartedEvent (org.apache.hadoop.mapreduce.jobhistory.AMStartedEvent)1 JobHistoryCopyService (org.apache.hadoop.mapreduce.jobhistory.JobHistoryCopyService)1 TaskInfo (org.apache.hadoop.mapreduce.jobhistory.JobHistoryParser.TaskInfo)1 AMInfo (org.apache.hadoop.mapreduce.v2.api.records.AMInfo)1