Repository: mesos Updated Branches: refs/heads/master 6ed9882a1 -> cacc1dbfc
Updated flags to support choosing the random sorter. This deprecates `--user_sorter` in favor of `--role_sorter`. This patch also modifies the `--allocator` default to exclude "DRF" from the value, while still ensuring the previous default works. For now, both sorter flags must be set to `drf` or `random`. Review: https://reviews.apache.org/r/67374/ Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/cacc1dbf Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/cacc1dbf Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/cacc1dbf Branch: refs/heads/master Commit: cacc1dbfc4ee5b72f08c32e7ccc39221091715a8 Parents: b8c635d Author: Benjamin Mahler <[email protected]> Authored: Mon Jun 4 15:17:39 2018 -0400 Committer: Benjamin Mahler <[email protected]> Committed: Mon Jun 4 17:15:49 2018 -0400 ---------------------------------------------------------------------- include/mesos/allocator/allocator.hpp | 8 +++++++- src/master/allocator/allocator.cpp | 24 +++++++++++++++++++++--- src/master/constants.hpp | 4 ++-- src/master/flags.cpp | 12 +++++++----- src/master/flags.hpp | 2 +- src/master/main.cpp | 12 +++++++----- 6 files changed, 45 insertions(+), 17 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/cacc1dbf/include/mesos/allocator/allocator.hpp ---------------------------------------------------------------------- diff --git a/include/mesos/allocator/allocator.hpp b/include/mesos/allocator/allocator.hpp index e5a5355..6478692 100644 --- a/include/mesos/allocator/allocator.hpp +++ b/include/mesos/allocator/allocator.hpp @@ -60,9 +60,15 @@ public: * allocator instance from a module using the given name. If `Try` * does not report an error, the wrapped `Allocator*` is not null. * + * TODO(bmahler): Figure out how to pass parameters without + * burning in the built-in module arguments. + * * @param name Name of the allocator. */ - static Try<Allocator*> create(const std::string& name); + static Try<Allocator*> create( + const std::string& name, + const std::string& roleSorter, + const std::string& frameworkSorter); Allocator() {} http://git-wip-us.apache.org/repos/asf/mesos/blob/cacc1dbf/src/master/allocator/allocator.cpp ---------------------------------------------------------------------- diff --git a/src/master/allocator/allocator.cpp b/src/master/allocator/allocator.cpp index e3dd737..4357436 100644 --- a/src/master/allocator/allocator.cpp +++ b/src/master/allocator/allocator.cpp @@ -27,18 +27,36 @@ using std::string; using mesos::internal::master::allocator::HierarchicalDRFAllocator; +using mesos::internal::master::allocator::HierarchicalRandomAllocator; namespace mesos { namespace allocator { -Try<Allocator*> Allocator::create(const string& name) +Try<Allocator*> Allocator::create( + const string& name, + const string& roleSorter, + const string& frameworkSorter) { // Create an instance of the default allocator. If other than the // default allocator is requested, search for it in loaded modules. + // // NOTE: We do not need an extra not-null check, because both // ModuleManager and built-in allocator factory do that already. - if (name == mesos::internal::master::DEFAULT_ALLOCATOR) { - return HierarchicalDRFAllocator::create(); + // + // We also look for "HierarchicalDRF" since that was the + // previous value for `DEFAULT_ALLOCATOR`. + if (name == "HierarchicalDRF" || + name == mesos::internal::master::DEFAULT_ALLOCATOR) { + if (roleSorter == "drf" && frameworkSorter == "drf") { + return HierarchicalDRFAllocator::create(); + } + + if (roleSorter == "random" && frameworkSorter == "random") { + return HierarchicalRandomAllocator::create(); + } + + return Error("Unsupported combination of 'role_sorter'" + " and 'framework_sorter': must be equal (for now)"); } return modules::ModuleManager::create<Allocator>(name); http://git-wip-us.apache.org/repos/asf/mesos/blob/cacc1dbf/src/master/constants.hpp ---------------------------------------------------------------------- diff --git a/src/master/constants.hpp b/src/master/constants.hpp index b31e5f0..f3b257a 100644 --- a/src/master/constants.hpp +++ b/src/master/constants.hpp @@ -127,8 +127,8 @@ constexpr Duration ZOOKEEPER_SESSION_TIMEOUT = Seconds(10); // Name of the default, CRAM-MD5 authenticator. constexpr char DEFAULT_AUTHENTICATOR[] = "crammd5"; -// Name of the default, HierarchicalDRF authenticator. -constexpr char DEFAULT_ALLOCATOR[] = "HierarchicalDRF"; +// Name of the default hierarchical allocator. +constexpr char DEFAULT_ALLOCATOR[] = "hierarchical"; // The default interval between allocations. constexpr Duration DEFAULT_ALLOCATION_INTERVAL = Seconds(1); http://git-wip-us.apache.org/repos/asf/mesos/blob/cacc1dbf/src/master/flags.cpp ---------------------------------------------------------------------- diff --git a/src/master/flags.cpp b/src/master/flags.cpp index 4ad1375..cc3317e 100644 --- a/src/master/flags.cpp +++ b/src/master/flags.cpp @@ -176,15 +176,17 @@ mesos::internal::master::Flags::Flags() "machines are accepted. Path can be of the form\n" "`file:///path/to/file` or `/path/to/file`.\n"); - add(&Flags::user_sorter, - "user_sorter", - "Policy to use for allocating resources between users. May be one of:\n" - " dominant_resource_fairness (drf)", + add(&Flags::role_sorter, + "role_sorter", + flags::DeprecatedName("user_sorter"), + "Policy to use for allocating resources between roles when\n" + "allocating up to quota guarantees as well as when allocating\n" + "up to quota limits. May be one of: [drf, random]", "drf"); add(&Flags::framework_sorter, "framework_sorter", - "Policy to use for allocating resources between a given user's\n" + "Policy to use for allocating resources between a given role's\n" "frameworks. Options are the same as for `--user_sorter`.", "drf"); http://git-wip-us.apache.org/repos/asf/mesos/blob/cacc1dbf/src/master/flags.hpp ---------------------------------------------------------------------- diff --git a/src/master/flags.hpp b/src/master/flags.hpp index 4715f2b..94b8ac2 100644 --- a/src/master/flags.hpp +++ b/src/master/flags.hpp @@ -60,7 +60,7 @@ public: Option<std::string> agent_removal_rate_limit; std::string webui_dir; Option<Path> whitelist; - std::string user_sorter; + std::string role_sorter; std::string framework_sorter; Duration allocation_interval; Option<std::string> cluster; http://git-wip-us.apache.org/repos/asf/mesos/blob/cacc1dbf/src/master/main.cpp ---------------------------------------------------------------------- diff --git a/src/master/main.cpp b/src/master/main.cpp index 3eb1f89..2c7b1bb 100644 --- a/src/master/main.cpp +++ b/src/master/main.cpp @@ -329,17 +329,19 @@ int main(int argc, char** argv) } // Create an instance of allocator. - const string allocatorName = flags.allocator; - Try<Allocator*> allocator = Allocator::create(allocatorName); + Try<Allocator*> allocator = Allocator::create( + flags.allocator, + flags.role_sorter, + flags.framework_sorter); if (allocator.isError()) { EXIT(EXIT_FAILURE) - << "Failed to create '" << allocatorName - << "' allocator: " << allocator.error(); + << "Failed to create allocator '" << flags.allocator << "'" + << ": " << allocator.error(); } CHECK_NOTNULL(allocator.get()); - LOG(INFO) << "Using '" << allocatorName << "' allocator"; + LOG(INFO) << "Using '" << flags.allocator << "' allocator"; Storage* storage = nullptr; #ifndef __WINDOWS__
