diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/leader/LeaderLatch.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/leader/LeaderLatch.java index 4226e8819d..99e0fb9a43 100644 --- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/leader/LeaderLatch.java +++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/leader/LeaderLatch.java @@ -509,7 +509,7 @@ public void processResult(CuratorFramework client, CuratorEvent event) throws Ex getChildren(); } } else { - log.error("creatingParentContainersIfNeeded() failed (rc = {})", event.getResultCode()); + log.error("[id={}] creatingParentContainersIfNeeded() failed (rc = {})", id, event.getResultCode()); } } }; @@ -528,7 +528,7 @@ private synchronized void internalStart() { reset(); } catch (Exception e) { ThreadUtils.checkInterrupted(e); - log.error("failed to check resetting leadership.", e); + log.error("[id={}] failed to check resetting leadership.", id, e); } } } @@ -545,10 +545,10 @@ private void checkLeadership(List children) throws Exception { List sortedChildren = LockInternals.getSortedChildren(LOCK_NAME, sorter, children); int ourIndex = (localOurPath != null) ? sortedChildren.indexOf(ZKPaths.getNodeFromPath(localOurPath)) : -1; - log.debug("checkLeadership with id: {}, ourPath: {}, children: {}", id, localOurPath, sortedChildren); + log.debug("[id={}] checkLeadership with ourPath: {}, children: {}", id, localOurPath, sortedChildren); if (ourIndex < 0) { - log.error("failed to find our node; resetting (index: {})", ourIndex); + log.error("[id={}] failed to find our node; resetting (index: {})", id, ourIndex); reset(); return; } @@ -582,7 +582,7 @@ public void process(WatchedEvent event) { getChildren(); } catch (Exception ex) { ThreadUtils.checkInterrupted(ex); - log.error("failed to check the leadership.", ex); + log.error("[id={}] failed to check the leadership.", id, ex); } } } @@ -592,7 +592,7 @@ public void process(WatchedEvent event) { @Override public void processResult(CuratorFramework client, CuratorEvent event) throws Exception { if (event.getResultCode() == KeeperException.Code.NONODE.intValue()) { - // previous node is gone - retry getChildren + log.debug("[id={}] previous node is gone; retry getChildren", id); getChildren(); } } @@ -608,8 +608,7 @@ public void processResult(CuratorFramework client, CuratorEvent event) throws Ex if (event.getResultCode() == KeeperException.Code.OK.intValue()) { checkLeadership(event.getChildren()); } else if (event.getResultCode() == KeeperException.Code.NONODE.intValue()) { - // latchPath has gone - reset - // + log.debug("[id={}] latchPath has gone; reset", id); // This is possible when RECONNECTED during: // (1) Scale the zk cluster to 0 nodes. // (2) Scale it back. @@ -617,7 +616,7 @@ public void processResult(CuratorFramework client, CuratorEvent event) throws Ex // See also https://issues.apache.org/jira/browse/CURATOR-724 reset(); } else { - log.error("getChildren() failed (rc = {})", event.getResultCode()); + log.error("[id={}] getChildren() failed (rc = {})", id, event.getResultCode()); } } }; @@ -638,7 +637,7 @@ protected void handleStateChange(ConnectionState newState) { getChildren(); } catch (Exception e) { ThreadUtils.checkInterrupted(e); - log.error("failed to recheck leadership on reconnected", e); + log.error("[id={}] failed to recheck leadership on reconnected", id, e); setLeadership(false); } break; @@ -676,7 +675,7 @@ private synchronized void setLeadership(boolean newValue) { private void setNode(String newValue) throws Exception { String oldPath = ourPath.getAndSet(newValue); - log.debug("setNode with id: {}, oldPath: {}, newValue: {}", id, oldPath, newValue); + log.debug("[id={}] setNode with oldPath: {}, newValue: {}", id, oldPath, newValue); if (oldPath != null) { client.delete().guaranteed().inBackground().forPath(oldPath); } diff --git a/curator-recipes/src/test/resources/log4j.properties b/curator-recipes/src/test/resources/log4j.properties index 706484ce59..98720873e3 100644 --- a/curator-recipes/src/test/resources/log4j.properties +++ b/curator-recipes/src/test/resources/log4j.properties @@ -22,4 +22,4 @@ log4j.additivity.org.apache.curator=false log4j.appender.console=org.apache.log4j.ConsoleAppender log4j.appender.console.layout=org.apache.log4j.PatternLayout -log4j.appender.console.layout.ConversionPattern=%-5p %c %x %m [%t]%n +log4j.appender.console.layout.ConversionPattern=%d{ISO8601} %-5p %c %x %m [%t]%n