From d33f2a4667e423fcbff25454f28412a5b3d01a42 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Fri, 25 Jun 2021 14:13:25 +0200 Subject: [PATCH] Correctly forward DOMDataTreeChangeListener.onInitialData() When registering proxy listener, make sure we do not lose onInitialData() events. Change-Id: I2529d64d10f477ad52e90dec15d88c6228a47af0 Signed-off-by: Robert Varga --- .../cluster/datastore/AbstractDataStore.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractDataStore.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractDataStore.java index 3852978092..70fef4197e 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractDataStore.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractDataStore.java @@ -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; @@ -44,6 +45,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; @@ -348,11 +350,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 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 changes) { + delegate.onDataTreeChanged(changes); + } + + @Override + public void onInitialData() { + delegate.onInitialData(); + } + }, insideShard); listenerRegistrationProxy.init(shardName); return (ListenerRegistration) listenerRegistrationProxy; -- 2.36.6