Github user tillrohrmann commented on a diff in the pull request:
https://github.com/apache/flink/pull/5114#discussion_r154723216
--- Diff: flink-mesos/src/main/java/org/apache/flink/mesos/Utils.java ---
@@ -101,4 +106,59 @@
.setRole(role)
.build();
}
+
+ /**
+ * Gets a stream of values from a collection of range resources.
+ */
+ public static LongStream rangeValues(Collection<Protos.Resource>
resources) {
+ return resources.stream()
+ .filter(Protos.Resource::hasRanges)
+ .flatMap(r -> r.getRanges().getRangeList().stream())
+ .flatMapToLong(Utils::rangeValues);
+ }
+
+ /**
+ * Gets a stream of values from a range.
+ */
+ public static LongStream rangeValues(Protos.Value.Range range) {
+ return LongStream.rangeClosed(range.getBegin(), range.getEnd());
--- End diff --
Null check for `range` missing.
---