Dump DTCL changes on trace 31/105031/2
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 27 Mar 2023 09:34:52 +0000 (11:34 +0200)
committerRobert Varga <nite@hq.sk>
Mon, 27 Mar 2023 10:38:31 +0000 (10:38 +0000)
Reduce memory usage by not dumping all changes at once, but rather each
of them separately and only when trace is enabled.

Change-Id: I954dd4576d2625a862b254532379974c19bc1c60
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataTreeChangeListenerActor.java

index 9384a84e382aceaed952efd2682d446b22f588ba..6f88d3ea986136416276fa39915c5bfe2673bee6 100644 (file)
@@ -60,9 +60,9 @@ class DataTreeChangeListenerActor extends AbstractUntypedActor {
         LOG.debug("{}: Notifying onInitialData to listener {}", logContext, listener);
 
         try {
-            this.listener.onInitialData();
+            listener.onInitialData();
         } catch (Exception e) {
-            LOG.error("{}: Error notifying listener {}", logContext, this.listener, e);
+            LOG.error("{}: Error notifying listener {}", logContext, listener, e);
         }
     }
 
@@ -75,15 +75,21 @@ class DataTreeChangeListenerActor extends AbstractUntypedActor {
             return;
         }
 
-        LOG.debug("{}: Sending {} change notification(s) {} to listener {}", logContext, message.getChanges().size(),
-                message.getChanges(), listener);
+        final var changes = message.getChanges();
+        LOG.debug("{}: Sending {} change notification(s) to listener {}", logContext, changes.size(), listener);
+        if (LOG.isTraceEnabled() && !changes.isEmpty()) {
+            LOG.trace("{}: detailed change follow", logContext);
+            for (int i = 0, size = changes.size(); i < size; ++i) {
+                LOG.trace("{}: change {}: {}", logContext, i, changes.get(i));
+            }
+        }
 
         notificationCount++;
 
         try {
-            this.listener.onDataTreeChanged(message.getChanges());
+            listener.onDataTreeChanged(changes);
         } catch (Exception e) {
-            LOG.error("{}: Error notifying listener {}", logContext, this.listener, e);
+            LOG.error("{}: Error notifying listener {}", logContext, listener, e);
         }
 
         // TODO: do we really need this?