hadoop-zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ph...@apache.org
Subject svn commit: r700664 - in /hadoop/zookeeper/trunk: CHANGES.txt src/java/main/org/apache/zookeeper/ClientCnxn.java src/java/main/org/apache/zookeeper/WatchedEvent.java src/java/main/org/apache/zookeeper/ZooKeeperMain.java
Date Wed, 01 Oct 2008 02:47:54 GMT
Author: phunt
Date: Tue Sep 30 19:47:54 2008
New Revision: 700664

URL: http://svn.apache.org/viewvc?rev=700664&view=rev
Log:
ZOOKEEPER-144 add tostring support for watcher event, and enums for event type/state

Modified:
    hadoop/zookeeper/trunk/CHANGES.txt
    hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/ClientCnxn.java
    hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/WatchedEvent.java
    hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/ZooKeeperMain.java

Modified: hadoop/zookeeper/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/CHANGES.txt?rev=700664&r1=700663&r2=700664&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/CHANGES.txt (original)
+++ hadoop/zookeeper/trunk/CHANGES.txt Tue Sep 30 19:47:54 2008
@@ -14,6 +14,9 @@
 
   BUGFIXES: 
 
+  ZOOKEEPER-144. add tostring support for watcher event, and enums for event
+  type/state (Jakob Homan via phunt)
+
   ZOOKEEPER-21. Improve zk ctor/watcher (state transition) docs (phunt)
 
   ZOOKEEPER-142. Provide Javadoc as to the maximum size of the data byte 

Modified: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/ClientCnxn.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/ClientCnxn.java?rev=700664&r1=700663&r2=700664&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/ClientCnxn.java (original)
+++ hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/ClientCnxn.java Tue Sep 30 19:47:54
2008
@@ -493,13 +493,13 @@
                 // -1 means notification
                 WatcherEvent event = new WatcherEvent();
                 event.deserialize(bbia, "response");
-                
+                WatchedEvent we = new WatchedEvent(event);
                 if (LOG.isDebugEnabled()) {
-                    LOG.debug("Got an event: " + event + " for sessionid 0x"
+                    LOG.debug("Got " + we + " for sessionid 0x"
                             + Long.toHexString(sessionId));
                 }
                 
-                eventThread.queueEvent( new WatchedEvent(event) );
+                eventThread.queueEvent( we );
                 return;
             }
             if (pendingQueue.size() == 0) {

Modified: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/WatchedEvent.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/WatchedEvent.java?rev=700664&r1=700663&r2=700664&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/WatchedEvent.java (original)
+++ hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/WatchedEvent.java Tue Sep 30
19:47:54 2008
@@ -62,12 +62,20 @@
         return path;
     }
 
+    @Override
+    public String toString() {
+        if(path == null)  // then is a state change 
+            return "WatchedEvent: Server state change. New state: " + keeperState;
+         else  // is a znode change
+            return "WatchedEvent: Znode change. Path: " + path + " Type: " + eventType;
+    }
+
     /**
      *  Convert WatchedEvent to type that can be sent over network
      */
     public WatcherEvent getWrapper() {
         return new WatcherEvent(eventType.getIntValue(), 
-                                       keeperState.getIntValue(), 
-                                       path);
+                                keeperState.getIntValue(), 
+                                path);
     }
 }

Modified: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/ZooKeeperMain.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/ZooKeeperMain.java?rev=700664&r1=700663&r2=700664&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/ZooKeeperMain.java (original)
+++ hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/ZooKeeperMain.java Tue Sep 30
19:47:54 2008
@@ -51,8 +51,7 @@
 
     static private class MyWatcher implements Watcher {
         public void process(WatchedEvent event) {
-            System.err.println(event.getPath() + ": " + event.getState() + "-"
-                    + event.getType());
+            System.err.println(event);
         }
     }
 



Mime
View raw message