@Override
  public FinishApplicationMasterResponse finishApplicationMaster(
      FinishApplicationMasterRequest request)
      throws YarnException, IOException {
    try {
      return this.rmClient.finishApplicationMaster(request);
    } catch (ApplicationMasterNotRegisteredException e) {
      LOG.warn("Out of sync with RM " + rmId
          + " for " + this.appId + ", hence resyncing.");
      // re register with RM
      reRegisterApplicationMaster(this.amRegistrationRequest);
      return finishApplicationMaster(request);
    }
  }
@Test
  public void testConcurrentReregister() throws YarnException, IOException {

    // Set RM restart and failover flag
    this.mockAMS.setFailoverFlag();

    this.mockAMS.setThrowAlreadyRegister();

    relayer.finishApplicationMaster(null);
  }