本文整理汇总了Java中org.apache.hadoop.yarn.util.ConverterUtils.toNodeIdWithDefaultPort方法的典型用法代码示例。如果您正苦于以下问题:Java ConverterUtils.toNodeIdWithDefaultPort方法的具体用法?Java ConverterUtils.toNodeIdWithDefaultPort怎么用?Java ConverterUtils.toNodeIdWithDefaultPort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.yarn.util.ConverterUtils
的用法示例。
在下文中一共展示了ConverterUtils.toNodeIdWithDefaultPort方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getLabelsOnNode
import org.apache.hadoop.yarn.util.ConverterUtils; //导入方法依赖的package包/类
@GET
@Path("/nodes/{nodeId}/get-labels")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public NodeLabelsInfo getLabelsOnNode(@Context HttpServletRequest hsr,
@PathParam("nodeId") String nodeId)
throws IOException {
init();
NodeId nid = ConverterUtils.toNodeIdWithDefaultPort(nodeId);
return new NodeLabelsInfo(
rm.getRMContext().getNodeLabelManager().getLabelsOnNode(nid));
}
示例2: buildNodeLabelsMapFromStr
import org.apache.hadoop.yarn.util.ConverterUtils; //导入方法依赖的package包/类
private Map<NodeId, Set<String>> buildNodeLabelsMapFromStr(String args) {
Map<NodeId, Set<String>> map = new HashMap<NodeId, Set<String>>();
for (String nodeToLabels : args.split("[ \n]")) {
nodeToLabels = nodeToLabels.trim();
if (nodeToLabels.isEmpty() || nodeToLabels.startsWith("#")) {
continue;
}
// "," also supported for compatibility
String[] splits = nodeToLabels.split("=");
int index = 0;
if (splits.length != 2) {
splits = nodeToLabels.split(",");
index = 1;
}
String nodeIdStr = splits[0];
if (index == 0) {
splits = splits[1].split(",");
}
Preconditions.checkArgument(!nodeIdStr.trim().isEmpty(),
"node name cannot be empty");
NodeId nodeId = ConverterUtils.toNodeIdWithDefaultPort(nodeIdStr);
map.put(nodeId, new HashSet<String>());
for (int i = index; i < splits.length; i++) {
if (!splits[i].trim().isEmpty()) {
map.get(nodeId).add(splits[i].trim());
}
}
int nLabels = map.get(nodeId).size();
Preconditions.checkArgument(nLabels <= 1, "%d labels specified on host=%s"
+ ", please note that we do not support specifying multiple"
+ " labels on a single host for now.", nLabels, nodeIdStr);
}
if (map.isEmpty()) {
throw new IllegalArgumentException(NO_MAPPING_ERR_MSG);
}
return map;
}