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/07 04:32:24 UTC
mesos git commit: Updated master to add/remove active roles for
multi-role frameworks.
Repository: mesos
Updated Branches:
refs/heads/master 861129913 -> e8fe8bb6d
Updated master to add/remove active roles for multi-role frameworks.
When a multi-role framework registers, the master should update the
`activeRoles` accordingly.
Review: https://reviews.apache.org/r/54360/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/e8fe8bb6
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/e8fe8bb6
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/e8fe8bb6
Branch: refs/heads/master
Commit: e8fe8bb6d11151940ea541a63ad1e1c4969ca7c2
Parents: 8611299
Author: Jay Guo <gu...@cn.ibm.com>
Authored: Tue Dec 6 20:07:15 2016 -0800
Committer: Benjamin Mahler <bm...@apache.org>
Committed: Tue Dec 6 20:16:26 2016 -0800
----------------------------------------------------------------------
src/master/master.cpp | 52 +++++++++++++++++++++++++++++++++-------------
1 file changed, 37 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/e8fe8bb6/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index b0670d9..67f3222 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -7030,15 +7030,26 @@ void Master::addFramework(Framework* framework)
.onAny(defer(self(), &Self::exited, framework->id(), http));
}
- const string& role = framework->info.role();
- CHECK(isWhitelistedRole(role))
- << "Unknown role " << role
- << " of framework " << *framework;
+ auto addFrameworkRole = [this](Framework* framework, const string& role) {
+ CHECK(isWhitelistedRole(role))
+ << "Unknown role '" << role << "'"
+ << " of framework " << *framework;
- if (!activeRoles.contains(role)) {
- activeRoles[role] = new Role();
+ if (!activeRoles.contains(role)) {
+ activeRoles[role] = new Role();
+ }
+ activeRoles.at(role)->addFramework(framework);
+ };
+
+ if (protobuf::frameworkHasCapability(
+ framework->info,
+ FrameworkInfo::Capability::MULTI_ROLE)) {
+ foreach (const string& role, framework->info.roles()) {
+ addFrameworkRole(framework, role);
+ }
+ } else {
+ addFrameworkRole(framework, framework->info.role());
}
- activeRoles[role]->addFramework(framework);
// There should be no offered resources yet!
CHECK_EQ(Resources(), framework->totalOfferedResources);
@@ -7321,15 +7332,26 @@ void Master::removeFramework(Framework* framework)
framework->unregisteredTime = Clock::now();
- const string& role = framework->info.role();
- CHECK(activeRoles.contains(role))
- << "Unknown role " << role
- << " of framework " << *framework;
+ auto removeFrameworkRole = [this](Framework* framework, const string& role) {
+ CHECK(isWhitelistedRole(role))
+ << "Unknown role '" << role << "'"
+ << " of framework " << *framework;
- activeRoles[role]->removeFramework(framework);
- if (activeRoles[role]->frameworks.empty()) {
- delete activeRoles[role];
- activeRoles.erase(role);
+ activeRoles[role]->removeFramework(framework);
+ if (activeRoles[role]->frameworks.empty()) {
+ delete activeRoles[role];
+ activeRoles.erase(role);
+ }
+ };
+
+ if (protobuf::frameworkHasCapability(
+ framework->info,
+ FrameworkInfo::Capability::MULTI_ROLE)) {
+ foreach (const string& role, framework->info.roles()) {
+ removeFrameworkRole(framework, role);
+ }
+ } else {
+ removeFrameworkRole(framework, framework->info.role());
}
// TODO(anand): This only works for pid based frameworks. We would