This is an automated email from the ASF dual-hosted git repository.

bmahler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git

commit 57b98ab790a8b2ed3e91cca825e1a38ebd51150a
Author: Andrei Sekretenko <[email protected]>
AuthorDate: Tue Jul 2 00:25:22 2019 -0400

    Added scheduler driver constructors which set initial suppressed roles.
    
    Review: https://reviews.apache.org/r/70943/
---
 include/mesos/scheduler.hpp | 19 ++++++++++
 src/sched/sched.cpp         | 90 ++++++++++++++++++++++++++++++++-------------
 2 files changed, 83 insertions(+), 26 deletions(-)

diff --git a/include/mesos/scheduler.hpp b/include/mesos/scheduler.hpp
index 27281c1..0a09d55 100644
--- a/include/mesos/scheduler.hpp
+++ b/include/mesos/scheduler.hpp
@@ -431,6 +431,24 @@ public:
       bool implicitAcknowlegements,
       const Credential& credential);
 
+  // These constructors are the same as the above two, but allow
+  // the framework to also specify the initial set of suppressed roles.
+  MesosSchedulerDriver(
+      Scheduler* scheduler,
+      const FrameworkInfo& framework,
+      const std::vector<std::string>& suppressedRoles,
+      const std::string& master,
+      bool implicitAcknowledgements);
+
+  MesosSchedulerDriver(
+      Scheduler* scheduler,
+      const FrameworkInfo& framework,
+      const std::vector<std::string>& suppressedRoles,
+      const std::string& master,
+      bool implicitAcknowlegements,
+      const Credential& credential);
+
+
   // This destructor will block indefinitely if
   // MesosSchedulerDriver::start was invoked successfully (possibly
   // via MesosSchedulerDriver::run) and MesosSchedulerDriver::stop has
@@ -498,6 +516,7 @@ private:
 
   Scheduler* scheduler;
   FrameworkInfo framework;
+  const std::vector<std::string> initialSuppressedRoles;
   std::string master;
 
   // Used for communicating with the master.
diff --git a/src/sched/sched.cpp b/src/sched/sched.cpp
index ac98b39..6b02ac0 100644
--- a/src/sched/sched.cpp
+++ b/src/sched/sched.cpp
@@ -195,6 +195,7 @@ public:
   SchedulerProcess(MesosSchedulerDriver* _driver,
                    Scheduler* _scheduler,
                    const FrameworkInfo& _framework,
+                   const vector<string>& _suppressedRoles,
                    const Option<Credential>& _credential,
                    bool _implicitAcknowledgements,
                    const string& schedulerId,
@@ -217,6 +218,7 @@ public:
       driver(_driver),
       scheduler(_scheduler),
       framework(_framework),
+      suppressedRoles(_suppressedRoles.begin(), _suppressedRoles.end()),
       mutex(_mutex),
       latch(_latch),
       failover(_framework.has_id() && !framework.id().value().empty()),
@@ -1958,6 +1960,51 @@ MesosSchedulerDriver::MesosSchedulerDriver(
 }
 
 
+MesosSchedulerDriver::MesosSchedulerDriver(
+    Scheduler* _scheduler,
+    const FrameworkInfo& _framework,
+    const vector<string>& _suppressedRoles,
+    const string& _master,
+    bool _implicitAcknowlegements)
+  : detector(nullptr),
+    scheduler(_scheduler),
+    framework(_framework),
+    initialSuppressedRoles(_suppressedRoles),
+    master(_master),
+    process(nullptr),
+    latch(nullptr),
+    status(DRIVER_NOT_STARTED),
+    implicitAcknowlegements(_implicitAcknowlegements),
+    credential(nullptr),
+    schedulerId("scheduler-" + id::UUID::random().toString())
+{
+  initialize();
+}
+
+
+MesosSchedulerDriver::MesosSchedulerDriver(
+    Scheduler* _scheduler,
+    const FrameworkInfo& _framework,
+    const vector<string>& _suppressedRoles,
+    const string& _master,
+    bool _implicitAcknowlegements,
+    const Credential& _credential)
+  : detector(nullptr),
+    scheduler(_scheduler),
+    framework(_framework),
+    initialSuppressedRoles(_suppressedRoles),
+    master(_master),
+    process(nullptr),
+    latch(nullptr),
+    status(DRIVER_NOT_STARTED),
+    implicitAcknowlegements(_implicitAcknowlegements),
+    credential(new Credential(_credential)),
+    schedulerId("scheduler-" + id::UUID::random().toString())
+{
+  initialize();
+}
+
+
 MesosSchedulerDriver::~MesosSchedulerDriver()
 {
   // We want to make sure the SchedulerProcess has completed so it
@@ -2064,32 +2111,23 @@ Status MesosSchedulerDriver::start()
 
     CHECK(process == nullptr);
 
-    if (credential == nullptr) {
-      process = new SchedulerProcess(
-          this,
-          scheduler,
-          framework,
-          None(),
-          implicitAcknowlegements,
-          schedulerId,
-          detector.get(),
-          flags,
-          &mutex,
-          latch);
-    } else {
-      const Credential& cred = *credential;
-      process = new SchedulerProcess(
-          this,
-          scheduler,
-          framework,
-          cred,
-          implicitAcknowlegements,
-          schedulerId,
-          detector.get(),
-          flags,
-          &mutex,
-          latch);
-    }
+    Option<Credential> cred = None();
+    if (credential != nullptr) {
+      cred = *credential;
+    }
+
+    process = new SchedulerProcess(
+        this,
+        scheduler,
+        framework,
+        initialSuppressedRoles,
+        cred,
+        implicitAcknowlegements,
+        schedulerId,
+        detector.get(),
+        flags,
+        &mutex,
+        latch);
 
     spawn(process);
 

Reply via email to