Convert to using BatchedListenerInvoker 74/46374/2
authorRobert Varga <rovarga@cisco.com>
Thu, 22 Sep 2016 18:21:31 +0000 (20:21 +0200)
committerRobert Varga <nite@hq.sk>
Mon, 3 Oct 2016 13:49:40 +0000 (13:49 +0000)
This will deliver all notifications in one go, leading to faster
flushing.

Change-Id: I7a5023fadbfc67a19348963c15ae332986cd18d8
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit f822ec2d88c315709ee845af39920a149b75b580)

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

index df0223e58723ab8e53850b91ea3c2595c067f425..690c5ae4dd2413dda1be27f07dc59e4256da958b 100644 (file)
@@ -17,7 +17,7 @@ import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
 import org.opendaylight.mdsal.dom.spi.AbstractDOMDataTreeChangeListenerRegistration;
 import org.opendaylight.yangtools.util.concurrent.QueuedNotificationManager;
-import org.opendaylight.yangtools.util.concurrent.QueuedNotificationManager.Invoker;
+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;
@@ -30,11 +30,11 @@ final class InMemoryDOMDataTreeShardChangePublisher extends AbstractDOMShardTree
 
     private static final Logger LOG = LoggerFactory.getLogger(InMemoryDOMDataTreeShardChangePublisher.class);
 
-    private static final Invoker<AbstractDOMDataTreeChangeListenerRegistration<?>, DataTreeCandidate>
-        MANAGER_INVOKER = (listener, notification) -> {
+    private static final BatchedInvoker<AbstractDOMDataTreeChangeListenerRegistration<?>, DataTreeCandidate>
+        MANAGER_INVOKER = (listener, notifications) -> {
             final DOMDataTreeChangeListener inst = listener.getInstance();
             if (inst != null) {
-                inst.onDataTreeChanged(ImmutableList.of(notification));
+                inst.onDataTreeChanged(ImmutableList.copyOf(notifications));
             }
         };
 
@@ -47,7 +47,7 @@ final class InMemoryDOMDataTreeShardChangePublisher extends AbstractDOMShardTree
                                             final YangInstanceIdentifier rootPath,
                                             final Map<DOMDataTreeIdentifier, ChildShardContext> childShards) {
         super(dataTree, rootPath, childShards);
-        notificationManager = new QueuedNotificationManager<>(
+        notificationManager = QueuedNotificationManager.create(
                 executor, MANAGER_INVOKER, maxQueueSize, "DataTreeChangeListenerQueueMgr");
     }