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 2011/06/05 07:27:08 UTC

svn commit: r1131765 - /incubator/mesos/trunk/src/master_detector.cpp

Author: benh
Date: Sun Jun  5 05:27:08 2011
New Revision: 1131765

URL: http://svn.apache.org/viewvc?rev=1131765&view=rev
Log:
Changing the ACL of ZooKeeper back to what FT-NEXUS had, since we don't have authentication implemented yet.

Modified:
    incubator/mesos/trunk/src/master_detector.cpp

Modified: incubator/mesos/trunk/src/master_detector.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/master_detector.cpp?rev=1131765&r1=1131764&r2=1131765&view=diff
==============================================================================
--- incubator/mesos/trunk/src/master_detector.cpp (original)
+++ incubator/mesos/trunk/src/master_detector.cpp Sun Jun  5 05:27:08 2011
@@ -45,21 +45,13 @@ void MasterDetector::process(ZooKeeper *
   static const string delimiter = "/";
 
   if ((state == ZOO_CONNECTED_STATE) && (type == ZOO_SESSION_EVENT)) {
-    // Assume the znode that was created does not end with a "/".
-    CHECK(znode.at(znode.length() - 1) != '/');
-
     // Create directory path znodes as necessary.
     size_t index = znode.find(delimiter, 0);
-
     while (index < string::npos) {
-      // Get out the prefix to create.
-      index = znode.find(delimiter, index + 1);
+      index = znode.find(delimiter, index+1);
       string prefix = znode.substr(0, index);
-
-      // Create the node (even if it already exists).
-      ret = zk->create(prefix, "", ZOO_CREATOR_ALL_ACL,
+      ret = zk->create(prefix, "", ZOO_OPEN_ACL_UNSAFE, // ZOO_CREATOR_ALL_ACL, // needs authentication
 		       0, &result);
-
       if (ret != ZOK && ret != ZNODEEXISTS)
 	fatal("failed to create ZooKeeper znode! (%s)", zk->error(ret));
     }
@@ -74,7 +66,7 @@ void MasterDetector::process(ZooKeeper *
 
     if (contend) {
       // We use the contend with the pid given in constructor.
-      ret = zk->create(znode + "/", pid, ZOO_CREATOR_ALL_ACL,
+      ret = zk->create(znode, pid, ZOO_CREATOR_ALL_ACL,
 		       ZOO_SEQUENCE | ZOO_EPHEMERAL, &result);
 
       if (ret != ZOK)
@@ -90,11 +82,8 @@ void MasterDetector::process(ZooKeeper *
       Process::post(pid, GOT_MASTER_SEQ, s.data(), s.size());
     }
 
-    // Now determine who the master is (it may be us).
     detectMaster();
   } else if ((state == ZOO_CONNECTED_STATE) && (type == ZOO_CHILD_EVENT)) {
-    // A new master might have showed up and created a sequence
-    // identifier or a master may have died, determine who the master is now!
     detectMaster();
   } else {
     LOG(INFO) << "Unimplemented watch event: (state is "
@@ -113,7 +102,7 @@ void MasterDetector::detectMaster()
     LOG(ERROR) << "failed to get masters: " << zk->error(ret);
   else
     LOG(INFO) << "found " << results.size() << " registered masters";
-
+  
   string masterSeq;
   long min = LONG_MAX;
   foreach (const string &result, results) {
@@ -155,7 +144,7 @@ PID MasterDetector::lookupMasterPID(cons
   int ret;
   string result;
 
-  ret = zk->get(znode + "/" + seq, false, &result, NULL);
+  ret = zk->get(znode + seq, false, &result, NULL);
 
   if (ret != ZOK)
     LOG(ERROR) << "failed to fetch new master pid: " << zk->error(ret);