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 javax.annotation.concurrent.NotThreadSafe;
16 import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener;
17 import org.opendaylight.yangtools.concepts.ListenerRegistration;
18 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
19 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
22 * Implementation of ShardDataTreeChangeListenerPublisher that offloads the generation and publication
23 * of data tree change notifications to an actor.
25 * @author Thomas Pantelis
28 class ShardDataTreeChangeListenerPublisherActorProxy extends AbstractShardDataTreeNotificationPublisherActorProxy
29 implements ShardDataTreeChangeListenerPublisher {
31 ShardDataTreeChangeListenerPublisherActorProxy(ActorContext actorContext, String actorName, String logContext) {
32 super(actorContext, actorName, logContext);
36 public void registerTreeChangeListener(YangInstanceIdentifier treeId,
37 DOMDataTreeChangeListener listener, Optional<DataTreeCandidate> currentState,
38 Consumer<ListenerRegistration<DOMDataTreeChangeListener>> onRegistration) {
39 final ShardDataTreeChangePublisherActor.RegisterListener regMessage =
40 new ShardDataTreeChangePublisherActor.RegisterListener(treeId, listener, currentState, onRegistration);
41 log.debug("{}: Sending {} to publisher actor {}", logContext(), regMessage, publisherActor());
42 publisherActor().tell(regMessage, ActorRef.noSender());
46 protected Props props() {
47 return ShardDataTreeChangePublisherActor.props(actorName(), logContext());