@Override
  public GetAttributesToNodesResponse getAttributesToNodes(
      GetAttributesToNodesRequest request) throws YarnException, IOException {
    if (request == null || request.getNodeAttributes() == null) {
      routerMetrics.incrGetAttributesToNodesFailedRetrieved();
      String msg = "Missing getAttributesToNodes request or nodeAttributes.";
      RouterAuditLogger.logFailure(user.getShortUserName(), GET_ATTRIBUTESTONODES, UNKNOWN,
          TARGET_CLIENT_RM_SERVICE, msg);
      RouterServerUtil.logAndThrowException(msg, null);
    }
    long startTime = clock.getTime();
    ClientMethod remoteMethod = new ClientMethod("getAttributesToNodes",
        new Class[] {GetAttributesToNodesRequest.class}, new Object[] {request});
    Collection<GetAttributesToNodesResponse> attributesToNodesResponses = null;
    try {
      attributesToNodesResponses =
          invokeConcurrent(remoteMethod, GetAttributesToNodesResponse.class);
    } catch (Exception ex) {
      routerMetrics.incrGetAttributesToNodesFailedRetrieved();
      String msg = "Unable to get attributes to nodes due to exception.";
      RouterAuditLogger.logFailure(user.getShortUserName(), GET_ATTRIBUTESTONODES, UNKNOWN,
          TARGET_CLIENT_RM_SERVICE, msg);
      RouterServerUtil.logAndThrowException(msg, ex);
    }
    long stopTime = clock.getTime();
    routerMetrics.succeededGetAttributesToNodesRetrieved(stopTime - startTime);
    RouterAuditLogger.logSuccess(user.getShortUserName(), GET_ATTRIBUTESTONODES,
        TARGET_CLIENT_RM_SERVICE);
    return RouterYarnClientUtils.mergeAttributesToNodesResponse(attributesToNodesResponses);
  }
@Test
  public void testGetAttributesToNodes() throws Exception {
    LOG.info("Test FederationClientInterceptor : Get AttributesToNodes request.");

    // null request
    LambdaTestUtils.intercept(YarnException.class, "Missing getAttributesToNodes request " +
        "or nodeAttributes.", () -> interceptor.getAttributesToNodes(null));

    // normal request
    GetAttributesToNodesResponse response =
        interceptor.getAttributesToNodes(GetAttributesToNodesRequest.newInstance());

    Assert.assertNotNull(response);
    Map<NodeAttributeKey, List<NodeToAttributeValue>> attrs = response.getAttributesToNodes();
    Assert.assertNotNull(attrs);
    Assert.assertEquals(4, attrs.size());

    NodeAttribute gpu = NodeAttribute.newInstance(NodeAttribute.PREFIX_CENTRALIZED, "GPU",
        NodeAttributeType.STRING, "nvidia");
    NodeToAttributeValue attributeValue1 =
        NodeToAttributeValue.newInstance("0-host1", gpu.getAttributeValue());
    NodeAttributeKey gpuKey = gpu.getAttributeKey();
    Assert.assertTrue(attrs.get(gpuKey).contains(attributeValue1));
  }