You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by mp...@apache.org on 2017/07/25 00:06:13 UTC
mesos git commit: Multi-role: Adjusted `long-lived-framework` to use
allocated resources.
Repository: mesos
Updated Branches:
refs/heads/master 2215600f4 -> 096e5e3ab
Multi-role: Adjusted `long-lived-framework` to use allocated resources.
With multi-role support, resources have an explicit notion of
an allocation role. The allocation role is used in the `contains` check
for example. The task/executor resources that the long-lived-framework
uses therefore need to be updated such that the check works correctly.
Review: https://reviews.apache.org/r/61094
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/096e5e3a
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/096e5e3a
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/096e5e3a
Branch: refs/heads/master
Commit: 096e5e3abf1d0d82ebd2f4585111fb88371242a6
Parents: 2215600
Author: Michael Park <mp...@apache.org>
Authored: Mon Jul 24 16:14:05 2017 -0700
Committer: Michael Park <mp...@apache.org>
Committed: Mon Jul 24 16:59:18 2017 -0700
----------------------------------------------------------------------
src/examples/long_lived_framework.cpp | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/096e5e3a/src/examples/long_lived_framework.cpp
----------------------------------------------------------------------
diff --git a/src/examples/long_lived_framework.cpp b/src/examples/long_lived_framework.cpp
index bfc71c5..af5b43e 100644
--- a/src/examples/long_lived_framework.cpp
+++ b/src/examples/long_lived_framework.cpp
@@ -106,9 +106,13 @@ public:
master(_master),
framework(_framework),
executor(_executor),
- taskResources(Resources::parse(
- "cpus:" + stringify(CPUS_PER_TASK) +
- ";mem:" + stringify(MEM_PER_TASK)).get()),
+ taskResources([&_framework]() {
+ Resources resources = Resources::parse(
+ "cpus:" + stringify(CPUS_PER_TASK) +
+ ";mem:" + stringify(MEM_PER_TASK)).get();
+ resources.allocate(_framework.role());
+ return resources;
+ }()),
tasksLaunched(0),
credential(_credential),
metrics(*this)
@@ -237,7 +241,11 @@ protected:
{
CHECK_EQ(SUBSCRIBED, state);
- static const Resources EXECUTOR_RESOURCES = Resources(executor.resources());
+ const Resources executorResources = [this]() {
+ Resources resources(executor.resources());
+ resources.allocate(framework.role());
+ return resources;
+ }();
metrics.offers_received += offers.size();
@@ -247,7 +255,7 @@ protected:
// Launch a new task with executor.
if (Resources(offer.resources()).toUnreserved()
- .contains(EXECUTOR_RESOURCES + taskResources)) {
+ .contains(taskResources + executorResources)) {
LOG(INFO)
<< "Starting executor and task " << tasksLaunched
<< " on " << offer.hostname();