mesos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jo...@apache.org
Subject [3/3] mesos git commit: Quota: Persisted quota to registry for set request.
Date Sun, 22 Nov 2015 18:25:42 GMT
Quota: Persisted quota to registry for set request.

Originally https://reviews.apache.org/r/39974

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


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

Branch: refs/heads/master
Commit: f0b846e15aa941ac3273e42197dfc34d39f11b25
Parents: 209fad0
Author: Alexander Rukletsov <rukletsov@gmail.com>
Authored: Sun Nov 22 13:16:13 2015 -0500
Committer: Joris Van Remoortere <joris.van.remoortere@gmail.com>
Committed: Sun Nov 22 13:25:07 2015 -0500

----------------------------------------------------------------------
 src/master/quota_handler.cpp | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/f0b846e1/src/master/quota_handler.cpp
----------------------------------------------------------------------
diff --git a/src/master/quota_handler.cpp b/src/master/quota_handler.cpp
index 03cef41..86d7331 100644
--- a/src/master/quota_handler.cpp
+++ b/src/master/quota_handler.cpp
@@ -25,6 +25,7 @@
 #include <process/defer.hpp>
 #include <process/future.hpp>
 #include <process/http.hpp>
+#include <process/owned.hpp>
 
 #include <stout/json.hpp>
 #include <stout/protobuf.hpp>
@@ -32,6 +33,7 @@
 #include "logging/logging.hpp"
 
 #include "master/quota.hpp"
+#include "master/registrar.hpp"
 
 namespace http = process::http;
 
@@ -43,6 +45,7 @@ using http::Conflict;
 using http::OK;
 
 using process::Future;
+using process::Owned;
 
 using mesos::quota::QuotaInfo;
 namespace mesos {
@@ -234,17 +237,17 @@ Future<http::Response> Master::QuotaHandler::set(
   // fails because in this case the master fails as well.
   master->quotas[quotaInfo.role()] = Quota{quotaInfo};
 
-  // Update the registry with the new quota.
-  // TODO(alexr): MESOS-3165.
+  // Update the registry with the new quota and acknowledge the request.
+  return master->registrar->apply(Owned<Operation>(
+      new quota::UpdateQuota(quotaInfo)))
+    .then(defer(master->self(), [=](bool result) -> Future<http::Response> {
+      // See the top comment in "master/quota.hpp" for why this check is here.
+      CHECK(result);
 
-  // We are all set, grant the request.
-  // TODO(alexr): Implement as per MESOS-3073.
-  // TODO(alexr): This should be done after registry operation succeeds.
+      master->allocator->setQuota(quotaInfo.role(), quotaInfo);
 
-  // Notfify allocator.
-  master->allocator->setQuota(quotaInfo.role(), quotaInfo);
-
-  return OK();
+      return OK();
+    }));
 }
 
 } // namespace master {


Mime
View raw message