Search in sources :

Example 41 with ApplicationClientProtocol

use of org.apache.hadoop.yarn.api.ApplicationClientProtocol in project hadoop by apache.

the class TestApplicationPriorityACLs method verifyAppPriorityIsAccepted.

private void verifyAppPriorityIsAccepted(String submitter, ApplicationId applicationId, int priority) throws IOException, InterruptedException {
    ApplicationClientProtocol submitterClient = getRMClientForUser(submitter);
    /**
     * If priority is greater than cluster max, RM will auto set to cluster max
     * Consider this scenario as a special case.
     */
    if (priority > clusterMaxPriority) {
        priority = clusterMaxPriority;
    }
    GetApplicationReportRequest request = GetApplicationReportRequest.newInstance(applicationId);
    try {
        GetApplicationReportResponse response = submitterClient.getApplicationReport(request);
        Assert.assertEquals(response.getApplicationReport().getPriority(), Priority.newInstance(priority));
    } catch (YarnException e) {
        Assert.fail("Application submission should not fail.");
    }
}
Also used : GetApplicationReportRequest(org.apache.hadoop.yarn.api.protocolrecords.GetApplicationReportRequest) GetApplicationReportResponse(org.apache.hadoop.yarn.api.protocolrecords.GetApplicationReportResponse) ApplicationClientProtocol(org.apache.hadoop.yarn.api.ApplicationClientProtocol) YarnException(org.apache.hadoop.yarn.exceptions.YarnException)

Example 42 with ApplicationClientProtocol

use of org.apache.hadoop.yarn.api.ApplicationClientProtocol in project hadoop by apache.

the class TestResourceMgrDelegate method tesAllJobs.

@Test
public void tesAllJobs() throws Exception {
    final ApplicationClientProtocol applicationsManager = Mockito.mock(ApplicationClientProtocol.class);
    GetApplicationsResponse allApplicationsResponse = Records.newRecord(GetApplicationsResponse.class);
    List<ApplicationReport> applications = new ArrayList<ApplicationReport>();
    applications.add(getApplicationReport(YarnApplicationState.FINISHED, FinalApplicationStatus.FAILED));
    applications.add(getApplicationReport(YarnApplicationState.FINISHED, FinalApplicationStatus.SUCCEEDED));
    applications.add(getApplicationReport(YarnApplicationState.FINISHED, FinalApplicationStatus.KILLED));
    applications.add(getApplicationReport(YarnApplicationState.FAILED, FinalApplicationStatus.FAILED));
    allApplicationsResponse.setApplicationList(applications);
    Mockito.when(applicationsManager.getApplications(Mockito.any(GetApplicationsRequest.class))).thenReturn(allApplicationsResponse);
    ResourceMgrDelegate resourceMgrDelegate = new ResourceMgrDelegate(new YarnConfiguration()) {

        @Override
        protected void serviceStart() throws Exception {
            Assert.assertTrue(this.client instanceof YarnClientImpl);
            ((YarnClientImpl) this.client).setRMClient(applicationsManager);
        }
    };
    JobStatus[] allJobs = resourceMgrDelegate.getAllJobs();
    Assert.assertEquals(State.FAILED, allJobs[0].getState());
    Assert.assertEquals(State.SUCCEEDED, allJobs[1].getState());
    Assert.assertEquals(State.KILLED, allJobs[2].getState());
    Assert.assertEquals(State.FAILED, allJobs[3].getState());
}
Also used : ApplicationReport(org.apache.hadoop.yarn.api.records.ApplicationReport) JobStatus(org.apache.hadoop.mapreduce.JobStatus) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) GetApplicationsResponse(org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsResponse) ArrayList(java.util.ArrayList) YarnClientImpl(org.apache.hadoop.yarn.client.api.impl.YarnClientImpl) ApplicationClientProtocol(org.apache.hadoop.yarn.api.ApplicationClientProtocol) GetApplicationsRequest(org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsRequest) Test(org.junit.Test)

Aggregations

ApplicationClientProtocol (org.apache.hadoop.yarn.api.ApplicationClientProtocol)42 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)12 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)12 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)11 Test (org.junit.Test)11 IOException (java.io.IOException)9 GetApplicationReportRequest (org.apache.hadoop.yarn.api.protocolrecords.GetApplicationReportRequest)8 KillApplicationRequest (org.apache.hadoop.yarn.api.protocolrecords.KillApplicationRequest)8 Configuration (org.apache.hadoop.conf.Configuration)7 GetNewApplicationRequest (org.apache.hadoop.yarn.api.protocolrecords.GetNewApplicationRequest)7 YarnRPC (org.apache.hadoop.yarn.ipc.YarnRPC)7 InetSocketAddress (java.net.InetSocketAddress)6 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)6 AccessControlList (org.apache.hadoop.security.authorize.AccessControlList)5 GetApplicationReportResponse (org.apache.hadoop.yarn.api.protocolrecords.GetApplicationReportResponse)5 HashSet (java.util.HashSet)4 SubmitApplicationRequest (org.apache.hadoop.yarn.api.protocolrecords.SubmitApplicationRequest)4 ImmutableSet (com.google.common.collect.ImmutableSet)3 EnumSet (java.util.EnumSet)3 HashMap (java.util.HashMap)3