AMRMProxyService extends CompositeService implements
    ApplicationMasterProtocol { protected RequestInterceptor createRequestInterceptorChain() { Configuration conf = getConfig(); List<String> interceptorClassNames = getInterceptorClassNames(conf); RequestInterceptor pipeline = null; RequestInterceptor current = null; for (String interceptorClassName : interceptorClassNames) { try { Class<?> interceptorClass = conf.getClassByName(interceptorClassName); if (RequestInterceptor.class.isAssignableFrom(interceptorClass)) { RequestInterceptor interceptorInstance = (RequestInterceptor) 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 " + RequestInterceptor.class.getCanonicalName()); } } catch (ClassNotFoundException e) { throw new YarnRuntimeException( "Could not instantiate ApplicationMasterRequestInterceptor: " + interceptorClassName, e); } } if (pipeline == null) { throw new YarnRuntimeException( "RequestInterceptor pipeline is not configured in the system"); } return pipeline; } AMRMProxyService(Context nmContext, AsyncDispatcher dispatcher); void recover(); @Override RegisterApplicationMasterResponse registerApplicationMaster(
      RegisterApplicationMasterRequest request); @Override FinishApplicationMasterResponse finishApplicationMaster(
      FinishApplicationMasterRequest request); @Override AllocateResponse allocate(AllocateRequest request); void processApplicationStartRequest(StartContainerRequest request); @Private InetSocketAddress getBindAddress(); @Private AMRMProxyTokenSecretManager getSecretManager();  }
@Test public void testRequestInterceptorChainCreation() throws Exception { RequestInterceptor root = super.getAMRMProxyService().createRequestInterceptorChain(); int index = 0; while (root != null) { switch (index) { case 0: case 1: case 2: Assert.assertEquals(PassThroughRequestInterceptor.class.getName(), root.getClass().getName()); break; case 3: Assert.assertEquals(MockRequestInterceptor.class.getName(), root .getClass().getName()); break; } root = root.getNextInterceptor(); index++; } Assert.assertEquals( "The number of interceptors in chain does not match", Integer.toString(4), Integer.toString(index)); }