You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by mz...@apache.org on 2019/08/14 03:40:35 UTC

[mesos] 03/03: Tracked weight info in the Role struct in the allocator.

This is an automated email from the ASF dual-hosted git repository.

mzhu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git

commit 1310bd0dfb826ed6dac80ef26a9bd5b6a9229752
Author: Meng Zhu <mz...@mesosphere.io>
AuthorDate: Tue Aug 6 12:35:23 2019 -0700

    Tracked weight info in the Role struct in the allocator.
    
    Review: https://reviews.apache.org/r/71258
---
 src/master/allocator/mesos/hierarchical.cpp | 1 +
 src/master/allocator/mesos/hierarchical.hpp | 9 ++++++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/master/allocator/mesos/hierarchical.cpp b/src/master/allocator/mesos/hierarchical.cpp
index 87b03d3..580d35a 100644
--- a/src/master/allocator/mesos/hierarchical.cpp
+++ b/src/master/allocator/mesos/hierarchical.cpp
@@ -1415,6 +1415,7 @@ void HierarchicalAllocatorProcess::updateWeights(
 
   foreach (const WeightInfo& weightInfo, weightInfos) {
     CHECK(weightInfo.has_role());
+    roles[weightInfo.role()].weight = weightInfo.weight();
     roleSorter->updateWeight(weightInfo.role(), weightInfo.weight());
   }
 
diff --git a/src/master/allocator/mesos/hierarchical.hpp b/src/master/allocator/mesos/hierarchical.hpp
index dee5baf..8be8dce 100644
--- a/src/master/allocator/mesos/hierarchical.hpp
+++ b/src/master/allocator/mesos/hierarchical.hpp
@@ -111,6 +111,8 @@ struct Framework
 
 struct Role
 {
+  Role() : weight(DEFAULT_WEIGHT) {}
+
   // IDs of the frameworks susbscibed to the role, if any.
   hashset<FrameworkID> frameworks;
 
@@ -124,11 +126,16 @@ struct Role
   // this role. By default, a role has no guarantee and no limit.
   Quota quota;
 
+  // Configured weight for the role. This affects sorting precedence.
+  // By default, weights == DEFAULT_WEIGHT == 1.0.
+  double weight;
+
   bool isEmpty() const
   {
     return frameworks.empty() &&
            reservationScalarQuantities.empty() &&
-           quota == DEFAULT_QUOTA;
+           quota == DEFAULT_QUOTA &&
+           weight == DEFAULT_WEIGHT;
   }
 };