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 54b45433e13579f6ab84fb955ee5248d9737ffd8
Author: Meng Zhu <[email protected]>
AuthorDate: Tue Aug 6 12:28:04 2019 -0700

    Defined constant `DEFAULT_WEIGHT`.
    
    A role's default weight == 1.0. This affects the sorting
    precedence during resource allocation.
    
    Review: https://reviews.apache.org/r/71257
---
 src/master/allocator/mesos/sorter/drf/sorter.cpp    | 3 ++-
 src/master/allocator/mesos/sorter/random/sorter.cpp | 3 ++-
 src/master/constants.hpp                            | 3 +++
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/master/allocator/mesos/sorter/drf/sorter.cpp 
b/src/master/allocator/mesos/sorter/drf/sorter.cpp
index b7da3ff..09889cd 100644
--- a/src/master/allocator/mesos/sorter/drf/sorter.cpp
+++ b/src/master/allocator/mesos/sorter/drf/sorter.cpp
@@ -15,6 +15,7 @@
 // limitations under the License.
 
 #include "master/allocator/mesos/sorter/drf/sorter.hpp"
+#include "master/constants.hpp"
 
 #include <iterator>
 #include <set>
@@ -654,7 +655,7 @@ double DRFSorter::calculateShare(const Node* node) const
 double DRFSorter::getWeight(const Node* node) const
 {
   if (node->weight.isNone()) {
-    node->weight = weights.get(node->path).getOrElse(1.0);
+    node->weight = weights.get(node->path).getOrElse(DEFAULT_WEIGHT);
   }
 
   return CHECK_NOTNONE(node->weight);
diff --git a/src/master/allocator/mesos/sorter/random/sorter.cpp 
b/src/master/allocator/mesos/sorter/random/sorter.cpp
index 3e93a4a..60a5797 100644
--- a/src/master/allocator/mesos/sorter/random/sorter.cpp
+++ b/src/master/allocator/mesos/sorter/random/sorter.cpp
@@ -16,6 +16,7 @@
 
 #include "master/allocator/mesos/sorter/random/sorter.hpp"
 #include "master/allocator/mesos/sorter/random/utils.hpp"
+#include "master/constants.hpp"
 
 #include <set>
 #include <string>
@@ -494,7 +495,7 @@ size_t RandomSorter::count() const
 double RandomSorter::getWeight(const Node* node) const
 {
   if (node->weight.isNone()) {
-    node->weight = weights.get(node->path).getOrElse(1.0);
+    node->weight = weights.get(node->path).getOrElse(DEFAULT_WEIGHT);
   }
 
   return CHECK_NOTNONE(node->weight);
diff --git a/src/master/constants.hpp b/src/master/constants.hpp
index 26afa35..c384b68 100644
--- a/src/master/constants.hpp
+++ b/src/master/constants.hpp
@@ -176,6 +176,9 @@ std::vector<MasterInfo::Capability> MASTER_CAPABILITIES();
 // A role's default quota: no guarantees and no limits.
 const Quota DEFAULT_QUOTA;
 
+// Default weight for a role.
+constexpr double DEFAULT_WEIGHT = 1.0;
+
 } // namespace master {
 } // namespace internal {
 } // namespace mesos {

Reply via email to