Search in sources :

Example 6 with ApplicationNotFoundException

use of org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException in project hadoop by apache.

the class TestClientRMService method testNonExistingApplicationReport.

@Test
public void testNonExistingApplicationReport() throws YarnException {
    RMContext rmContext = mock(RMContext.class);
    when(rmContext.getRMApps()).thenReturn(new ConcurrentHashMap<ApplicationId, RMApp>());
    ClientRMService rmService = new ClientRMService(rmContext, null, null, null, null, null);
    RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null);
    GetApplicationReportRequest request = recordFactory.newRecordInstance(GetApplicationReportRequest.class);
    request.setApplicationId(ApplicationId.newInstance(0, 0));
    try {
        rmService.getApplicationReport(request);
        Assert.fail();
    } catch (ApplicationNotFoundException ex) {
        Assert.assertEquals(ex.getMessage(), "Application with id '" + request.getApplicationId() + "' doesn't exist in RM. Please check that the " + "job submission was successful.");
    }
}
Also used : RMApp(org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp) GetApplicationReportRequest(org.apache.hadoop.yarn.api.protocolrecords.GetApplicationReportRequest) RecordFactory(org.apache.hadoop.yarn.factories.RecordFactory) ApplicationNotFoundException(org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) Test(org.junit.Test)

Example 7 with ApplicationNotFoundException

use of org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException in project hadoop by apache.

the class TestClientRMService method testGetContainerReport.

@Test
public void testGetContainerReport() throws YarnException, IOException {
    ClientRMService rmService = createRMService();
    RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null);
    GetContainerReportRequest request = recordFactory.newRecordInstance(GetContainerReportRequest.class);
    ApplicationAttemptId attemptId = ApplicationAttemptId.newInstance(ApplicationId.newInstance(123456, 1), 1);
    ContainerId containerId = ContainerId.newContainerId(attemptId, 1);
    request.setContainerId(containerId);
    try {
        GetContainerReportResponse response = rmService.getContainerReport(request);
        Assert.assertEquals(containerId, response.getContainerReport().getContainerId());
    } catch (ApplicationNotFoundException ex) {
        Assert.fail(ex.getMessage());
    }
}
Also used : RecordFactory(org.apache.hadoop.yarn.factories.RecordFactory) ContainerId(org.apache.hadoop.yarn.api.records.ContainerId) ApplicationNotFoundException(org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException) GetContainerReportResponse(org.apache.hadoop.yarn.api.protocolrecords.GetContainerReportResponse) ApplicationAttemptId(org.apache.hadoop.yarn.api.records.ApplicationAttemptId) GetContainerReportRequest(org.apache.hadoop.yarn.api.protocolrecords.GetContainerReportRequest) Test(org.junit.Test)

Example 8 with ApplicationNotFoundException

use of org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException in project hadoop by apache.

the class TestClientRMService method testGetContainers.

@Test
public void testGetContainers() throws YarnException, IOException {
    ClientRMService rmService = createRMService();
    RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null);
    GetContainersRequest request = recordFactory.newRecordInstance(GetContainersRequest.class);
    ApplicationAttemptId attemptId = ApplicationAttemptId.newInstance(ApplicationId.newInstance(123456, 1), 1);
    ContainerId containerId = ContainerId.newContainerId(attemptId, 1);
    request.setApplicationAttemptId(attemptId);
    try {
        GetContainersResponse response = rmService.getContainers(request);
        Assert.assertEquals(containerId, response.getContainerList().get(0).getContainerId());
    } catch (ApplicationNotFoundException ex) {
        Assert.fail(ex.getMessage());
    }
}
Also used : RecordFactory(org.apache.hadoop.yarn.factories.RecordFactory) ContainerId(org.apache.hadoop.yarn.api.records.ContainerId) ApplicationNotFoundException(org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException) GetContainersResponse(org.apache.hadoop.yarn.api.protocolrecords.GetContainersResponse) ApplicationAttemptId(org.apache.hadoop.yarn.api.records.ApplicationAttemptId) GetContainersRequest(org.apache.hadoop.yarn.api.protocolrecords.GetContainersRequest) Test(org.junit.Test)

Example 9 with ApplicationNotFoundException

use of org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException in project hadoop by apache.

the class TestClientRMService method testForceKillNonExistingApplication.

@Test
public void testForceKillNonExistingApplication() throws YarnException {
    RMContext rmContext = mock(RMContext.class);
    when(rmContext.getRMApps()).thenReturn(new ConcurrentHashMap<ApplicationId, RMApp>());
    ClientRMService rmService = new ClientRMService(rmContext, null, null, null, null, null);
    ApplicationId applicationId = BuilderUtils.newApplicationId(System.currentTimeMillis(), 0);
    KillApplicationRequest request = KillApplicationRequest.newInstance(applicationId);
    try {
        rmService.forceKillApplication(request);
        Assert.fail();
    } catch (ApplicationNotFoundException ex) {
        Assert.assertEquals(ex.getMessage(), "Trying to kill an absent " + "application " + request.getApplicationId());
    }
}
Also used : RMApp(org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp) ApplicationNotFoundException(org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException) KillApplicationRequest(org.apache.hadoop.yarn.api.protocolrecords.KillApplicationRequest) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) Test(org.junit.Test)

Example 10 with ApplicationNotFoundException

use of org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException in project hadoop by apache.

the class TestClientRMService method testGetApplicationReport.

@Test
public void testGetApplicationReport() throws Exception {
    YarnScheduler yarnScheduler = mock(YarnScheduler.class);
    RMContext rmContext = mock(RMContext.class);
    mockRMContext(yarnScheduler, rmContext);
    ApplicationId appId1 = getApplicationId(1);
    ApplicationACLsManager mockAclsManager = mock(ApplicationACLsManager.class);
    when(mockAclsManager.checkAccess(UserGroupInformation.getCurrentUser(), ApplicationAccessType.VIEW_APP, null, appId1)).thenReturn(true);
    ClientRMService rmService = new ClientRMService(rmContext, yarnScheduler, null, mockAclsManager, null, null);
    try {
        RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null);
        GetApplicationReportRequest request = recordFactory.newRecordInstance(GetApplicationReportRequest.class);
        request.setApplicationId(appId1);
        GetApplicationReportResponse response = rmService.getApplicationReport(request);
        ApplicationReport report = response.getApplicationReport();
        ApplicationResourceUsageReport usageReport = report.getApplicationResourceUsageReport();
        Assert.assertEquals(10, usageReport.getMemorySeconds());
        Assert.assertEquals(3, usageReport.getVcoreSeconds());
        Assert.assertEquals("<Not set>", report.getAmNodeLabelExpression());
        Assert.assertEquals("<Not set>", report.getAppNodeLabelExpression());
        // if application has am node label set to blank
        ApplicationId appId2 = getApplicationId(2);
        when(mockAclsManager.checkAccess(UserGroupInformation.getCurrentUser(), ApplicationAccessType.VIEW_APP, null, appId2)).thenReturn(true);
        request.setApplicationId(appId2);
        response = rmService.getApplicationReport(request);
        report = response.getApplicationReport();
        Assert.assertEquals(NodeLabel.DEFAULT_NODE_LABEL_PARTITION, report.getAmNodeLabelExpression());
        Assert.assertEquals(NodeLabel.NODE_LABEL_EXPRESSION_NOT_SET, report.getAppNodeLabelExpression());
        // if application has am node label set to blank
        ApplicationId appId3 = getApplicationId(3);
        when(mockAclsManager.checkAccess(UserGroupInformation.getCurrentUser(), ApplicationAccessType.VIEW_APP, null, appId3)).thenReturn(true);
        request.setApplicationId(appId3);
        response = rmService.getApplicationReport(request);
        report = response.getApplicationReport();
        Assert.assertEquals("high-mem", report.getAmNodeLabelExpression());
        Assert.assertEquals("high-mem", report.getAppNodeLabelExpression());
        // if application id is null
        GetApplicationReportRequest invalidRequest = recordFactory.newRecordInstance(GetApplicationReportRequest.class);
        invalidRequest.setApplicationId(null);
        try {
            rmService.getApplicationReport(invalidRequest);
        } catch (YarnException e) {
            // rmService should return a ApplicationNotFoundException
            // when a null application id is provided
            Assert.assertTrue(e instanceof ApplicationNotFoundException);
        }
    } finally {
        rmService.close();
    }
}
Also used : ApplicationReport(org.apache.hadoop.yarn.api.records.ApplicationReport) ApplicationACLsManager(org.apache.hadoop.yarn.server.security.ApplicationACLsManager) GetApplicationReportRequest(org.apache.hadoop.yarn.api.protocolrecords.GetApplicationReportRequest) RecordFactory(org.apache.hadoop.yarn.factories.RecordFactory) ApplicationNotFoundException(org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException) YarnScheduler(org.apache.hadoop.yarn.server.resourcemanager.scheduler.YarnScheduler) ApplicationResourceUsageReport(org.apache.hadoop.yarn.api.records.ApplicationResourceUsageReport) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) GetApplicationReportResponse(org.apache.hadoop.yarn.api.protocolrecords.GetApplicationReportResponse) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) Test(org.junit.Test)

Aggregations

ApplicationNotFoundException (org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException)50 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)28 ApplicationReport (org.apache.hadoop.yarn.api.records.ApplicationReport)21 Test (org.junit.Test)21 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)20 IOException (java.io.IOException)19 RMApp (org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp)13 ApplicationAttemptNotFoundException (org.apache.hadoop.yarn.exceptions.ApplicationAttemptNotFoundException)12 ApplicationAttemptId (org.apache.hadoop.yarn.api.records.ApplicationAttemptId)11 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)9 ContainerNotFoundException (org.apache.hadoop.yarn.exceptions.ContainerNotFoundException)7 GetApplicationReportRequest (org.apache.hadoop.yarn.api.protocolrecords.GetApplicationReportRequest)6 RecordFactory (org.apache.hadoop.yarn.factories.RecordFactory)6 RMAppAttempt (org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt)5 TezException (org.apache.tez.dag.api.TezException)5 GetApplicationReportResponse (org.apache.hadoop.yarn.api.protocolrecords.GetApplicationReportResponse)4 ContainerId (org.apache.hadoop.yarn.api.records.ContainerId)4 YarnClient (org.apache.hadoop.yarn.client.api.YarnClient)4 ServiceException (com.google.protobuf.ServiceException)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3