Committed by
Gerrit Code Review
Avoid overlap of resource allocations
Change-Id: I7b1905ea694039909623fdc0bf3e505799cbdafa
Showing
1 changed file
with
9 additions
and
0 deletions
... | @@ -363,6 +363,15 @@ public class ConsistentLinkResourceStore extends | ... | @@ -363,6 +363,15 @@ public class ConsistentLinkResourceStore extends |
363 | after.add(allocations); | 363 | after.add(allocations); |
364 | linkAllocs.putIfAbsent(linkKey, after); | 364 | linkAllocs.putIfAbsent(linkKey, after); |
365 | } else { | 365 | } else { |
366 | + boolean overlapped = before.stream() | ||
367 | + .flatMap(x -> x.getResourceAllocation(link).stream()) | ||
368 | + .anyMatch(x -> allocations.getResourceAllocation(link).contains(x)); | ||
369 | + if (overlapped) { | ||
370 | + throw new ResourceAllocationException( | ||
371 | + String.format("Resource allocations are overlapped between %s and %s", | ||
372 | + before, allocations) | ||
373 | + ); | ||
374 | + } | ||
366 | List<LinkResourceAllocations> after = new ArrayList<>(before.size() + 1); | 375 | List<LinkResourceAllocations> after = new ArrayList<>(before.size() + 1); |
367 | after.addAll(before); | 376 | after.addAll(before); |
368 | after.add(allocations); | 377 | after.add(allocations); | ... | ... |
-
Please register or login to post a comment