Repository: mesos
Updated Branches:
  refs/heads/master 7ed073e48 -> cc68152b3


Avoid copying of register framework messages in the master.

Prior to this patch, the register framework message was copied
into a subscribe call. This updates the handler to perform moves
instead.

Review: https://reviews.apache.org/r/66860/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/cbe2edd8
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/cbe2edd8
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/cbe2edd8

Branch: refs/heads/master
Commit: cbe2edd80e554309c32f7e7d29dbe08fc251da93
Parents: 7ed073e
Author: Meng Zhu <[email protected]>
Authored: Fri May 4 14:00:30 2018 -0700
Committer: Benjamin Mahler <[email protected]>
Committed: Fri May 4 14:00:30 2018 -0700

----------------------------------------------------------------------
 src/master/master.cpp | 10 ++++++----
 src/master/master.hpp |  2 +-
 2 files changed, 7 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/cbe2edd8/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index 810ccd3..3ac2860 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -804,8 +804,7 @@ void Master::initialize()
       &SubmitSchedulerRequest::name);
 
   install<RegisterFrameworkMessage>(
-      &Master::registerFramework,
-      &RegisterFrameworkMessage::framework);
+      &Master::registerFramework);
 
   install<ReregisterFrameworkMessage>(
       &Master::reregisterFramework,
@@ -2470,8 +2469,11 @@ void Master::receive(
 
 void Master::registerFramework(
     const UPID& from,
-    const FrameworkInfo& frameworkInfo)
+    RegisterFrameworkMessage&& registerFrameworkMessage)
 {
+  FrameworkInfo frameworkInfo =
+    std::move(*registerFrameworkMessage.mutable_framework());
+
   if (frameworkInfo.has_id() && !frameworkInfo.id().value().empty()) {
     const string error = "Registering with 'id' already set";
 
@@ -2486,7 +2488,7 @@ void Master::registerFramework(
   }
 
   scheduler::Call::Subscribe call;
-  call.mutable_framework_info()->CopyFrom(frameworkInfo);
+  *call.mutable_framework_info() = std::move(frameworkInfo);
 
   subscribe(from, call);
 }

http://git-wip-us.apache.org/repos/asf/mesos/blob/cbe2edd8/src/master/master.hpp
----------------------------------------------------------------------
diff --git a/src/master/master.hpp b/src/master/master.hpp
index 067a346..45bdf36 100644
--- a/src/master/master.hpp
+++ b/src/master/master.hpp
@@ -444,7 +444,7 @@ public:
 
   void registerFramework(
       const process::UPID& from,
-      const FrameworkInfo& frameworkInfo);
+      RegisterFrameworkMessage&& registerFrameworkMessage);
 
   void reregisterFramework(
       const process::UPID& from,

Reply via email to