Merge "Event Source: switch from wildcards to regexs"
[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 }