public static GetClusterNodeAttributesResponse mergeClusterNodeAttributesResponse(
      Collection<GetClusterNodeAttributesResponse> responses) {
    Set<NodeAttributeInfo> nodeAttributeInfo = new HashSet<>();
    for (GetClusterNodeAttributesResponse response : responses) {
      if (response != null && response.getNodeAttributes() != null) {
        nodeAttributeInfo.addAll(response.getNodeAttributes());
      }
    }
    return GetClusterNodeAttributesResponse.newInstance(nodeAttributeInfo);
  }
@Test
  public void testMergeClusterNodeAttributesResponse() {
    // normal response1
    NodeAttributeInfo nodeAttributeInfo1 =
        NodeAttributeInfo.newInstance(NodeAttributeKey.newInstance("GPU"),
        NodeAttributeType.STRING);
    Set<NodeAttributeInfo> attributes1 = new HashSet<>();
    attributes1.add(nodeAttributeInfo1);
    GetClusterNodeAttributesResponse response1 =
        GetClusterNodeAttributesResponse.newInstance(attributes1);

    // normal response2
    NodeAttributeInfo nodeAttributeInfo2 =
        NodeAttributeInfo.newInstance(NodeAttributeKey.newInstance("CPU"),
        NodeAttributeType.STRING);
    Set<NodeAttributeInfo> attributes2 = new HashSet<>();
    attributes2.add(nodeAttributeInfo2);
    GetClusterNodeAttributesResponse response2 =
        GetClusterNodeAttributesResponse.newInstance(attributes2);

    // empty response3
    GetClusterNodeAttributesResponse response3 =
        GetClusterNodeAttributesResponse.newInstance(new HashSet<>());

    // null response4
    GetClusterNodeAttributesResponse response4 = null;

    List<GetClusterNodeAttributesResponse> responses = new ArrayList<>();
    responses.add(response1);
    responses.add(response2);
    responses.add(response3);
    responses.add(response4);

    GetClusterNodeAttributesResponse response =
        RouterYarnClientUtils.mergeClusterNodeAttributesResponse(responses);

    Assert.assertNotNull(response);

    Set<NodeAttributeInfo> nodeAttributeInfos = response.getNodeAttributes();
    Assert.assertEquals(2, nodeAttributeInfos.size());
    Assert.assertTrue(nodeAttributeInfos.contains(nodeAttributeInfo1));
    Assert.assertTrue(nodeAttributeInfos.contains(nodeAttributeInfo2));
  }