commit | c7ffdfe3da70d0719d2716dfbd79e1d250a41397 | [log] [tgz] |
---|---|---|
author | Sho SHIMIZU <sshimizu@us.fujitsu.com> | Fri May 06 18:38:41 2016 -0700 |
committer | Gerrit Code Review <gerrit@onlab.us> | Thu May 12 18:58:10 2016 +0000 |
tree | b68ccd0c7705131f30b14e09809f2170fb6c4c68 | |
parent | 84ff8fcd94fa66e7d83680ba2f5f2e1ecdecc71f [diff] [blame] |
Refactor: Move allocation check into transactional store implementation Change-Id: Id2381d6789f12c8a0c0730b17e3395d144265f14
diff --git a/core/store/dist/src/main/java/org/onosproject/store/resource/impl/TransactionalContinuousResourceStore.java b/core/store/dist/src/main/java/org/onosproject/store/resource/impl/TransactionalContinuousResourceStore.java index c7a7d6e..c8c91c8 100644 --- a/core/store/dist/src/main/java/org/onosproject/store/resource/impl/TransactionalContinuousResourceStore.java +++ b/core/store/dist/src/main/java/org/onosproject/store/resource/impl/TransactionalContinuousResourceStore.java
@@ -102,6 +102,14 @@ return true; } + // even if one of the resources is allocated to a consumer, + // all unregistrations are regarded as failure + boolean allocated = values.stream().anyMatch(x -> isAllocated(x.id())); + if (allocated) { + log.warn("Failed to unregister {}: allocation exists", key); + return false; + } + Set<ContinuousResource> oldValues = childMap.putIfAbsent(key, new LinkedHashSet<>()); if (oldValues == null) { log.trace("No-Op removing values. key {} did not exist", key);