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 05:27:45 UTC
svn commit: r1131597 - in /incubator/mesos/trunk/src: master.hpp
master_main.cpp slave_main.cpp
Author: benh
Date: Sun Jun 5 03:27:44 2011
New Revision: 1131597
URL: http://svn.apache.org/viewvc?rev=1131597&view=rev
Log:
Hooking up primitive ZooKeeper support.
Modified:
incubator/mesos/trunk/src/master.hpp
incubator/mesos/trunk/src/master_main.cpp
incubator/mesos/trunk/src/slave_main.cpp
Modified: incubator/mesos/trunk/src/master.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/master.hpp?rev=1131597&r1=1131596&r2=1131597&view=diff
==============================================================================
--- incubator/mesos/trunk/src/master.hpp (original)
+++ incubator/mesos/trunk/src/master.hpp Sun Jun 5 03:27:44 2011
@@ -21,6 +21,7 @@
#include <boost/unordered_map.hpp>
#include <boost/unordered_set.hpp>
+#include "fatal.hpp"
#include "foreach.hpp"
#include "hash_pid.hpp"
#include "master_state.hpp"
Modified: incubator/mesos/trunk/src/master_main.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/master_main.cpp?rev=1131597&r1=1131596&r2=1131597&view=diff
==============================================================================
--- incubator/mesos/trunk/src/master_main.cpp (original)
+++ incubator/mesos/trunk/src/master_main.cpp Sun Jun 5 03:27:44 2011
@@ -2,7 +2,8 @@
#include "master.hpp"
#include "master_webui.hpp"
-#include "url_processor.hpp"
+#include "zookeeper_master.hpp"
+
using std::cerr;
using std::endl;
@@ -12,9 +13,10 @@ using namespace nexus::internal::master;
void usage(const char* programName)
{
cerr << "Usage: " << programName
- << " [--port PORT] [--allocator ALLOCATOR] [--fault-tolerant ZOO_SERVERS] [--quiet]"
- << endl
- << "ZOO_SERVERS is a url of the form zoo://<zoosrv1>,<zoosrv2>..., or zoofile://listfile"
+ << " [--port PORT]"
+ << " [--allocator ALLOCATOR]"
+ << " [--zookeeper host:port]"
+ << " [--quiet]"
<< endl;
}
@@ -29,18 +31,17 @@ int main (int argc, char **argv)
option options[] = {
{"allocator", required_argument, 0, 'a'},
{"port", required_argument, 0, 'p'},
- {"fault-tolerant", required_argument, 0, 'f'},
+ {"zookeeper", required_argument, 0, 'z'},
{"quiet", no_argument, 0, 'q'},
};
- bool isFT = false;
- string zooarg = "";
bool quiet = false;
string allocator = "simple";
+ string zookeeper;
int opt;
int index;
- while ((opt = getopt_long(argc, argv, "a:p:f:q", options, &index)) != -1) {
+ while ((opt = getopt_long(argc, argv, "a:p:z:q", options, &index)) != -1) {
switch (opt) {
case 'a':
allocator = optarg;
@@ -48,10 +49,9 @@ int main (int argc, char **argv)
case 'p':
setenv("LIBPROCESS_PORT", optarg, 1);
break;
- case 'f':
- isFT = true;
- zooarg = optarg;
- break;
+ case 'z':
+ zookeeper = optarg;
+ break;
case 'q':
quiet = true;
break;
@@ -67,21 +67,21 @@ int main (int argc, char **argv)
if (!quiet)
google::SetStderrLogging(google::INFO);
- FLAGS_log_dir = "/tmp";
FLAGS_logbufsecs = 1;
google::InitGoogleLogging(argv[0]);
LOG(INFO) << "Build: " << BUILD_DATE << " by " << BUILD_USER;
LOG(INFO) << "Starting Nexus master";
- if (isFT)
- LOG(INFO) << "Nexus in fault-tolerant mode";
- PID master = Process::spawn(new Master(allocator, zooarg));
+ Master* master = new Master(allocator);
+ PID pid = Process::spawn(master);
+
+ if (!zookeeper.empty())
+ Process::spawn(new ZooKeeperProcessForMaster(pid, zookeeper));
-#undef NEXUS_WEBUI
#ifdef NEXUS_WEBUI
- startMasterWebUI(master);
+ startMasterWebUI(pid);
#endif
- Process::wait(master);
+ Process::wait(pid);
return 0;
}
Modified: incubator/mesos/trunk/src/slave_main.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/slave_main.cpp?rev=1131597&r1=1131596&r2=1131597&view=diff
==============================================================================
--- incubator/mesos/trunk/src/slave_main.cpp (original)
+++ incubator/mesos/trunk/src/slave_main.cpp Sun Jun 5 03:27:44 2011
@@ -2,6 +2,7 @@
#include "slave.hpp"
#include "slave_webui.hpp"
+#include "zookeeper_slave.hpp"
using namespace std;
using namespace nexus::internal::slave;
@@ -10,7 +11,12 @@ using namespace nexus::internal::slave;
void usage(const char *programName)
{
cerr << "Usage: " << programName
- << " [--cpus NUM] [--mem NUM] [--isolation TYPE] [--quiet] <master_or_zoo_pid>"
+ << " [--cpus NUM]"
+ << " [--mem NUM]"
+ << " [--isolation TYPE]"
+ << " [--zookeeper host:port]"
+ << " [--quiet]"
+ << " <master_pid>"
<< endl;
}
@@ -26,18 +32,20 @@ int main(int argc, char **argv)
{"cpus", required_argument, 0, 'c'},
{"mem", required_argument, 0, 'm'},
{"isolation", required_argument, 0, 'i'},
+ {"zookeeper", required_argument, 0, 'z'},
{"quiet", no_argument, 0, 'q'},
};
Resources resources(1, 1 * Gigabyte);
- bool quiet = false;
string isolation = "process";
+ string zookeeper = "";
+ bool quiet = false;
int opt;
int index;
- while ((opt = getopt_long(argc, argv, "c:m:i:q", options, &index)) != -1) {
+ while ((opt = getopt_long(argc, argv, "c:m:i:z:q", options, &index)) != -1) {
switch (opt) {
- case 'c':
+ case 'c':
resources.cpus = atoi(optarg);
break;
case 'm':
@@ -46,6 +54,9 @@ int main(int argc, char **argv)
case 'i':
isolation = optarg;
break;
+ case 'z':
+ zookeeper = optarg;
+ break;
case 'q':
quiet = true;
break;
@@ -61,28 +72,39 @@ int main(int argc, char **argv)
if (!quiet)
google::SetStderrLogging(google::INFO);
- FLAGS_log_dir = "/tmp";
FLAGS_logbufsecs = 1;
google::InitGoogleLogging(argv[0]);
- // Check that we have exactly one non-option argument (the master PID)
- if (optind != argc - 1) {
+ // Check that we either have zookeeper as an argument or exactly one
+ // non-option argument (i.e., the master PID).
+ if (zookeeper.empty() && optind != argc - 1) {
usage(argv[0]);
exit(1);
}
- // Read and resolve the master PID
- string master(argv[optind]);
+ // Resolve the master PID.
+ PID master;
+ if (!zookeeper.empty()) {
+ Process::wait(Process::spawn(new ZooKeeperProcessForSlave(zookeeper)));
+ master = make_pid(ZooKeeperProcessForSlave::master.c_str());
+ } else {
+ istringstream iss(argv[optind]);
+ if (!(iss >> master)) {
+ cerr << "Failed to resolve master PID " << argv[optind] << endl;
+ exit(1);
+ }
+ }
LOG(INFO) << "Build: " << BUILD_DATE << " by " << BUILD_USER;
LOG(INFO) << "Starting Nexus slave";
- PID slave = Process::spawn(new Slave(master, resources, false, isolation));
+ Slave* slave = new Slave(master, resources, false, isolation);
+ PID pid = Process::spawn(slave);
#ifdef NEXUS_WEBUI
- startSlaveWebUI(slave);
+ startSlaveWebUI(pid);
#endif
- Process::wait(slave);
+ Process::wait(pid);
return 0;
}