You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by jo...@apache.org on 2015/12/04 03:00:22 UTC

[3/3] mesos git commit: Filtered non-whitelisted and deactivated agents once per allocation.

Filtered non-whitelisted and deactivated agents once per allocation.

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


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

Branch: refs/heads/master
Commit: 1c4e0b9b3fda1f9116fd69d6e3b8d96d266d470c
Parents: b9762af
Author: Alexander Rukletsov <ru...@gmail.com>
Authored: Thu Dec 3 20:33:24 2015 -0500
Committer: Joris Van Remoortere <jo...@gmail.com>
Committed: Thu Dec 3 20:37:53 2015 -0500

----------------------------------------------------------------------
 src/master/allocator/mesos/hierarchical.cpp | 29 +++++++++---------------
 1 file changed, 11 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/1c4e0b9b/src/master/allocator/mesos/hierarchical.cpp
----------------------------------------------------------------------
diff --git a/src/master/allocator/mesos/hierarchical.cpp b/src/master/allocator/mesos/hierarchical.cpp
index e6be2d7..6d82ae7 100644
--- a/src/master/allocator/mesos/hierarchical.cpp
+++ b/src/master/allocator/mesos/hierarchical.cpp
@@ -1092,22 +1092,25 @@ void HierarchicalAllocatorProcess::allocate(
   // make sure that we don't assume cluster knowledge when summing resources
   // from that set.
 
+  vector<SlaveID> slaveIds;
+  slaveIds.reserve(slaveIds_.size());
+
+  // Filter out non-whitelisted and deactivated slaves in order not to send
+  // offers for them.
+  foreach (const SlaveID& slaveId, slaveIds_) {
+    if (isWhitelisted(slaveId) && slaves[slaveId].activated) {
+      slaveIds.push_back(slaveId);
+    }
+  }
+
   // Randomize the order in which slaves' resources are allocated.
   // TODO(vinod): Implement a smarter sorting algorithm.
-  vector<SlaveID> slaveIds(slaveIds_.begin(), slaveIds_.end());
   std::random_shuffle(slaveIds.begin(), slaveIds.end());
 
   // Quota comes first and fair share second. Here we process only those
   // roles, for which quota is set (quota'ed roles). Such roles form a
   // special allocation group with a dedicated sorter.
   foreach (const SlaveID& slaveId, slaveIds) {
-    // Don't send offers for non-whitelisted and deactivated slaves.
-    // TODO(alexr): We skip non-whitelisted or deactivated agents in every
-    // loop. Consider doing it once at the beginning before shuffling.
-    if (!isWhitelisted(slaveId) || !slaves[slaveId].activated) {
-      continue;
-    }
-
     foreach (const string& role, quotaRoleSorter->sort()) {
       CHECK_SOME(roles[role].quota);
 
@@ -1188,11 +1191,6 @@ void HierarchicalAllocatorProcess::allocate(
   // ensure we do not over-allocate resources during the WDRF phase.
   Resources remainingClusterResources;
   foreach (const SlaveID& slaveId, slaveIds) {
-    // Don't consider non-whitelisted and deactivated agents.
-    if (!isWhitelisted(slaveId) || !slaves[slaveId].activated) {
-      continue;
-    }
-
     remainingClusterResources +=
       slaves[slaveId].total - slaves[slaveId].allocated;
   }
@@ -1234,11 +1232,6 @@ void HierarchicalAllocatorProcess::allocate(
   // At this point resources for quotas are allocated or accounted for.
   // Proceed with allocating the remaining free pool using WDRF.
   foreach (const SlaveID& slaveId, slaveIds) {
-    // Don't send offers for non-whitelisted and deactivated slaves.
-    if (!isWhitelisted(slaveId) || !slaves[slaveId].activated) {
-      continue;
-    }
-
     // If there are no resources available for the current WDRF stage, stop.
     if ((remainingClusterResources - allocatedForWDRF).empty()) {
       break;