本文整理匯總了Java中org.apache.hadoop.yarn.api.records.NodeReport.getNodeLabels方法的典型用法代碼示例。如果您正苦於以下問題:Java NodeReport.getNodeLabels方法的具體用法?Java NodeReport.getNodeLabels怎麽用?Java NodeReport.getNodeLabels使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.hadoop.yarn.api.records.NodeReport
的用法示例。
在下文中一共展示了NodeReport.getNodeLabels方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: printNodeStatus
import org.apache.hadoop.yarn.api.records.NodeReport; //導入方法依賴的package包/類
/**
* Prints the node report for node id.
*
* @param nodeIdStr
* @throws YarnException
*/
private void printNodeStatus(String nodeIdStr) throws YarnException,
IOException {
NodeId nodeId = ConverterUtils.toNodeId(nodeIdStr);
List<NodeReport> nodesReport = client.getNodeReports();
// Use PrintWriter.println, which uses correct platform line ending.
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintWriter nodeReportStr = new PrintWriter(
new OutputStreamWriter(baos, Charset.forName("UTF-8")));
NodeReport nodeReport = null;
for (NodeReport report : nodesReport) {
if (!report.getNodeId().equals(nodeId)) {
continue;
}
nodeReport = report;
nodeReportStr.println("Node Report : ");
nodeReportStr.print("\tNode-Id : ");
nodeReportStr.println(nodeReport.getNodeId());
nodeReportStr.print("\tRack : ");
nodeReportStr.println(nodeReport.getRackName());
nodeReportStr.print("\tNode-State : ");
nodeReportStr.println(nodeReport.getNodeState());
nodeReportStr.print("\tNode-Http-Address : ");
nodeReportStr.println(nodeReport.getHttpAddress());
nodeReportStr.print("\tLast-Health-Update : ");
nodeReportStr.println(DateFormatUtils.format(
new Date(nodeReport.getLastHealthReportTime()),
"E dd/MMM/yy hh:mm:ss:SSzz"));
nodeReportStr.print("\tHealth-Report : ");
nodeReportStr
.println(nodeReport.getHealthReport());
nodeReportStr.print("\tContainers : ");
nodeReportStr.println(nodeReport.getNumContainers());
nodeReportStr.print("\tMemory-Used : ");
nodeReportStr.println((nodeReport.getUsed() == null) ? "0MB"
: (nodeReport.getUsed().getMemory() + "MB"));
nodeReportStr.print("\tMemory-Capacity : ");
nodeReportStr.println(nodeReport.getCapability().getMemory() + "MB");
nodeReportStr.print("\tCPU-Used : ");
nodeReportStr.println((nodeReport.getUsed() == null) ? "0 vcores"
: (nodeReport.getUsed().getVirtualCores() + " vcores"));
nodeReportStr.print("\tCPU-Capacity : ");
nodeReportStr.println(nodeReport.getCapability().getVirtualCores() + " vcores");
nodeReportStr.print("\tGPU-Used : ");
nodeReportStr.println((nodeReport.getUsed() == null) ? "0 gcores"
: (nodeReport.getUsed().getGpuCores() + " gcores"));
nodeReportStr.print("\tGPU-Capacity : ");
nodeReportStr.println(nodeReport.getCapability().getGpuCores() + " gcores");
nodeReportStr.print("\tNode-Labels : ");
// Create a List for node labels since we need it get sorted
List<String> nodeLabelsList =
new ArrayList<String>(report.getNodeLabels());
Collections.sort(nodeLabelsList);
nodeReportStr.println(StringUtils.join(nodeLabelsList.iterator(), ','));
}
if (nodeReport == null) {
nodeReportStr.print("Could not find the node report for node id : "
+ nodeIdStr);
}
nodeReportStr.close();
sysout.println(baos.toString("UTF-8"));
}
示例2: 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();
}
示例3: printNodeStatus
import org.apache.hadoop.yarn.api.records.NodeReport; //導入方法依賴的package包/類
/**
* Prints the node report for node id.
*
* @param nodeIdStr
* @throws YarnException
*/
private void printNodeStatus(String nodeIdStr) throws YarnException,
IOException {
NodeId nodeId = ConverterUtils.toNodeId(nodeIdStr);
List<NodeReport> nodesReport = client.getNodeReports();
// Use PrintWriter.println, which uses correct platform line ending.
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintWriter nodeReportStr = new PrintWriter(
new OutputStreamWriter(baos, Charset.forName("UTF-8")));
NodeReport nodeReport = null;
for (NodeReport report : nodesReport) {
if (!report.getNodeId().equals(nodeId)) {
continue;
}
nodeReport = report;
nodeReportStr.println("Node Report : ");
nodeReportStr.print("\tNode-Id : ");
nodeReportStr.println(nodeReport.getNodeId());
nodeReportStr.print("\tRack : ");
nodeReportStr.println(nodeReport.getRackName());
nodeReportStr.print("\tNode-State : ");
nodeReportStr.println(nodeReport.getNodeState());
nodeReportStr.print("\tNode-Http-Address : ");
nodeReportStr.println(nodeReport.getHttpAddress());
nodeReportStr.print("\tLast-Health-Update : ");
nodeReportStr.println(DateFormatUtils.format(
new Date(nodeReport.getLastHealthReportTime()),
"E dd/MMM/yy hh:mm:ss:SSzz"));
nodeReportStr.print("\tHealth-Report : ");
nodeReportStr
.println(nodeReport.getHealthReport());
nodeReportStr.print("\tContainers : ");
nodeReportStr.println(nodeReport.getNumContainers());
nodeReportStr.print("\tMemory-Used : ");
nodeReportStr.println((nodeReport.getUsed() == null) ? "0MB"
: (nodeReport.getUsed().getMemory() + "MB"));
nodeReportStr.print("\tMemory-Capacity : ");
nodeReportStr.println(nodeReport.getCapability().getMemory() + "MB");
nodeReportStr.print("\tCPU-Used : ");
nodeReportStr.println((nodeReport.getUsed() == null) ? "0 vcores"
: (nodeReport.getUsed().getVirtualCores() + " vcores"));
nodeReportStr.print("\tCPU-Capacity : ");
nodeReportStr.println(nodeReport.getCapability().getVirtualCores() + " vcores");
nodeReportStr.print("\tNode-Labels : ");
// Create a List for node labels since we need it get sorted
List<String> nodeLabelsList =
new ArrayList<String>(report.getNodeLabels());
Collections.sort(nodeLabelsList);
nodeReportStr.println(StringUtils.join(nodeLabelsList.iterator(), ','));
}
if (nodeReport == null) {
nodeReportStr.print("Could not find the node report for node id : "
+ nodeIdStr);
}
nodeReportStr.close();
sysout.println(baos.toString("UTF-8"));
}