Search in sources :

Example 6 with ContainerNotFoundException

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

the class TestYarnCLI method testGetContainerReportException.

@Test
public void testGetContainerReportException() throws Exception {
    ApplicationCLI cli = createAndGetAppCLI();
    ApplicationId applicationId = ApplicationId.newInstance(1234, 5);
    ApplicationAttemptId attemptId = ApplicationAttemptId.newInstance(applicationId, 1);
    long cntId = 1;
    ContainerId containerId1 = ContainerId.newContainerId(attemptId, cntId++);
    when(client.getContainerReport(containerId1)).thenThrow(new ApplicationNotFoundException("History file for application" + applicationId + " is not found"));
    int exitCode = cli.run(new String[] { "container", "-status", containerId1.toString() });
    verify(sysOut).println("Application for Container with id '" + containerId1 + "' doesn't exist in RM or Timeline Server.");
    Assert.assertNotSame("should return non-zero exit code.", 0, exitCode);
    ContainerId containerId2 = ContainerId.newContainerId(attemptId, cntId++);
    when(client.getContainerReport(containerId2)).thenThrow(new ApplicationAttemptNotFoundException("History file for application attempt" + attemptId + " is not found"));
    exitCode = cli.run(new String[] { "container", "-status", containerId2.toString() });
    verify(sysOut).println("Application Attempt for Container with id '" + containerId2 + "' doesn't exist in RM or Timeline Server.");
    Assert.assertNotSame("should return non-zero exit code.", 0, exitCode);
    ContainerId containerId3 = ContainerId.newContainerId(attemptId, cntId++);
    when(client.getContainerReport(containerId3)).thenThrow(new ContainerNotFoundException("History file for container" + containerId3 + " is not found"));
    exitCode = cli.run(new String[] { "container", "-status", containerId3.toString() });
    verify(sysOut).println("Container with id '" + containerId3 + "' doesn't exist in RM or Timeline Server.");
    Assert.assertNotSame("should return non-zero exit code.", 0, exitCode);
}
Also used : ContainerId(org.apache.hadoop.yarn.api.records.ContainerId) ApplicationNotFoundException(org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException) ApplicationAttemptId(org.apache.hadoop.yarn.api.records.ApplicationAttemptId) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) ContainerNotFoundException(org.apache.hadoop.yarn.exceptions.ContainerNotFoundException) ApplicationAttemptNotFoundException(org.apache.hadoop.yarn.exceptions.ApplicationAttemptNotFoundException) Test(org.junit.Test)

Aggregations

ContainerNotFoundException (org.apache.hadoop.yarn.exceptions.ContainerNotFoundException)6 ApplicationAttemptNotFoundException (org.apache.hadoop.yarn.exceptions.ApplicationAttemptNotFoundException)4 ApplicationNotFoundException (org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException)4 ApplicationAttemptId (org.apache.hadoop.yarn.api.records.ApplicationAttemptId)3 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)3 ContainerId (org.apache.hadoop.yarn.api.records.ContainerId)3 IOException (java.io.IOException)2 GetContainerReportRequest (org.apache.hadoop.yarn.api.protocolrecords.GetContainerReportRequest)2 GetContainerReportResponse (org.apache.hadoop.yarn.api.protocolrecords.GetContainerReportResponse)2 ContainerReport (org.apache.hadoop.yarn.api.records.ContainerReport)2 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)2 Test (org.junit.Test)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 OutputStreamWriter (java.io.OutputStreamWriter)1 PrintWriter (java.io.PrintWriter)1 PrivilegedExceptionAction (java.security.PrivilegedExceptionAction)1 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)1 AuthenticationException (org.apache.hadoop.security.authentication.client.AuthenticationException)1 ApplicationAttemptReport (org.apache.hadoop.yarn.api.records.ApplicationAttemptReport)1 TimelineEntity (org.apache.hadoop.yarn.api.records.timeline.TimelineEntity)1