Java Code Examples for org.apache.mesos.Protos.Resource#getName()
The following examples show how to use
org.apache.mesos.Protos.Resource#getName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ComposeRewriteHelper.java From docker-compose-executor with Apache License 2.0 | 6 votes |
private Iterator<Long> getPortMappingIterator(TaskInfo taskInfo) { List<Resource> list = taskInfo.getResourcesList(); List<Long> ports = new ArrayList<Long>(); for (Resource resource : list) { String name = resource.getName(); if ("ports".equals(name)) { Ranges ranges = resource.getRanges(); for (Range range : ranges.getRangeList()) { long startPort = range.getBegin(); long endPort = range.getEnd(); for (int i = 0; i <= endPort - startPort; i++) { ports.add(startPort + i); } } } } return ports.iterator(); }
Example 2
Source File: MesosUtilities.java From oodt with Apache License 2.0 | 6 votes |
/** * Creates string out an offer in a nice format. * @param resource - mesos resource to make into string. * @return string representing a resource. */ public static String getResourceMessage(Resource resource) { Type type = resource.getType(); String ret = resource.getName() +" "+resource.getRole()+ ": "; switch (type) { case SCALAR: ret += resource.getScalar().getValue(); break; case RANGES: for (Range range : resource.getRanges().getRangeList()) ret += range.getBegin() + " - "+range.getEnd()+","; break; case TEXT: ret += " TEXT type...cannot find."; break; case SET: for (String string : resource.getSet().getItemList()) ret += string + ","; break; } return ret; }
Example 3
Source File: BdsMesosScheduler.java From BigDataScript with Apache License 2.0 | 6 votes |
/** * Convert offer to hostResources */ HostResources parseOffer(Offer offer) { HostResources hr = new HostResources(); hr.setMem(0); hr.setCpus(0); for (Resource r : offer.getResourcesList()) { String resourceName = r.getName(); int value = (int) r.getScalar().getValue(); switch (resourceName) { case OFFER_MEM: hr.setMem(MB * value); break; case OFFER_CPUS: hr.setCpus(value); break; } } return hr; }
Example 4
Source File: PrettyProtobuf.java From storm with Apache License 2.0 | 5 votes |
/** * 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 = String.format("%s(%s)", 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 = String.format("Unrecognized Resource Type: `%s'", r.getType()); break; } map.put(name, value); } return map; }