@Override
  public DeleteFederationApplicationResponse deleteFederationApplication(
      DeleteFederationApplicationRequest request) throws YarnException, IOException {

    // Parameter validation.
    if (request == null) {
      routerMetrics.incrDeleteFederationApplicationFailedRetrieved();
      RouterServerUtil.logAndThrowException(
          "Missing deleteFederationApplication Request.", null);
    }

    String application = request.getApplication();
    if (StringUtils.isBlank(application)) {
      routerMetrics.incrDeleteFederationApplicationFailedRetrieved();
      RouterServerUtil.logAndThrowException(
          "ApplicationId cannot be null.", null);
    }

    // Try calling deleteApplicationHomeSubCluster to delete the application.
    try {
      long startTime = clock.getTime();
      ApplicationId applicationId = ApplicationId.fromString(application);
      federationFacade.deleteApplicationHomeSubCluster(applicationId);
      long stopTime = clock.getTime();
      routerMetrics.succeededDeleteFederationApplicationFailedRetrieved(stopTime - startTime);
      return DeleteFederationApplicationResponse.newInstance(
          "applicationId = " + applicationId + " delete success.");
    } catch (Exception e) {
      RouterServerUtil.logAndThrowException(e,
          "Unable to deleteFederationApplication due to exception. " + e.getMessage());
    }

    throw new YarnException("Unable to deleteFederationApplication.");
  }
@Test
  public void testDeleteFederationApplication() throws Exception {
    ApplicationId applicationId = ApplicationId.newInstance(10, 1);
    DeleteFederationApplicationRequest request1 =
        DeleteFederationApplicationRequest.newInstance(applicationId.toString());
    LambdaTestUtils.intercept(YarnException.class,
        "Application application_10_0001 does not exist.",
        () -> interceptor.deleteFederationApplication(request1));

    ApplicationId applicationId2 = ApplicationId.newInstance(10, 2);
    SubClusterId homeSubCluster = SubClusterId.newInstance("SC-1");
    ApplicationHomeSubCluster appHomeSubCluster =
        ApplicationHomeSubCluster.newInstance(applicationId2, homeSubCluster);
    facade.addApplicationHomeSubCluster(appHomeSubCluster);
    DeleteFederationApplicationRequest request2 =
        DeleteFederationApplicationRequest.newInstance(applicationId2.toString());
    DeleteFederationApplicationResponse deleteFederationApplicationResponse =
        interceptor.deleteFederationApplication(request2);
    assertNotNull(deleteFederationApplicationResponse);
    assertEquals("applicationId = " + applicationId2 + " delete success.",
        deleteFederationApplicationResponse.getMessage());
  }