FederationClientInterceptor extends AbstractClientRequestInterceptor { @Override public GetNewApplicationResponse getNewApplication( GetNewApplicationRequest request) throws YarnException, IOException { long startTime = clock.getTime(); Map<SubClusterId, SubClusterInfo> subClustersActive = federationFacade.getSubClusters(true); for (int i = 0; i < numSubmitRetries; ++i) { SubClusterId subClusterId = getRandomActiveSubCluster(subClustersActive); LOG.debug( "getNewApplication try #{} on SubCluster {}", i, subClusterId); ApplicationClientProtocol clientRMProxy = getClientRMProxyForSubCluster(subClusterId); GetNewApplicationResponse response = null; try { response = clientRMProxy.getNewApplication(request); } catch (Exception e) { LOG.warn("Unable to create a new ApplicationId in SubCluster " + subClusterId.getId(), e); } if (response != null) { long stopTime = clock.getTime(); routerMetrics.succeededAppsCreated(stopTime - startTime); return response; } else { subClustersActive.remove(subClusterId); } } routerMetrics.incrAppsFailedCreated(); String errMsg = "Fail to create a new application."; LOG.error(errMsg); throw new YarnException(errMsg); }  @Override void init(String userName); @Override void setNextInterceptor(ClientRequestInterceptor next); @Override GetNewApplicationResponse getNewApplication(
      GetNewApplicationRequest request); @Override SubmitApplicationResponse submitApplication(
      SubmitApplicationRequest request); @Override KillApplicationResponse forceKillApplication(
      KillApplicationRequest request); @Override GetApplicationReportResponse getApplicationReport(
      GetApplicationReportRequest request); @Override GetApplicationsResponse getApplications(GetApplicationsRequest request); @Override GetClusterMetricsResponse getClusterMetrics(
      GetClusterMetricsRequest request); @Override GetClusterNodesResponse getClusterNodes(GetClusterNodesRequest request); @Override GetQueueInfoResponse getQueueInfo(GetQueueInfoRequest request); @Override GetQueueUserAclsInfoResponse getQueueUserAcls(
      GetQueueUserAclsInfoRequest request); @Override MoveApplicationAcrossQueuesResponse moveApplicationAcrossQueues(
      MoveApplicationAcrossQueuesRequest request); @Override GetNewReservationResponse getNewReservation(
      GetNewReservationRequest request); @Override ReservationSubmissionResponse submitReservation(
      ReservationSubmissionRequest request); @Override ReservationListResponse listReservations(
      ReservationListRequest request); @Override ReservationUpdateResponse updateReservation(
      ReservationUpdateRequest request); @Override ReservationDeleteResponse deleteReservation(
      ReservationDeleteRequest request); @Override GetNodesToLabelsResponse getNodeToLabels(
      GetNodesToLabelsRequest request); @Override GetLabelsToNodesResponse getLabelsToNodes(
      GetLabelsToNodesRequest request); @Override GetClusterNodeLabelsResponse getClusterNodeLabels(
      GetClusterNodeLabelsRequest request); @Override GetApplicationAttemptReportResponse getApplicationAttemptReport(
      GetApplicationAttemptReportRequest request); @Override GetApplicationAttemptsResponse getApplicationAttempts(
      GetApplicationAttemptsRequest request); @Override GetContainerReportResponse getContainerReport(
      GetContainerReportRequest request); @Override GetContainersResponse getContainers(GetContainersRequest request); @Override GetDelegationTokenResponse getDelegationToken(
      GetDelegationTokenRequest request); @Override RenewDelegationTokenResponse renewDelegationToken(
      RenewDelegationTokenRequest request); @Override CancelDelegationTokenResponse cancelDelegationToken(
      CancelDelegationTokenRequest request); @Override FailApplicationAttemptResponse failApplicationAttempt(
      FailApplicationAttemptRequest request); @Override UpdateApplicationPriorityResponse updateApplicationPriority(
      UpdateApplicationPriorityRequest request); @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 void shutdown(); @Override GetAttributesToNodesResponse getAttributesToNodes(
      GetAttributesToNodesRequest request); @Override GetClusterNodeAttributesResponse getClusterNodeAttributes(
      GetClusterNodeAttributesRequest request); @Override GetNodesToAttributesResponse getNodesToAttributes(
      GetNodesToAttributesRequest request);  }
@Test public void testGetNewApplication() throws YarnException, IOException, InterruptedException { LOG.info("Test FederationClientInterceptor: Get New Application"); GetNewApplicationRequest request = GetNewApplicationRequest.newInstance(); GetNewApplicationResponse response = interceptor.getNewApplication(request); Assert.assertNotNull(response); Assert.assertNotNull(response.getApplicationId()); Assert.assertTrue(response.getApplicationId() .getClusterTimestamp() == ResourceManager.getClusterTimeStamp()); }