You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ya...@apache.org on 2017/05/30 23:01:27 UTC
mesos git commit: Used loop to implement allocator interval-based
allocation.
Repository: mesos
Updated Branches:
refs/heads/master 0a8321885 -> ad100c322
Used loop to implement allocator interval-based allocation.
This also gets rid of the old "batch" allocation concept because we now
use the term to describe the batching of pending allocation candidates.
Review: https://reviews.apache.org/r/59254
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/ad100c32
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/ad100c32
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/ad100c32
Branch: refs/heads/master
Commit: ad100c322ae1f5b53b0100d1c074054a9ebf3bca
Parents: 0a83218
Author: Jiang Yan Xu <xu...@apple.com>
Authored: Thu May 11 03:14:35 2017 -0700
Committer: Jiang Yan Xu <xu...@apple.com>
Committed: Tue May 30 15:40:51 2017 -0700
----------------------------------------------------------------------
src/master/allocator/mesos/hierarchical.cpp | 35 ++++++++++++++----------
src/master/allocator/mesos/hierarchical.hpp | 3 --
2 files changed, 21 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/ad100c32/src/master/allocator/mesos/hierarchical.cpp
----------------------------------------------------------------------
diff --git a/src/master/allocator/mesos/hierarchical.cpp b/src/master/allocator/mesos/hierarchical.cpp
index 5511bf6..f5b48d8 100644
--- a/src/master/allocator/mesos/hierarchical.cpp
+++ b/src/master/allocator/mesos/hierarchical.cpp
@@ -25,10 +25,12 @@
#include <mesos/resources.hpp>
#include <mesos/type_utils.hpp>
+#include <process/after.hpp>
#include <process/delay.hpp>
#include <process/dispatch.hpp>
#include <process/event.hpp>
#include <process/id.hpp>
+#include <process/loop.hpp>
#include <process/timeout.hpp>
#include <stout/check.hpp>
@@ -44,9 +46,14 @@ using std::vector;
using mesos::allocator::InverseOfferStatus;
+using process::after;
+using process::Continue;
+using process::ControlFlow;
using process::Failure;
using process::Future;
+using process::loop;
using process::Owned;
+using process::PID;
using process::Timeout;
using mesos::internal::protobuf::framework::Capabilities;
@@ -157,7 +164,19 @@ void HierarchicalAllocatorProcess::initialize(
VLOG(1) << "Initialized hierarchical allocator process";
- delay(allocationInterval, self(), &Self::batch);
+ // Start a loop to run allocation periodically.
+ PID<HierarchicalAllocatorProcess> _self = self();
+
+ loop(None(), // Use `None` so we iterate outside the allocator process.
+ [_allocationInterval]() {
+ return after(_allocationInterval);
+ },
+ [_self, this](const Nothing&) {
+ return dispatch(_self, [this]() { return allocate(); })
+ .then([]() -> ControlFlow<Nothing> {
+ return Continue();
+ });
+ });
}
@@ -1166,7 +1185,7 @@ void HierarchicalAllocatorProcess::recoverResources(
// expire before we perform the next allocation for this agent,
// see MESOS-4302 for more information.
//
- // Because the next batched allocation goes through a dispatch
+ // Because the next periodic allocation goes through a dispatch
// after `allocationInterval`, we do the same for `expire()`
// (with a hepler `_expire()`) to achieve the above.
//
@@ -1364,18 +1383,6 @@ void HierarchicalAllocatorProcess::resume()
}
-void HierarchicalAllocatorProcess::batch()
-{
- process::PID<HierarchicalAllocatorProcess> pid = self();
- Duration _allocationInterval = allocationInterval;
-
- allocate()
- .onAny([_allocationInterval, pid]() {
- delay(_allocationInterval, pid, &HierarchicalAllocatorProcess::batch);
- });
-}
-
-
Future<Nothing> HierarchicalAllocatorProcess::allocate()
{
return allocate(slaves.keys());
http://git-wip-us.apache.org/repos/asf/mesos/blob/ad100c32/src/master/allocator/mesos/hierarchical.hpp
----------------------------------------------------------------------
diff --git a/src/master/allocator/mesos/hierarchical.hpp b/src/master/allocator/mesos/hierarchical.hpp
index 123f97c..82fea40 100644
--- a/src/master/allocator/mesos/hierarchical.hpp
+++ b/src/master/allocator/mesos/hierarchical.hpp
@@ -215,9 +215,6 @@ protected:
void pause();
void resume();
- // Callback for doing batch allocations.
- void batch();
-
// Allocate any allocatable resources from all known agents.
process::Future<Nothing> allocate();