本文整理汇总了Java中org.apache.hadoop.yarn.api.records.NodeReport.getAggregatedContainersUtilization方法的典型用法代码示例。如果您正苦于以下问题:Java NodeReport.getAggregatedContainersUtilization方法的具体用法?Java NodeReport.getAggregatedContainersUtilization怎么用?Java NodeReport.getAggregatedContainersUtilization使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.yarn.api.records.NodeReport
的用法示例。
在下文中一共展示了NodeReport.getAggregatedContainersUtilization方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: listDetailedClusterNodes
import org.apache.hadoop.yarn.api.records.NodeReport; //导入方法依赖的package包/类
/**
* Lists the nodes which are matching the given node states along with
* detailed node informations such as resource usage etc.
*
* @param nodeStates
* @throws YarnException
* @throws IOException
*/
private void listDetailedClusterNodes(Set<NodeState> nodeStates)
throws YarnException, IOException {
PrintWriter writer = new PrintWriter(new OutputStreamWriter(sysout,
Charset.forName("UTF-8")));
List<NodeReport> nodesReport = client.getNodeReports(nodeStates
.toArray(new NodeState[0]));
writer.println("Total Nodes:" + nodesReport.size());
writer.printf(NODES_PATTERN, "Node-Id", "Node-State", "Node-Http-Address",
"Number-of-Running-Containers");
for (NodeReport nodeReport : nodesReport) {
writer.printf(NODES_PATTERN, nodeReport.getNodeId(),
nodeReport.getNodeState(), nodeReport.getHttpAddress(),
nodeReport.getNumContainers());
writer.println("Detailed Node Information :");
writer.print("\tConfigured Resources : ");
writer.println(nodeReport.getCapability());
writer.print("\tAllocated Resources : ");
if (nodeReport.getUsed() != null) {
writer.print(nodeReport.getUsed());
}
writer.println();
writer.print("\tResource Utilization by Node : ");
if (nodeReport.getNodeUtilization() != null) {
writer.print("PMem:"
+ nodeReport.getNodeUtilization().getPhysicalMemory()
+ " MB, VMem:" + nodeReport.getNodeUtilization().getVirtualMemory()
+ " MB, VCores:" + nodeReport.getNodeUtilization().getCPU());
}
writer.println();
writer.print("\tResource Utilization by Containers : ");
if (nodeReport.getAggregatedContainersUtilization() != null) {
writer.print("PMem:"
+ nodeReport.getAggregatedContainersUtilization()
.getPhysicalMemory()
+ " MB, VMem:"
+ nodeReport.getAggregatedContainersUtilization()
.getVirtualMemory() + " MB, VCores:"
+ nodeReport.getAggregatedContainersUtilization().getCPU());
}
writer.println();
writer.print("\tNode-Labels : ");
// Create a List for node labels since we need it get sorted
List<String> nodeLabelsList = new ArrayList<String>(
nodeReport.getNodeLabels());
Collections.sort(nodeLabelsList);
writer.println(StringUtils.join(nodeLabelsList.iterator(), ','));
}
writer.flush();
}