Author: phunt
Date: Fri Jun 25 20:08:12 2010
New Revision: 958096

URL: http://svn.apache.org/viewvc?rev=958096&view=rev
Log:
ZOOKEEPER-778: Add server id to message logs

Modified:
    hadoop/zookeeper/trunk/CHANGES.txt
    hadoop/zookeeper/trunk/conf/log4j.properties
    
hadoop/zookeeper/trunk/src/contrib/loggraph/src/java/org/apache/zookeeper/graph/Log4JSource.java
    
hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/QuorumPeerConfig.java

Modified: hadoop/zookeeper/trunk/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/CHANGES.txt?rev=958096&r1=958095&r2=958096&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/CHANGES.txt (original)
+++ hadoop/zookeeper/trunk/CHANGES.txt Fri Jun 25 20:08:12 2010
@@ -68,12 +68,15 @@ IMPROVEMENTS:
   ZOOKEEPER-766. forrest recipes docs don't mention the lock/queue recipe
   implementations available in the release (phunt via mahadev)
 
-  ZOOKEEPER-769: Leader can treat observers as quorum members (Sergey
-  Doroshenko via henryr)
+  ZOOKEEPER-769: Leader can treat observers as quorum members
+  (Sergey Doroshenko via henryr)
+
+  ZOOKEEPER-788: Add server id to message logs
+  (Ivan Kelly via flavio)
 
 NEW FEATURES:
-  ZOOKEEPER-729. Java client API to recursively delete a subtree. (Kay
-  Kay via henry)
+  ZOOKEEPER-729. Java client API to recursively delete a subtree.
+  (Kay Kay via henry)
 
   ZOOKEEPER-747. Add C# generation to Jute (Eric Hauser via phunt)
 

Modified: hadoop/zookeeper/trunk/conf/log4j.properties
URL: 
http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/conf/log4j.properties?rev=958096&r1=958095&r2=958096&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/conf/log4j.properties (original)
+++ hadoop/zookeeper/trunk/conf/log4j.properties Fri Jun 25 20:08:12 2010
@@ -19,7 +19,7 @@ log4j.rootLogger=INFO, CONSOLE
 log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
 log4j.appender.CONSOLE.Threshold=INFO
 log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
-log4j.appender.CONSOLE.layout.ConversionPattern=%d{ISO8601} - %-5p 
[%t:%c...@%l] - %m%n
+log4j.appender.CONSOLE.layout.ConversionPattern=%d{ISO8601} [myid:%X{myid}] - 
%-5p [%t:%c...@%l] - %m%n
 
 #
 # Add ROLLINGFILE to rootLogger to get log file output
@@ -34,7 +34,7 @@ log4j.appender.ROLLINGFILE.MaxFileSize=1
 #log4j.appender.ROLLINGFILE.MaxBackupIndex=10
 
 log4j.appender.ROLLINGFILE.layout=org.apache.log4j.PatternLayout
-log4j.appender.ROLLINGFILE.layout.ConversionPattern=%d{ISO8601} - %-5p 
[%t:%c...@%l] - %m%n
+log4j.appender.ROLLINGFILE.layout.ConversionPattern=%d{ISO8601} 
[myid:%X{myid}] - %-5p [%t:%c...@%l] - %m%n
 
 
 #
@@ -46,4 +46,4 @@ log4j.appender.TRACEFILE.File=zookeeper_
 
 log4j.appender.TRACEFILE.layout=org.apache.log4j.PatternLayout
 ### Notice we are including log4j's NDC here (%x)
-log4j.appender.TRACEFILE.layout.ConversionPattern=%d{ISO8601} - %-5p 
[%t:%c...@%l][%x] - %m%n
+log4j.appender.TRACEFILE.layout.ConversionPattern=%d{ISO8601} [myid:%X{myid}] 
- %-5p [%t:%c...@%l][%x] - %m%n

Modified: 
hadoop/zookeeper/trunk/src/contrib/loggraph/src/java/org/apache/zookeeper/graph/Log4JSource.java
URL: 
http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/contrib/loggraph/src/java/org/apache/zookeeper/graph/Log4JSource.java?rev=958096&r1=958095&r2=958096&view=diff
==============================================================================
--- 
hadoop/zookeeper/trunk/src/contrib/loggraph/src/java/org/apache/zookeeper/graph/Log4JSource.java
 (original)
+++ 
hadoop/zookeeper/trunk/src/contrib/loggraph/src/java/org/apache/zookeeper/graph/Log4JSource.java
 Fri Jun 25 20:08:12 2010
@@ -282,7 +282,7 @@ public class Log4JSource implements LogS
        File f = new File(file);
        RandomAccessFileReader in = new RandomAccessFileReader(f);
        SimpleDateFormat dateformat = new SimpleDateFormat(DATE_FORMAT);
-       Pattern idp = 
Pattern.compile("Notification:\\s+\\d+,\\s+\\d+,\\s+\\d+,\\s+(\\d+)");// 1, 
My\\s+id\\s+=\\s+(\\d+)");
+       Pattern idp = Pattern.compile("\\[myid:(\\d+)\\]");
 
        long lastFp = in.getPosition();
        String line = in.readLine();

Modified: 
hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/QuorumPeerConfig.java
URL: 
http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/QuorumPeerConfig.java?rev=958096&r1=958095&r2=958096&view=diff
==============================================================================
--- 
hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/QuorumPeerConfig.java
 (original)
+++ 
hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/QuorumPeerConfig.java
 Fri Jun 25 20:08:12 2010
@@ -32,6 +32,8 @@ import java.util.Properties;
 import java.util.Map.Entry;
 
 import org.apache.log4j.Logger;
+import org.apache.log4j.MDC;
+
 import org.apache.zookeeper.server.ZooKeeperServer;
 import org.apache.zookeeper.server.quorum.QuorumPeer.LearnerType;
 import org.apache.zookeeper.server.quorum.QuorumPeer.QuorumServer;
@@ -306,6 +308,7 @@ public class QuorumPeerConfig {
             }
             try {
                 serverId = Long.parseLong(myIdString);
+               MDC.put("myid", serverId);
             } catch (NumberFormatException e) {
                 throw new IllegalArgumentException("serverid " + myIdString
                         + " is not a number");


Reply via email to