@Override
  public Map<SubClusterId, List<ResourceRequest>> splitResourceRequests(
      List<ResourceRequest> resourceRequests,
      Set<SubClusterId> timedOutSubClusters) throws YarnException {
    if (homeSubcluster == null) {
      throw new FederationPolicyException("No home subcluster available");
    }

    Map<SubClusterId, SubClusterInfo> active = getActiveSubclusters();
    if (!active.containsKey(homeSubcluster)) {
      throw new FederationPolicyException(
          "The local subcluster " + homeSubcluster + " is not active");
    }

    List<ResourceRequest> resourceRequestsCopy =
        new ArrayList<>(resourceRequests);
    return Collections.singletonMap(homeSubcluster, resourceRequestsCopy);
  }
@Test
  public void testHomeSubclusterNotActive() throws YarnException {

    // We setup the home subcluster to a non-existing one
    initializePolicyContext(getPolicy(), mock(WeightedPolicyInfo.class),
        getActiveSubclusters(), "badsc");

    // Verify the request fails because the home subcluster is not available
    try {
      String[] hosts = new String[] {"host0", "host1", "host2", "host3"};
      List<ResourceRequest> resourceRequests = createResourceRequests(
          hosts, 2 * 1024, 2, 1, 3, null, false);
      HomeAMRMProxyPolicy federationPolicy = (HomeAMRMProxyPolicy)getPolicy();
      federationPolicy.splitResourceRequests(resourceRequests,
          new HashSet<SubClusterId>());
      fail("It should fail when the home subcluster is not active");
    } catch(FederationPolicyException e) {
      GenericTestUtils.assertExceptionContains("is not active", e);
    }
  }