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/12/02 21:29:17 UTC

[10/10] mesos git commit: Added helper function, `Master::isCompletedFramework`.

Added helper function, `Master::isCompletedFramework`.

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


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

Branch: refs/heads/master
Commit: 0ff163246f29006e0fb07a52f6842ae9cf7efa19
Parents: d73cc38
Author: Neil Conway <ne...@gmail.com>
Authored: Fri Dec 2 13:28:48 2016 -0800
Committer: Vinod Kone <vi...@gmail.com>
Committed: Fri Dec 2 13:28:48 2016 -0800

----------------------------------------------------------------------
 src/master/master.cpp | 56 +++++++++++++++++++++++++---------------------
 src/master/master.hpp |  2 ++
 2 files changed, 32 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/0ff16324/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index 203567c..c2c08e1 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -2354,19 +2354,15 @@ void Master::subscribe(
                             " without --root_submissions set");
   }
 
-  if (validationError.isNone() && frameworkInfo.has_id()) {
-    foreach (const shared_ptr<Framework>& framework, frameworks.completed) {
-      if (framework->id() == frameworkInfo.id()) {
-        // This could happen if a framework tries to subscribe after
-        // its failover timeout has elapsed or it unregistered itself
-        // by calling 'stop()' on the scheduler driver.
-        //
-        // TODO(vinod): Master should persist admitted frameworks to the
-        // registry and remove them from it after failover timeout.
-        validationError = Error("Framework has been removed");
-        break;
-      }
-    }
+  if (validationError.isNone() && frameworkInfo.has_id() &&
+      isCompletedFramework(frameworkInfo.id())) {
+    // This could happen if a framework tries to subscribe after its
+    // failover timeout has elapsed or it unregistered itself by
+    // calling 'stop()' on the scheduler driver.
+    //
+    // TODO(vinod): Master should persist admitted frameworks to the
+    // registry and remove them from it after failover timeout.
+    validationError = Error("Framework has been removed");
   }
 
   if (validationError.isNone() && !isValidFailoverTimeout(frameworkInfo)) {
@@ -2583,19 +2579,15 @@ void Master::subscribe(
                             " without --root_submissions set");
   }
 
-  if (validationError.isNone() && frameworkInfo.has_id()) {
-    foreach (const shared_ptr<Framework>& framework, frameworks.completed) {
-      if (framework->id() == frameworkInfo.id()) {
-        // This could happen if a framework tries to subscribe after
-        // its failover timeout has elapsed or it unregistered itself
-        // by calling 'stop()' on the scheduler driver.
-        //
-        // TODO(vinod): Master should persist admitted frameworks to the
-        // registry and remove them from it after failover timeout.
-        validationError = Error("Framework has been removed");
-        break;
-      }
-    }
+  if (validationError.isNone() && frameworkInfo.has_id() &&
+      isCompletedFramework(frameworkInfo.id())) {
+    // This could happen if a framework tries to subscribe after its
+    // failover timeout has elapsed or it unregistered itself by
+    // calling 'stop()' on the scheduler driver.
+    //
+    // TODO(vinod): Master should persist admitted frameworks to the
+    // registry and remove them from it after failover timeout.
+    validationError = Error("Framework has been removed");
   }
 
   if (validationError.isNone() && !isValidFailoverTimeout(frameworkInfo)) {
@@ -8005,6 +7997,18 @@ void Master::removeInverseOffer(InverseOffer* inverseOffer, bool rescind)
 }
 
 
+bool Master::isCompletedFramework(const FrameworkID& frameworkId)
+{
+  foreach (const shared_ptr<Framework>& framework, frameworks.completed) {
+    if (framework->id() == frameworkId) {
+      return true;
+    }
+  }
+
+  return false;
+}
+
+
 // TODO(bmahler): Consider killing this.
 Framework* Master::getFramework(const FrameworkID& frameworkId)
 {

http://git-wip-us.apache.org/repos/asf/mesos/blob/0ff16324/src/master/master.hpp
----------------------------------------------------------------------
diff --git a/src/master/master.hpp b/src/master/master.hpp
index 5114e9d..f4be5e5 100644
--- a/src/master/master.hpp
+++ b/src/master/master.hpp
@@ -860,6 +860,8 @@ protected:
   // Remove an inverse offer and optionally rescind it as well.
   void removeInverseOffer(InverseOffer* inverseOffer, bool rescind = false);
 
+  bool isCompletedFramework(const FrameworkID& frameworkId);
+
   Framework* getFramework(const FrameworkID& frameworkId);
   Offer* getOffer(const OfferID& offerId);
   InverseOffer* getInverseOffer(const OfferID& inverseOfferId);