Correctly forward DOMDataTreeChangeListener.onInitialData() 09/96609/1
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 25 Jun 2021 12:13:25 +0000 (14:13 +0200)
committerRobert Varga <nite@hq.sk>
Fri, 25 Jun 2021 14:07:16 +0000 (14:07 +0000)
When registering proxy listener, make sure we do not lose
onInitialData() events.

Change-Id: I2529d64d10f477ad52e90dec15d88c6228a47af0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit d33f2a4667e423fcbff25454f28412a5b3d01a42)

opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractDataStore.java

index 95cd0adc8aa48b71de1b9befe6248637cb9e3e2b..5d74f7bb7b70651b511190093a1750158d60a620 100644 (file)
@@ -20,6 +20,7 @@ import com.google.common.base.Throwables;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.SettableFuture;
 import com.google.common.util.concurrent.Uninterruptibles;
+import java.util.Collection;
 import java.util.Set;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
@@ -47,6 +48,7 @@ import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
 import org.opendaylight.mdsal.dom.spi.store.DOMStoreTreeChangePublisher;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextListener;
 import org.slf4j.Logger;
@@ -351,11 +353,20 @@ public abstract class AbstractDataStore implements DistributedDataStoreInterface
         LOG.debug("Registering tree listener: {} for tree: {} shard: {}, path inside shard: {}",
                 delegate,shardLookup, shardName, insideShard);
 
+        // wrap this in the ClusteredDOMDataTreeChangeLister interface
+        // since we always want clustered registration
         final DataTreeChangeListenerProxy<DOMDataTreeChangeListener> listenerRegistrationProxy =
-                new DataTreeChangeListenerProxy<>(actorUtils,
-                        // wrap this in the ClusteredDOMDataTreeChangeLister interface
-                        // since we always want clustered registration
-                        (ClusteredDOMDataTreeChangeListener) delegate::onDataTreeChanged, insideShard);
+                new DataTreeChangeListenerProxy<>(actorUtils, new ClusteredDOMDataTreeChangeListener() {
+                    @Override
+                    public void onDataTreeChanged(final Collection<DataTreeCandidate> changes) {
+                        delegate.onDataTreeChanged(changes);
+                    }
+
+                    @Override
+                    public void onInitialData() {
+                        delegate.onInitialData();
+                    }
+                }, insideShard);
         listenerRegistrationProxy.init(shardName);
 
         return (ListenerRegistration<L>) listenerRegistrationProxy;