浏览代码

ZOOKEEPER-3232: make the log of notification about LE more readable

- The first PR of the NEW YEAR:2019.good luck to me(:D).
- More details in [ZOOKEEPER-3232](https://issues.apache.org/jira/browse/ZOOKEEPER-3232)

Author: maoling <maoling199210191@sina.com>

Reviewers: fangmin@apache.org, evolivelli@apche.org

Closes #749 from maoling/ZOOKEEPER-3232
maoling 6 年之前
父节点
当前提交
fd465ebf53

+ 6 - 10
zookeeper-server/src/main/java/org/apache/zookeeper/server/quorum/FastLeaderElection.java

@@ -711,16 +711,12 @@ public class FastLeaderElection implements Election {
         }
         }
     }
     }
 
 
-    private void printNotification(Notification n){
-        LOG.info("Notification: "
-                + Long.toHexString(n.version) + " (message format version), "
-                + n.leader + " (n.leader), 0x"
-                + Long.toHexString(n.zxid) + " (n.zxid), 0x"
-                + Long.toHexString(n.electionEpoch) + " (n.round), " + n.state
-                + " (n.state), " + n.sid + " (n.sid), 0x"
-                + Long.toHexString(n.peerEpoch) + " (n.peerEPoch), "
-                + self.getPeerState() + " (my state)"
-                + (n.qv!=null ? (Long.toHexString(n.qv.getVersion()) + " (n.config version)"):""));
+    private void printNotification(Notification n) {
+        LOG.info("Notification: my state:{}; n.sid:{}, n.state:{}, n.leader:{}, n.round:0x{}, " +
+                        "n.peerEpoch:0x{}, n.zxid:0x{}, message format version:0x{}, n.config version:0x{}",
+                self.getPeerState(), n.sid, n.state, n.leader, Long.toHexString(n.electionEpoch),
+                Long.toHexString(n.peerEpoch), Long.toHexString(n.zxid), Long.toHexString(n.version),
+                (n.qv != null ? (Long.toHexString(n.qv.getVersion())) : "0"));
     }
     }