You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bm...@apache.org on 2016/04/08 05:14:51 UTC
[2/3] mesos git commit: Added the quota sorter type to the allocator
template.
Added the quota sorter type to the allocator template.
Review: https://reviews.apache.org/r/45533/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/b1e2ef09
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/b1e2ef09
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/b1e2ef09
Branch: refs/heads/master
Commit: b1e2ef09ed3daaf84741a989e9e726b76020aff8
Parents: c409d5d
Author: Benjamin Bannier <be...@mesosphere.io>
Authored: Thu Apr 7 17:25:55 2016 -0700
Committer: Benjamin Mahler <bm...@apache.org>
Committed: Thu Apr 7 17:26:57 2016 -0700
----------------------------------------------------------------------
src/master/allocator/mesos/hierarchical.cpp | 7 ++-----
src/master/allocator/mesos/hierarchical.hpp | 24 ++++++++++++++++--------
2 files changed, 18 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/b1e2ef09/src/master/allocator/mesos/hierarchical.cpp
----------------------------------------------------------------------
diff --git a/src/master/allocator/mesos/hierarchical.cpp b/src/master/allocator/mesos/hierarchical.cpp
index a8d80b4..0de03c7 100644
--- a/src/master/allocator/mesos/hierarchical.cpp
+++ b/src/master/allocator/mesos/hierarchical.cpp
@@ -135,12 +135,9 @@ void HierarchicalAllocatorProcess::initialize(
// Resources for quota'ed roles are allocated separately and prior to
// non-quota'ed roles, hence a dedicated sorter for quota'ed roles is
- // necessary. We create an instance of the same sorter type we use for
- // all roles.
- //
- // TODO(alexr): Consider introducing a sorter type for quota'ed roles.
+ // necessary.
roleSorter.reset(roleSorterFactory());
- quotaRoleSorter.reset(roleSorterFactory());
+ quotaRoleSorter.reset(quotaRoleSorterFactory());
VLOG(1) << "Initialized hierarchical allocator process";
http://git-wip-us.apache.org/repos/asf/mesos/blob/b1e2ef09/src/master/allocator/mesos/hierarchical.hpp
----------------------------------------------------------------------
diff --git a/src/master/allocator/mesos/hierarchical.hpp b/src/master/allocator/mesos/hierarchical.hpp
index be4ccff..29d0759 100644
--- a/src/master/allocator/mesos/hierarchical.hpp
+++ b/src/master/allocator/mesos/hierarchical.hpp
@@ -45,10 +45,13 @@ namespace allocator {
// We forward declare the hierarchical allocator process so that we
// can typedef an instantiation of it with DRF sorters.
-template <typename RoleSorter, typename FrameworkSorter>
+template <
+ typename RoleSorter,
+ typename FrameworkSorter,
+ typename QuotaRoleSorter>
class HierarchicalAllocatorProcess;
-typedef HierarchicalAllocatorProcess<DRFSorter, DRFSorter>
+typedef HierarchicalAllocatorProcess<DRFSorter, DRFSorter, DRFSorter>
HierarchicalDRFAllocatorProcess;
typedef MesosAllocator<HierarchicalDRFAllocatorProcess>
@@ -69,7 +72,8 @@ class HierarchicalAllocatorProcess : public MesosAllocatorProcess
public:
HierarchicalAllocatorProcess(
const std::function<Sorter*()>& _roleSorterFactory,
- const std::function<Sorter*()>& _frameworkSorterFactory)
+ const std::function<Sorter*()>& _frameworkSorterFactory,
+ const std::function<Sorter*()>& _quotaRoleSorterFactory)
: ProcessBase(process::ID::generate("hierarchical-allocator")),
initialized(false),
paused(true),
@@ -77,7 +81,8 @@ public:
roleSorter(NULL),
quotaRoleSorter(NULL),
roleSorterFactory(_roleSorterFactory),
- frameworkSorterFactory(_frameworkSorterFactory) {}
+ frameworkSorterFactory(_frameworkSorterFactory),
+ quotaRoleSorterFactory(_quotaRoleSorterFactory) {}
virtual ~HierarchicalAllocatorProcess() {}
@@ -448,10 +453,9 @@ protected:
hashmap<std::string, process::Owned<Sorter>> frameworkSorters;
// Factory functions for sorters.
- //
- // NOTE: `quotaRoleSorter` currently reuses `roleSorterFactory`.
const std::function<Sorter*()> roleSorterFactory;
const std::function<Sorter*()> frameworkSorterFactory;
+ const std::function<Sorter*()> quotaRoleSorterFactory;
};
@@ -461,7 +465,10 @@ protected:
// We map the templatized version of the `HierarchicalAllocatorProcess` to one
// that relies on sorter factories in the internal namespace. This allows us
// to keep the implemention of the allocator in the implementation file.
-template <typename RoleSorter, typename FrameworkSorter>
+template <
+ typename RoleSorter,
+ typename FrameworkSorter,
+ typename QuotaRoleSorter>
class HierarchicalAllocatorProcess
: public internal::HierarchicalAllocatorProcess
{
@@ -469,7 +476,8 @@ public:
HierarchicalAllocatorProcess()
: internal::HierarchicalAllocatorProcess(
[]() -> Sorter* { return new RoleSorter(); },
- []() -> Sorter* { return new FrameworkSorter(); }) {}
+ []() -> Sorter* { return new FrameworkSorter(); },
+ []() -> Sorter* { return new QuotaRoleSorter(); }) {}
};
} // namespace allocator {