Do not implement concepts.Builder
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / ShardDataTreeChangeListenerPublisherActorProxy.java
1 /*
2  * Copyright (c) 2016 Brocade Communications 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 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;
19
20 /**
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.
23  *
24  * @author Thomas Pantelis
25  */
26 class ShardDataTreeChangeListenerPublisherActorProxy extends AbstractShardDataTreeNotificationPublisherActorProxy
27         implements ShardDataTreeChangeListenerPublisher {
28
29     ShardDataTreeChangeListenerPublisherActorProxy(final ActorContext actorContext, final String actorName,
30         final String logContext) {
31         super(actorContext, actorName, logContext);
32     }
33
34     @Override
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());
42     }
43
44     @Override
45     protected Props props() {
46         return ShardDataTreeChangePublisherActor.props(actorName(), logContext());
47     }
48 }