summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2016-06-22 10:59:16 +0200
committerMarek Gradzki <mgradzki@cisco.com>2016-06-22 11:02:17 +0200
commit49794c9e62d4f69ce3f0a106907f3a4332c09b03 (patch)
treeaf36419d11c2f5a0540c53c43a6f37ded8b4954c
parenta760fd96233ae4e95e5b2667cdebc1aff92da800 (diff)
HONEYCOMB-99: perform write/update after delete for all list writers
Order of delete/write/update operations can have side-effects for devices like VPP: Adding more than one IPv4 address can in some circumstances be silently ignored by VPP, therefore in case of updating IPs list, addresses have to be deleted first. Change-Id: I8712827e3c95232dac20a9ee35be1bc5b567bd54 Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
-rw-r--r--v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/write/CompositeListWriter.java16
1 files changed, 10 insertions, 6 deletions
diff --git a/v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/write/CompositeListWriter.java b/v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/write/CompositeListWriter.java
index de1ac39d3..fe9e8d5e3 100644
--- a/v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/write/CompositeListWriter.java
+++ b/v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/write/CompositeListWriter.java
@@ -138,6 +138,16 @@ public class CompositeListWriter<D extends DataObject & Identifiable<K>, K exten
final Map<Object, D> dataBefore = listOfIdentifiableToMap(customizer.extract(currentId, parentDataBefore));
final Map<Object, D> dataAfter = listOfIdentifiableToMap(customizer.extract(currentId, parentDataAfter));
+ // The order of delete/write/update operations can have side-effects for devices like VPP
+ // TODO make it configurable
+
+ // First perform delete:
+ for (Object deletedNodeKey : Sets.difference(dataBefore.keySet(), dataAfter.keySet())) {
+ final D deleted = dataBefore.get(deletedNodeKey);
+ deleteCurrent(currentId, deleted, ctx);
+ }
+
+ // Then write/update:
for (Map.Entry<Object, D> after : dataAfter.entrySet()) {
final D before = dataBefore.get(after.getKey());
if(before == null) {
@@ -147,12 +157,6 @@ public class CompositeListWriter<D extends DataObject & Identifiable<K>, K exten
}
}
- // Delete the rest in dataBefore
- for (Object deletedNodeKey : Sets.difference(dataBefore.keySet(), dataAfter.keySet())) {
- final D deleted = dataBefore.get(deletedNodeKey);
- deleteCurrent(currentId, deleted, ctx);
- }
-
}
@Override