Improve global config application 88/82188/1
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 21 May 2019 11:37:51 +0000 (13:37 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 21 May 2019 11:37:51 +0000 (13:37 +0200)
Rather than iterating through all reported changes and publishing
configuration for each of them, acquire the last component and
publish only that.

This leads to faster DTCL (as not all roots need to be acquired)
as well as better atomicity, as readers do not observe intermediate
state if there are multiple changes reported.

Change-Id: I5805566291ea6ebdd6a6c49594fded5aa4243bcb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
netconf/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/CallHomeAuthProviderImpl.java

index 63c25482e9c2027fd967b6b9357e7327b9f52521..b6c0b299e9d4d8d515002a96cc1c8bac7b41a190 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.netconf.callhome.mount;
 
+import com.google.common.collect.Iterables;
 import com.google.common.net.InetAddresses;
 import java.io.IOException;
 import java.net.InetSocketAddress;
@@ -237,8 +238,8 @@ public class CallHomeAuthProviderImpl implements CallHomeAuthorizationProvider,
 
         @Override
         public void onDataTreeChanged(final Collection<DataTreeModification<Global>> mods) {
-            for (DataTreeModification<Global> dataTreeModification : mods) {
-                current = dataTreeModification.getRootNode().getDataAfter();
+            if (!mods.isEmpty()) {
+                current = Iterables.getLast(mods).getRootNode().getDataAfter();
             }
         }