RouterClientRMService extends AbstractService implements ApplicationClientProtocol { @VisibleForTesting protected ClientRequestInterceptor createRequestInterceptorChain() { Configuration conf = getConfig(); List<String> interceptorClassNames = getInterceptorClassNames(conf); ClientRequestInterceptor pipeline = null; ClientRequestInterceptor current = null; for (String interceptorClassName : interceptorClassNames) { try { Class<?> interceptorClass = conf.getClassByName(interceptorClassName); if (ClientRequestInterceptor.class.isAssignableFrom(interceptorClass)) { ClientRequestInterceptor interceptorInstance = (ClientRequestInterceptor) ReflectionUtils .newInstance(interceptorClass, conf); if (pipeline == null) { pipeline = interceptorInstance; current = interceptorInstance; continue; } else { current.setNextInterceptor(interceptorInstance); current = interceptorInstance; } } else { throw new YarnRuntimeException( "Class: " + interceptorClassName + " not instance of " + ClientRequestInterceptor.class.getCanonicalName()); } } catch (ClassNotFoundException e) { throw new YarnRuntimeException( "Could not instantiate ApplicationClientRequestInterceptor: " + interceptorClassName, e); } } if (pipeline == null) { throw new YarnRuntimeException( "RequestInterceptor pipeline is not configured in the system"); } return pipeline; } RouterClientRMService(); @VisibleForTesting Server getServer(); @Override GetNewApplicationResponse getNewApplication(
      GetNewApplicationRequest request); @Override SubmitApplicationResponse submitApplication(
      SubmitApplicationRequest request); @Override KillApplicationResponse forceKillApplication(
      KillApplicationRequest 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 GetApplicationReportResponse getApplicationReport(
      GetApplicationReportRequest request); @Override GetApplicationsResponse getApplications(GetApplicationsRequest 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 GetAttributesToNodesResponse getAttributesToNodes(
      GetAttributesToNodesRequest request); @Override GetClusterNodeAttributesResponse getClusterNodeAttributes(
      GetClusterNodeAttributesRequest request); @Override GetNodesToAttributesResponse getNodesToAttributes(
      GetNodesToAttributesRequest request);  }
@Test public void testRequestInterceptorChainCreation() throws Exception { ClientRequestInterceptor root = super.getRouterClientRMService().createRequestInterceptorChain(); int index = 0; while (root != null) { switch (index) { case 0: case 1: case 2: Assert.assertEquals(PassThroughClientRequestInterceptor.class.getName(), root.getClass().getName()); break; case 3: Assert.assertEquals(MockClientRequestInterceptor.class.getName(), root.getClass().getName()); break; default: Assert.fail(); } root = root.getNextInterceptor(); index++; } Assert.assertEquals("The number of interceptors in chain does not match", 4, index); }