mesos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ka...@apache.org
Subject [01/11] mesos git commit: Added master_detector and master_contender flags.
Date Wed, 06 Apr 2016 22:48:31 GMT
Repository: mesos
Updated Branches:
  refs/heads/master 18f60da86 -> f4207d4b1


Added master_detector and master_contender flags.

The master_detector and master_contender flags allow modules to be
used for specifying the MasterContender and MasterDetector
implementations to use.

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


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

Branch: refs/heads/master
Commit: f4207d4b1fe5c67502e3fe2e83f1cd3999588404
Parents: e4a82b0
Author: Anurag Singh <anurag.prakash.singh@gmail.com>
Authored: Wed Apr 6 15:08:52 2016 -0400
Committer: Kapil Arya <kapil@mesosphere.io>
Committed: Wed Apr 6 18:36:18 2016 -0400

----------------------------------------------------------------------
 src/master/flags.cpp | 14 ++++++++++++++
 src/master/flags.hpp |  2 ++
 src/master/main.cpp  | 27 ++++++++++++++++++++++++---
 src/slave/flags.cpp  |  6 ++++++
 src/slave/flags.hpp  |  1 +
 src/slave/main.cpp   | 26 +++++++++++++++++++-------
 6 files changed, 66 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/f4207d4b/src/master/flags.cpp
----------------------------------------------------------------------
diff --git a/src/master/flags.cpp b/src/master/flags.cpp
index 06852c9..e522499 100644
--- a/src/master/flags.cpp
+++ b/src/master/flags.cpp
@@ -472,4 +472,18 @@ mesos::internal::master::Flags::Flags()
       "max_completed_tasks_per_framework",
       "Maximum number of completed tasks per framework to store in memory.",
       DEFAULT_MAX_COMPLETED_TASKS_PER_FRAMEWORK);
+
+  add(&Flags::master_contender,
+      "master_contender",
+      "The symbol name of the master contender to use.\n"
+      "This symbol should exist in a module specified through\n"
+      "the --modules flag. Cannot be used in conjunction with --zk.\n"
+      "Must be used in conjunction with --master_detector.");
+
+  add(&Flags::master_detector,
+      "master_detector",
+      "The symbol name of the master detector to use. This symbol\n"
+      "should exist in a module specified through the --modules flag.\n"
+      "Cannot be used in conjunction with --zk.\n"
+      "Must be used in conjunction with --master_contender.");
 }

http://git-wip-us.apache.org/repos/asf/mesos/blob/f4207d4b/src/master/flags.hpp
----------------------------------------------------------------------
diff --git a/src/master/flags.hpp b/src/master/flags.hpp
index f8d2cc4..83bb908 100644
--- a/src/master/flags.hpp
+++ b/src/master/flags.hpp
@@ -82,6 +82,8 @@ public:
   std::string http_authenticators;
   size_t max_completed_frameworks;
   size_t max_completed_tasks_per_framework;
+  Option<std::string> master_contender;
+  Option<std::string> master_detector;
 
 #ifdef WITH_NETWORK_ISOLATOR
   Option<size_t> max_executors_per_slave;

http://git-wip-us.apache.org/repos/asf/mesos/blob/f4207d4b/src/master/main.cpp
----------------------------------------------------------------------
diff --git a/src/master/main.cpp b/src/master/main.cpp
index d85fb07..ea7f0fc 100644
--- a/src/master/main.cpp
+++ b/src/master/main.cpp
@@ -236,6 +236,21 @@ int main(int argc, char** argv)
     os::setenv("LIBPROCESS_ADVERTISE_PORT", advertise_port.get());
   }
 
+  if (zk.isNone()) {
+    if (flags.master_contender.isSome() ^ flags.master_detector.isSome()) {
+      EXIT(EXIT_FAILURE)
+        << flags.usage("Both --master_contender and --master_detector should "
+                       "be specified or omitted.");
+    }
+  } else {
+    if (flags.master_contender.isSome() || flags.master_detector.isSome()) {
+      EXIT(EXIT_FAILURE)
+        << flags.usage("Only one of --zk or the "
+                       "--master_contender/--master_detector "
+                       "pair should be specified.");
+    }
+  }
+
   // Initialize libprocess.
   process::initialize("master");
 
@@ -342,18 +357,24 @@ int main(int argc, char** argv)
   MasterContender* contender;
   MasterDetector* detector;
 
-  Try<MasterContender*> contender_ = MasterContender::create(zk);
+  Try<MasterContender*> contender_ = MasterContender::create(
+      zk, flags.master_contender);
+
   if (contender_.isError()) {
     EXIT(EXIT_FAILURE)
       << "Failed to create a master contender: " << contender_.error();
   }
+
   contender = contender_.get();
 
-  Try<MasterDetector*> detector_ = MasterDetector::create(zk);
+  Try<MasterDetector*> detector_ = MasterDetector::create(
+      zk, flags.master_detector);
+
   if (detector_.isError()) {
     EXIT(EXIT_FAILURE)
       << "Failed to create a master detector: " << detector_.error();
   }
+
   detector = detector_.get();
 
   Option<Authorizer*> authorizer_ = None();
@@ -477,7 +498,7 @@ int main(int argc, char** argv)
       slaveRemovalLimiter,
       flags);
 
-  if (zk.isNone()) {
+  if (zk.isNone() && flags.master_detector.isNone()) {
     // It means we are using the standalone detector so we need to
     // appoint this Master as the leader.
     dynamic_cast<StandaloneMasterDetector*>(detector)->appoint(master->info());

http://git-wip-us.apache.org/repos/asf/mesos/blob/f4207d4b/src/slave/flags.cpp
----------------------------------------------------------------------
diff --git a/src/slave/flags.cpp b/src/slave/flags.cpp
index 315cf47..7164afe 100644
--- a/src/slave/flags.cpp
+++ b/src/slave/flags.cpp
@@ -770,4 +770,10 @@ mesos::internal::slave::Flags::Flags()
       "and available. The interval between updates is controlled by this\n"
       "flag.",
       Seconds(15));
+
+  add(&Flags::master_detector,
+      "master_detector",
+      "The symbol name of the master detector to use. This symbol\n"
+      "should exist in a module specified through the --modules flag.\n"
+      "Cannot be used in conjunction with --master.");
 }

http://git-wip-us.apache.org/repos/asf/mesos/blob/f4207d4b/src/slave/flags.hpp
----------------------------------------------------------------------
diff --git a/src/slave/flags.hpp b/src/slave/flags.hpp
index 69e1b01..4236b7f 100644
--- a/src/slave/flags.hpp
+++ b/src/slave/flags.hpp
@@ -143,6 +143,7 @@ public:
   Option<std::string> qos_controller;
   Duration qos_correction_interval_min;
   Duration oversubscribed_resources_interval;
+  Option<std::string> master_detector;
 };
 
 } // namespace slave {

http://git-wip-us.apache.org/repos/asf/mesos/blob/f4207d4b/src/slave/main.cpp
----------------------------------------------------------------------
diff --git a/src/slave/main.cpp b/src/slave/main.cpp
index 8dcf74d..70df4f3 100644
--- a/src/slave/main.cpp
+++ b/src/slave/main.cpp
@@ -61,6 +61,8 @@
 using namespace mesos::internal;
 using namespace mesos::internal::slave;
 
+using mesos::master::detector::MasterDetector;
+
 using mesos::modules::Anonymous;
 using mesos::modules::ModuleManager;
 
@@ -164,8 +166,15 @@ int main(int argc, char** argv)
     return EXIT_SUCCESS;
   }
 
-  if (master.isNone()) {
-    cerr << flags.usage("Missing required option `--master`") << endl;
+  if (master.isNone() && flags.master_detector.isNone()) {
+    cerr << flags.usage("Missing required option `--master` or "
+                        "`--master_detector`.") << endl;
+    return EXIT_FAILURE;
+  }
+
+  if (master.isSome() && flags.master_detector.isSome()) {
+    cerr << flags.usage("Only one of --master or --master_detector options "
+                        "should be specified.");
     return EXIT_FAILURE;
   }
 
@@ -262,13 +271,16 @@ int main(int argc, char** argv)
       << "Failed to create a containerizer: " << containerizer.error();
   }
 
-  Try<MasterDetector*> detector = MasterDetector::create(master.get());
+  Try<MasterDetector*> detector_ = MasterDetector::create(
+      master, flags.master_detector);
 
-  if (detector.isError()) {
+  if (detector_.isError()) {
     EXIT(EXIT_FAILURE)
-      << "Failed to create a master detector: " << detector.error();
+      << "Failed to create a master detector: " << detector_.error();
   }
 
+  MasterDetector* detector = detector_.get();
+
   if (flags.firewall_rules.isSome()) {
     vector<Owned<FirewallRule>> rules;
 
@@ -332,7 +344,7 @@ int main(int argc, char** argv)
   Slave* slave = new Slave(
       id,
       flags,
-      detector.get(),
+      detector,
       containerizer.get(),
       &files,
       &gc,
@@ -349,7 +361,7 @@ int main(int argc, char** argv)
 
   delete qosController.get();
 
-  delete detector.get();
+  delete detector;
 
   delete containerizer.get();
 


Mime
View raw message