Search in sources :

Example 6 with Range

use of org.apache.mesos.v1.Protos.Value.Range in project Singularity by HubSpot.

the class MesosUtils method getAllPorts.

public static List<Long> getAllPorts(List<Resource> resources) {
    Ranges ranges = getRanges(resources, PORTS);
    final List<Long> ports = Lists.newArrayList();
    if (ranges != null) {
        for (Range range : ranges.getRangeList()) {
            for (long port = range.getBegin(); port <= range.getEnd(); port++) {
                ports.add(port);
            }
        }
    }
    return ports;
}
Also used : Ranges(org.apache.mesos.v1.Protos.Value.Ranges) Range(org.apache.mesos.v1.Protos.Value.Range)

Aggregations

Range (org.apache.mesos.v1.Protos.Value.Range)4 Ranges (org.apache.mesos.v1.Protos.Value.Ranges)3 ArrayList (java.util.ArrayList)2 Resource (org.apache.mesos.v1.Protos.Resource)2 Random (java.util.Random)1