@Override
  public RefreshNodesResourcesResponse refreshNodesResources(RefreshNodesResourcesRequest request)
      throws YarnException, IOException {

    // parameter verification.
    if (request == null) {
      routerMetrics.incrRefreshNodesResourcesFailedRetrieved();
      RouterServerUtil.logAndThrowException("Missing RefreshNodesResources request.", null);
    }

    String subClusterId = request.getSubClusterId();
    if (StringUtils.isBlank(subClusterId)) {
      routerMetrics.incrRefreshNodesResourcesFailedRetrieved();
      RouterServerUtil.logAndThrowException("Missing RefreshNodesResources SubClusterId.", null);
    }

    try {
      long startTime = clock.getTime();
      RMAdminProtocolMethod remoteMethod = new RMAdminProtocolMethod(
          new Class[]{RefreshNodesResourcesRequest.class}, new Object[]{request});
      Collection<RefreshNodesResourcesResponse> refreshNodesResourcesResps =
          remoteMethod.invokeConcurrent(this, RefreshNodesResourcesResponse.class, subClusterId);
      if (CollectionUtils.isNotEmpty(refreshNodesResourcesResps)) {
        long stopTime = clock.getTime();
        routerMetrics.succeededRefreshNodesResourcesRetrieved(stopTime - startTime);
        return RefreshNodesResourcesResponse.newInstance();
      }
    } catch (YarnException e) {
      routerMetrics.incrRefreshNodesResourcesFailedRetrieved();
      RouterServerUtil.logAndThrowException(e,
          "Unable to refreshNodesResources due to exception. " + e.getMessage());
    }

    routerMetrics.incrRefreshNodesResourcesFailedRetrieved();
    throw new YarnException("Unable to refreshNodesResources.");
  }
@Test
  public void testRefreshNodesResourcesNormalRequest() throws Exception {
    // case 1, test the existing subCluster (SC-1).
    RefreshNodesResourcesRequest request = RefreshNodesResourcesRequest.newInstance("SC-1");
    RefreshNodesResourcesResponse response = interceptor.refreshNodesResources(request);
    assertNotNull(response);

    // case 2, test the non-exist subCluster.
    RefreshNodesResourcesRequest request1 = RefreshNodesResourcesRequest.newInstance("SC-NON");
    LambdaTestUtils.intercept(Exception.class, "subClusterId = SC-NON is not an active subCluster.",
        () -> interceptor.refreshNodesResources(request1));
  }