Search in sources :

Example 11 with ApplicationClientProtocol

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

the class ReservationACLsTestBase method listReservation.

private ReservationListResponse listReservation(String lister, String queueName) throws Exception {
    final ReservationListRequest listRequest = ReservationListRequest.newInstance(queueName, null, -1, -1, false);
    ApplicationClientProtocol ownerClient = getRMClientForUser(lister);
    return ownerClient.listReservations(listRequest);
}
Also used : ReservationListRequest(org.apache.hadoop.yarn.api.protocolrecords.ReservationListRequest) ApplicationClientProtocol(org.apache.hadoop.yarn.api.ApplicationClientProtocol)

Example 12 with ApplicationClientProtocol

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

the class ReservationACLsTestBase method submitReservation.

private void submitReservation(String submitter, String queueName, ReservationId reservationId) throws Exception {
    ApplicationClientProtocol submitterClient = getRMClientForUser(submitter);
    ReservationSubmissionRequest reservationSubmissionRequest = ReservationSubmissionRequest.newInstance(makeSimpleReservationDefinition(), queueName, reservationId);
    ReservationSubmissionResponse response = submitterClient.submitReservation(reservationSubmissionRequest);
}
Also used : ReservationSubmissionRequest(org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionRequest) ReservationSubmissionResponse(org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionResponse) ApplicationClientProtocol(org.apache.hadoop.yarn.api.ApplicationClientProtocol)

Example 13 with ApplicationClientProtocol

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

the class TestYarnClientProtocolProvider method testClusterGetDelegationToken.

@Test
public void testClusterGetDelegationToken() throws Exception {
    Configuration conf = new Configuration(false);
    Cluster cluster = null;
    try {
        conf = new Configuration();
        conf.set(MRConfig.FRAMEWORK_NAME, MRConfig.YARN_FRAMEWORK_NAME);
        cluster = new Cluster(conf);
        YARNRunner yrunner = (YARNRunner) cluster.getClient();
        GetDelegationTokenResponse getDTResponse = recordFactory.newRecordInstance(GetDelegationTokenResponse.class);
        org.apache.hadoop.yarn.api.records.Token rmDTToken = recordFactory.newRecordInstance(org.apache.hadoop.yarn.api.records.Token.class);
        rmDTToken.setIdentifier(ByteBuffer.wrap(new byte[2]));
        rmDTToken.setKind("Testclusterkind");
        rmDTToken.setPassword(ByteBuffer.wrap("testcluster".getBytes()));
        rmDTToken.setService("0.0.0.0:8032");
        getDTResponse.setRMDelegationToken(rmDTToken);
        final ApplicationClientProtocol cRMProtocol = mock(ApplicationClientProtocol.class);
        when(cRMProtocol.getDelegationToken(any(GetDelegationTokenRequest.class))).thenReturn(getDTResponse);
        ResourceMgrDelegate rmgrDelegate = new ResourceMgrDelegate(new YarnConfiguration(conf)) {

            @Override
            protected void serviceStart() throws Exception {
                assertTrue(this.client instanceof YarnClientImpl);
                this.client = spy(this.client);
                doNothing().when(this.client).close();
                ((YarnClientImpl) this.client).setRMClient(cRMProtocol);
            }
        };
        yrunner.setResourceMgrDelegate(rmgrDelegate);
        Token t = cluster.getDelegationToken(new Text(" "));
        assertTrue("Token kind is instead " + t.getKind().toString(), "Testclusterkind".equals(t.getKind().toString()));
    } finally {
        if (cluster != null) {
            cluster.close();
        }
    }
}
Also used : YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) Configuration(org.apache.hadoop.conf.Configuration) GetDelegationTokenResponse(org.apache.hadoop.yarn.api.protocolrecords.GetDelegationTokenResponse) Token(org.apache.hadoop.security.token.Token) Text(org.apache.hadoop.io.Text) YarnClientImpl(org.apache.hadoop.yarn.client.api.impl.YarnClientImpl) ApplicationClientProtocol(org.apache.hadoop.yarn.api.ApplicationClientProtocol) GetDelegationTokenRequest(org.apache.hadoop.yarn.api.protocolrecords.GetDelegationTokenRequest) ResourceMgrDelegate(org.apache.hadoop.mapred.ResourceMgrDelegate) YARNRunner(org.apache.hadoop.mapred.YARNRunner) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) Test(org.junit.Test)

Example 14 with ApplicationClientProtocol

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

the class TestAggregatedLogDeletionService method createMockRMClient.

private static ApplicationClientProtocol createMockRMClient(List<ApplicationId> finishedApplicaitons, List<ApplicationId> runningApplications) throws Exception {
    final ApplicationClientProtocol mockProtocol = mock(ApplicationClientProtocol.class);
    if (finishedApplicaitons != null && !finishedApplicaitons.isEmpty()) {
        for (ApplicationId appId : finishedApplicaitons) {
            GetApplicationReportRequest request = GetApplicationReportRequest.newInstance(appId);
            GetApplicationReportResponse response = createApplicationReportWithFinishedApplication();
            when(mockProtocol.getApplicationReport(request)).thenReturn(response);
        }
    }
    if (runningApplications != null && !runningApplications.isEmpty()) {
        for (ApplicationId appId : runningApplications) {
            GetApplicationReportRequest request = GetApplicationReportRequest.newInstance(appId);
            GetApplicationReportResponse response = createApplicationReportWithRunningApplication();
            when(mockProtocol.getApplicationReport(request)).thenReturn(response);
        }
    }
    return mockProtocol;
}
Also used : GetApplicationReportRequest(org.apache.hadoop.yarn.api.protocolrecords.GetApplicationReportRequest) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) GetApplicationReportResponse(org.apache.hadoop.yarn.api.protocolrecords.GetApplicationReportResponse) ApplicationClientProtocol(org.apache.hadoop.yarn.api.ApplicationClientProtocol)

Example 15 with ApplicationClientProtocol

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

the class TestRPC method testUnknownCall.

@Test
public void testUnknownCall() {
    Configuration conf = new Configuration();
    conf.set(YarnConfiguration.IPC_RPC_IMPL, HadoopYarnProtoRPC.class.getName());
    YarnRPC rpc = YarnRPC.create(conf);
    String bindAddr = "localhost:0";
    InetSocketAddress addr = NetUtils.createSocketAddr(bindAddr);
    Server server = rpc.getServer(ContainerManagementProtocol.class, new DummyContainerManager(), addr, conf, null, 1);
    server.start();
    // Any unrelated protocol would do
    ApplicationClientProtocol proxy = (ApplicationClientProtocol) rpc.getProxy(ApplicationClientProtocol.class, NetUtils.getConnectAddress(server), conf);
    try {
        proxy.getNewApplication(Records.newRecord(GetNewApplicationRequest.class));
        Assert.fail("Excepted RPC call to fail with unknown method.");
    } catch (YarnException e) {
        Assert.assertTrue(e.getMessage().matches("Unknown method getNewApplication called on.*" + "org.apache.hadoop.yarn.proto.ApplicationClientProtocol" + "\\$ApplicationClientProtocolService\\$BlockingInterface " + "protocol."));
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        server.stop();
    }
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) Server(org.apache.hadoop.ipc.Server) InetSocketAddress(java.net.InetSocketAddress) YarnRPC(org.apache.hadoop.yarn.ipc.YarnRPC) HadoopYarnProtoRPC(org.apache.hadoop.yarn.ipc.HadoopYarnProtoRPC) ApplicationClientProtocol(org.apache.hadoop.yarn.api.ApplicationClientProtocol) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) IOException(java.io.IOException) GetNewApplicationRequest(org.apache.hadoop.yarn.api.protocolrecords.GetNewApplicationRequest) 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