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>
(cherry picked from commit
3c9bfd451c6b862079a1eb5bb31ec98150b1d18f)
*/
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;
private volatile Global current = null;
@Override
- public void onDataTreeChanged(@Nonnull final Collection<DataTreeModification<Global>> mods) {
- for (DataTreeModification<Global> dataTreeModification : mods) {
- current = dataTreeModification.getRootNode().getDataAfter();
+ public void onDataTreeChanged(final Collection<DataTreeModification<Global>> mods) {
+ if (!mods.isEmpty()) {
+ current = Iterables.getLast(mods).getRootNode().getDataAfter();
}
}