2 * Copyright (c) 2016 Brocade Communications 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.ActorContext;
11 import akka.actor.ActorRef;
12 import akka.actor.Props;
13 import java.util.Optional;
14 import java.util.function.Consumer;
15 import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
16 import org.opendaylight.yangtools.concepts.ListenerRegistration;
17 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
18 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidate;
21 * Implementation of ShardDataTreeChangeListenerPublisher that offloads the generation and publication of data tree
22 * change notifications to an actor. This class is NOT thread-safe.
24 * @author Thomas Pantelis
26 class ShardDataTreeChangeListenerPublisherActorProxy extends AbstractShardDataTreeNotificationPublisherActorProxy
27 implements ShardDataTreeChangeListenerPublisher {
29 ShardDataTreeChangeListenerPublisherActorProxy(final ActorContext actorContext, final String actorName,
30 final String logContext) {
31 super(actorContext, actorName, logContext);
35 public void registerTreeChangeListener(final YangInstanceIdentifier treeId,
36 final DOMDataTreeChangeListener listener, final Optional<DataTreeCandidate> currentState,
37 final Consumer<ListenerRegistration<DOMDataTreeChangeListener>> onRegistration) {
38 final ShardDataTreeChangePublisherActor.RegisterListener regMessage =
39 new ShardDataTreeChangePublisherActor.RegisterListener(treeId, listener, currentState, onRegistration);
40 log.debug("{}: Sending {} to publisher actor {}", logContext(), regMessage, publisherActor());
41 publisherActor().tell(regMessage, ActorRef.noSender());
45 protected Props props() {
46 return ShardDataTreeChangePublisherActor.props(actorName(), logContext());