Avoid copying of re-register framework messages in the master. Prior to this patch, the re-register framework message was copied into a subscribe call. This updates the handler to perform moves instead.
Review: https://reviews.apache.org/r/66900/ Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/cc68152b Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/cc68152b Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/cc68152b Branch: refs/heads/master Commit: cc68152b3d3e83a674c231dc14298b482a189e49 Parents: cbe2edd Author: Meng Zhu <[email protected]> Authored: Fri May 4 14:00:46 2018 -0700 Committer: Benjamin Mahler <[email protected]> Committed: Fri May 4 14:00:46 2018 -0700 ---------------------------------------------------------------------- src/master/master.cpp | 14 +++++++------- src/master/master.hpp | 3 +-- 2 files changed, 8 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/cc68152b/src/master/master.cpp ---------------------------------------------------------------------- diff --git a/src/master/master.cpp b/src/master/master.cpp index 3ac2860..3b5d2eb 100644 --- a/src/master/master.cpp +++ b/src/master/master.cpp @@ -807,9 +807,7 @@ void Master::initialize() &Master::registerFramework); install<ReregisterFrameworkMessage>( - &Master::reregisterFramework, - &ReregisterFrameworkMessage::framework, - &ReregisterFrameworkMessage::failover); + &Master::reregisterFramework); install<UnregisterFrameworkMessage>( &Master::unregisterFramework, @@ -2496,9 +2494,11 @@ void Master::registerFramework( void Master::reregisterFramework( const UPID& from, - const FrameworkInfo& frameworkInfo, - bool failover) + ReregisterFrameworkMessage&& reregisterFrameworkMessage) { + FrameworkInfo frameworkInfo = + std::move(*reregisterFrameworkMessage.mutable_framework()); + if (!frameworkInfo.has_id() || frameworkInfo.id().value().empty()) { const string error = "Re-registering without an 'id'"; @@ -2513,8 +2513,8 @@ void Master::reregisterFramework( } scheduler::Call::Subscribe call; - call.mutable_framework_info()->CopyFrom(frameworkInfo); - call.set_force(failover); + *call.mutable_framework_info() = std::move(frameworkInfo); + call.set_force(reregisterFrameworkMessage.failover()); subscribe(from, call); } http://git-wip-us.apache.org/repos/asf/mesos/blob/cc68152b/src/master/master.hpp ---------------------------------------------------------------------- diff --git a/src/master/master.hpp b/src/master/master.hpp index 45bdf36..76e7763 100644 --- a/src/master/master.hpp +++ b/src/master/master.hpp @@ -448,8 +448,7 @@ public: void reregisterFramework( const process::UPID& from, - const FrameworkInfo& frameworkInfo, - bool failover); + ReregisterFrameworkMessage&& reregisterFrameworkMessage); void unregisterFramework( const process::UPID& from,
