Avoid overlap of resource allocations

Change-Id: I7b1905ea694039909623fdc0bf3e505799cbdafa
diff --git a/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentLinkResourceStore.java b/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentLinkResourceStore.java
index 11137aa..c332ada5 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentLinkResourceStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentLinkResourceStore.java
@@ -363,6 +363,15 @@
             after.add(allocations);
             linkAllocs.putIfAbsent(linkKey, after);
         } else {
+            boolean overlapped = before.stream()
+                    .flatMap(x -> x.getResourceAllocation(link).stream())
+                    .anyMatch(x -> allocations.getResourceAllocation(link).contains(x));
+            if (overlapped) {
+                throw new ResourceAllocationException(
+                        String.format("Resource allocations are overlapped between %s and %s",
+                        before, allocations)
+                );
+            }
             List<LinkResourceAllocations> after = new ArrayList<>(before.size() + 1);
             after.addAll(before);
             after.add(allocations);