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 com.google.common.base.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.api.schema.tree.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(ActorContext actorContext, String actorName, String logContext) {
30 super(actorContext, actorName, logContext);
34 public void registerTreeChangeListener(YangInstanceIdentifier treeId,
35 DOMDataTreeChangeListener listener, Optional<DataTreeCandidate> currentState,
36 Consumer<ListenerRegistration<DOMDataTreeChangeListener>> onRegistration) {
37 final ShardDataTreeChangePublisherActor.RegisterListener regMessage =
38 new ShardDataTreeChangePublisherActor.RegisterListener(treeId, listener, currentState, onRegistration);
39 log.debug("{}: Sending {} to publisher actor {}", logContext(), regMessage, publisherActor());
40 publisherActor().tell(regMessage, ActorRef.noSender());
44 protected Props props() {
45 return ShardDataTreeChangePublisherActor.props(actorName(), logContext());