Search in sources :

Example 1 with GetClusterMetricsResponse

use of org.apache.hadoop.yarn.api.protocolrecords.GetClusterMetricsResponse in project hadoop by apache.

the class TestYARNRunner method testResourceMgrDelegate.

@Test(timeout = 20000)
public void testResourceMgrDelegate() throws Exception {
    /* we not want a mock of resource mgr delegate */
    final ApplicationClientProtocol clientRMProtocol = mock(ApplicationClientProtocol.class);
    ResourceMgrDelegate delegate = new ResourceMgrDelegate(conf) {

        @Override
        protected void serviceStart() throws Exception {
            assertTrue(this.client instanceof YarnClientImpl);
            ((YarnClientImpl) this.client).setRMClient(clientRMProtocol);
        }
    };
    /* make sure kill calls finish application master */
    when(clientRMProtocol.forceKillApplication(any(KillApplicationRequest.class))).thenReturn(KillApplicationResponse.newInstance(true));
    delegate.killApplication(appId);
    verify(clientRMProtocol).forceKillApplication(any(KillApplicationRequest.class));
    /* make sure getalljobs calls get all applications */
    when(clientRMProtocol.getApplications(any(GetApplicationsRequest.class))).thenReturn(recordFactory.newRecordInstance(GetApplicationsResponse.class));
    delegate.getAllJobs();
    verify(clientRMProtocol).getApplications(any(GetApplicationsRequest.class));
    /* make sure getapplication report is called */
    when(clientRMProtocol.getApplicationReport(any(GetApplicationReportRequest.class))).thenReturn(recordFactory.newRecordInstance(GetApplicationReportResponse.class));
    delegate.getApplicationReport(appId);
    verify(clientRMProtocol).getApplicationReport(any(GetApplicationReportRequest.class));
    /* make sure metrics is called */
    GetClusterMetricsResponse clusterMetricsResponse = recordFactory.newRecordInstance(GetClusterMetricsResponse.class);
    clusterMetricsResponse.setClusterMetrics(recordFactory.newRecordInstance(YarnClusterMetrics.class));
    when(clientRMProtocol.getClusterMetrics(any(GetClusterMetricsRequest.class))).thenReturn(clusterMetricsResponse);
    delegate.getClusterMetrics();
    verify(clientRMProtocol).getClusterMetrics(any(GetClusterMetricsRequest.class));
    when(clientRMProtocol.getClusterNodes(any(GetClusterNodesRequest.class))).thenReturn(recordFactory.newRecordInstance(GetClusterNodesResponse.class));
    delegate.getActiveTrackers();
    verify(clientRMProtocol).getClusterNodes(any(GetClusterNodesRequest.class));
    GetNewApplicationResponse newAppResponse = recordFactory.newRecordInstance(GetNewApplicationResponse.class);
    newAppResponse.setApplicationId(appId);
    when(clientRMProtocol.getNewApplication(any(GetNewApplicationRequest.class))).thenReturn(newAppResponse);
    delegate.getNewJobID();
    verify(clientRMProtocol).getNewApplication(any(GetNewApplicationRequest.class));
    GetQueueInfoResponse queueInfoResponse = recordFactory.newRecordInstance(GetQueueInfoResponse.class);
    queueInfoResponse.setQueueInfo(recordFactory.newRecordInstance(QueueInfo.class));
    when(clientRMProtocol.getQueueInfo(any(GetQueueInfoRequest.class))).thenReturn(queueInfoResponse);
    delegate.getQueues();
    verify(clientRMProtocol).getQueueInfo(any(GetQueueInfoRequest.class));
    GetQueueUserAclsInfoResponse aclResponse = recordFactory.newRecordInstance(GetQueueUserAclsInfoResponse.class);
    when(clientRMProtocol.getQueueUserAcls(any(GetQueueUserAclsInfoRequest.class))).thenReturn(aclResponse);
    delegate.getQueueAclsForCurrentUser();
    verify(clientRMProtocol).getQueueUserAcls(any(GetQueueUserAclsInfoRequest.class));
}
Also used : QueueInfo(org.apache.hadoop.yarn.api.records.QueueInfo) GetApplicationReportRequest(org.apache.hadoop.yarn.api.protocolrecords.GetApplicationReportRequest) GetNewApplicationResponse(org.apache.hadoop.yarn.api.protocolrecords.GetNewApplicationResponse) YarnClusterMetrics(org.apache.hadoop.yarn.api.records.YarnClusterMetrics) GetQueueInfoRequest(org.apache.hadoop.yarn.api.protocolrecords.GetQueueInfoRequest) GetQueueInfoResponse(org.apache.hadoop.yarn.api.protocolrecords.GetQueueInfoResponse) GetClusterNodesResponse(org.apache.hadoop.yarn.api.protocolrecords.GetClusterNodesResponse) KillApplicationRequest(org.apache.hadoop.yarn.api.protocolrecords.KillApplicationRequest) YarnClientImpl(org.apache.hadoop.yarn.client.api.impl.YarnClientImpl) ApplicationClientProtocol(org.apache.hadoop.yarn.api.ApplicationClientProtocol) GetApplicationsRequest(org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsRequest) GetNewApplicationRequest(org.apache.hadoop.yarn.api.protocolrecords.GetNewApplicationRequest) GetQueueUserAclsInfoResponse(org.apache.hadoop.yarn.api.protocolrecords.GetQueueUserAclsInfoResponse) GetQueueUserAclsInfoRequest(org.apache.hadoop.yarn.api.protocolrecords.GetQueueUserAclsInfoRequest) GetClusterMetricsResponse(org.apache.hadoop.yarn.api.protocolrecords.GetClusterMetricsResponse) GetApplicationsResponse(org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsResponse) GetClusterMetricsRequest(org.apache.hadoop.yarn.api.protocolrecords.GetClusterMetricsRequest) GetApplicationReportResponse(org.apache.hadoop.yarn.api.protocolrecords.GetApplicationReportResponse) GetClusterNodesRequest(org.apache.hadoop.yarn.api.protocolrecords.GetClusterNodesRequest) Test(org.junit.Test)

Example 2 with GetClusterMetricsResponse

use of org.apache.hadoop.yarn.api.protocolrecords.GetClusterMetricsResponse in project hadoop by apache.

the class YarnClientImpl method getYarnClusterMetrics.

@Override
public YarnClusterMetrics getYarnClusterMetrics() throws YarnException, IOException {
    GetClusterMetricsRequest request = Records.newRecord(GetClusterMetricsRequest.class);
    GetClusterMetricsResponse response = rmClient.getClusterMetrics(request);
    return response.getClusterMetrics();
}
Also used : GetClusterMetricsResponse(org.apache.hadoop.yarn.api.protocolrecords.GetClusterMetricsResponse) GetClusterMetricsRequest(org.apache.hadoop.yarn.api.protocolrecords.GetClusterMetricsRequest)

Example 3 with GetClusterMetricsResponse

use of org.apache.hadoop.yarn.api.protocolrecords.GetClusterMetricsResponse in project hadoop by apache.

the class ClientRMService method getClusterMetrics.

@Override
public GetClusterMetricsResponse getClusterMetrics(GetClusterMetricsRequest request) throws YarnException {
    GetClusterMetricsResponse response = recordFactory.newRecordInstance(GetClusterMetricsResponse.class);
    YarnClusterMetrics ymetrics = recordFactory.newRecordInstance(YarnClusterMetrics.class);
    ymetrics.setNumNodeManagers(this.rmContext.getRMNodes().size());
    ClusterMetrics clusterMetrics = ClusterMetrics.getMetrics();
    ymetrics.setNumDecommissionedNodeManagers(clusterMetrics.getNumDecommisionedNMs());
    ymetrics.setNumActiveNodeManagers(clusterMetrics.getNumActiveNMs());
    ymetrics.setNumLostNodeManagers(clusterMetrics.getNumLostNMs());
    ymetrics.setNumUnhealthyNodeManagers(clusterMetrics.getUnhealthyNMs());
    ymetrics.setNumRebootedNodeManagers(clusterMetrics.getNumRebootedNMs());
    response.setClusterMetrics(ymetrics);
    return response;
}
Also used : YarnClusterMetrics(org.apache.hadoop.yarn.api.records.YarnClusterMetrics) YarnClusterMetrics(org.apache.hadoop.yarn.api.records.YarnClusterMetrics) GetClusterMetricsResponse(org.apache.hadoop.yarn.api.protocolrecords.GetClusterMetricsResponse)

Aggregations

GetClusterMetricsResponse (org.apache.hadoop.yarn.api.protocolrecords.GetClusterMetricsResponse)3 GetClusterMetricsRequest (org.apache.hadoop.yarn.api.protocolrecords.GetClusterMetricsRequest)2 YarnClusterMetrics (org.apache.hadoop.yarn.api.records.YarnClusterMetrics)2 ApplicationClientProtocol (org.apache.hadoop.yarn.api.ApplicationClientProtocol)1 GetApplicationReportRequest (org.apache.hadoop.yarn.api.protocolrecords.GetApplicationReportRequest)1 GetApplicationReportResponse (org.apache.hadoop.yarn.api.protocolrecords.GetApplicationReportResponse)1 GetApplicationsRequest (org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsRequest)1 GetApplicationsResponse (org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsResponse)1 GetClusterNodesRequest (org.apache.hadoop.yarn.api.protocolrecords.GetClusterNodesRequest)1 GetClusterNodesResponse (org.apache.hadoop.yarn.api.protocolrecords.GetClusterNodesResponse)1 GetNewApplicationRequest (org.apache.hadoop.yarn.api.protocolrecords.GetNewApplicationRequest)1 GetNewApplicationResponse (org.apache.hadoop.yarn.api.protocolrecords.GetNewApplicationResponse)1 GetQueueInfoRequest (org.apache.hadoop.yarn.api.protocolrecords.GetQueueInfoRequest)1 GetQueueInfoResponse (org.apache.hadoop.yarn.api.protocolrecords.GetQueueInfoResponse)1 GetQueueUserAclsInfoRequest (org.apache.hadoop.yarn.api.protocolrecords.GetQueueUserAclsInfoRequest)1 GetQueueUserAclsInfoResponse (org.apache.hadoop.yarn.api.protocolrecords.GetQueueUserAclsInfoResponse)1 KillApplicationRequest (org.apache.hadoop.yarn.api.protocolrecords.KillApplicationRequest)1 QueueInfo (org.apache.hadoop.yarn.api.records.QueueInfo)1 YarnClientImpl (org.apache.hadoop.yarn.client.api.impl.YarnClientImpl)1 Test (org.junit.Test)1