@Override
  public ReservationDeleteResponse deleteReservation(
      ReservationDeleteRequest request) throws YarnException, IOException {
    if (request == null || request.getReservationId() == null) {
      routerMetrics.incrDeleteReservationFailedRetrieved();
      String msg = "Missing deleteReservation request or reservationId.";
      RouterServerUtil.logAndThrowException(msg, null);
      RouterAuditLogger.logFailure(user.getShortUserName(), DELETE_RESERVATION, UNKNOWN,
          TARGET_CLIENT_RM_SERVICE, msg);
    }

    long startTime = clock.getTime();
    ReservationId reservationId = request.getReservationId();
    SubClusterId subClusterId = getReservationHomeSubCluster(reservationId);

    try {
      ApplicationClientProtocol client = getClientRMProxyForSubCluster(subClusterId);
      ReservationDeleteResponse response = client.deleteReservation(request);
      if (response != null) {
        federationFacade.deleteReservationHomeSubCluster(reservationId);
        long stopTime = clock.getTime();
        routerMetrics.succeededDeleteReservationRetrieved(stopTime - startTime);
        RouterAuditLogger.logSuccess(user.getShortUserName(), DELETE_RESERVATION,
            TARGET_CLIENT_RM_SERVICE);
        return response;
      }
    } catch (Exception ex) {
      routerMetrics.incrUpdateReservationFailedRetrieved();
      String msg = "Unable to reservation delete due to exception.";
      RouterAuditLogger.logFailure(user.getShortUserName(), DELETE_RESERVATION, UNKNOWN,
          TARGET_CLIENT_RM_SERVICE, msg);
      RouterServerUtil.logAndThrowException(msg, ex);
    }

    routerMetrics.incrDeleteReservationFailedRetrieved();
    String msg = String.format("Reservation %s failed to be delete.", reservationId);
    RouterAuditLogger.logFailure(user.getShortUserName(), DELETE_RESERVATION, UNKNOWN,
        TARGET_CLIENT_RM_SERVICE, msg);
    throw new YarnException(msg);
  }
@Test
  public void testDeleteReservation() throws Exception {
    LOG.info("Test FederationClientInterceptor : DeleteReservation request.");

    // get new reservationId
    GetNewReservationRequest request = GetNewReservationRequest.newInstance();
    GetNewReservationResponse response = interceptor.getNewReservation(request);
    Assert.assertNotNull(response);

    // allow plan follower to synchronize, manually trigger an assignment
    Map<SubClusterId, MockRM> mockRMs = interceptor.getMockRMs();
    for (MockRM mockRM : mockRMs.values()) {
      ReservationSystem reservationSystem = mockRM.getReservationSystem();
      reservationSystem.synchronizePlan("root.decided", true);
    }

    // Submit Reservation
    ReservationId reservationId = response.getReservationId();
    ReservationDefinition rDefinition = createReservationDefinition(1024, 1);
    ReservationSubmissionRequest rSubmissionRequest = ReservationSubmissionRequest.newInstance(
        rDefinition, "decided", reservationId);

    ReservationSubmissionResponse submissionResponse =
        interceptor.submitReservation(rSubmissionRequest);
    Assert.assertNotNull(submissionResponse);

    // Delete Reservation
    ReservationDeleteRequest deleteRequest = ReservationDeleteRequest.newInstance(reservationId);
    ReservationDeleteResponse deleteResponse = interceptor.deleteReservation(deleteRequest);
    Assert.assertNotNull(deleteResponse);

    LambdaTestUtils.intercept(YarnException.class,
        "Reservation " + reservationId + " does not exist",
        () -> stateStoreUtil.queryReservationHomeSC(reservationId));
  }