2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.mdsal.dom.store.inmemory;
10 import java.util.Collection;
12 import java.util.concurrent.Executor;
13 import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
14 import org.opendaylight.mdsal.dom.spi.AbstractDOMDataTreeChangeListenerRegistration;
15 import org.opendaylight.mdsal.dom.spi.shard.ChildShardContext;
16 import org.opendaylight.yangtools.util.concurrent.QueuedNotificationManager;
17 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
18 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
19 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
23 final class InMemoryDOMDataTreeShardChangePublisher extends AbstractDOMShardTreeChangePublisher {
25 private static final Logger LOG = LoggerFactory.getLogger(InMemoryDOMDataTreeShardChangePublisher.class);
27 private final QueuedNotificationManager<AbstractDOMDataTreeChangeListenerRegistration<?>, DataTreeCandidate>
30 InMemoryDOMDataTreeShardChangePublisher(final Executor executor,
31 final int maxQueueSize,
32 final DataTree dataTree,
33 final YangInstanceIdentifier rootPath,
34 final Map<DOMDataTreeIdentifier, ChildShardContext> childShards) {
35 super(dataTree, rootPath, childShards);
36 notificationManager = QueuedNotificationManager.create(executor, (listener, notifications) -> {
37 // FIXME: we are not checking for listener being closed
38 listener.getInstance().onDataTreeChanged(notifications);
39 }, maxQueueSize, "DataTreeChangeListenerQueueMgr");
43 protected void notifyListener(final AbstractDOMDataTreeChangeListenerRegistration<?> registration,
44 final Collection<DataTreeCandidate> changes) {
45 LOG.debug("Enqueueing candidates {} for registration {}", changes, registration);
46 notificationManager.submitNotifications(registration, changes);
50 protected void registrationRemoved(final AbstractDOMDataTreeChangeListenerRegistration<?> registration) {
51 LOG.debug("Closing registration {}", registration);
55 synchronized void publishChange(final DataTreeCandidate candidate) {
56 processCandidateTree(candidate);