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/07/01 00:43:50 UTC
[4/5] mesos git commit: Implement fairness exclusion: initialize the
sorter.
Implement fairness exclusion: initialize the sorter.
Review: https://reviews.apache.org/r/48907/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/ededfa99
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/ededfa99
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/ededfa99
Branch: refs/heads/guangya_fairness_exclusion
Commit: ededfa991d3d5426ba400fa9062eb8a1954efd68
Parents: 2ee8642
Author: Guangya Liu <gy...@gmail.com>
Authored: Thu Jun 30 16:39:41 2016 -0700
Committer: Benjamin Mahler <bm...@apache.org>
Committed: Thu Jun 30 17:24:16 2016 -0700
----------------------------------------------------------------------
src/master/allocator/mesos/hierarchical.cpp | 3 +++
src/master/allocator/sorter/drf/sorter.cpp | 17 +++++++++--------
src/master/allocator/sorter/drf/sorter.hpp | 8 ++++----
src/master/allocator/sorter/sorter.hpp | 9 ++++-----
4 files changed, 20 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/ededfa99/src/master/allocator/mesos/hierarchical.cpp
----------------------------------------------------------------------
diff --git a/src/master/allocator/mesos/hierarchical.cpp b/src/master/allocator/mesos/hierarchical.cpp
index 20f9e72..3838123 100644
--- a/src/master/allocator/mesos/hierarchical.cpp
+++ b/src/master/allocator/mesos/hierarchical.cpp
@@ -142,7 +142,9 @@ void HierarchicalAllocatorProcess::initialize(
// non-quota'ed roles, hence a dedicated sorter for quota'ed roles is
// necessary.
roleSorter.reset(roleSorterFactory());
+ roleSorter->initialize(fairnessExcludeResourceNames);
quotaRoleSorter.reset(quotaRoleSorterFactory());
+ quotaRoleSorter->initialize(fairnessExcludeResourceNames);
VLOG(1) << "Initialized hierarchical allocator process";
@@ -229,6 +231,7 @@ void HierarchicalAllocatorProcess::addFramework(
activeRoles[role] = 1;
roleSorter->add(role, roleWeight(role));
frameworkSorters[role].reset(frameworkSorterFactory());
+ frameworkSorters[role]->initialize(fairnessExcludeResourceNames);
metrics.addRole(role);
} else {
activeRoles[role]++;
http://git-wip-us.apache.org/repos/asf/mesos/blob/ededfa99/src/master/allocator/sorter/drf/sorter.cpp
----------------------------------------------------------------------
diff --git a/src/master/allocator/sorter/drf/sorter.cpp b/src/master/allocator/sorter/drf/sorter.cpp
index c5a7ec1..967290d 100644
--- a/src/master/allocator/sorter/drf/sorter.cpp
+++ b/src/master/allocator/sorter/drf/sorter.cpp
@@ -61,6 +61,13 @@ DRFSorter::DRFSorter(
: metrics(Metrics(allocator, *this, metricsPrefix)) {}
+void DRFSorter::initialize(
+ const Option<set<string>>& _fairnessExcludeResourceNames)
+{
+ fairnessExcludeResourceNames = _fairnessExcludeResourceNames;
+}
+
+
void DRFSorter::add(const string& name, double weight)
{
CHECK(!contains(name));
@@ -409,9 +416,9 @@ double DRFSorter::calculateShare(const string& name)
// scalars.
foreach (const string& scalar, total_.scalarQuantities.names()) {
- // Filter out the exclude resource names.
+ // Filter out the resources excluded from fair sharing.
if (fairnessExcludeResourceNames.isSome() &&
- fairnessExcludeResourceNames.get().count(scalar)) {
+ fairnessExcludeResourceNames->count(scalar) > 0) {
continue;
}
@@ -453,12 +460,6 @@ double DRFSorter::calculateShare(const string& name)
}
-void DRFSorter::initialize(
- const Option<set<std::string>>& _fairnessExcludeResourceNames) {
- fairnessExcludeResourceNames = _fairnessExcludeResourceNames;
-}
-
-
set<Client, DRFComparator>::iterator DRFSorter::find(const string& name)
{
set<Client, DRFComparator>::iterator it;
http://git-wip-us.apache.org/repos/asf/mesos/blob/ededfa99/src/master/allocator/sorter/drf/sorter.hpp
----------------------------------------------------------------------
diff --git a/src/master/allocator/sorter/drf/sorter.hpp b/src/master/allocator/sorter/drf/sorter.hpp
index a40a995..0aa1a71 100644
--- a/src/master/allocator/sorter/drf/sorter.hpp
+++ b/src/master/allocator/sorter/drf/sorter.hpp
@@ -73,6 +73,9 @@ public:
virtual ~DRFSorter() {}
+ virtual void initialize(
+ const Option<std::set<std::string>>& fairnessExcludeResourceNames);
+
virtual void add(const std::string& name, double weight = 1);
virtual void update(const std::string& name, double weight);
@@ -124,9 +127,6 @@ public:
virtual int count();
- virtual void initialize(
- const Option<std::set<std::string>>& fairnessExcludeResourceNames);
-
private:
// Recalculates the share for the client and moves
// it in 'clients' accordingly.
@@ -135,7 +135,7 @@ private:
// Returns the dominant resource share for the client.
double calculateShare(const std::string& name);
- // Resource names that will be ignored by `calculateShare()`.
+ // Resources (by name) that will be excluded from fair sharing.
Option<std::set<std::string>> fairnessExcludeResourceNames;
// Returns an iterator to the specified client, if
http://git-wip-us.apache.org/repos/asf/mesos/blob/ededfa99/src/master/allocator/sorter/sorter.hpp
----------------------------------------------------------------------
diff --git a/src/master/allocator/sorter/sorter.hpp b/src/master/allocator/sorter/sorter.hpp
index a2a053b..5ce6bb8 100644
--- a/src/master/allocator/sorter/sorter.hpp
+++ b/src/master/allocator/sorter/sorter.hpp
@@ -52,6 +52,10 @@ public:
virtual ~Sorter() = default;
+ // Initialize the sorter.
+ virtual void initialize(
+ const Option<std::set<std::string>>& fairnessExcludeResourceNames) = 0;
+
// Adds a client to allocate resources to. A client
// may be a user or a framework.
virtual void add(const std::string& client, double weight = 1) = 0;
@@ -141,11 +145,6 @@ public:
// Returns the number of clients this Sorter contains,
// either active or deactivated.
virtual int count() = 0;
-
- // Initialize resource names that will be ignored by sorter when
- // calculating dominant share for frameworks or roles.
- virtual void initialize(
- const Option<std::set<std::string>>& fairnessExcludeResourceNames) = 0;
};
} // namespace allocator {