@Override
  public GetNodesToAttributesResponse getNodesToAttributes(
      GetNodesToAttributesRequest request) throws YarnException, IOException {
    if (request == null || request.getHostNames() == null) {
      routerMetrics.incrGetNodesToAttributesFailedRetrieved();
      String msg = "Missing getNodesToAttributes request or hostNames.";
      RouterAuditLogger.logFailure(user.getShortUserName(), GET_NODESTOATTRIBUTES, UNKNOWN,
          TARGET_CLIENT_RM_SERVICE, msg);
      RouterServerUtil.logAndThrowException(msg, null);
    }
    long startTime = clock.getTime();
    ClientMethod remoteMethod = new ClientMethod("getNodesToAttributes",
        new Class[] {GetNodesToAttributesRequest.class}, new Object[] {request});
    Collection<GetNodesToAttributesResponse> nodesToAttributesResponses = null;
    try {
      nodesToAttributesResponses = invokeConcurrent(remoteMethod,
          GetNodesToAttributesResponse.class);
    } catch (Exception ex) {
      routerMetrics.incrGetNodesToAttributesFailedRetrieved();
      String msg = "Unable to get nodes to attributes due to exception.";
      RouterAuditLogger.logFailure(user.getShortUserName(), GET_NODESTOATTRIBUTES, UNKNOWN,
          TARGET_CLIENT_RM_SERVICE, msg);
      RouterServerUtil.logAndThrowException(msg, ex);
    }
    long stopTime = clock.getTime();
    routerMetrics.succeededGetNodesToAttributesRetrieved(stopTime - startTime);
    RouterAuditLogger.logSuccess(user.getShortUserName(), GET_NODESTOATTRIBUTES,
        TARGET_CLIENT_RM_SERVICE);
    return RouterYarnClientUtils.mergeNodesToAttributesResponse(nodesToAttributesResponses);
  }
@Test
  public void testNodesToAttributes() throws Exception {
    LOG.info("Test FederationClientInterceptor : Get NodesToAttributes request.");

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

    // normal request
    Set<String> hostNames = Collections.singleton("0-host1");
    GetNodesToAttributesResponse response =
        interceptor.getNodesToAttributes(GetNodesToAttributesRequest.newInstance(hostNames));
    Assert.assertNotNull(response);

    Map<String, Set<NodeAttribute>> nodeAttributeMap = response.getNodeToAttributes();
    Assert.assertNotNull(nodeAttributeMap);
    Assert.assertEquals(1, nodeAttributeMap.size());

    NodeAttribute gpu = NodeAttribute.newInstance(NodeAttribute.PREFIX_CENTRALIZED, "GPU",
        NodeAttributeType.STRING, "nvida");
    Assert.assertTrue(nodeAttributeMap.get("0-host1").contains(gpu));
  }