Bump yangtools to 3.0.0
[controller.git] / opendaylight / md-sal / sal-inmemory-datastore / src / main / java / org / opendaylight / controller / md / sal / dom / store / impl / InMemoryDOMStoreTreeChangePublisher.java
index e9b559452ac5085c7569be03015b890a62b6b550..3337d1ce9bcdc14c5225978592492eb52943f017 100644 (file)
@@ -8,7 +8,6 @@
 package org.opendaylight.controller.md.sal.dom.store.impl;
 
 import java.util.Collection;
-import java.util.Collections;
 import java.util.Optional;
 import java.util.concurrent.ExecutorService;
 import org.eclipse.jdt.annotation.NonNull;
@@ -17,7 +16,6 @@ import org.opendaylight.controller.md.sal.dom.spi.AbstractDOMDataTreeChangeListe
 import org.opendaylight.controller.sal.core.spi.data.AbstractDOMStoreTreeChangePublisher;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.util.concurrent.QueuedNotificationManager;
-import org.opendaylight.yangtools.util.concurrent.QueuedNotificationManager.Invoker;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
@@ -28,22 +26,20 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 final class InMemoryDOMStoreTreeChangePublisher extends AbstractDOMStoreTreeChangePublisher {
-    private static final Invoker<AbstractDOMDataTreeChangeListenerRegistration<?>, DataTreeCandidate> MANAGER_INVOKER =
-        (listener, notification) -> {
-            // FIXME: this is inefficient, as we could grab the entire queue for the listener and post it
-            listener.getInstance().onDataTreeChanged(Collections.singletonList(notification));
-        };
-
     private static final Logger LOG = LoggerFactory.getLogger(InMemoryDOMStoreTreeChangePublisher.class);
+
     private final QueuedNotificationManager<AbstractDOMDataTreeChangeListenerRegistration<?>, DataTreeCandidate>
             notificationManager;
 
     InMemoryDOMStoreTreeChangePublisher(final ExecutorService listenerExecutor, final int maxQueueSize) {
-        notificationManager = new QueuedNotificationManager<>(listenerExecutor, MANAGER_INVOKER, maxQueueSize,
+        notificationManager = QueuedNotificationManager.create(listenerExecutor, (listener, notifications) -> {
+            // FIXME: we are not checking for listener being closed
+            listener.getInstance().onDataTreeChanged(notifications);
+        }, maxQueueSize,
                 "DataTreeChangeListenerQueueMgr");
     }
 
-    private InMemoryDOMStoreTreeChangePublisher(QueuedNotificationManager<
+    private InMemoryDOMStoreTreeChangePublisher(final QueuedNotificationManager<
             AbstractDOMDataTreeChangeListenerRegistration<?>, DataTreeCandidate> notificationManager) {
         this.notificationManager = notificationManager;
     }