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 2015/12/01 12:57:01 UTC
[2/2] mesos git commit: Updated codebase to use `nonRevocable()`
where appropriate.
Updated codebase to use `nonRevocable()` where appropriate.
Review: https://reviews.apache.org/r/40756
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/ffbed5ea
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/ffbed5ea
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/ffbed5ea
Branch: refs/heads/master
Commit: ffbed5ea3bb059ed6dd8830d8a6acc5195ed3683
Parents: dba67f5
Author: Alexander Rukletsov <ru...@gmail.com>
Authored: Tue Dec 1 06:50:41 2015 -0500
Committer: Michael Park <mp...@apache.org>
Committed: Tue Dec 1 06:50:43 2015 -0500
----------------------------------------------------------------------
src/common/http.cpp | 2 +-
src/master/allocator/mesos/hierarchical.cpp | 10 ++++------
src/master/master.cpp | 6 +++---
src/slave/slave.cpp | 3 +--
4 files changed, 9 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/ffbed5ea/src/common/http.cpp
----------------------------------------------------------------------
diff --git a/src/common/http.cpp b/src/common/http.cpp
index 692ea3f..586d1c8 100644
--- a/src/common/http.cpp
+++ b/src/common/http.cpp
@@ -91,7 +91,7 @@ JSON::Object model(const Resources& resources)
object.values["disk"] = 0;
// Model non-revocable resources.
- Resources nonRevocable = resources - resources.revocable();
+ Resources nonRevocable = resources.nonRevocable();
foreachpair (
const string& name, const Value::Type& type, nonRevocable.types()) {
http://git-wip-us.apache.org/repos/asf/mesos/blob/ffbed5ea/src/master/allocator/mesos/hierarchical.cpp
----------------------------------------------------------------------
diff --git a/src/master/allocator/mesos/hierarchical.cpp b/src/master/allocator/mesos/hierarchical.cpp
index 31ed62e..b8f3be8 100644
--- a/src/master/allocator/mesos/hierarchical.cpp
+++ b/src/master/allocator/mesos/hierarchical.cpp
@@ -423,11 +423,9 @@ void HierarchicalAllocatorProcess::updateSlave(
// Update the total resources.
- // First remove the old oversubscribed resources from the total.
- slaves[slaveId].total -= slaves[slaveId].total.revocable();
-
- // Now add the new estimate of oversubscribed resources.
- slaves[slaveId].total += oversubscribed;
+ // Remove the old oversubscribed resources from the total and then
+ // add the new estimate of oversubscribed resources.
+ slaves[slaveId].total = slaves[slaveId].total.nonRevocable() + oversubscribed;
// Now, update the total resources in the role sorters.
roleSorter->update(slaveId, slaves[slaveId].total.unreserved());
@@ -1024,7 +1022,7 @@ void HierarchicalAllocatorProcess::allocate(
// Remove revocable resources if the framework has not opted
// for them.
if (!frameworks[frameworkId].revocable) {
- resources -= resources.revocable();
+ resources = resources.nonRevocable();
}
// If the resources are not allocatable, ignore.
http://git-wip-us.apache.org/repos/asf/mesos/blob/ffbed5ea/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index b918ae4..2d6e14e 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -4319,8 +4319,8 @@ void Master::updateSlave(
// NOTE: We don't need to rescind inverse offers here as they are unrelated to
// oversubscription.
- slave->totalResources -= slave->totalResources.revocable();
- slave->totalResources += oversubscribedResources.revocable();
+ slave->totalResources =
+ slave->totalResources.nonRevocable() + oversubscribedResources.revocable();
// Now, update the allocator with the new estimate.
allocator->updateSlave(slaveId, oversubscribedResources);
@@ -6587,7 +6587,7 @@ double Master::_resources_used(const string& name)
foreachvalue (Slave* slave, slaves.registered) {
foreachvalue (const Resources& resources, slave->usedResources) {
- foreach (const Resource& resource, resources - resources.revocable()) {
+ foreach (const Resource& resource, resources.nonRevocable()) {
if (resource.name() == name && resource.type() == Value::SCALAR) {
used += resource.scalar().value();
}
http://git-wip-us.apache.org/repos/asf/mesos/blob/ffbed5ea/src/slave/slave.cpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.cpp b/src/slave/slave.cpp
index 9055f2a..777f36b 100644
--- a/src/slave/slave.cpp
+++ b/src/slave/slave.cpp
@@ -4874,8 +4874,7 @@ double Slave::_resources_used(const string& name)
foreachvalue (Framework* framework, frameworks) {
foreachvalue (Executor* executor, framework->executors) {
- foreach (const Resource& resource,
- executor->resources - executor->resources.revocable()) {
+ foreach (const Resource& resource, executor->resources.nonRevocable()) {
if (resource.name() == name && resource.type() == Value::SCALAR) {
used += resource.scalar().value();
}