You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bm...@apache.org on 2016/12/09 20:17:54 UTC
mesos git commit: Updated `Role::resources()` in master to handle
multi-role frameworks.
Repository: mesos
Updated Branches:
refs/heads/master 590c9f42d -> 244f593ff
Updated `Role::resources()` in master to handle multi-role frameworks.
Currently, the `Role::resources()` method in the `master::Role` struct
returns the total resources used and offered to a framework, which will
be incorrect for multi-role frameworks.
For now, since the support for multi-role frameworks is incomplete
(in particular, the `Resource.allocation_info` is not yet populated),
we continue to handle single-role frameworks in the old manner. Once
the `Resource.allocation_info` is populated, we will remove the
single-role special case logic in `Role::resources()`.
Review: https://reviews.apache.org/r/54524/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/244f593f
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/244f593f
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/244f593f
Branch: refs/heads/master
Commit: 244f593ff9b71c30a5fc0b67b63a772ca1f4d3f7
Parents: 590c9f4
Author: Jay Guo <gu...@gmail.com>
Authored: Fri Dec 9 11:52:34 2016 -0800
Committer: Benjamin Mahler <bm...@apache.org>
Committed: Fri Dec 9 12:06:18 2016 -0800
----------------------------------------------------------------------
src/master/master.cpp | 2 +-
src/master/master.hpp | 26 ++++++++++++++++++++++++--
2 files changed, 25 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/244f593f/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index 353e6ea..8c1c7f9 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -6992,7 +6992,7 @@ void Master::addFramework(Framework* framework)
<< " of framework " << *framework;
if (!activeRoles.contains(role)) {
- activeRoles[role] = new Role();
+ activeRoles[role] = new Role(role);
}
activeRoles.at(role)->addFramework(framework);
};
http://git-wip-us.apache.org/repos/asf/mesos/blob/244f593f/src/master/master.hpp
----------------------------------------------------------------------
diff --git a/src/master/master.hpp b/src/master/master.hpp
index d3c20d7..c304e69 100644
--- a/src/master/master.hpp
+++ b/src/master/master.hpp
@@ -2661,6 +2661,10 @@ inline std::ostream& operator<<(
// Information about an active role.
struct Role
{
+ Role() = delete;
+
+ Role(const std::string& _role) : role(_role) {}
+
void addFramework(Framework* framework)
{
frameworks[framework->id()] = framework;
@@ -2674,14 +2678,32 @@ struct Role
Resources resources() const
{
Resources resources;
+
+ auto allocatedTo = [](const std::string& role) {
+ return [role](const Resource& resource) {
+ return resource.allocation_info().role() == role;
+ };
+ };
+
foreachvalue (Framework* framework, frameworks) {
- resources += framework->totalUsedResources;
- resources += framework->totalOfferedResources;
+ // TODO(jay_guo): MULTI_ROLE is handled as a special case because
+ // the `Resource.allocation_info.role` is not yet populated. Once
+ // the support is complete, we do not need the `else` logic here.
+ if (protobuf::frameworkHasCapability(
+ framework->info, FrameworkInfo::Capability::MULTI_ROLE)) {
+ resources += framework->totalUsedResources.filter(allocatedTo(role));
+ resources += framework->totalOfferedResources.filter(allocatedTo(role));
+ } else {
+ resources += framework->totalUsedResources;
+ resources += framework->totalOfferedResources;
+ }
}
return resources;
}
+ const std::string role;
+
// NOTE: The dynamic role/quota relation is stored in and administrated
// by the master. There is no direct representation of quota information
// here to avoid duplication and to support that an operator can associate