本文整理汇总了Java中org.apache.hadoop.yarn.util.ConverterUtils.toNodeId方法的典型用法代码示例。如果您正苦于以下问题:Java ConverterUtils.toNodeId方法的具体用法?Java ConverterUtils.toNodeId怎么用?Java ConverterUtils.toNodeId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.yarn.util.ConverterUtils
的用法示例。
在下文中一共展示了ConverterUtils.toNodeId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: verifyAndGetNodeId
import org.apache.hadoop.yarn.util.ConverterUtils; //导入方法依赖的package包/类
private NodeId verifyAndGetNodeId(Block html) {
String nodeIdStr = $(NM_NODENAME);
if (nodeIdStr == null || nodeIdStr.isEmpty()) {
html.h1()._("Cannot get container logs without a NodeId")._();
return null;
}
NodeId nodeId = null;
try {
nodeId = ConverterUtils.toNodeId(nodeIdStr);
} catch (IllegalArgumentException e) {
html.h1()._("Cannot get container logs. Invalid nodeId: " + nodeIdStr)
._();
return null;
}
return nodeId;
}
示例2: getNode
import org.apache.hadoop.yarn.util.ConverterUtils; //导入方法依赖的package包/类
@GET
@Path("/nodes/{nodeId}")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public NodeInfo getNode(@PathParam("nodeId") String nodeId) {
init();
if (nodeId == null || nodeId.isEmpty()) {
throw new NotFoundException("nodeId, " + nodeId + ", is empty or null");
}
ResourceScheduler sched = this.rm.getResourceScheduler();
if (sched == null) {
throw new NotFoundException("Null ResourceScheduler instance");
}
NodeId nid = ConverterUtils.toNodeId(nodeId);
RMNode ni = this.rm.getRMContext().getRMNodes().get(nid);
boolean isInactive = false;
if (ni == null) {
ni = this.rm.getRMContext().getInactiveRMNodes().get(nid.getHost());
if (ni == null) {
throw new NotFoundException("nodeId, " + nodeId + ", is not found");
}
isInactive = true;
}
NodeInfo nodeInfo = new NodeInfo(ni, sched);
if (isInactive) {
nodeInfo.setNodeHTTPAddress(EMPTY);
}
return nodeInfo;
}
示例3: printNodeStatus
import org.apache.hadoop.yarn.util.ConverterUtils; //导入方法依赖的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"));
}