From 49794c9e62d4f69ce3f0a106907f3a4332c09b03 Mon Sep 17 00:00:00 2001 From: Marek Gradzki Date: Wed, 22 Jun 2016 10:59:16 +0200 Subject: 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 --- .../v3po/translate/impl/write/CompositeListWriter.java | 16 ++++++++++------ 1 file 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, K exten final Map dataBefore = listOfIdentifiableToMap(customizer.extract(currentId, parentDataBefore)); final Map 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 after : dataAfter.entrySet()) { final D before = dataBefore.get(after.getKey()); if(before == null) { @@ -147,12 +157,6 @@ public class CompositeListWriter, 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 -- cgit 1.2.3-korg