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 2013/04/12 19:38:13 UTC
svn commit: r1467368 - /incubator/mesos/trunk/src/tests/cluster.hpp
Author: benh
Date: Fri Apr 12 17:38:12 2013
New Revision: 1467368
URL: http://svn.apache.org/r1467368
Log:
Added a Cluster::Masters::start which takes an AllocatorProcess.
Review: https://reviews.apache.org/r/10303
Modified:
incubator/mesos/trunk/src/tests/cluster.hpp
Modified: incubator/mesos/trunk/src/tests/cluster.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/tests/cluster.hpp?rev=1467368&r1=1467367&r2=1467368&view=diff
==============================================================================
--- incubator/mesos/trunk/src/tests/cluster.hpp (original)
+++ incubator/mesos/trunk/src/tests/cluster.hpp Fri Apr 12 17:38:12 2013
@@ -73,6 +73,8 @@ public:
// Start and manage a new master.
Try<process::PID<master::Master> > start();
Try<process::PID<master::Master> > start(const master::Flags& flags);
+ Try<process::PID<master::Master> > start(
+ master::AllocatorProcess* allocatorProcess);
// Stops and cleans up a master at the specified PID.
Try<Nothing> stop(const process::PID<master::Master>& pid);
@@ -257,6 +259,33 @@ inline Try<process::PID<master::Master>
}
+inline Try<process::PID<master::Master> > Cluster::Masters::start(
+ master::AllocatorProcess* allocatorProcess)
+{
+ // Disallow multiple masters when not using ZooKeeper.
+ if (!masters.empty() && url.isNone()) {
+ return Error("Can not start multiple masters when not using ZooKeeper");
+ }
+
+ Master master;
+ master.allocatorProcess = NULL;
+ master.allocator = new master::Allocator(allocatorProcess);
+ master.master = new master::Master(master.allocator, &cluster->files, flags);
+
+ process::PID<master::Master> pid = process::spawn(master.master);
+
+ if (url.isSome()) {
+ master.detector = new ZooKeeperMasterDetector(url.get(), pid, true, true);
+ } else {
+ master.detector = new BasicMasterDetector(pid);
+ }
+
+ masters[pid] = master;
+
+ return pid;
+}
+
+
inline Try<Nothing> Cluster::Masters::stop(
const process::PID<master::Master>& pid)
{
@@ -271,7 +300,10 @@ inline Try<Nothing> Cluster::Masters::st
delete master.master;
delete master.allocator; // Terminates and waits for the allocator process.
- delete master.allocatorProcess;
+
+ if (master.allocatorProcess != NULL) {
+ delete master.allocatorProcess;
+ }
delete master.detector;