Add more debug logging for DTCL registration/notification code paths 54/56154/3
authorTom Pantelis <tompantelis@gmail.com>
Thu, 27 Apr 2017 11:23:34 +0000 (07:23 -0400)
committerTom Pantelis <tompantelis@gmail.com>
Fri, 28 Apr 2017 17:44:36 +0000 (13:44 -0400)
Added logging so the listener instance and actor can be traced
end-to-end from FE registration to the BE publisher actor.

Also added log context to some classes to identify which shard it
belongs to.

Change-Id: I3e6dd92e7632139372407abf94a160096aa7750e
Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
23 files changed:
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractDataListenerSupport.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractShardDataTreeNotificationPublisherActorProxy.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataTreeChangeListenerActor.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataTreeChangeListenerProxy.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataTreeChangeListenerSupport.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DefaultShardDataChangeListenerPublisher.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DefaultShardDataTreeChangeListenerPublisher.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ForwardingDataTreeChangeListener.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataChangeListenerPublisherActorProxy.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataChangePublisherActor.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTree.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeChangeListenerPublisherActorProxy.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeChangePublisherActor.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeNotificationPublisher.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeNotificationPublisherActor.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/EnableNotification.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/RegisterChangeListener.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/RegisterDataTreeChangeListener.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManager.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/PrefixedShardConfigUpdateHandler.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataChangeListenerTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataTreeChangeListenerActorTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataTreeChangeListenerProxyTest.java

index f9995a28b1436b14e3b3e42c934affba6a5ff69b..15de81e290549080b0d991a093eef5732db4eed2 100644 (file)
@@ -42,7 +42,7 @@ abstract class AbstractDataListenerSupport<L extends EventListener, M extends Li
     void onLeadershipChange(boolean isLeader, boolean hasLeader) {
         log.debug("{}: onLeadershipChange, isLeader: {}, hasLeader : {}", persistenceId(), isLeader, hasLeader);
 
-        final EnableNotification msg = new EnableNotification(isLeader);
+        final EnableNotification msg = new EnableNotification(isLeader, persistenceId());
         for (ActorSelection dataChangeListener : leaderOnlyListenerActors) {
             dataChangeListener.tell(msg, getSelf());
         }
@@ -66,7 +66,8 @@ abstract class AbstractDataListenerSupport<L extends EventListener, M extends Li
 
     @Override
     void onMessage(M message, boolean isLeader, boolean hasLeader) {
-        log.debug("{}: {} for {}, leader: {}", persistenceId(), logName(), message.getPath(), isLeader);
+        log.debug("{}: {} for {}, isLeader: {}, hasLeader: {}", persistenceId(), logName(), message,
+                isLeader, hasLeader);
 
         ActorRef registrationActor = createActor(DataTreeNotificationListenerRegistrationActor.props());
 
@@ -99,7 +100,7 @@ abstract class AbstractDataListenerSupport<L extends EventListener, M extends Li
         final ActorSelection listenerActor = selectActor(message.getListenerActorPath());
 
         // We have a leader so enable the listener.
-        listenerActor.tell(new EnableNotification(true), getSelf());
+        listenerActor.tell(new EnableNotification(true, persistenceId()), getSelf());
 
         if (!message.isRegisterOnAllInstances()) {
             // This is a leader-only registration so store a reference to the listener actor so it can be notified
index 6b348fb76f904e6de35e105b0bc46cf796aabe32..1780bb78b324d6172b482f7212c870997ff222ec 100644 (file)
@@ -24,13 +24,12 @@ import org.slf4j.LoggerFactory;
  */
 @NotThreadSafe
 abstract class AbstractShardDataTreeNotificationPublisherActorProxy implements ShardDataTreeNotificationPublisher {
-    private static final Logger LOG = LoggerFactory.getLogger(
-            AbstractShardDataTreeNotificationPublisherActorProxy.class);
+    protected final Logger log = LoggerFactory.getLogger(getClass());
 
     private final ActorContext actorContext;
     private final String actorName;
     private final String logContext;
-    private ActorRef notifierActor;
+    private ActorRef publisherActor;
 
     protected AbstractShardDataTreeNotificationPublisherActorProxy(ActorContext actorContext, String actorName,
             String logContext) {
@@ -50,21 +49,21 @@ abstract class AbstractShardDataTreeNotificationPublisherActorProxy implements S
     }
 
     @Override
-    public void publishChanges(DataTreeCandidate candidate, String logContext) {
-        notifierActor().tell(new ShardDataTreeNotificationPublisherActor.PublishNotifications(candidate),
+    public void publishChanges(DataTreeCandidate candidate) {
+        publisherActor().tell(new ShardDataTreeNotificationPublisherActor.PublishNotifications(candidate),
                 ActorRef.noSender());
     }
 
-    protected final ActorRef notifierActor() {
-        if (notifierActor == null) {
-            LOG.debug("Creating actor {}", actorName);
-
+    protected final ActorRef publisherActor() {
+        if (publisherActor == null) {
             String dispatcher = new Dispatchers(actorContext.system().dispatchers()).getDispatcherPath(
                     Dispatchers.DispatcherType.Notification);
-            notifierActor = actorContext.actorOf(props().withDispatcher(dispatcher).withMailbox(
+            publisherActor = actorContext.actorOf(props().withDispatcher(dispatcher).withMailbox(
                     org.opendaylight.controller.cluster.datastore.utils.ActorContext.BOUNDED_MAILBOX), actorName);
+
+            log.debug("{}: Created publisher actor {} with name {}", logContext, publisherActor, actorName);
         }
 
-        return notifierActor;
+        return publisherActor;
     }
 }
index 2936a28b90a1f77cc640602c977751597fc8008b..902156f3468867df4986bc159407fc139072a282 100644 (file)
@@ -24,6 +24,7 @@ final class DataTreeChangeListenerActor extends AbstractUntypedActor {
     private final DOMDataTreeChangeListener listener;
     private final YangInstanceIdentifier registeredPath;
     private boolean notificationsEnabled = false;
+    private String logContext = "";
 
     private DataTreeChangeListenerActor(final DOMDataTreeChangeListener listener,
             final YangInstanceIdentifier registeredPath) {
@@ -46,16 +47,18 @@ final class DataTreeChangeListenerActor extends AbstractUntypedActor {
     private void dataChanged(final DataTreeChanged message) {
         // Do nothing if notifications are not enabled
         if (!notificationsEnabled) {
-            LOG.debug("Notifications not enabled for listener {} - dropping change notification", listener);
+            LOG.debug("{}: Notifications not enabled for listener {} - dropping change notification",
+                    logContext, listener);
             return;
         }
 
-        LOG.debug("Sending change notification {} to listener {}", message.getChanges(), listener);
+        LOG.debug("{}: Sending {} change notification(s) {} to listener {}", logContext, message.getChanges().size(),
+                message.getChanges(), listener);
 
         try {
             this.listener.onDataTreeChanged(message.getChanges());
         } catch (Exception e) {
-            LOG.error("Error notifying listener {}", this.listener, e);
+            LOG.error("{}: Error notifying listener {}", logContext, this.listener, e);
         }
 
         // TODO: do we really need this?
@@ -67,8 +70,9 @@ final class DataTreeChangeListenerActor extends AbstractUntypedActor {
     }
 
     private void enableNotification(final EnableNotification message) {
+        logContext = message.getLogContext();
         notificationsEnabled = message.isEnabled();
-        LOG.debug("{} notifications for listener {}", notificationsEnabled ? "Enabled" : "Disabled",
+        LOG.debug("{}: {} notifications for listener {}", logContext, notificationsEnabled ? "Enabled" : "Disabled",
                 listener);
     }
 
index dd280a6c08bc505fc279354f18b200377a6f4765..5f5114d399c0485453449e08e70a6055c5accfc1 100644 (file)
@@ -50,6 +50,9 @@ final class DataTreeChangeListenerProxy<T extends DOMDataTreeChangeListener> ext
         this.dataChangeListenerActor = actorContext.getActorSystem().actorOf(
                 DataTreeChangeListenerActor.props(getInstance(), registeredPath)
                     .withDispatcher(actorContext.getNotificationDispatcherPath()));
+
+        LOG.debug("{}: Created actor {} for DTCL {}", actorContext.getDatastoreContext().getLogicalStoreType(),
+                dataChangeListenerActor, listener);
     }
 
     @Override
@@ -69,11 +72,12 @@ final class DataTreeChangeListenerProxy<T extends DOMDataTreeChangeListener> ext
             @Override
             public void onComplete(final Throwable failure, final ActorRef shard) {
                 if (failure instanceof LocalShardNotFoundException) {
-                    LOG.debug("No local shard found for {} - DataTreeChangeListener {} at path {} "
-                            + "cannot be registered", shardName, getInstance(), registeredPath);
+                    LOG.debug("{}: No local shard found for {} - DataTreeChangeListener {} at path {} "
+                            + "cannot be registered", logContext(), shardName, getInstance(), registeredPath);
                 } else if (failure != null) {
-                    LOG.error("Failed to find local shard {} - DataTreeChangeListener {} at path {} "
-                            + "cannot be registered: {}", shardName, getInstance(), registeredPath, failure);
+                    LOG.error("{}: Failed to find local shard {} - DataTreeChangeListener {} at path {} "
+                            + "cannot be registered: {}", logContext(), shardName, getInstance(), registeredPath,
+                            failure);
                 } else {
                     doRegistration(shard);
                 }
@@ -83,7 +87,7 @@ final class DataTreeChangeListenerProxy<T extends DOMDataTreeChangeListener> ext
 
     private void setListenerRegistrationActor(final ActorSelection actor) {
         if (actor == null) {
-            LOG.debug("Ignoring null actor on {}", this);
+            LOG.debug("{}: Ignoring null actor on {}", logContext(), this);
             return;
         }
 
@@ -109,7 +113,7 @@ final class DataTreeChangeListenerProxy<T extends DOMDataTreeChangeListener> ext
             @Override
             public void onComplete(final Throwable failure, final Object result) {
                 if (failure != null) {
-                    LOG.error("Failed to register DataTreeChangeListener {} at path {}",
+                    LOG.error("{}: Failed to register DataTreeChangeListener {} at path {}", logContext(),
                             getInstance(), registeredPath, failure);
                 } else {
                     RegisterDataTreeChangeListenerReply reply = (RegisterDataTreeChangeListenerReply) result;
@@ -129,4 +133,8 @@ final class DataTreeChangeListenerProxy<T extends DOMDataTreeChangeListener> ext
     ActorRef getDataChangeListenerActor() {
         return dataChangeListenerActor;
     }
+
+    private String logContext() {
+        return actorContext.getDatastoreContext().getLogicalStoreType().toString();
+    }
 }
index f250fb2904a76230c80475f15c3209c96dcf467d..a3ed4a19c9b31de30d5c53dc569b95d6d6697566 100644 (file)
@@ -27,7 +27,7 @@ final class DataTreeChangeListenerSupport extends AbstractDataListenerSupport<DO
 
         DOMDataTreeChangeListener listener = new ForwardingDataTreeChangeListener(listenerActor);
 
-        log().debug("{}: Registering for path {}", persistenceId(), message.getPath());
+        log().debug("{}: Registering listenerActor {} for path {}", persistenceId(), listenerActor, message.getPath());
 
         final ShardDataTree shardDataTree = getShard().getDataStore();
         shardDataTree.registerTreeChangeListener(message.getPath(),
index 98083a0b1c9a7e5932e32d3aba29aa9c8334321a..89da5b2621b7322eda587c889c8c0a376742421c 100644 (file)
@@ -36,11 +36,16 @@ final class DefaultShardDataChangeListenerPublisher implements ShardDataChangeLi
     private static final Logger LOG = LoggerFactory.getLogger(DefaultShardDataChangeListenerPublisher.class);
 
     private final ListenerTree dataChangeListenerTree = ListenerTree.create();
+    private final String logContext;
+
+    DefaultShardDataChangeListenerPublisher(String logContext) {
+        this.logContext = logContext;
+    }
 
     @Override
     public void submitNotification(final DataChangeListenerRegistration<?> listener,
             final DOMImmutableDataChangeEvent notification) {
-        LOG.debug("Notifying listener {} about {}", listener.getInstance(), notification);
+        LOG.debug("{}: Notifying listener {} about {}", logContext, listener.getInstance(), notification);
 
         listener.getInstance().onDataChanged(notification);
     }
@@ -49,7 +54,7 @@ final class DefaultShardDataChangeListenerPublisher implements ShardDataChangeLi
     public void submitNotifications(final DataChangeListenerRegistration<?> listener,
             final Iterable<DOMImmutableDataChangeEvent> notifications) {
         final AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>> instance = listener.getInstance();
-        LOG.debug("Notifying listener {} about {}", instance, notifications);
+        LOG.debug("{}: Notifying listener {} about {}", logContext, instance, notifications);
 
         for (DOMImmutableDataChangeEvent n : notifications) {
             instance.onDataChanged(n);
@@ -57,7 +62,7 @@ final class DefaultShardDataChangeListenerPublisher implements ShardDataChangeLi
     }
 
     @Override
-    public void publishChanges(DataTreeCandidate candidate, String logContext) {
+    public void publishChanges(DataTreeCandidate candidate) {
         ResolveDataChangeEventsTask.create(candidate, dataChangeListenerTree).resolve(this);
     }
 
@@ -73,15 +78,15 @@ final class DefaultShardDataChangeListenerPublisher implements ShardDataChangeLi
         onRegistration.accept(registration);
 
         if (initialState.isPresent()) {
-            notifySingleListener(path, listener, scope, initialState.get());
+            notifySingleListener(path, listener, scope, initialState.get(), logContext);
         }
     }
 
     static void notifySingleListener(final YangInstanceIdentifier path,
             final AsyncDataChangeListener<YangInstanceIdentifier,NormalizedNode<?, ?>> listener,
-            final DataChangeScope scope, final DataTreeCandidate initialState) {
-        DefaultShardDataChangeListenerPublisher publisher = new DefaultShardDataChangeListenerPublisher();
+            final DataChangeScope scope, final DataTreeCandidate initialState, String logContext) {
+        DefaultShardDataChangeListenerPublisher publisher = new DefaultShardDataChangeListenerPublisher(logContext);
         publisher.registerDataChangeListener(path, listener, scope, Optional.absent(), noop -> { });
-        publisher.publishChanges(initialState, "");
+        publisher.publishChanges(initialState);
     }
 }
index 02326e0f84364ab65e007224a09f6a8217f33f96..895ce30e8ba10ebd16f3bffddac94e706fd8d01c 100644 (file)
@@ -30,15 +30,22 @@ import org.slf4j.LoggerFactory;
 final class DefaultShardDataTreeChangeListenerPublisher extends AbstractDOMStoreTreeChangePublisher
         implements ShardDataTreeChangeListenerPublisher {
     private static final Logger LOG = LoggerFactory.getLogger(DefaultShardDataTreeChangeListenerPublisher.class);
+    private String logContext;
+
+    DefaultShardDataTreeChangeListenerPublisher(String logContext) {
+        this.logContext = logContext;
+    }
 
     @Override
-    public void publishChanges(final DataTreeCandidate candidate, String logContext) {
+    public void publishChanges(final DataTreeCandidate candidate) {
+        LOG.debug("{}: publishChanges: {}", logContext, candidate);
         processCandidateTree(candidate);
     }
 
     @Override
     protected void notifyListener(AbstractDOMDataTreeChangeListenerRegistration<?> registration,
             Collection<DataTreeCandidate> changes) {
+        LOG.debug("{}: notifyListener: listener: {}", logContext, registration.getInstance());
         registration.getInstance().onDataTreeChanged(changes);
     }
 
@@ -51,10 +58,10 @@ final class DefaultShardDataTreeChangeListenerPublisher extends AbstractDOMStore
     public void registerTreeChangeListener(YangInstanceIdentifier treeId, DOMDataTreeChangeListener listener,
             Optional<DataTreeCandidate> initialState,
             Consumer<ListenerRegistration<DOMDataTreeChangeListener>> onRegistration) {
+        LOG.debug("{}: registerTreeChangeListener: path: {}, listener: {}", logContext, treeId, listener);
+
         AbstractDOMDataTreeChangeListenerRegistration<org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener>
-            registration = super.registerTreeChangeListener(treeId,
-                (org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener)changes ->
-                    listener.onDataTreeChanged(changes));
+            registration = super.registerTreeChangeListener(treeId, new ForwardingDOMDataTreeChangeListener(listener));
 
         onRegistration.accept(
             new org.opendaylight.controller.md.sal.dom.spi.AbstractDOMDataTreeChangeListenerRegistration<
@@ -66,14 +73,36 @@ final class DefaultShardDataTreeChangeListenerPublisher extends AbstractDOMStore
             });
 
         if (initialState.isPresent()) {
-            notifySingleListener(treeId, listener, initialState.get());
+            notifySingleListener(treeId, listener, initialState.get(), logContext);
         }
     }
 
     static void notifySingleListener(YangInstanceIdentifier treeId, DOMDataTreeChangeListener listener,
-            DataTreeCandidate state) {
-        DefaultShardDataTreeChangeListenerPublisher publisher = new DefaultShardDataTreeChangeListenerPublisher();
+            DataTreeCandidate state, String logContext) {
+        LOG.debug("{}: notifySingleListener: path: {}, listener: {}", logContext, treeId, listener);
+        DefaultShardDataTreeChangeListenerPublisher publisher =
+                new DefaultShardDataTreeChangeListenerPublisher(logContext);
+        publisher.logContext = logContext;
         publisher.registerTreeChangeListener(treeId, listener, Optional.absent(), noop -> { });
-        publisher.publishChanges(state, "");
+        publisher.publishChanges(state);
+    }
+
+    private static class ForwardingDOMDataTreeChangeListener
+            implements org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener {
+        final DOMDataTreeChangeListener delegate;
+
+        ForwardingDOMDataTreeChangeListener(DOMDataTreeChangeListener delegate) {
+            this.delegate = delegate;
+        }
+
+        @Override
+        public void onDataTreeChanged(Collection<DataTreeCandidate> changes) {
+            delegate.onDataTreeChanged(changes);
+        }
+
+        @Override
+        public String toString() {
+            return delegate.toString();
+        }
     }
 }
index 12e4294916219fa824bb692f300ebf50568c2b63..6cda0de15217c758ee1b04eb51da42b50a78b90d 100644 (file)
@@ -14,6 +14,8 @@ import java.util.Collection;
 import org.opendaylight.controller.cluster.datastore.messages.DataTreeChanged;
 import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Internal implementation of a {@link DOMDataTreeChangeListener} which
@@ -21,6 +23,8 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
  * message and forwards them towards the client's {@link DataTreeChangeListenerActor}.
  */
 final class ForwardingDataTreeChangeListener implements DOMDataTreeChangeListener {
+    private static final Logger LOG = LoggerFactory.getLogger(ForwardingDataTreeChangeListener.class);
+
     private final ActorSelection actor;
 
     ForwardingDataTreeChangeListener(final ActorSelection actor) {
@@ -29,6 +33,12 @@ final class ForwardingDataTreeChangeListener implements DOMDataTreeChangeListene
 
     @Override
     public void onDataTreeChanged(Collection<DataTreeCandidate> changes) {
+        LOG.debug("Sending DataTreeChanged to {}", actor);
         actor.tell(new DataTreeChanged(changes), ActorRef.noSender());
     }
+
+    @Override
+    public String toString() {
+        return "ForwardingDataTreeChangeListener [actor=" + actor + "]";
+    }
 }
index a17c603596d1e9b0d8045f521bfb08b23c3953fa..28b58f72628d04131bd45c4deb972592d704fdf6 100644 (file)
@@ -40,7 +40,7 @@ class ShardDataChangeListenerPublisherActorProxy extends AbstractShardDataTreeNo
             Optional<DataTreeCandidate> initialState,
             Consumer<ListenerRegistration<AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>>>>
                 onRegistration) {
-        notifierActor().tell(new ShardDataChangePublisherActor.RegisterListener(path, listener, scope, initialState,
+        publisherActor().tell(new ShardDataChangePublisherActor.RegisterListener(path, listener, scope, initialState,
                 onRegistration), ActorRef.noSender());
     }
 
index cb7d80dbdc199b36ab031ec32f08134dfd3c0901..ef40480e4d86fbf7fd15d70e613fedaaaaff3ee6 100644 (file)
@@ -27,7 +27,7 @@ public class ShardDataChangePublisherActor
         extends ShardDataTreeNotificationPublisherActor<ShardDataChangeListenerPublisher> {
 
     private ShardDataChangePublisherActor(final String name, final String logContext) {
-        super(new DefaultShardDataChangeListenerPublisher(), name, logContext);
+        super(new DefaultShardDataChangeListenerPublisher(logContext), name, logContext);
     }
 
     @Override
@@ -36,7 +36,7 @@ public class ShardDataChangePublisherActor
             RegisterListener reg = (RegisterListener)message;
             if (reg.initialState.isPresent()) {
                 DefaultShardDataChangeListenerPublisher.notifySingleListener(reg.path, reg.listener, reg.scope,
-                        reg.initialState.get());
+                        reg.initialState.get(), logContext());
             }
 
             publisher().registerDataChangeListener(reg.path, reg.listener, reg.scope, Optional.absent(),
index 1460982bf3d4010fa4558074033dd3df7b510033..4eeed882fa1a3ee63a7f9deea5a04d2957212b4b 100644 (file)
@@ -163,7 +163,8 @@ public class ShardDataTree extends ShardDataTreeTransactionParent {
     @VisibleForTesting
     public ShardDataTree(final Shard shard, final SchemaContext schemaContext, final TreeType treeType) {
         this(shard, schemaContext, treeType, YangInstanceIdentifier.EMPTY,
-                new DefaultShardDataTreeChangeListenerPublisher(), new DefaultShardDataChangeListenerPublisher(), "");
+                new DefaultShardDataTreeChangeListenerPublisher(""),
+                new DefaultShardDataChangeListenerPublisher(""), "");
     }
 
     final String logContext() {
@@ -538,8 +539,8 @@ public class ShardDataTree extends ShardDataTreeTransactionParent {
 
     @VisibleForTesting
     public void notifyListeners(final DataTreeCandidate candidate) {
-        treeChangeListenerPublisher.publishChanges(candidate, logContext);
-        dataChangeListenerPublisher.publishChanges(candidate, logContext);
+        treeChangeListenerPublisher.publishChanges(candidate);
+        dataChangeListenerPublisher.publishChanges(candidate);
     }
 
     /**
index ceaeeccaad8b700a9c262f25cdc7d1f50f590f60..020319203b0ccfccb423545534cfcae0ff61d1b1 100644 (file)
@@ -36,8 +36,10 @@ class ShardDataTreeChangeListenerPublisherActorProxy extends AbstractShardDataTr
     public void registerTreeChangeListener(YangInstanceIdentifier treeId,
             DOMDataTreeChangeListener listener, Optional<DataTreeCandidate> currentState,
             Consumer<ListenerRegistration<DOMDataTreeChangeListener>> onRegistration) {
-        notifierActor().tell(new ShardDataTreeChangePublisherActor.RegisterListener(treeId, listener, currentState,
-                onRegistration), ActorRef.noSender());
+        final ShardDataTreeChangePublisherActor.RegisterListener regMessage =
+                new ShardDataTreeChangePublisherActor.RegisterListener(treeId, listener, currentState, onRegistration);
+        log.debug("{}: Sending {} to publisher actor {}", logContext(), regMessage, publisherActor());
+        publisherActor().tell(regMessage, ActorRef.noSender());
     }
 
     @Override
index f054ccdae8258c6246317cd7cb18bfc47364471d..61a3fa13be6415c27e839580df9e2eac1d58258a 100644 (file)
@@ -25,16 +25,17 @@ public class ShardDataTreeChangePublisherActor
         extends ShardDataTreeNotificationPublisherActor<ShardDataTreeChangeListenerPublisher> {
 
     private ShardDataTreeChangePublisherActor(final String name, final String logContext) {
-        super(new DefaultShardDataTreeChangeListenerPublisher(), name, logContext);
+        super(new DefaultShardDataTreeChangeListenerPublisher(logContext), name, logContext);
     }
 
     @Override
     protected void handleReceive(Object message) {
         if (message instanceof RegisterListener) {
             RegisterListener reg = (RegisterListener)message;
+            LOG.debug("{}: Received {}", logContext(), reg);
             if (reg.initialState.isPresent()) {
                 DefaultShardDataTreeChangeListenerPublisher.notifySingleListener(reg.path, reg.listener,
-                        reg.initialState.get());
+                        reg.initialState.get(), logContext());
             }
 
             publisher().registerTreeChangeListener(reg.path, reg.listener, Optional.absent(), reg.onRegistration);
@@ -61,5 +62,11 @@ public class ShardDataTreeChangePublisherActor
             this.initialState = Preconditions.checkNotNull(initialState);
             this.onRegistration = Preconditions.checkNotNull(onRegistration);
         }
+
+        @Override
+        public String toString() {
+            return "RegisterListener [path=" + path + ", listener=" + listener + ", initialState present="
+                    + initialState.isPresent() + "]";
+        }
     }
 }
index 30b7eaf2ae5f8e5e29a843f01aeafecdbd41c1bf..4dbd818488c29243116f191469f959d6eb3a42ed 100644 (file)
@@ -18,5 +18,5 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
 interface ShardDataTreeNotificationPublisher {
     long PUBLISH_DELAY_THRESHOLD_IN_MS = TimeUnit.MILLISECONDS.convert(1, TimeUnit.SECONDS);
 
-    void publishChanges(DataTreeCandidate candidate, String logContext);
+    void publishChanges(DataTreeCandidate candidate);
 }
index ea088308299272f4cbf9cf30cda48fddd454f3ca..c22bc3bd98930c2e561a7b4f9b06083da1dfb8d0 100644 (file)
@@ -46,7 +46,7 @@ public class ShardDataTreeNotificationPublisherActor<T extends ShardDataTreeNoti
             timer.start();
 
             try {
-                publisher.publishChanges(toPublish.candidate, logContext);
+                publisher.publishChanges(toPublish.candidate);
             } finally {
                 long elapsedTime = timer.elapsed(TimeUnit.MILLISECONDS);
 
index 67dab7e663557e6236de61df5b11a7ff39cc02c0..3cd96177f5c52c7edd4a9b2522ca8c2c77cd09a1 100644 (file)
@@ -10,12 +10,18 @@ package org.opendaylight.controller.cluster.datastore.messages;
 
 public class EnableNotification {
     private final boolean enabled;
+    private final String logContext;
 
-    public EnableNotification(boolean enabled) {
+    public EnableNotification(boolean enabled, String logContext) {
         this.enabled = enabled;
+        this.logContext = logContext;
     }
 
     public boolean isEnabled() {
         return enabled;
     }
+
+    public String getLogContext() {
+        return logContext;
+    }
 }
index 163525a8ca57f1496e8b932c7851e6a618a9f988..d83ff2483a099c1b5c1e635ea78d91e680adc4f8 100644 (file)
@@ -45,4 +45,10 @@ public class RegisterChangeListener implements ListenerRegistrationMessage {
     public boolean isRegisterOnAllInstances() {
         return registerOnAllInstances;
     }
+
+    @Override
+    public String toString() {
+        return "RegisterChangeListener [path=" + path + ", scope=" + scope + ", registerOnAllInstances="
+                + registerOnAllInstances + ", dataChangeListenerActor=" + dataChangeListenerActor + "]";
+    }
 }
index abf072b640aa08b57855cd9eb5dba34d8089af7f..e091b5bd0ffcb8c99759c53c2628facf0201dfa1 100644 (file)
@@ -66,4 +66,10 @@ public final class RegisterDataTreeChangeListener implements Externalizable, Lis
         path = SerializationUtils.deserializePath(in);
         registerOnAllInstances = in.readBoolean();
     }
+
+    @Override
+    public String toString() {
+        return "RegisterDataTreeChangeListener [path=" + path + ", registerOnAllInstances=" + registerOnAllInstances
+                + ", dataTreeChangeListenerPath=" + dataTreeChangeListenerPath + "]";
+    }
 }
index 4ae15407763d494156431da07a9f159ff87f57c1..a8eebf83a6da5b2516a8303753b25a313fc7abfa 100644 (file)
@@ -298,7 +298,7 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
     }
 
     private void onInitConfigListener() {
-        LOG.debug("{}: Initializing config listener.", persistenceId());
+        LOG.debug("{}: Initializing config listener on {}", persistenceId(), cluster.getCurrentMemberName());
 
         final org.opendaylight.mdsal.common.api.LogicalDatastoreType type =
                 org.opendaylight.mdsal.common.api.LogicalDatastoreType
index f8ecdb804cbfba927637fdd99ada12e9e981bdf6..ac209e3c6dbd532d0febb1f286610ee577874096 100644 (file)
@@ -77,6 +77,7 @@ public class PrefixedShardConfigUpdateHandler {
         private final MemberName memberName;
         private final LogicalDatastoreType type;
         private final ActorRef handlingActor;
+        private final String logName;
 
         public ShardConfigHandler(final MemberName memberName,
                            final LogicalDatastoreType type,
@@ -84,6 +85,7 @@ public class PrefixedShardConfigUpdateHandler {
             this.memberName = memberName;
             this.type = type;
             this.handlingActor = handlingActor;
+            logName = memberName.getName() + "-" + type;
         }
 
         @Override
@@ -111,8 +113,8 @@ public class PrefixedShardConfigUpdateHandler {
 
         private void resolveWrite(final DataTreeCandidateNode rootNode) {
 
-            LOG.debug("{}: New config received {}", memberName, rootNode);
-            LOG.debug("{}: Data after: {}", memberName, rootNode.getDataAfter());
+            LOG.debug("{}: New config received {}", logName, rootNode);
+            LOG.debug("{}: Data after: {}", logName, rootNode.getDataAfter());
 
             // were in the shards list, iter children and resolve
             for (final DataTreeCandidateNode childNode : rootNode.getChildNodes()) {
@@ -134,6 +136,7 @@ public class PrefixedShardConfigUpdateHandler {
             }
         }
 
+        @SuppressWarnings("unchecked")
         private void resolveWrittenShard(final DataTreeCandidateNode childNode) {
             final MapEntryNode entryNode = (MapEntryNode) childNode.getDataAfter().get();
             final LeafNode<YangInstanceIdentifier> prefix =
@@ -141,7 +144,7 @@ public class PrefixedShardConfigUpdateHandler {
 
             final YangInstanceIdentifier identifier = prefix.getValue();
 
-            LOG.debug("{}: Deserialized {} from datastore", memberName, identifier);
+            LOG.debug("{}: Deserialized {} from datastore", logName, identifier);
 
             final ContainerNode replicas =
                     (ContainerNode) entryNode.getChild(new NodeIdentifier(SHARD_REPLICAS_QNAME)).get();
@@ -153,13 +156,13 @@ public class PrefixedShardConfigUpdateHandler {
                     .map(child -> MemberName.forName(child.getValue()))
                     .collect(Collectors.toList());
 
-            LOG.debug("{}: Replicas read from ds {}", memberName, retReplicas.toString());
+            LOG.debug("{}: Replicas read from ds {}", logName, retReplicas.toString());
 
             final PrefixShardConfiguration newConfig =
                     new PrefixShardConfiguration(new DOMDataTreeIdentifier(type, identifier),
                             PrefixShardStrategy.NAME, retReplicas);
 
-            LOG.debug("{}: Resulting config {}", memberName, newConfig);
+            LOG.debug("{}: Resulting config {} - sending PrefixShardCreated to {}", logName, newConfig, handlingActor);
 
             handlingActor.tell(new PrefixShardCreated(newConfig), noSender());
         }
@@ -183,5 +186,10 @@ public class PrefixedShardConfigUpdateHandler {
         private void resolveDelete(final DataTreeCandidateNode rootNode) {
 
         }
+
+        @Override
+        public String toString() {
+            return "ShardConfigHandler [logName=" + logName + ", handlingActor=" + handlingActor + "]";
+        }
     }
 }
index f3dcaa2b709810d169ae1ae1cc0b54c716051fe9..a2e6b117eb90d1d267192289a343015e4c10ae1d 100644 (file)
@@ -37,7 +37,7 @@ public class DataChangeListenerTest extends AbstractActorTest {
 
                 // Let the DataChangeListener know that notifications should be
                 // enabled
-                subject.tell(new EnableNotification(true), getRef());
+                subject.tell(new EnableNotification(true, "test"), getRef());
 
                 subject.tell(new DataChanged(mockChangeEvent), getRef());
 
@@ -122,7 +122,7 @@ public class DataChangeListenerTest extends AbstractActorTest {
 
                 // Let the DataChangeListener know that notifications should be
                 // enabled
-                subject.tell(new EnableNotification(true), getRef());
+                subject.tell(new EnableNotification(true, "test"), getRef());
 
                 subject.tell(new DataChanged(mockChangeEvent1), getRef());
                 expectMsgClass(DataChangedReply.class);
index 62b95c214b1d50068ffec642821adae9bb1913c9..a98d55a99fadb2bb01a7320b0cd88ff9d7c8f711 100644 (file)
@@ -38,7 +38,7 @@ public class DataTreeChangeListenerActorTest extends AbstractActorTest {
 
                 // Let the DataChangeListener know that notifications should be
                 // enabled
-                subject.tell(new EnableNotification(true), getRef());
+                subject.tell(new EnableNotification(true, "test"), getRef());
 
                 subject.tell(new DataTreeChanged(mockCandidates), getRef());
 
@@ -126,7 +126,7 @@ public class DataTreeChangeListenerActorTest extends AbstractActorTest {
 
                 // Let the DataChangeListener know that notifications should be
                 // enabled
-                subject.tell(new EnableNotification(true), getRef());
+                subject.tell(new EnableNotification(true, "test"), getRef());
 
                 subject.tell(new DataTreeChanged(mockCandidates1), getRef());
                 expectMsgClass(DataTreeChangedReply.class);
index 6f2f99b24ef7a088586e39ce7334a4cc3e8d4d61..820fe5614fadaf96d970a40e0722196a2c0e8ef7 100644 (file)
@@ -226,6 +226,7 @@ public class DataTreeChangeListenerProxyTest extends AbstractActorTest {
                 final YangInstanceIdentifier path = YangInstanceIdentifier.of(TestModel.TEST_QNAME);
 
                 doReturn(executor).when(actorContext).getClientDispatcher();
+                doReturn(DatastoreContext.newBuilder().build()).when(actorContext).getDatastoreContext();
                 doReturn(mockActorSystem).when(actorContext).getActorSystem();
 
                 String shardName = "shard-1";