X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=dom%2Fmdsal-dom-inmemory-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fmdsal%2Fdom%2Fstore%2Finmemory%2FInMemoryDOMStoreTreeChangePublisher.java;h=919f888f024121f577285eb2a7e31cff04615d56;hb=41c34ca065881c748d1811b7ba6a5145ce6ed608;hp=8771315e58f635b14e77c705d083312b30fb7a4e;hpb=564120a9eb5d77b947187468f255353fa70ab4df;p=mdsal.git diff --git a/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/InMemoryDOMStoreTreeChangePublisher.java b/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/InMemoryDOMStoreTreeChangePublisher.java index 8771315e58..919f888f02 100644 --- a/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/InMemoryDOMStoreTreeChangePublisher.java +++ b/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/InMemoryDOMStoreTreeChangePublisher.java @@ -7,15 +7,14 @@ */ package org.opendaylight.mdsal.dom.store.inmemory; -import org.opendaylight.mdsal.dom.spi.store.AbstractDOMStoreTreeChangePublisher; - -import org.opendaylight.mdsal.dom.spi.AbstractDOMDataTreeChangeListenerRegistration; -import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener; import com.google.common.base.Optional; import java.util.Collection; import java.util.Collections; import java.util.concurrent.ExecutorService; import javax.annotation.Nonnull; +import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener; +import org.opendaylight.mdsal.dom.spi.AbstractDOMDataTreeChangeListenerRegistration; +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.Invoker; @@ -31,24 +30,29 @@ import org.slf4j.LoggerFactory; final class InMemoryDOMStoreTreeChangePublisher extends AbstractDOMStoreTreeChangePublisher { private static final Invoker, DataTreeCandidate> MANAGER_INVOKER = new Invoker, DataTreeCandidate>() { - @Override - public void invokeListener(final AbstractDOMDataTreeChangeListenerRegistration listener, final DataTreeCandidate notification) { - // FIXME: this is inefficient, as we could grab the entire queue for the listener and post it - final DOMDataTreeChangeListener inst = listener.getInstance(); - if (inst != null) { - inst.onDataTreeChanged(Collections.singletonList(notification)); - } - } - }; + @Override + public void invokeListener(final AbstractDOMDataTreeChangeListenerRegistration listener, + final DataTreeCandidate notification) { + // FIXME: this is inefficient, as we could grab the entire queue for the listener and post it + final DOMDataTreeChangeListener inst = listener.getInstance(); + if (inst != null) { + inst.onDataTreeChanged(Collections.singletonList(notification)); + } + } + }; private static final Logger LOG = LoggerFactory.getLogger(InMemoryDOMStoreTreeChangePublisher.class); - private final QueuedNotificationManager, DataTreeCandidate> notificationManager; + + private final QueuedNotificationManager, DataTreeCandidate> + notificationManager; InMemoryDOMStoreTreeChangePublisher(final ExecutorService listenerExecutor, final int maxQueueSize) { - notificationManager = new QueuedNotificationManager<>(listenerExecutor, MANAGER_INVOKER, maxQueueSize, "DataTreeChangeListenerQueueMgr"); + notificationManager = new QueuedNotificationManager<>(listenerExecutor, MANAGER_INVOKER, maxQueueSize, + "DataTreeChangeListenerQueueMgr"); } @Override - protected void notifyListeners(final Collection> registrations, final YangInstanceIdentifier path, final DataTreeCandidateNode node) { + protected void notifyListeners(final Collection> registrations, + final YangInstanceIdentifier path, final DataTreeCandidateNode node) { final DataTreeCandidate candidate = DataTreeCandidates.newDataTreeCandidate(path, node); for (AbstractDOMDataTreeChangeListenerRegistration reg : registrations) { @@ -58,13 +62,15 @@ final class InMemoryDOMStoreTreeChangePublisher extends AbstractDOMStoreTreeChan } @Override - protected synchronized void registrationRemoved(final AbstractDOMDataTreeChangeListenerRegistration registration) { + protected synchronized void registrationRemoved( + final AbstractDOMDataTreeChangeListenerRegistration registration) { LOG.debug("Closing registration {}", registration); // FIXME: remove the queue for this registration and make sure we clear it } - ListenerRegistration registerTreeChangeListener(final YangInstanceIdentifier treeId, final L listener, final DataTreeSnapshot snapshot) { + ListenerRegistration registerTreeChangeListener( + final YangInstanceIdentifier treeId, final L listener, final DataTreeSnapshot snapshot) { final AbstractDOMDataTreeChangeListenerRegistration reg = registerTreeChangeListener(treeId, listener); final Optional> node = snapshot.readNode(treeId);