Check registration being closed 56/82556/1
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 30 Apr 2019 03:35:41 +0000 (05:35 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 18 Jun 2019 17:14:46 +0000 (19:14 +0200)
Check if the registration has been closed before firing events.
This way we stop delivering events a bit sooner, improving shutdown
speed and correctness.

JIRA: MDSAL-429
Change-Id: I533f2b07e8cd14597c29d2d3d9c11c44a1bb7ff5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit d90336420645d32d2c4684c7fd3839827e903774)

dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/InMemoryDOMDataTreeShardChangePublisher.java
dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/InMemoryDOMStoreTreeChangePublisher.java

index c2a4c1feaf8ae913f1fbe7b4396004085384aacc..057ebc77ff894278539aecf482e4baff01d3e2ae 100644 (file)
@@ -11,12 +11,10 @@ import com.google.common.collect.ImmutableList;
 import java.util.Collection;
 import java.util.Map;
 import java.util.concurrent.Executor;
-import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
 import org.opendaylight.mdsal.dom.spi.AbstractDOMDataTreeChangeListenerRegistration;
 import org.opendaylight.mdsal.dom.spi.shard.ChildShardContext;
 import org.opendaylight.yangtools.util.concurrent.QueuedNotificationManager;
-import org.opendaylight.yangtools.util.concurrent.QueuedNotificationManager.BatchedInvoker;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
@@ -27,14 +25,6 @@ final class InMemoryDOMDataTreeShardChangePublisher extends AbstractDOMShardTree
 
     private static final Logger LOG = LoggerFactory.getLogger(InMemoryDOMDataTreeShardChangePublisher.class);
 
-    private static final BatchedInvoker<AbstractDOMDataTreeChangeListenerRegistration<?>, DataTreeCandidate>
-        MANAGER_INVOKER = (listener, notifications) -> {
-            final DOMDataTreeChangeListener inst = listener.getInstance();
-            if (inst != null) {
-                inst.onDataTreeChanged(ImmutableList.copyOf(notifications));
-            }
-        };
-
     private final QueuedNotificationManager<AbstractDOMDataTreeChangeListenerRegistration<?>, DataTreeCandidate>
         notificationManager;
 
@@ -44,8 +34,11 @@ final class InMemoryDOMDataTreeShardChangePublisher extends AbstractDOMShardTree
                                             final YangInstanceIdentifier rootPath,
                                             final Map<DOMDataTreeIdentifier, ChildShardContext> childShards) {
         super(dataTree, rootPath, childShards);
-        notificationManager = QueuedNotificationManager.create(executor, MANAGER_INVOKER, maxQueueSize,
-            "DataTreeChangeListenerQueueMgr");
+        notificationManager = QueuedNotificationManager.create(executor, (listener, notifications) -> {
+            if (!listener.isClosed()) {
+                listener.getInstance().onDataTreeChanged(ImmutableList.copyOf(notifications));
+            }
+        }, maxQueueSize, "DataTreeChangeListenerQueueMgr");
     }
 
     @Override
index 9b8e25cd30b48f27a413220a724b68d9ac37c058..d930e5cc72f009c702040decde2a7c39773ec75d 100644 (file)
@@ -19,7 +19,6 @@ import org.opendaylight.mdsal.dom.spi.AbstractDOMDataTreeChangeListenerRegistrat
 import org.opendaylight.mdsal.dom.spi.store.AbstractDOMStoreTreeChangePublisher;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.util.concurrent.QueuedNotificationManager;
-import org.opendaylight.yangtools.util.concurrent.QueuedNotificationManager.BatchedInvoker;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
@@ -30,21 +29,17 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 final class InMemoryDOMStoreTreeChangePublisher extends AbstractDOMStoreTreeChangePublisher {
-    private static final BatchedInvoker<AbstractDOMDataTreeChangeListenerRegistration<?>, DataTreeCandidate>
-        MANAGER_INVOKER = (listener, notifications) -> {
-            final DOMDataTreeChangeListener inst = listener.getInstance();
-            if (inst != null) {
-                inst.onDataTreeChanged(ImmutableList.copyOf(notifications));
-            }
-        };
     private static final Logger LOG = LoggerFactory.getLogger(InMemoryDOMStoreTreeChangePublisher.class);
 
     private final QueuedNotificationManager<AbstractDOMDataTreeChangeListenerRegistration<?>, DataTreeCandidate>
         notificationManager;
 
     InMemoryDOMStoreTreeChangePublisher(final ExecutorService listenerExecutor, final int maxQueueSize) {
-        notificationManager = QueuedNotificationManager.create(listenerExecutor, MANAGER_INVOKER, maxQueueSize,
-                "DataTreeChangeListenerQueueMgr");
+        notificationManager = QueuedNotificationManager.create(listenerExecutor, (listener, notifications) -> {
+            if (!listener.isClosed()) {
+                listener.getInstance().onDataTreeChanged(ImmutableList.copyOf(notifications));
+            }
+        }, maxQueueSize, "DataTreeChangeListenerQueueMgr");
     }
 
     private InMemoryDOMStoreTreeChangePublisher(final QueuedNotificationManager<