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
commit1a32ce522566a08042846ee14b3df27838ed2e66 (patch)
treefc4199da20f8012f3d9795c1f69d7ad582724a04
parentf19c503b83a5e9ac7205b47152e86159fe50b54a (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