Search in sources :

Example 1 with ApplicationNotFoundException

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

the class TestRemoteAppChecker method testNonExistentApp.

@Test
public void testNonExistentApp() throws Exception {
    YarnClient client = createCheckerWithMockedClient();
    ApplicationId id = ApplicationId.newInstance(1, 1);
    // test for null
    doReturn(null).when(client).getApplicationReport(id);
    assertFalse(checker.isApplicationActive(id));
    // test for ApplicationNotFoundException
    doThrow(new ApplicationNotFoundException("Throw!")).when(client).getApplicationReport(id);
    assertFalse(checker.isApplicationActive(id));
}
Also used : ApplicationNotFoundException(org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) YarnClient(org.apache.hadoop.yarn.client.api.YarnClient) Test(org.junit.Test)

Example 2 with ApplicationNotFoundException

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

the class EntityGroupFSTimelineStore method getAppState.

/**
   * Ask the RM for the state of the application.
   * This method has to be synchronized to control traffic to RM
   * @param appId application ID
   * @param yarnClient
   * @return the state or {@link AppState#UNKNOWN} if it could not
   * be determined
   * @throws IOException
   */
private static synchronized AppState getAppState(ApplicationId appId, YarnClient yarnClient) throws IOException {
    AppState appState = AppState.ACTIVE;
    try {
        ApplicationReport report = yarnClient.getApplicationReport(appId);
        YarnApplicationState yarnState = report.getYarnApplicationState();
        if (APP_FINAL_STATES.contains(yarnState)) {
            appState = AppState.COMPLETED;
        }
    } catch (ApplicationNotFoundException e) {
        appState = AppState.UNKNOWN;
    } catch (YarnException e) {
        throw new IOException(e);
    }
    return appState;
}
Also used : ApplicationReport(org.apache.hadoop.yarn.api.records.ApplicationReport) ApplicationNotFoundException(org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException) YarnApplicationState(org.apache.hadoop.yarn.api.records.YarnApplicationState) IOException(java.io.IOException) YarnException(org.apache.hadoop.yarn.exceptions.YarnException)

Example 3 with ApplicationNotFoundException

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

the class TestClientRMService method testGetApplicationAttemptReport.

@Test
public void testGetApplicationAttemptReport() throws YarnException, IOException {
    ClientRMService rmService = createRMService();
    RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null);
    GetApplicationAttemptReportRequest request = recordFactory.newRecordInstance(GetApplicationAttemptReportRequest.class);
    ApplicationAttemptId attemptId = ApplicationAttemptId.newInstance(ApplicationId.newInstance(123456, 1), 1);
    request.setApplicationAttemptId(attemptId);
    try {
        GetApplicationAttemptReportResponse response = rmService.getApplicationAttemptReport(request);
        Assert.assertEquals(attemptId, response.getApplicationAttemptReport().getApplicationAttemptId());
    } catch (ApplicationNotFoundException ex) {
        Assert.fail(ex.getMessage());
    }
}
Also used : RecordFactory(org.apache.hadoop.yarn.factories.RecordFactory) ApplicationNotFoundException(org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException) GetApplicationAttemptReportRequest(org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptReportRequest) GetApplicationAttemptReportResponse(org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptReportResponse) ApplicationAttemptId(org.apache.hadoop.yarn.api.records.ApplicationAttemptId) Test(org.junit.Test)

Example 4 with ApplicationNotFoundException

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

the class TestClientRMService method testUpdateApplicationPriorityRequest.

@Test(timeout = 120000)
public void testUpdateApplicationPriorityRequest() throws Exception {
    int maxPriority = 10;
    int appPriority = 5;
    YarnConfiguration conf = new YarnConfiguration();
    conf.setInt(YarnConfiguration.MAX_CLUSTER_LEVEL_APPLICATION_PRIORITY, maxPriority);
    MockRM rm = new MockRM(conf);
    rm.init(conf);
    rm.start();
    rm.registerNode("host1:1234", 1024);
    // Start app1 with appPriority 5
    RMApp app1 = rm.submitApp(1024, Priority.newInstance(appPriority));
    Assert.assertEquals("Incorrect priority has been set to application", appPriority, app1.getApplicationPriority().getPriority());
    appPriority = 11;
    ClientRMService rmService = rm.getClientRMService();
    testApplicationPriorityUpdation(rmService, app1, appPriority, maxPriority);
    appPriority = 9;
    testApplicationPriorityUpdation(rmService, app1, appPriority, appPriority);
    rm.killApp(app1.getApplicationId());
    rm.waitForState(app1.getApplicationId(), RMAppState.KILLED);
    // Update priority request for invalid application id.
    ApplicationId invalidAppId = ApplicationId.newInstance(123456789L, 3);
    UpdateApplicationPriorityRequest updateRequest = UpdateApplicationPriorityRequest.newInstance(invalidAppId, Priority.newInstance(appPriority));
    try {
        rmService.updateApplicationPriority(updateRequest);
        Assert.fail("ApplicationNotFoundException should be thrown " + "for invalid application id");
    } catch (ApplicationNotFoundException e) {
    // Expected
    }
    updateRequest = UpdateApplicationPriorityRequest.newInstance(app1.getApplicationId(), Priority.newInstance(11));
    Assert.assertEquals("Incorrect priority has been set to application", appPriority, rmService.updateApplicationPriority(updateRequest).getApplicationPriority().getPriority());
    rm.stop();
}
Also used : RMApp(org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) ApplicationNotFoundException(org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException) UpdateApplicationPriorityRequest(org.apache.hadoop.yarn.api.protocolrecords.UpdateApplicationPriorityRequest) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) Test(org.junit.Test)

Example 5 with ApplicationNotFoundException

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

the class TestClientRMService method testGetApplicationAttempts.

@Test
public void testGetApplicationAttempts() throws YarnException, IOException {
    ClientRMService rmService = createRMService();
    RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null);
    GetApplicationAttemptsRequest request = recordFactory.newRecordInstance(GetApplicationAttemptsRequest.class);
    ApplicationAttemptId attemptId = ApplicationAttemptId.newInstance(ApplicationId.newInstance(123456, 1), 1);
    request.setApplicationId(ApplicationId.newInstance(123456, 1));
    try {
        GetApplicationAttemptsResponse response = rmService.getApplicationAttempts(request);
        Assert.assertEquals(1, response.getApplicationAttemptList().size());
        Assert.assertEquals(attemptId, response.getApplicationAttemptList().get(0).getApplicationAttemptId());
    } catch (ApplicationNotFoundException ex) {
        Assert.fail(ex.getMessage());
    }
}
Also used : RecordFactory(org.apache.hadoop.yarn.factories.RecordFactory) ApplicationNotFoundException(org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException) GetApplicationAttemptsRequest(org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptsRequest) ApplicationAttemptId(org.apache.hadoop.yarn.api.records.ApplicationAttemptId) GetApplicationAttemptsResponse(org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptsResponse) 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