@Override
  public GetSubClustersResponse getFederationSubClusters(GetSubClustersRequest request)
       throws YarnException, IOException {

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

    // Step1. Get all subClusters of the cluster.
    Map<SubClusterId, SubClusterInfo> subClusters =
        federationFacade.getSubClusters(false);

    // Step2. Get FederationSubCluster data.
    List<FederationSubCluster> federationSubClusters = new ArrayList<>();
    long startTime = clock.getTime();
    for (Map.Entry<SubClusterId, SubClusterInfo> subCluster : subClusters.entrySet()) {
      SubClusterId subClusterId = subCluster.getKey();
      try {
        SubClusterInfo subClusterInfo = subCluster.getValue();
        long lastHeartBeat = subClusterInfo.getLastHeartBeat();
        Date lastHeartBeatDate = new Date(lastHeartBeat);
        FederationSubCluster federationSubCluster = FederationSubCluster.newInstance(
            subClusterId.getId(), subClusterInfo.getState().name(), lastHeartBeatDate.toString());
        federationSubClusters.add(federationSubCluster);
      } catch (Exception e) {
        routerMetrics.incrGetFederationSubClustersFailedRetrieved();
        LOG.error("getSubClusters SubClusterId = [%s] error.", subClusterId, e);
      }
    }
    long stopTime = clock.getTime();
    routerMetrics.succeededGetFederationSubClustersRetrieved(stopTime - startTime);

    // Step3. Return results.
    return GetSubClustersResponse.newInstance(federationSubClusters);
  }
@Test
  public void testGetFederationSubClusters() throws Exception {
    LambdaTestUtils.intercept(YarnException.class,
        "Missing getFederationSubClusters Request.",
        () -> interceptor.getFederationSubClusters(null));

    GetSubClustersRequest request = GetSubClustersRequest.newInstance();
    GetSubClustersResponse federationSubClusters = interceptor.getFederationSubClusters(request);
    assertNotNull(federationSubClusters);

    List<FederationSubCluster> federationSubClustersList =
        federationSubClusters.getFederationSubClusters();
    assertNotNull(federationSubClustersList);
    assertEquals(4, federationSubClustersList.size());
  }