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 akka.actor.ActorRef;
11 import akka.actor.ActorSelection;
12 import org.opendaylight.controller.cluster.datastore.actors.DataTreeNotificationListenerRegistrationActor;
13 import org.opendaylight.controller.cluster.datastore.messages.RegisterChangeListener;
14 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener;
15 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
16 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
18 final class DataChangeListenerSupport extends AbstractDataListenerSupport<
19 AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>>, RegisterChangeListener> {
21 DataChangeListenerSupport(final Shard shard) {
26 void doRegistration(final RegisterChangeListener message, final ActorRef registrationActor) {
27 final ActorSelection listenerActor = processListenerRegistrationMessage(message);
29 AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>> listener =
30 new DataChangeListenerProxy(listenerActor);
32 log().debug("{}: Registering for path {}", persistenceId(), message.getPath());
34 final ShardDataTree shardDataTree = getShard().getDataStore();
35 shardDataTree.registerDataChangeListener(message.getPath(), listener, message.getScope(),
36 shardDataTree.readCurrentData(), registration -> registrationActor.tell(
37 new DataTreeNotificationListenerRegistrationActor.SetRegistration(registration, () ->
38 removeListenerActor(listenerActor)), ActorRef.noSender()));
42 protected String logName() {
43 return "registerDataChangeListener";