org.apache.hadoop.yarn.api.ApplicationClientProtocol.getNodesToAttributes()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(3.7k)|赞(0)|评价(0)|浏览(87)

本文整理了Java中org.apache.hadoop.yarn.api.ApplicationClientProtocol.getNodesToAttributes()方法的一些代码示例,展示了ApplicationClientProtocol.getNodesToAttributes()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ApplicationClientProtocol.getNodesToAttributes()方法的具体详情如下:
包路径:org.apache.hadoop.yarn.api.ApplicationClientProtocol
类名称:ApplicationClientProtocol
方法名:getNodesToAttributes

ApplicationClientProtocol.getNodesToAttributes介绍

[英]The interface used by client to get node to attributes mappings. in existing cluster.
[中]客户端用于获取节点到属性映射的接口。在现有集群中。

代码示例

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-router

@Override
public GetNodesToAttributesResponse getNodesToAttributes(
  GetNodesToAttributesRequest request) throws YarnException, IOException {
 return clientRMProxy.getNodesToAttributes(request);
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-client

@Override
 public Map<String, Set<NodeAttribute>> getNodeToAttributes(
   Set<String> hostNames) throws YarnException, IOException {
  GetNodesToAttributesRequest request =
    GetNodesToAttributesRequest.newInstance(hostNames);
  return rmClient.getNodesToAttributes(request).getNodeToAttributes();
 }
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-client

private int printAttributesByNode(String[] nodeArray)
  throws YarnException, IOException {
 ApplicationClientProtocol protocol = createApplicationProtocol();
 HashSet<String> nodes = new HashSet<>(Arrays.asList(nodeArray));
 GetNodesToAttributesRequest request =
   GetNodesToAttributesRequest.newInstance(nodes);
 GetNodesToAttributesResponse response =
   protocol.getNodesToAttributes(request);
 Map<String, Set<NodeAttribute>> nodeToAttrs =
   response.getNodeToAttributes();
 ByteArrayOutputStream baos = new ByteArrayOutputStream();
 PrintWriter writer = new PrintWriter(
   new OutputStreamWriter(baos, Charset.forName("UTF-8")));
 writer.printf(NODEATTRIBUTE, "Attribute", "Type", "Value");
 nodeToAttrs.forEach((node, v) -> {
  // print node header
  writer.println(node + ":");
  v.iterator().forEachRemaining(attr -> writer
    .format(NODEATTRIBUTE, getKeyString(attr.getAttributeKey()),
      attr.getAttributeType().name(), attr.getAttributeValue()));
 });
 writer.close();
 sysOut.println(baos.toString("UTF-8"));
 return 0;
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-common

@Override
 public GetNodesToAttributesResponseProto getNodesToAttributes(
   RpcController controller,
   YarnServiceProtos.GetNodesToAttributesRequestProto proto)
   throws ServiceException {
  GetNodesToAttributesRequestPBImpl req =
    new GetNodesToAttributesRequestPBImpl(proto);
  try {
   GetNodesToAttributesResponse resp = real.getNodesToAttributes(req);
   return ((GetNodesToAttributesResponsePBImpl) resp).getProto();
  } catch (YarnException ye) {
   throw new ServiceException(ye);
  } catch (IOException ie) {
   throw new ServiceException(ie);
  }
 }
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager

GetNodesToAttributesRequest.newInstance(null);
GetNodesToAttributesResponse response1 =
  client.getNodesToAttributes(request1);
Map<String, Set<NodeAttribute>> hostToAttrs =
  response1.getNodeToAttributes();
  GetNodesToAttributesRequest.newInstance(ImmutableSet.of(node1));
GetNodesToAttributesResponse response2 =
  client.getNodesToAttributes(request2);
hostToAttrs = response2.getNodeToAttributes();
Assert.assertEquals(1, response2.getNodeToAttributes().size());
  GetNodesToAttributesRequest.newInstance(Collections.emptySet());
GetNodesToAttributesResponse response3 =
  client.getNodesToAttributes(request3);
hostToAttrs = response3.getNodeToAttributes();
Assert.assertEquals(2, hostToAttrs.size());
  GetNodesToAttributesRequest.newInstance(ImmutableSet.of("invalid"));
GetNodesToAttributesResponse response4 =
  client.getNodesToAttributes(request4);
hostToAttrs = response4.getNodeToAttributes();
Assert.assertEquals(0, hostToAttrs.size());

相关文章

微信公众号

最新文章

更多

ApplicationClientProtocol类方法