Add sender actor to the ForwardingDataTreeChangeListener
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / ForwardingDataTreeChangeListener.java
index 73b5623..82a30b6 100644 (file)
@@ -12,6 +12,7 @@ import static java.util.Objects.requireNonNull;
 import akka.actor.ActorRef;
 import akka.actor.ActorSelection;
 import java.util.Collection;
+import org.eclipse.jdt.annotation.Nullable;
 import org.opendaylight.controller.cluster.datastore.messages.DataTreeChanged;
 import org.opendaylight.controller.cluster.datastore.messages.OnInitialData;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
@@ -28,25 +29,28 @@ final class ForwardingDataTreeChangeListener implements DOMDataTreeChangeListene
     private static final Logger LOG = LoggerFactory.getLogger(ForwardingDataTreeChangeListener.class);
 
     private final ActorSelection actor;
+    private final ActorRef sendingActor;
 
-    ForwardingDataTreeChangeListener(final ActorSelection actor) {
+    ForwardingDataTreeChangeListener(final ActorSelection actor, @Nullable final ActorRef sendingActor) {
         this.actor = requireNonNull(actor, "actor should not be null");
+        this.sendingActor = sendingActor;
     }
 
     @Override
     public void onDataTreeChanged(final Collection<DataTreeCandidate> changes) {
         LOG.debug("Sending DataTreeChanged to {}", actor);
-        actor.tell(new DataTreeChanged(changes), ActorRef.noSender());
+        actor.tell(new DataTreeChanged(changes), sendingActor);
     }
 
     @Override
     public void onInitialData() {
         LOG.debug("Sending OnInitialData to {}", actor);
-        actor.tell(OnInitialData.INSTANCE, ActorRef.noSender());
+        actor.tell(OnInitialData.INSTANCE, sendingActor);
     }
 
     @Override
     public String toString() {
-        return "ForwardingDataTreeChangeListener [actor=" + actor + "]";
+        return "ForwardingDataTreeChangeListener [actor=" + actor
+            + ", sending actor=" + (sendingActor != null ? sendingActor : "NO_SENDER") + "]";
     }
 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.