Quota: Added status endpoint to master. Review: https://reviews.apache.org/r/39492/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/9669945e Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/9669945e Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/9669945e Branch: refs/heads/master Commit: 9669945e08e4902eb12ad182c3828b7fa6e4ee14 Parents: 9b97304 Author: Joerg Schad <[email protected]> Authored: Tue Jan 5 17:28:27 2016 -0800 Committer: Joris Van Remoortere <[email protected]> Committed: Tue Jan 5 17:51:05 2016 -0800 ---------------------------------------------------------------------- include/mesos/quota/quota.proto | 10 ++++++++++ src/master/master.hpp | 8 ++------ src/master/quota_handler.cpp | 21 +++++++++++++++++++++ 3 files changed, 33 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/9669945e/include/mesos/quota/quota.proto ---------------------------------------------------------------------- diff --git a/include/mesos/quota/quota.proto b/include/mesos/quota/quota.proto index 03e816d..ab505b1 100644 --- a/include/mesos/quota/quota.proto +++ b/include/mesos/quota/quota.proto @@ -43,3 +43,13 @@ message QuotaInfo { // because quota does not reserve specific resources. repeated Resource guarantee = 3; } + + +/** + * `QuotaStatus` describes the internal representation for the /quota/status + * response. + */ +message QuotaStatus { + // Quotas which are currently set, i.e. known to the master. + repeated QuotaInfo infos = 1; +} http://git-wip-us.apache.org/repos/asf/mesos/blob/9669945e/src/master/master.hpp ---------------------------------------------------------------------- diff --git a/src/master/master.hpp b/src/master/master.hpp index 1cc5531..2936d32 100644 --- a/src/master/master.hpp +++ b/src/master/master.hpp @@ -942,13 +942,9 @@ private: CHECK_NOTNULL(master); } + // Returns a list of set quotas. process::Future<process::http::Response> status( - const process::http::Request& request) const - { - // TODO(joerg84): For now this is just a stub. It will be filled as - // part of MESOS-1791. - return process::http::NotImplemented(); - } + const process::http::Request& request) const; process::Future<process::http::Response> set( const process::http::Request& request) const; http://git-wip-us.apache.org/repos/asf/mesos/blob/9669945e/src/master/quota_handler.cpp ---------------------------------------------------------------------- diff --git a/src/master/quota_handler.cpp b/src/master/quota_handler.cpp index 1d84ef5..ac4da74 100644 --- a/src/master/quota_handler.cpp +++ b/src/master/quota_handler.cpp @@ -51,6 +51,7 @@ using http::OK; using http::Unauthorized; using mesos::quota::QuotaInfo; +using mesos::quota::QuotaStatus; using process::Future; using process::Owned; @@ -472,6 +473,26 @@ Future<http::Response> Master::QuotaHandler::remove( } +Future<http::Response> Master::QuotaHandler::status( + const http::Request& request) const +{ + VLOG(1) << "Handling quota status request"; + + // Check that the request type is GET which is guaranteed by the master. + CHECK_EQ("GET", request.method); + + QuotaStatus status; + status.mutable_infos()->Reserve(static_cast<int>(master->quotas.size())); + + // Create an entry (including role and resources) for each quota. + foreachvalue (const Quota& quota, master->quotas) { + status.add_infos()->CopyFrom(quota.info); + } + + return OK(JSON::protobuf(status), request.url.query.get("jsonp")); +} + + Future<bool> Master::QuotaHandler::authorize( const Option<string>& principal, const string& role) const
