ClientRMService extends AbstractService implements
    ApplicationClientProtocol { @Override public GetQueueInfoResponse getQueueInfo(GetQueueInfoRequest request) throws YarnException { UserGroupInformation callerUGI; try { callerUGI = UserGroupInformation.getCurrentUser(); } catch (IOException ie) { LOG.info("Error getting UGI ", ie); throw RPCUtil.getRemoteException(ie); } GetQueueInfoResponse response = recordFactory.newRecordInstance(GetQueueInfoResponse.class); RMAuditLogger.ArgsBuilder arguments = new RMAuditLogger.ArgsBuilder() .append(Keys.QUEUENAME, request.getQueueName()) .append(Keys.INCLUDEAPPS, String.valueOf(request.getIncludeApplications())) .append(Keys.INCLUDECHILDQUEUES, String.valueOf(request.getIncludeChildQueues())) .append(Keys.RECURSIVE, String.valueOf(request.getRecursive())); try { QueueInfo queueInfo = scheduler.getQueueInfo(request.getQueueName(), request.getIncludeChildQueues(), request.getRecursive()); List<ApplicationReport> appReports = EMPTY_APPS_REPORT; if (request.getIncludeApplications()) { List<ApplicationAttemptId> apps = scheduler.getAppsInQueue(request.getQueueName()); appReports = new ArrayList<ApplicationReport>(apps.size()); for (ApplicationAttemptId app : apps) { RMApp rmApp = rmContext.getRMApps().get(app.getApplicationId()); if (rmApp != null) { if (!checkAccess(callerUGI, rmApp.getUser(), ApplicationAccessType.VIEW_APP, rmApp)) { continue; } appReports.add( rmApp.createAndGetApplicationReport( callerUGI.getUserName(), true)); } } } queueInfo.setApplications(appReports); response.setQueueInfo(queueInfo); RMAuditLogger.logSuccess(callerUGI.getUserName(), AuditConstants.GET_QUEUE_INFO_REQUEST, "ClientRMService", arguments); } catch (IOException ioe) { LOG.info("Failed to getQueueInfo for " + request.getQueueName(), ioe); RMAuditLogger.logFailure(callerUGI.getUserName(), AuditConstants.GET_QUEUE_INFO_REQUEST, "UNKNOWN", "ClientRMService", ioe.getMessage(), arguments); } return response; } ClientRMService(RMContext rmContext, YarnScheduler scheduler,
      RMAppManager rmAppManager, ApplicationACLsManager applicationACLsManager,
      QueueACLsManager queueACLsManager,
      RMDelegationTokenSecretManager rmDTSecretManager);  ClientRMService(RMContext rmContext, YarnScheduler scheduler,
      RMAppManager rmAppManager, ApplicationACLsManager applicationACLsManager,
      QueueACLsManager queueACLsManager,
      RMDelegationTokenSecretManager rmDTSecretManager, Clock clock); @Private InetSocketAddress getBindAddress(); @Override GetNewApplicationResponse getNewApplication(
      GetNewApplicationRequest request); @Override GetApplicationReportResponse getApplicationReport(
      GetApplicationReportRequest request); @Override GetApplicationAttemptReportResponse getApplicationAttemptReport(
      GetApplicationAttemptReportRequest request); @Override GetApplicationAttemptsResponse getApplicationAttempts(
      GetApplicationAttemptsRequest request); @Override GetContainerReportResponse getContainerReport(
      GetContainerReportRequest request); @Override GetContainersResponse getContainers(GetContainersRequest request); @Override SubmitApplicationResponse submitApplication(
      SubmitApplicationRequest request); @SuppressWarnings("unchecked") @Override FailApplicationAttemptResponse failApplicationAttempt(
      FailApplicationAttemptRequest request); @SuppressWarnings("unchecked") @Override KillApplicationResponse forceKillApplication(
      KillApplicationRequest request); @Override GetClusterMetricsResponse getClusterMetrics(
      GetClusterMetricsRequest request); @Override GetApplicationsResponse getApplications(GetApplicationsRequest request); @Override GetClusterNodesResponse getClusterNodes(GetClusterNodesRequest request); @Override GetQueueInfoResponse getQueueInfo(GetQueueInfoRequest request); @Override GetQueueUserAclsInfoResponse getQueueUserAcls(
      GetQueueUserAclsInfoRequest request); @Override GetDelegationTokenResponse getDelegationToken(
      GetDelegationTokenRequest request); @Override RenewDelegationTokenResponse renewDelegationToken(
      RenewDelegationTokenRequest request); @Override CancelDelegationTokenResponse cancelDelegationToken(
      CancelDelegationTokenRequest request); @SuppressWarnings("unchecked") @Override MoveApplicationAcrossQueuesResponse moveApplicationAcrossQueues(
      MoveApplicationAcrossQueuesRequest request); @VisibleForTesting Server getServer(); @Override GetNewReservationResponse getNewReservation(
      GetNewReservationRequest request); @Override ReservationSubmissionResponse submitReservation(
      ReservationSubmissionRequest request); @Override ReservationUpdateResponse updateReservation(
      ReservationUpdateRequest request); @Override ReservationDeleteResponse deleteReservation(
      ReservationDeleteRequest request); @Override ReservationListResponse listReservations(
        ReservationListRequest requestInfo); @Override GetNodesToLabelsResponse getNodeToLabels(
      GetNodesToLabelsRequest request); @Override GetLabelsToNodesResponse getLabelsToNodes(
      GetLabelsToNodesRequest request); @Override GetClusterNodeLabelsResponse getClusterNodeLabels(
      GetClusterNodeLabelsRequest request); @Override UpdateApplicationPriorityResponse updateApplicationPriority(
      UpdateApplicationPriorityRequest request); @SuppressWarnings("unchecked") @Override SignalContainerResponse signalToContainer(
      SignalContainerRequest request); @Override UpdateApplicationTimeoutsResponse updateApplicationTimeouts(
      UpdateApplicationTimeoutsRequest request); @Override GetAllResourceProfilesResponse getResourceProfiles(
      GetAllResourceProfilesRequest request); @Override GetResourceProfileResponse getResourceProfile(
      GetResourceProfileRequest request); @Override GetAllResourceTypeInfoResponse getResourceTypeInfo(
      GetAllResourceTypeInfoRequest request); @Override GetAttributesToNodesResponse getAttributesToNodes(
      GetAttributesToNodesRequest request); @Override GetClusterNodeAttributesResponse getClusterNodeAttributes(
      GetClusterNodeAttributesRequest request); @Override GetNodesToAttributesResponse getNodesToAttributes(
      GetNodesToAttributesRequest request); @VisibleForTesting void setDisplayPerUserApps(boolean displayPerUserApps);  }
@Test public void testGetQueueInfo() throws Exception { ResourceScheduler scheduler = mock(ResourceScheduler.class); RMContext rmContext = mock(RMContext.class); mockRMContext(scheduler, rmContext); ApplicationACLsManager mockAclsManager = mock(ApplicationACLsManager.class); QueueACLsManager mockQueueACLsManager = mock(QueueACLsManager.class); when(mockQueueACLsManager.checkAccess(any(UserGroupInformation.class), any(QueueACL.class), any(RMApp.class), any(String.class), any())) .thenReturn(true); when(mockAclsManager.checkAccess(any(UserGroupInformation.class), any(ApplicationAccessType.class), any(), any(ApplicationId.class))).thenReturn(true); ClientRMService rmService = new ClientRMService(rmContext, scheduler, null, mockAclsManager, mockQueueACLsManager, null); GetQueueInfoRequest request = recordFactory .newRecordInstance(GetQueueInfoRequest.class); request.setQueueName("testqueue"); request.setIncludeApplications(true); GetQueueInfoResponse queueInfo = rmService.getQueueInfo(request); List<ApplicationReport> applications = queueInfo.getQueueInfo() .getApplications(); Assert.assertEquals(2, applications.size()); Map<String, QueueConfigurations> queueConfigsByPartition = queueInfo.getQueueInfo().getQueueConfigurations(); Assert.assertEquals(1, queueConfigsByPartition.size()); Assert.assertTrue(queueConfigsByPartition.containsKey("*")); QueueConfigurations queueConfigs = queueConfigsByPartition.get("*"); Assert.assertEquals(0.5f, queueConfigs.getCapacity(), 0.0001f); Assert.assertEquals(0.1f, queueConfigs.getAbsoluteCapacity(), 0.0001f); Assert.assertEquals(1.0f, queueConfigs.getMaxCapacity(), 0.0001f); Assert.assertEquals(1.0f, queueConfigs.getAbsoluteMaxCapacity(), 0.0001f); Assert.assertEquals(0.2f, queueConfigs.getMaxAMPercentage(), 0.0001f); request.setQueueName("nonexistentqueue"); request.setIncludeApplications(true); queueInfo = rmService.getQueueInfo(request); ApplicationACLsManager mockAclsManager1 = mock(ApplicationACLsManager.class); QueueACLsManager mockQueueACLsManager1 = mock(QueueACLsManager.class); when(mockQueueACLsManager1.checkAccess(any(UserGroupInformation.class), any(QueueACL.class), any(RMApp.class), any(String.class), any())) .thenReturn(false); when(mockAclsManager1.checkAccess(any(UserGroupInformation.class), any(ApplicationAccessType.class), anyString(), any(ApplicationId.class))).thenReturn(false); ClientRMService rmService1 = new ClientRMService(rmContext, scheduler, null, mockAclsManager1, mockQueueACLsManager1, null); request.setQueueName("testqueue"); request.setIncludeApplications(true); GetQueueInfoResponse queueInfo1 = rmService1.getQueueInfo(request); List<ApplicationReport> applications1 = queueInfo1.getQueueInfo() .getApplications(); Assert.assertEquals(0, applications1.size()); }