Repository: mesos
Updated Branches:
  refs/heads/master 42f43ceb3 -> 52dfc2f00


Added quota to /roles endpoint of master.

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


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

Branch: refs/heads/master
Commit: 43108b575e5a5f18f3884fad91d137439ae82faa
Parents: 42f43ce
Author: Jay Guo <[email protected]>
Authored: Mon Mar 27 18:18:52 2017 -0700
Committer: Benjamin Mahler <[email protected]>
Committed: Mon Mar 27 18:28:33 2017 -0700

----------------------------------------------------------------------
 src/common/http.cpp | 15 +++++++++++++++
 src/common/http.hpp |  3 +++
 src/master/http.cpp | 12 +++++++++++-
 3 files changed, 29 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/43108b57/src/common/http.cpp
----------------------------------------------------------------------
diff --git a/src/common/http.cpp b/src/common/http.cpp
index 7afbc61..98750a0 100644
--- a/src/common/http.cpp
+++ b/src/common/http.cpp
@@ -29,6 +29,7 @@
 #include <mesos/authentication/http/combined_authenticator.hpp>
 #include <mesos/authorizer/authorizer.hpp>
 #include <mesos/module/http_authenticator.hpp>
+#include <mesos/quota/quota.hpp>
 
 #include <process/authenticator.hpp>
 #include <process/dispatch.hpp>
@@ -491,6 +492,20 @@ JSON::Object model(const FileInfo& fileInfo)
   return file;
 }
 
+
+JSON::Object model(const quota::QuotaInfo& quotaInfo)
+{
+  JSON::Object object;
+
+  object.values["guarantee"] = model(quotaInfo.guarantee());
+  object.values["role"] = quotaInfo.role();
+  if (quotaInfo.has_principal()) {
+    object.values["principal"] = quotaInfo.principal();
+  }
+
+  return object;
+}
+
 }  // namespace internal {
 
 void json(JSON::ObjectWriter* writer, const Attributes& attributes)

http://git-wip-us.apache.org/repos/asf/mesos/blob/43108b57/src/common/http.hpp
----------------------------------------------------------------------
diff --git a/src/common/http.hpp b/src/common/http.hpp
index 9a10312..b6e61f7 100644
--- a/src/common/http.hpp
+++ b/src/common/http.hpp
@@ -24,6 +24,8 @@
 
 #include <mesos/authorizer/authorizer.hpp>
 
+#include <mesos/quota/quota.hpp>
+
 #include <process/future.hpp>
 #include <process/http.hpp>
 #include <process/owned.hpp>
@@ -118,6 +120,7 @@ JSON::Object model(const ExecutorInfo& executorInfo);
 JSON::Array model(const Labels& labels);
 JSON::Object model(const Task& task);
 JSON::Object model(const FileInfo& fileInfo);
+JSON::Object model(const quota::QuotaInfo& quotaInfo);
 
 void json(JSON::ObjectWriter* writer, const Task& task);
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/43108b57/src/master/http.cpp
----------------------------------------------------------------------
diff --git a/src/master/http.cpp b/src/master/http.cpp
index 862b68f..96409f6 100644
--- a/src/master/http.cpp
+++ b/src/master/http.cpp
@@ -3321,6 +3321,7 @@ Future<Response> Master::Http::stateSummary(
 JSON::Object model(
     const string& name,
     Option<double> weight,
+    Option<Quota> quota,
     Option<Role*> _role)
 {
   JSON::Object object;
@@ -3332,6 +3333,10 @@ JSON::Object model(
     object.values["weight"] = 1.0; // Default weight.
   }
 
+  if (quota.isSome()) {
+    object.values["quota"] = model(quota->info);
+  }
+
   if (_role.isNone()) {
     object.values["resources"] = model(Resources());
     object.values["frameworks"] = JSON::Array();
@@ -3468,12 +3473,17 @@ Future<Response> Master::Http::roles(
             weight = master->weights[name];
           }
 
+          Option<Quota> quota = None();
+          if (master->quotas.contains(name)) {
+            quota = master->quotas.at(name);
+          }
+
           Option<Role*> role = None();
           if (master->roles.contains(name)) {
             role = master->roles.at(name);
           }
 
-          array.values.push_back(model(name, weight, role));
+          array.values.push_back(model(name, weight, quota, role));
         }
 
         object.values["roles"] = std::move(array);

Reply via email to