You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ya...@apache.org on 2014/06/17 23:10:38 UTC
[2/5] git commit: Created framework rate limits protobuf object which
is loaded as JSON through master flags.
Created framework rate limits protobuf object which is loaded as JSON through master flags.
Review: https://reviews.apache.org/r/22425
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/2f9ffddf
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/2f9ffddf
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/2f9ffddf
Branch: refs/heads/master
Commit: 2f9ffddf98f544b778fdeee50a1ae09ec0e7c786
Parents: 4a0b349
Author: Jiang Yan Xu <ya...@jxu.me>
Authored: Mon Jun 16 17:21:24 2014 -0700
Committer: Jiang Yan Xu <ya...@jxu.me>
Committed: Tue Jun 17 14:10:20 2014 -0700
----------------------------------------------------------------------
include/mesos/mesos.proto | 30 ++++++++++++++++++++++++++++++
src/master/flags.hpp | 24 ++++++++++++++++++++++++
src/master/master.cpp | 12 ++++++++++++
src/master/master.hpp | 2 ++
4 files changed, 68 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/2f9ffddf/include/mesos/mesos.proto
----------------------------------------------------------------------
diff --git a/include/mesos/mesos.proto b/include/mesos/mesos.proto
index 709b8b1..2f6be05 100644
--- a/include/mesos/mesos.proto
+++ b/include/mesos/mesos.proto
@@ -746,3 +746,33 @@ message ACLs {
repeated ACL.HTTPGet http_get = 4;
repeated ACL.HTTPPut http_put = 5;
}
+
+
+/**
+ * Rate (queries per second, QPS) limit for messages from a framework to master.
+ * Strictly speaking they are the combined rate from all frameworks of the same
+ * principal.
+ */
+message RateLimit {
+ // Leaving QPS unset gives it unlimited rate (i.e., not throttled).
+ optional double qps = 1;
+
+ // Principal of framework(s) to be throttled. Should match
+ // FrameworkInfo.princpal and Credential.principal (if using authentication).
+ required string principal = 2;
+}
+
+
+/**
+ * Collection of RateLimit.
+ * Frameworks without rate limits defined here are not throttled.
+ * TODO(xujyan): Currently when a framework is not specified in 'limits' it is
+ * not throttled. This can be done more explicitly by adding a RateLimit entry
+ * without setting its 'qps'. We should consider adding an optional
+ * 'aggregate_default_qps' which can be used to throttle the frameworks not
+ * specified here.
+ */
+message RateLimits {
+ // Items should have unique principals.
+ repeated RateLimit limits = 1;
+}
http://git-wip-us.apache.org/repos/asf/mesos/blob/2f9ffddf/src/master/flags.hpp
----------------------------------------------------------------------
diff --git a/src/master/flags.hpp b/src/master/flags.hpp
index 7850e45..47bb0dc 100644
--- a/src/master/flags.hpp
+++ b/src/master/flags.hpp
@@ -237,6 +237,29 @@ public:
" }\n"
" ]\n"
"}");
+
+ add(&Flags::rate_limits,
+ "rate_limits",
+ "The value could be a JSON formatted string of rate limits\n"
+ "or a file path containing the JSON formatted rate limits used\n"
+ "for framework rate limiting.\n"
+ "Path could be of the form 'file:///path/to/file'\n"
+ "or '/path/to/file'.\n"
+ "\n"
+ "See the RateLimits protobuf in mesos.proto for the expected format.\n"
+ "\n"
+ "Example:\n"
+ "{\n"
+ " \"limits\": [\n"
+ " {\n"
+ " \"principal\": \"foo\",\n"
+ " \"qps\": 55.5\n"
+ " },\n"
+ " {\n"
+ " \"principal\": \"bar\"\n"
+ " }\n"
+ " ]\n"
+ "}");
}
bool version;
@@ -264,6 +287,7 @@ public:
bool authenticate_slaves;
Option<std::string> credentials;
Option<ACLs> acls;
+ Option<JSON::Object> rate_limits;
};
} // namespace mesos {
http://git-wip-us.apache.org/repos/asf/mesos/blob/2f9ffddf/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index fb5c770..c7357da 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -45,6 +45,7 @@
#include <stout/option.hpp>
#include <stout/os.hpp>
#include <stout/path.hpp>
+#include <stout/protobuf.hpp>
#include <stout/stringify.hpp>
#include <stout/utils.hpp>
#include <stout/uuid.hpp>
@@ -350,6 +351,17 @@ void Master::initialize()
LOG(INFO) << "Authorization enabled";
}
+ if (flags.rate_limits.isSome()) {
+ Try<RateLimits> limits_ =
+ ::protobuf::parse<RateLimits>(flags.rate_limits.get());
+ if (limits_.isError()) {
+ EXIT(1) << "Invalid RateLimits format: " << limits_.error()
+ << " (see --rate_limits flag)";
+ }
+ limits = limits_.get();
+ LOG(INFO) << "Framework rate limiting enabled";
+ }
+
hashmap<string, RoleInfo> roleInfos;
// Add the default role.
http://git-wip-us.apache.org/repos/asf/mesos/blob/2f9ffddf/src/master/master.hpp
----------------------------------------------------------------------
diff --git a/src/master/master.hpp b/src/master/master.hpp
index d55c4f5..d682613 100644
--- a/src/master/master.hpp
+++ b/src/master/master.hpp
@@ -510,6 +510,8 @@ private:
// Principals of authenticated frameworks/slaves keyed by PID.
hashmap<process::UPID, std::string> authenticated;
+ Option<RateLimits> limits;
+
int64_t nextFrameworkId; // Used to give each framework a unique ID.
int64_t nextOfferId; // Used to give each slot offer a unique ID.
int64_t nextSlaveId; // Used to give each slave a unique ID.