AMRMProxyService extends AbstractService implements
    ApplicationMasterProtocol { @Override public RegisterApplicationMasterResponse registerApplicationMaster( RegisterApplicationMasterRequest request) throws YarnException, IOException { LOG.info("Registering application master." + " Host:" + request.getHost() + " Port:" + request.getRpcPort() + " Tracking Url:" + request.getTrackingUrl()); RequestInterceptorChainWrapper pipeline = authorizeAndGetInterceptorChain(); return pipeline.getRootInterceptor() .registerApplicationMaster(request); } AMRMProxyService(Context nmContext, AsyncDispatcher dispatcher); @Override RegisterApplicationMasterResponse registerApplicationMaster(
      RegisterApplicationMasterRequest request); @Override FinishApplicationMasterResponse finishApplicationMaster(
      FinishApplicationMasterRequest request); @Override AllocateResponse allocate(AllocateRequest request); void processApplicationStartRequest(StartContainerRequest request);  }
@Test public void testRegisterOneApplicationMaster() throws Exception { int testAppId = 1; RegisterApplicationMasterResponse response1 = registerApplicationMaster(testAppId); Assert.assertNotNull(response1); Assert.assertEquals(Integer.toString(testAppId), response1.getQueue()); }
@Test public void testRegisterMulitpleApplicationMasters() throws Exception { for (int testAppId = 0; testAppId < 3; testAppId++) { RegisterApplicationMasterResponse response = registerApplicationMaster(testAppId); Assert.assertNotNull(response); Assert .assertEquals(Integer.toString(testAppId), response.getQueue()); } }
@Test public void testFinishMulitpleApplicationMastersInParallel() throws Exception { int numberOfRequests = 5; ArrayList<String> testContexts = new ArrayList<String>(); LOG.info("Creating " + numberOfRequests + " contexts for testing"); for (int i = 0; i < numberOfRequests; i++) { testContexts.add("test-endpoint-" + Integer.toString(i)); LOG.info("Created test context: " + testContexts.get(i)); RegisterApplicationMasterResponse registerResponse = registerApplicationMaster(i); Assert.assertNotNull(registerResponse); Assert .assertEquals(Integer.toString(i), registerResponse.getQueue()); } finishApplicationMastersInParallel(testContexts); }