ClientRMService extends AbstractService implements
    ApplicationClientProtocol { @Override public ReservationListResponse listReservations( ReservationListRequest requestInfo) throws YarnException, IOException { checkReservationSystem(); ReservationListResponse response = recordFactory.newRecordInstance(ReservationListResponse.class); Plan plan = rValidator.validateReservationListRequest( reservationSystem, requestInfo); boolean includeResourceAllocations = requestInfo .getIncludeResourceAllocations(); ReservationId reservationId = null; if (requestInfo.getReservationId() != null && !requestInfo .getReservationId().isEmpty()) { reservationId = ReservationId.parseReservationId( requestInfo.getReservationId()); } checkReservationACLs(requestInfo.getQueue(), AuditConstants.LIST_RESERVATION_REQUEST, reservationId); long startTime = Math.max(requestInfo.getStartTime(), 0); long endTime = requestInfo.getEndTime() <= -1? Long.MAX_VALUE : requestInfo .getEndTime(); Set<ReservationAllocation> reservations; reservations = plan.getReservations(reservationId, new ReservationInterval( startTime, endTime)); List<ReservationAllocationState> info = ReservationSystemUtil.convertAllocationsToReservationInfo( reservations, includeResourceAllocations); response.setReservationAllocationState(info); 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 testListReservationsByTimeIntervalContainingNoReservations() { ResourceManager rm = setupResourceManager(); ClientRMService clientService = rm.getClientRMService(); Clock clock = new UTCClock(); long arrival = clock.getTime(); long duration = 60000; long deadline = (long) (arrival + 1.05 * duration); ReservationSubmissionRequest sRequest = submitReservationTestHelper(clientService, arrival, deadline, duration); ReservationListRequest request = ReservationListRequest.newInstance( ReservationSystemTestUtil.reservationQ, "", Long.MAX_VALUE, -1, false); ReservationListResponse response = null; try { response = clientService.listReservations(request); } catch (Exception e) { Assert.fail(e.getMessage()); } Assert.assertNotNull(response); Assert.assertEquals(response.getReservationAllocationState().size(), 0); duration = 30000; deadline = sRequest.getReservationDefinition().getDeadline(); request = ReservationListRequest.newInstance( ReservationSystemTestUtil.reservationQ, "", deadline + duration, deadline + 2 * duration, false); response = null; try { response = clientService.listReservations(request); } catch (Exception e) { Assert.fail(e.getMessage()); } Assert.assertNotNull(response); Assert.assertEquals(response.getReservationAllocationState().size(), 0); arrival = clock.getTime(); request = ReservationListRequest.newInstance( ReservationSystemTestUtil.reservationQ, "", 0, arrival - duration, false); response = null; try { response = clientService.listReservations(request); } catch (Exception e) { Assert.fail(e.getMessage()); } Assert.assertNotNull(response); Assert.assertEquals(response.getReservationAllocationState().size(), 0); request = ReservationListRequest .newInstance(ReservationSystemTestUtil.reservationQ, "", 0, 1, false); response = null; try { response = clientService.listReservations(request); } catch (Exception e) { Assert.fail(e.getMessage()); } Assert.assertNotNull(response); Assert.assertEquals(response.getReservationAllocationState().size(), 0); rm.stop(); }