@Override
  public DeleteFederationQueuePoliciesResponse deleteFederationPoliciesByQueues(
      DeleteFederationQueuePoliciesRequest request) throws YarnException, IOException {

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

    List<String> queues = request.getQueues();
    if (CollectionUtils.isEmpty(queues)) {
      routerMetrics.incrDeleteFederationPoliciesByQueuesRetrieved();
      RouterServerUtil.logAndThrowException("queues cannot be null.", null);
    }

    // Try calling deleteApplicationHomeSubCluster to delete the application.
    try {
      long startTime = clock.getTime();
      federationFacade.deletePolicyConfigurations(queues);
      long stopTime = clock.getTime();
      routerMetrics.succeededDeleteFederationPoliciesByQueuesRetrieved(stopTime - startTime);
      return DeleteFederationQueuePoliciesResponse.newInstance(
         "queues = " + StringUtils.join(queues, ",") + " delete success.");
    } catch (Exception e) {
      RouterServerUtil.logAndThrowException(e,
          "Unable to deleteFederationPoliciesByQueues due to exception. " + e.getMessage());
    }
    throw new YarnException("Unable to deleteFederationPoliciesByQueues.");
  }
@Test
  public void testDeleteFederationPoliciesByQueues() throws IOException, YarnException {
    // subClusters
    List<String> subClusterLists = new ArrayList<>();
    subClusterLists.add("SC-1");
    subClusterLists.add("SC-2");

    // generate queue A, queue B, queue C
    FederationQueueWeight rootA = generateFederationQueueWeight("root.a", subClusterLists);
    FederationQueueWeight rootB = generateFederationQueueWeight("root.b", subClusterLists);
    FederationQueueWeight rootC = generateFederationQueueWeight("root.c", subClusterLists);

    List<FederationQueueWeight> federationQueueWeights = new ArrayList<>();
    federationQueueWeights.add(rootA);
    federationQueueWeights.add(rootB);
    federationQueueWeights.add(rootC);

    // Step1. Save Queue Policies in Batches
    BatchSaveFederationQueuePoliciesRequest request =
        BatchSaveFederationQueuePoliciesRequest.newInstance(federationQueueWeights);

    BatchSaveFederationQueuePoliciesResponse policiesResponse =
        interceptor.batchSaveFederationQueuePolicies(request);

    assertNotNull(policiesResponse);
    assertNotNull(policiesResponse.getMessage());
    assertEquals("batch save policies success.", policiesResponse.getMessage());

    // Step2. Delete the policy of root.c
    List<String> deleteQueues = new ArrayList<>();
    deleteQueues.add("root.c");
    DeleteFederationQueuePoliciesRequest deleteRequest =
        DeleteFederationQueuePoliciesRequest.newInstance(deleteQueues);
    DeleteFederationQueuePoliciesResponse deleteResponse =
        interceptor.deleteFederationPoliciesByQueues(deleteRequest);
    assertNotNull(deleteResponse);
    String message = deleteResponse.getMessage();
    assertEquals("queues = root.c delete success.", message);
  }