AMRMProxyService extends CompositeService implements
    ApplicationMasterProtocol { @Override public AllocateResponse allocate(AllocateRequest request) throws YarnException, IOException { long startTime = clock.getTime(); try { AMRMTokenIdentifier amrmTokenIdentifier = YarnServerSecurityUtils.authorizeRequest(); RequestInterceptorChainWrapper pipeline = getInterceptorChain(amrmTokenIdentifier); AllocateResponse allocateResponse = pipeline.getRootInterceptor().allocate(request); updateAMRMTokens(amrmTokenIdentifier, pipeline, allocateResponse); long endTime = clock.getTime(); this.metrics.succeededAllocateRequests(endTime - startTime); LOG.info("Allocate processing finished in {} ms for application {}", endTime - startTime, pipeline.getApplicationAttemptId()); return allocateResponse; } catch (Throwable t) { this.metrics.incrFailedAllocateRequests(); throw t; } } 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 testAllocateRequestWithoutRegistering() throws Exception { try { allocate(1); Assert .fail("The request to allocate application master should have failed"); } catch (Throwable ex) { LOG.info("AllocateRequest failed as expected because AM was not registered"); } }