mesos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From y..@apache.org
Subject [4/6] git commit: Removed the wait in StartMaster() for the master to get elected before returning because it's no longer necessary.
Date Mon, 23 Jun 2014 18:25:47 GMT
Removed the wait in StartMaster() for the master to get elected before returning because it's
no longer necessary.

- Cluster::Masters::start now wait for the master to be recovered, which happens only after
it's elected.

Review: https://reviews.apache.org/r/22856


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/1b2596d6
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/1b2596d6
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/1b2596d6

Branch: refs/heads/master
Commit: 1b2596d6174d284909bdef5548c524ba2fdae305
Parents: bd8343a
Author: Jiang Yan Xu <yan@jxu.me>
Authored: Fri Jun 20 00:37:42 2014 -0700
Committer: Jiang Yan Xu <yan@jxu.me>
Committed: Mon Jun 23 11:19:40 2014 -0700

----------------------------------------------------------------------
 src/tests/cluster.hpp |  2 ++
 src/tests/mesos.cpp   | 53 ++++++----------------------------------------
 src/tests/mesos.hpp   | 19 +++--------------
 3 files changed, 11 insertions(+), 63 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/1b2596d6/src/tests/cluster.hpp
----------------------------------------------------------------------
diff --git a/src/tests/cluster.hpp b/src/tests/cluster.hpp
index 1c96ee7..a83a60e 100644
--- a/src/tests/cluster.hpp
+++ b/src/tests/cluster.hpp
@@ -423,6 +423,8 @@ inline Try<process::PID<master::Master> > Cluster::Masters::start(
   // Speed up the tests by ensuring that the Master is recovered
   // before the test proceeds. Otherwise, authentication and
   // registration messages may be dropped, causing delayed retries.
+  // NOTE: The tests may still need to settle the Clock while it's
+  // paused to ensure that the Master finishes executing _recover().
   if (!_recover.await(Seconds(10))) {
     LOG(FATAL) << "Failed to wait for _recover";
   }

http://git-wip-us.apache.org/repos/asf/mesos/blob/1b2596d6/src/tests/mesos.cpp
----------------------------------------------------------------------
diff --git a/src/tests/mesos.cpp b/src/tests/mesos.cpp
index 1037420..24af32b 100644
--- a/src/tests/mesos.cpp
+++ b/src/tests/mesos.cpp
@@ -45,8 +45,6 @@ using std::string;
 
 using namespace process;
 
-using testing::_;
-
 namespace mesos {
 namespace internal {
 namespace tests {
@@ -159,67 +157,28 @@ slave::Flags MesosTest::CreateSlaveFlags()
 
 
 Try<process::PID<master::Master> > MesosTest::StartMaster(
-    const Option<master::Flags>& flags,
-    bool wait)
+    const Option<master::Flags>& flags)
 {
-  Future<Nothing> detected = FUTURE_DISPATCH(_, &master::Master::detected);
-
-  Try<process::PID<master::Master> > master = cluster.masters.start(
+  return cluster.masters.start(
       flags.isNone() ? CreateMasterFlags() : flags.get());
-
-  // Wait until the leader is detected because otherwise this master
-  // may reject authentication requests because it doesn't know it's
-  // the leader yet [MESOS-881].
-  if (wait && master.isSome() && !detected.await(Seconds(10))) {
-    return Error("Failed to wait " + stringify(Seconds(10)) +
-                 " for master to detect the leader");
-  }
-
-  return master;
 }
 
 
 Try<process::PID<master::Master> > MesosTest::StartMaster(
     master::allocator::AllocatorProcess* allocator,
-    const Option<master::Flags>& flags,
-    bool wait)
+    const Option<master::Flags>& flags)
 {
-  Future<Nothing> detected = FUTURE_DISPATCH(_, &master::Master::detected);
-
-  Try<process::PID<master::Master> > master = cluster.masters.start(
+  return cluster.masters.start(
       allocator, flags.isNone() ? CreateMasterFlags() : flags.get());
-
-  // Wait until the leader is detected because otherwise this master
-  // may reject authentication requests because it doesn't know it's
-  // the leader yet [MESOS-881].
-  if (wait && master.isSome() && !detected.await(Seconds(10))) {
-    return Error("Failed to wait " + stringify(Seconds(10)) +
-                 " for master to detect the leader");
-  }
-
-  return master;
 }
 
 
 Try<process::PID<master::Master> > MesosTest::StartMaster(
     Authorizer* authorizer,
-    const Option<master::Flags>& flags,
-    bool wait)
+    const Option<master::Flags>& flags)
 {
-  Future<Nothing> detected = FUTURE_DISPATCH(_, &master::Master::detected);
-
-  Try<process::PID<master::Master> > master = cluster.masters.start(
+  return cluster.masters.start(
       authorizer, flags.isNone() ? CreateMasterFlags() : flags.get());
-
-  // Wait until the leader is detected because otherwise this master
-  // may reject authentication requests because it doesn't know it's
-  // the leader yet [MESOS-881].
-  if (wait && master.isSome() && !detected.await(Seconds(10))) {
-    return Error("Failed to wait " + stringify(Seconds(10)) +
-                 " for master to detect the leader");
-  }
-
-  return master;
 }
 
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/1b2596d6/src/tests/mesos.hpp
----------------------------------------------------------------------
diff --git a/src/tests/mesos.hpp b/src/tests/mesos.hpp
index 0b9b2f9..c40c82d 100644
--- a/src/tests/mesos.hpp
+++ b/src/tests/mesos.hpp
@@ -83,33 +83,20 @@ protected:
   virtual slave::Flags CreateSlaveFlags();
 
   // Starts a master with the specified flags.
-  // Waits for the master to detect a leader (could be itself) before
-  // returning if 'wait' is set to true.
-  // TODO(xujyan): Return a future which becomes ready when the
-  // master detects a leader (when wait == true) and have the tests
-  // do AWAIT_READY.
   virtual Try<process::PID<master::Master> > StartMaster(
-      const Option<master::Flags>& flags = None(),
-      bool wait = true);
+      const Option<master::Flags>& flags = None());
 
   // Starts a master with the specified allocator process and flags.
-  // Waits for the master to detect a leader (could be itself) before
-  // returning if 'wait' is set to true.
-  // TODO(xujyan): Return a future which becomes ready when the
-  // master detects a leader (when wait == true) and have the tests
-  // do AWAIT_READY.
   virtual Try<process::PID<master::Master> > StartMaster(
       master::allocator::AllocatorProcess* allocator,
-      const Option<master::Flags>& flags = None(),
-      bool wait = true);
+      const Option<master::Flags>& flags = None());
 
   // Starts a master with the specified authorizer and flags.
   // Waits for the master to detect a leader (could be itself) before
   // returning if 'wait' is set to true.
   virtual Try<process::PID<master::Master> > StartMaster(
       Authorizer* authorizer,
-      const Option<master::Flags>& flags = None(),
-      bool wait = true);
+      const Option<master::Flags>& flags = None());
 
   // Starts a slave with the specified flags.
   virtual Try<process::PID<slave::Slave> > StartSlave(


Mime
View raw message