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:49 UTC

[3/5] mesos git commit: Implement fairness exclusion: Updated sorter.

Implement fairness exclusion: Updated sorter.

Review: https://reviews.apache.org/r/49190/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/2ee8642a
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/2ee8642a
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/2ee8642a

Branch: refs/heads/guangya_fairness_exclusion
Commit: 2ee8642a75baffd15ecc7e02aee917aa37c7304d
Parents: e8e9928
Author: Guangya Liu <gy...@gmail.com>
Authored: Thu Jun 30 16:32:08 2016 -0700
Committer: Benjamin Mahler <bm...@apache.org>
Committed: Thu Jun 30 17:24:16 2016 -0700

----------------------------------------------------------------------
 src/master/allocator/sorter/drf/sorter.cpp | 12 ++++++++++++
 src/master/allocator/sorter/drf/sorter.hpp |  6 ++++++
 src/master/allocator/sorter/sorter.hpp     |  5 +++++
 3 files changed, 23 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/2ee8642a/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 27d56f2..c5a7ec1 100644
--- a/src/master/allocator/sorter/drf/sorter.cpp
+++ b/src/master/allocator/sorter/drf/sorter.cpp
@@ -409,6 +409,12 @@ double DRFSorter::calculateShare(const string& name)
   // scalars.
 
   foreach (const string& scalar, total_.scalarQuantities.names()) {
+    // Filter out the exclude resource names.
+    if (fairnessExcludeResourceNames.isSome() &&
+        fairnessExcludeResourceNames.get().count(scalar)) {
+      continue;
+    }
+
     // We collect the scalar accumulated total value from the
     // `Resources` object.
     //
@@ -447,6 +453,12 @@ 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/2ee8642a/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 35273b5..a40a995 100644
--- a/src/master/allocator/sorter/drf/sorter.hpp
+++ b/src/master/allocator/sorter/drf/sorter.hpp
@@ -124,6 +124,9 @@ 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.
@@ -132,6 +135,9 @@ private:
   // Returns the dominant resource share for the client.
   double calculateShare(const std::string& name);
 
+  // Resource names that will be ignored by `calculateShare()`.
+  Option<std::set<std::string>> fairnessExcludeResourceNames;
+
   // Returns an iterator to the specified client, if
   // it exists in this Sorter.
   std::set<Client, DRFComparator>::iterator find(const std::string& name);

http://git-wip-us.apache.org/repos/asf/mesos/blob/2ee8642a/src/master/allocator/sorter/sorter.hpp
----------------------------------------------------------------------
diff --git a/src/master/allocator/sorter/sorter.hpp b/src/master/allocator/sorter/sorter.hpp
index 68a2f56..a2a053b 100644
--- a/src/master/allocator/sorter/sorter.hpp
+++ b/src/master/allocator/sorter/sorter.hpp
@@ -141,6 +141,11 @@ 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 {