CDS: Implement front-end support for local transactions
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / ShardDataTreeNotificationManager.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 org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener;
11 import org.opendaylight.controller.md.sal.dom.store.impl.DOMImmutableDataChangeEvent;
12 import org.opendaylight.controller.md.sal.dom.store.impl.DataChangeListenerRegistration;
13 import org.opendaylight.yangtools.util.concurrent.NotificationManager;
14 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
15 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory;
18
19 final class ShardDataTreeNotificationManager implements NotificationManager<DataChangeListenerRegistration<?>, DOMImmutableDataChangeEvent> {
20     private static final Logger LOG = LoggerFactory.getLogger(ShardDataTreeNotificationManager.class);
21
22     @Override
23     public void submitNotification(final DataChangeListenerRegistration<?> listener, final DOMImmutableDataChangeEvent notification) {
24         LOG.debug("Notifying listener {} about {}", listener.getInstance(), notification);
25
26         listener.getInstance().onDataChanged(notification);
27     }
28
29     @Override
30     public void submitNotifications(final DataChangeListenerRegistration<?> listener, final Iterable<DOMImmutableDataChangeEvent> notifications) {
31         final AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>> instance = listener.getInstance();
32         LOG.debug("Notifying listener {} about {}", instance, notifications);
33
34         for (DOMImmutableDataChangeEvent n : notifications) {
35             instance.onDataChanged(n);
36         }
37     }
38 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.