Fixed a bug in the allocator's framework activation. Review: https://reviews.apache.org/r/28668
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/f68d6cd7 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/f68d6cd7 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/f68d6cd7 Branch: refs/heads/master Commit: f68d6cd7746cfb47e136a5c95b9bc7bcdcdf269d Parents: 9b84b52 Author: Benjamin Mahler <[email protected]> Authored: Tue Dec 2 19:33:15 2014 -0800 Committer: Benjamin Mahler <[email protected]> Committed: Wed Dec 3 15:02:05 2014 -0800 ---------------------------------------------------------------------- src/master/allocator.hpp | 12 ++++-------- src/master/hierarchical_allocator_process.hpp | 10 +++++----- src/master/master.cpp | 4 ++-- src/tests/allocator_tests.cpp | 2 +- src/tests/mesos.hpp | 10 ++++------ 5 files changed, 16 insertions(+), 22 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/f68d6cd7/src/master/allocator.hpp ---------------------------------------------------------------------- diff --git a/src/master/allocator.hpp b/src/master/allocator.hpp index 8fb660d..af4782b 100644 --- a/src/master/allocator.hpp +++ b/src/master/allocator.hpp @@ -79,8 +79,7 @@ public: // Offers are sent only to activated frameworks. void activateFramework( - const FrameworkID& frameworkId, - const FrameworkInfo& frameworkInfo); + const FrameworkID& frameworkId); void deactivateFramework( const FrameworkID& frameworkId); @@ -155,8 +154,7 @@ public: const FrameworkID& frameworkId) = 0; virtual void activateFramework( - const FrameworkID& frameworkId, - const FrameworkInfo& frameworkInfo) = 0; + const FrameworkID& frameworkId) = 0; virtual void deactivateFramework( const FrameworkID& frameworkId) = 0; @@ -247,14 +245,12 @@ inline void Allocator::removeFramework( inline void Allocator::activateFramework( - const FrameworkID& frameworkId, - const FrameworkInfo& frameworkInfo) + const FrameworkID& frameworkId) { process::dispatch( process, &AllocatorProcess::activateFramework, - frameworkId, - frameworkInfo); + frameworkId); } http://git-wip-us.apache.org/repos/asf/mesos/blob/f68d6cd7/src/master/hierarchical_allocator_process.hpp ---------------------------------------------------------------------- diff --git a/src/master/hierarchical_allocator_process.hpp b/src/master/hierarchical_allocator_process.hpp index f0baa05..ddd42e7 100644 --- a/src/master/hierarchical_allocator_process.hpp +++ b/src/master/hierarchical_allocator_process.hpp @@ -83,8 +83,7 @@ public: const FrameworkID& frameworkId); void activateFramework( - const FrameworkID& frameworkId, - const FrameworkInfo& frameworkInfo); + const FrameworkID& frameworkId); void deactivateFramework( const FrameworkID& frameworkId); @@ -333,12 +332,13 @@ HierarchicalAllocatorProcess<RoleSorter, FrameworkSorter>::removeFramework( template <class RoleSorter, class FrameworkSorter> void HierarchicalAllocatorProcess<RoleSorter, FrameworkSorter>::activateFramework( - const FrameworkID& frameworkId, - const FrameworkInfo& frameworkInfo) + const FrameworkID& frameworkId) { CHECK(initialized); - const std::string& role = frameworkInfo.role(); + CHECK(frameworks.contains(frameworkId)); + const std::string& role = frameworks[frameworkId].role; + sorters[role]->activate(frameworkId.value()); LOG(INFO) << "Activated framework " << frameworkId; http://git-wip-us.apache.org/repos/asf/mesos/blob/f68d6cd7/src/master/master.cpp ---------------------------------------------------------------------- diff --git a/src/master/master.cpp b/src/master/master.cpp index 3d85e7b..b910665 100644 --- a/src/master/master.cpp +++ b/src/master/master.cpp @@ -1580,7 +1580,7 @@ void Master::_reregisterFramework( // the allocator has the correct view of the framework's share. if (!framework->active) { framework->active = true; - allocator->activateFramework(framework->id, framework->info); + allocator->activateFramework(framework->id); } FrameworkReregisteredMessage message; @@ -4162,7 +4162,7 @@ void Master::failoverFramework(Framework* framework, const UPID& newPid) // the allocator has the correct view of the framework's share. if (!framework->active) { framework->active = true; - allocator->activateFramework(framework->id, framework->info); + allocator->activateFramework(framework->id); } // 'Failover' the framework's metrics. i.e., change the lookup key http://git-wip-us.apache.org/repos/asf/mesos/blob/f68d6cd7/src/tests/allocator_tests.cpp ---------------------------------------------------------------------- diff --git a/src/tests/allocator_tests.cpp b/src/tests/allocator_tests.cpp index b2924e3..65f05fd 100644 --- a/src/tests/allocator_tests.cpp +++ b/src/tests/allocator_tests.cpp @@ -1304,7 +1304,7 @@ TYPED_TEST(AllocatorTest, SchedulerFailover) MesosSchedulerDriver driver2( &sched2, frameworkInfo2, master.get(), DEFAULT_CREDENTIAL); - EXPECT_CALL(this->allocator, activateFramework(_, _)); + EXPECT_CALL(this->allocator, activateFramework(_)); EXPECT_CALL(sched2, registered(_, frameworkId, _)); http://git-wip-us.apache.org/repos/asf/mesos/blob/f68d6cd7/src/tests/mesos.hpp ---------------------------------------------------------------------- diff --git a/src/tests/mesos.hpp b/src/tests/mesos.hpp index 02a7129..aa10343 100644 --- a/src/tests/mesos.hpp +++ b/src/tests/mesos.hpp @@ -664,7 +664,7 @@ public: ON_CALL(*this, removeFramework(_)) .WillByDefault(InvokeFrameworkRemoved(this)); - ON_CALL(*this, activateFramework(_, _)) + ON_CALL(*this, activateFramework(_)) .WillByDefault(InvokeFrameworkActivated(this)); ON_CALL(*this, deactivateFramework(_)) @@ -714,9 +714,8 @@ public: MOCK_METHOD1(removeFramework, void( const FrameworkID&)); - MOCK_METHOD2(activateFramework, void( - const FrameworkID&, - const FrameworkInfo&)); + MOCK_METHOD1(activateFramework, void( + const FrameworkID&)); MOCK_METHOD1(deactivateFramework, void( const FrameworkID&)); @@ -800,8 +799,7 @@ ACTION_P(InvokeFrameworkActivated, allocator) process::dispatch( allocator->real, &master::allocator::AllocatorProcess::activateFramework, - arg0, - arg1); + arg0); }
