You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by vi...@apache.org on 2016/03/04 01:10:37 UTC

[2/3] mesos git commit: Added the ability to stop running the scheduler library process.

Added the ability to stop running the scheduler library process.

This change adds the ability to stop running the scheduler library
process so that no future callbacks are delivered to the scheduler.

This helps us during testing to ensure no further callbacks happen
to stack allocated mock objects.

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


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

Branch: refs/heads/master
Commit: d27b8661654c5b02032731ec8298394381552b87
Parents: b446dbf
Author: Anand Mazumdar <ma...@gmail.com>
Authored: Thu Mar 3 16:09:54 2016 -0800
Committer: Vinod Kone <vi...@gmail.com>
Committed: Thu Mar 3 16:09:54 2016 -0800

----------------------------------------------------------------------
 include/mesos/v1/scheduler.hpp |  9 +++++++++
 src/scheduler/scheduler.cpp    | 18 +++++++++++++++---
 2 files changed, 24 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/d27b8661/include/mesos/v1/scheduler.hpp
----------------------------------------------------------------------
diff --git a/include/mesos/v1/scheduler.hpp b/include/mesos/v1/scheduler.hpp
index a0fb73b..765935e 100644
--- a/include/mesos/v1/scheduler.hpp
+++ b/include/mesos/v1/scheduler.hpp
@@ -83,6 +83,15 @@ protected:
       const std::function<void(const std::queue<Event>&)>& received,
       const Option<std::shared_ptr<mesos::internal::MasterDetector>>& detector);
 
+  // Stops the library so that:
+  //   - No more calls can be sent to the master.
+  //   - No more callbacks can be made to the scheduler. In some cases, there
+  //     may be one additional callback if the library was in the middle of
+  //     processing an event.
+  //
+  // NOTE: This is used for testing.
+  virtual void stop();
+
 private:
   MesosProcess* process;
 };

http://git-wip-us.apache.org/repos/asf/mesos/blob/d27b8661/src/scheduler/scheduler.cpp
----------------------------------------------------------------------
diff --git a/src/scheduler/scheduler.cpp b/src/scheduler/scheduler.cpp
index 2c6bf0d..b010a81 100644
--- a/src/scheduler/scheduler.cpp
+++ b/src/scheduler/scheduler.cpp
@@ -714,9 +714,9 @@ Mesos::Mesos(
 
 Mesos::~Mesos()
 {
-  terminate(process);
-  wait(process);
-  delete process;
+  if (process != NULL) {
+    stop();
+  }
 }
 
 
@@ -725,6 +725,18 @@ void Mesos::send(const Call& call)
   dispatch(process, &MesosProcess::send, call);
 }
 
+
+void Mesos::stop()
+{
+  if (process != NULL) {
+    terminate(process);
+    wait(process);
+
+    delete process;
+    process = NULL;
+  }
+}
+
 } // namespace scheduler {
 } // namespace v1 {
 } // namespace mesos {