Merge "Bug 2820 - LLDP TLV support and testing"
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / ShardDataTreeChangePublisher.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.cluster.datastore;
9
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.spi.DefaultDataTreeCandidate;
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
21
22 @NotThreadSafe
23 final class ShardDataTreeChangePublisher extends AbstractDOMStoreTreeChangePublisher {
24     private static final Logger LOG = LoggerFactory.getLogger(ShardDataTreeChangePublisher.class);
25
26     void publishChanges(final DataTreeCandidate candidate) {
27         processCandidateTree(candidate);
28     }
29
30     @Override
31     protected void notifyListeners(final Collection<AbstractDOMDataTreeChangeListenerRegistration<?>> registrations,
32             final YangInstanceIdentifier path, final DataTreeCandidateNode node) {
33         final Collection<DataTreeCandidate> changes = Collections.<DataTreeCandidate>singleton(new DefaultDataTreeCandidate(path, node));
34
35         for (AbstractDOMDataTreeChangeListenerRegistration<?> reg : registrations) {
36             reg.getInstance().onDataTreeChanged(changes);
37         }
38     }
39
40     @Override
41     protected void registrationRemoved(final AbstractDOMDataTreeChangeListenerRegistration<?> registration) {
42         LOG.debug("Registration {} removed", registration);
43     }
44 }