2 * Copyright (c) 2015 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.controller.cluster.datastore;
10 import java.util.Collection;
11 import java.util.Collections;
12 import javax.annotation.concurrent.NotThreadSafe;
13 import org.opendaylight.controller.md.sal.dom.spi.AbstractDOMDataTreeChangeListenerRegistration;
14 import org.opendaylight.controller.sal.core.spi.data.AbstractDOMStoreTreeChangePublisher;
15 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
16 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
17 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
18 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidates;
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
23 * Default implementation of ShardDataTreeChangeListenerPublisher that directly generates and publishes
24 * notifications for DataTreeChangeListeners.
26 * @author Thomas Pantelis
29 final class DefaultShardDataTreeChangeListenerPublisher extends AbstractDOMStoreTreeChangePublisher
30 implements ShardDataTreeChangeListenerPublisher {
31 private static final Logger LOG = LoggerFactory.getLogger(DefaultShardDataTreeChangeListenerPublisher.class);
34 public void publishChanges(final DataTreeCandidate candidate, String logContext) {
35 processCandidateTree(candidate);
39 public ShardDataTreeChangeListenerPublisher newInstance() {
40 return new DefaultShardDataTreeChangeListenerPublisher();
44 protected void notifyListeners(final Collection<AbstractDOMDataTreeChangeListenerRegistration<?>> registrations,
45 final YangInstanceIdentifier path, final DataTreeCandidateNode node) {
46 final Collection<DataTreeCandidate> changes = Collections.<DataTreeCandidate>singleton(
47 DataTreeCandidates.newDataTreeCandidate(path, node));
49 for (AbstractDOMDataTreeChangeListenerRegistration<?> reg : registrations) {
50 reg.getInstance().onDataTreeChanged(changes);
55 protected void registrationRemoved(final AbstractDOMDataTreeChangeListenerRegistration<?> registration) {
56 LOG.debug("Registration {} removed", registration);