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/06/21 20:53:58 UTC
mesos git commit: Fixed a DRF sorter bug: updating weights should
"dirty" the sorting.
Repository: mesos
Updated Branches:
refs/heads/master 8927be759 -> 0c0757ab3
Fixed a DRF sorter bug: updating weights should "dirty" the sorting.
Review: https://reviews.apache.org/r/48062/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/0c0757ab
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/0c0757ab
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/0c0757ab
Branch: refs/heads/master
Commit: 0c0757ab34c189d59d960be6ec49eefd462d3e4a
Parents: 8927be7
Author: Guangya Liu <gy...@gmail.com>
Authored: Tue Jun 21 13:43:22 2016 -0700
Committer: Benjamin Mahler <bm...@apache.org>
Committed: Tue Jun 21 13:43:22 2016 -0700
----------------------------------------------------------------------
src/master/allocator/sorter/drf/sorter.cpp | 7 +++++
src/tests/sorter_tests.cpp | 36 +++++++++++++++++++++++++
2 files changed, 43 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/0c0757ab/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 65d473a..d277199 100644
--- a/src/master/allocator/sorter/drf/sorter.cpp
+++ b/src/master/allocator/sorter/drf/sorter.cpp
@@ -65,6 +65,13 @@ void DRFSorter::update(const string& name, double weight)
{
CHECK(weights.contains(name));
weights[name] = weight;
+
+ // If the total resources have changed, we're going to
+ // recalculate all the shares, so don't bother just
+ // updating this client.
+ if (!dirty) {
+ update(name);
+ }
}
http://git-wip-us.apache.org/repos/asf/mesos/blob/0c0757ab/src/tests/sorter_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/sorter_tests.cpp b/src/tests/sorter_tests.cpp
index eb207a3..1610f03 100644
--- a/src/tests/sorter_tests.cpp
+++ b/src/tests/sorter_tests.cpp
@@ -176,6 +176,42 @@ TEST(SorterTest, WDRFSorter)
}
+TEST(SorterTest, WDRFSorterUpdateWeight)
+{
+ DRFSorter sorter;
+
+ SlaveID slaveId;
+ slaveId.set_value("agentId");
+
+ Resources totalResources = Resources::parse("cpus:100;mem:100").get();
+
+ // The `dirty` in `sorter` will be set as `true` which means that the
+ // total resources have changed, the `sorter` is going to recalculate
+ // all the shares for each client.
+ sorter.add(slaveId, totalResources);
+
+ sorter.add("a");
+ Resources aResources = Resources::parse("cpus:5;mem:5").get();
+ sorter.allocated("a", slaveId, aResources);
+
+ Resources bResources = Resources::parse("cpus:6;mem:6").get();
+ sorter.add("b");
+ sorter.allocated("b", slaveId, bResources);
+
+ // shares: a = .05, b = .06
+ EXPECT_EQ(list<string>({"a", "b"}), sorter.sort());
+
+ // The `dirty` in `sorter` is set back to `false`, this means that the
+ // `sorter` will not re-calculate `share` for each client but only for
+ // the client whose allocation has been updated.
+
+ sorter.update("b", 2);
+
+ // shares: a = .05, b = .03
+ EXPECT_EQ(list<string>({"b", "a"}), sorter.sort());
+}
+
+
// Some resources are split across multiple resource objects (e.g.
// persistent volumes). This test ensures that the shares for these
// are accounted correctly.