@Override
  public GetResourceProfileResponse getResourceProfile(
      GetResourceProfileRequest request) throws YarnException, IOException {
    if (request == null || request.getProfileName() == null) {
      routerMetrics.incrGetResourceProfileFailedRetrieved();
      String msg = "Missing getResourceProfile request or profileName.";
      RouterAuditLogger.logFailure(user.getShortUserName(), GET_RESOURCEPROFILE, UNKNOWN,
          TARGET_CLIENT_RM_SERVICE, msg);
      RouterServerUtil.logAndThrowException(msg, null);
    }
    long startTime = clock.getTime();
    ClientMethod remoteMethod = new ClientMethod("getResourceProfile",
        new Class[] {GetResourceProfileRequest.class}, new Object[] {request});
    Collection<GetResourceProfileResponse> resourceProfile = null;
    try {
      resourceProfile = invokeConcurrent(remoteMethod, GetResourceProfileResponse.class);
    } catch (Exception ex) {
      routerMetrics.incrGetResourceProfileFailedRetrieved();
      String msg = "Unable to get resource profile due to exception.";
      RouterAuditLogger.logFailure(user.getShortUserName(), GET_RESOURCEPROFILE, UNKNOWN,
          TARGET_CLIENT_RM_SERVICE, msg);
      RouterServerUtil.logAndThrowException(msg, ex);
    }
    long stopTime = clock.getTime();
    routerMetrics.succeededGetResourceProfileRetrieved(stopTime - startTime);
    RouterAuditLogger.logSuccess(user.getShortUserName(), GET_RESOURCEPROFILE,
        TARGET_CLIENT_RM_SERVICE);
    return RouterYarnClientUtils.mergeClusterResourceProfileResponse(resourceProfile);
  }
@Test
  public void testGetResourceProfile() throws Exception {
    LOG.info("Test FederationClientInterceptor : Get Resource Profile request.");

    // null request
    LambdaTestUtils.intercept(YarnException.class,
        "Missing getResourceProfile request or profileName.",
        () -> interceptor.getResourceProfile(null));

    // normal request
    GetResourceProfileRequest request = GetResourceProfileRequest.newInstance("maximum");
    GetResourceProfileResponse response = interceptor.getResourceProfile(request);

    Assert.assertNotNull(response);
    Assert.assertEquals(32768, response.getResource().getMemorySize());
    Assert.assertEquals(16, response.getResource().getVirtualCores());

    GetResourceProfileRequest request2 = GetResourceProfileRequest.newInstance("default");
    GetResourceProfileResponse response2 = interceptor.getResourceProfile(request2);

    Assert.assertNotNull(response2);
    Assert.assertEquals(8192, response2.getResource().getMemorySize());
    Assert.assertEquals(8, response2.getResource().getVirtualCores());

    GetResourceProfileRequest request3 = GetResourceProfileRequest.newInstance("minimum");
    GetResourceProfileResponse response3 = interceptor.getResourceProfile(request3);

    Assert.assertNotNull(response3);
    Assert.assertEquals(4096, response3.getResource().getMemorySize());
    Assert.assertEquals(4, response3.getResource().getVirtualCores());
  }