BUG-8618: improve debug logs 25/59025/2
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 15 Jun 2017 01:12:56 +0000 (03:12 +0200)
committerTom Pantelis <tompantelis@gmail.com>
Thu, 15 Jun 2017 13:48:39 +0000 (13:48 +0000)
We can have a reasonable ID prepended, add that. Also improve range
of threshold parameter, as we are addressing journal entries here.

Change-Id: I86aac1be04df8b72bfa6ffaa2b7a7e3b4cbfad6e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 22e817f688bb73420ddcac1f20cf71379ff3a508)

opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/SyncStatusTracker.java

index 08c90e3..e2512d5 100644 (file)
@@ -38,14 +38,14 @@ public class SyncStatusTracker {
     private static final boolean IN_SYNC = true;
     private static final boolean NOT_IN_SYNC = false;
 
-    private final String id;
+    private final long syncThreshold;
     private final ActorRef actor;
-    private final int syncThreshold;
+    private final String id;
 
     private LeaderInfo syncTarget;
     private boolean syncStatus;
 
-    public SyncStatusTracker(final ActorRef actor, final String id, final int syncThreshold) {
+    public SyncStatusTracker(final ActorRef actor, final String id, final long syncThreshold) {
         this.actor = Preconditions.checkNotNull(actor, "actor should not be null");
         this.id = Preconditions.checkNotNull(id, "id should not be null");
         Preconditions.checkArgument(syncThreshold >= 0, "syncThreshold should be greater than or equal to 0");
@@ -56,7 +56,7 @@ public class SyncStatusTracker {
         Preconditions.checkNotNull(leaderId, "leaderId should not be null");
 
         if (syncTarget == null || !leaderId.equals(syncTarget.leaderId)) {
-            LOG.debug("Last sync leader does not match current leader {}, need to catch up to {}",
+            LOG.debug("{}: Last sync leader does not match current leader {}, need to catch up to {}", id,
                 leaderId, leaderCommit);
             changeSyncStatus(NOT_IN_SYNC, true);
             syncTarget = new LeaderInfo(leaderId, leaderCommit);
@@ -65,11 +65,11 @@ public class SyncStatusTracker {
 
         final long lag = leaderCommit - commitIndex;
         if (lag > syncThreshold) {
-            LOG.debug("Lagging {} entries behind leader {}", lag, leaderId);
+            LOG.debug("{}: Lagging {} entries behind leader {}", id, lag, leaderId);
             changeSyncStatus(NOT_IN_SYNC, false);
         } else if (commitIndex >= syncTarget.minimumCommitIndex) {
-            LOG.debug("Lagging {} entries behind leader and reached {} (of expected {})", lag, leaderId, commitIndex,
-                syncTarget.minimumCommitIndex);
+            LOG.debug("{}: Lagging {} entries behind leader and reached {} (of expected {})", id, lag, leaderId,
+                commitIndex, syncTarget.minimumCommitIndex);
             changeSyncStatus(IN_SYNC, false);
         }
     }
@@ -79,7 +79,7 @@ public class SyncStatusTracker {
             actor.tell(new FollowerInitialSyncUpStatus(newSyncStatus, id), ActorRef.noSender());
             syncStatus = newSyncStatus;
         } else {
-            LOG.trace("No change in sync status of {}, dampening message", actor);
+            LOG.trace("{}: No change in sync status of, dampening message", id);
         }
     }
 }

©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.