You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2012/11/04 02:29:44 UTC

svn commit: r1405463 - /incubator/mesos/branches/0.10.0/src/zookeeper/watcher.hpp

Author: benh
Date: Sun Nov  4 01:29:43 2012
New Revision: 1405463

URL: http://svn.apache.org/viewvc?rev=1405463&view=rev
Log:
Minor tweaks to the ZooKeeper libprocess watcher wrapper (a comment
update and a minor change to be more conservative with use cases)
(https://reviews.apache.org/r/7294).

Modified:
    incubator/mesos/branches/0.10.0/src/zookeeper/watcher.hpp

Modified: incubator/mesos/branches/0.10.0/src/zookeeper/watcher.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/branches/0.10.0/src/zookeeper/watcher.hpp?rev=1405463&r1=1405462&r2=1405463&view=diff
==============================================================================
--- incubator/mesos/branches/0.10.0/src/zookeeper/watcher.hpp (original)
+++ incubator/mesos/branches/0.10.0/src/zookeeper/watcher.hpp Sun Nov  4 01:29:43 2012
@@ -8,7 +8,10 @@
 #include "zookeeper/zookeeper.hpp"
 
 
-// A watcher which dispatches events to a process.
+// A watcher which dispatches events to a process. Note that it is
+// only "safe" to reuse an instance across ZooKeeper instances after a
+// session expiration. TODO(benh): Add a 'reset/initialize' to the
+// Watcher so that a single instance can be reused.
 template <typename T>
 class ProcessWatcher : public Watcher
 {
@@ -25,17 +28,23 @@ public:
       if (state == ZOO_CONNECTED_STATE) {
         // Connected (initial or reconnect).
         process::dispatch(pid, &T::connected, reconnect);
+        // If this watcher gets reused then the next connected
+        // event shouldn't be perceived as a reconnect.
+        reconnect = false;
       } else if (state == ZOO_CONNECTING_STATE) {
         // The client library automatically reconnects, taking
         // into account failed servers in the connection string,
         // appropriately handling the "herd effect", etc.
-        reconnect = true;
         process::dispatch(pid, &T::reconnecting);
+        // TODO(benh): If this watcher gets reused then the next
+        // connected event will be perceived as a reconnect, but it
+        // should not.
+        reconnect = true;
       } else if (state == ZOO_EXPIRED_SESSION_STATE) {
+        process::dispatch(pid, &T::expired);
         // If this watcher gets reused then the next connected
         // event shouldn't be perceived as a reconnect.
         reconnect = false;
-        process::dispatch(pid, &T::expired);
       } else {
         LOG(FATAL) << "Unhandled ZooKeeper state (" << state << ")"
                    << " for ZOO_SESSION_EVENT";