本文整理汇总了Java中org.apache.mesos.Protos.Resource.getName方法的典型用法代码示例。如果您正苦于以下问题:Java Resource.getName方法的具体用法?Java Resource.getName怎么用?Java Resource.getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.mesos.Protos.Resource
的用法示例。
在下文中一共展示了Resource.getName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resourcesToOrderedMap
import org.apache.mesos.Protos.Resource; //导入方法依赖的package包/类
/**
* Return Resource names mapped to values.
*/
private static Map<String, String> resourcesToOrderedMap(List<Resource> resources) {
Map<String, String> map = new TreeMap<>();
for (Resource r : resources) {
String name;
String value = "";
if (r.hasRole()) {
name = r.getName() + "(" + r.getRole() + ")";
} else {
name = r.getName();
}
switch (r.getType()) {
case SCALAR:
value = String.valueOf(r.getScalar().getValue());
break;
case RANGES:
value = rangesToString(r.getRanges());
break;
case SET:
value = setToString(r.getSet());
break;
default:
// If hit, then a new Resource Type needs to be handled here.
value = "Unrecognized Resource Type: `" + r.getType() + "'";
break;
}
map.put(name, value);
}
return map;
}
示例2: getResourceSpec
import org.apache.mesos.Protos.Resource; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
private static ResourceSpec getResourceSpec(Resource resource) {
if (!ResourceUtils.hasResourceId(resource)) {
throw new IllegalStateException(
"Cannot generate resource spec from resource which has not been reserved by the SDK.");
}
return new DefaultResourceSpec(
resource.getName(),
ValueUtils.getValue(resource),
ResourceUtils.getRole(resource),
resource.getRole(),
ResourceUtils.getPrincipal(resource).get());
}