Repository: mesos
Updated Branches:
  refs/heads/master 76b746682 -> 8570c1508


Extracted public logic of updating weights into _updateWeights.

This patch refactored the logic of updating weights in WeightsHandler.
Extracted the public code into new `_updateWeights()` method so that
the new operator API can reuse this method to update weights.

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


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

Branch: refs/heads/master
Commit: 965ac52aee85612f4217a5737b2ee31588222f43
Parents: 76b7466
Author: zhou xing <xingz...@cn.ibm.com>
Authored: Tue Jun 28 13:20:21 2016 -0700
Committer: Vinod Kone <vinodk...@gmail.com>
Committed: Tue Jun 28 13:20:21 2016 -0700

----------------------------------------------------------------------
 src/master/master.hpp          |  7 ++++++-
 src/master/weights_handler.cpp | 14 +++++++++++---
 2 files changed, 17 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/965ac52a/src/master/master.hpp
----------------------------------------------------------------------
diff --git a/src/master/master.hpp b/src/master/master.hpp
index 111c522..8bcc16b 100644
--- a/src/master/master.hpp
+++ b/src/master/master.hpp
@@ -1136,7 +1136,12 @@ private:
     process::Future<std::vector<WeightInfo>> _getWeights(
         const Option<std::string>& principal) const;
 
-    process::Future<process::http::Response> _update(
+    process::Future<process::http::Response>_updateWeights(
+        const Option<std::string>& principal,
+        const google::protobuf::RepeatedPtrField<WeightInfo>& weightInfos)
+            const;
+
+    process::Future<process::http::Response> __updateWeights(
         const std::vector<WeightInfo>& updateWeightInfos) const;
 
     // Rescind all outstanding offers if any of the 'weightInfos' roles has

http://git-wip-us.apache.org/repos/asf/mesos/blob/965ac52a/src/master/weights_handler.cpp
----------------------------------------------------------------------
diff --git a/src/master/weights_handler.cpp b/src/master/weights_handler.cpp
index 0332d86..02a5a1c 100644
--- a/src/master/weights_handler.cpp
+++ b/src/master/weights_handler.cpp
@@ -179,9 +179,17 @@ Future<http::Response> Master::WeightsHandler::update(
         request.body + "': " + weightInfos.error());
   }
 
+  return _updateWeights(principal, weightInfos.get());
+}
+
+
+Future<http::Response> Master::WeightsHandler::_updateWeights(
+    const Option<string>& principal,
+    const RepeatedPtrField<WeightInfo>& weightInfos) const {
   vector<WeightInfo> validatedWeightInfos;
   vector<string> roles;
-  foreach (WeightInfo& weightInfo, weightInfos.get()) {
+
+  foreach (WeightInfo weightInfo, weightInfos) {
     string role = strings::trim(weightInfo.role());
 
     Option<Error> roleError = roles::validate(role);
@@ -216,12 +224,12 @@ Future<http::Response> Master::WeightsHandler::update(
         return Forbidden();
       }
 
-      return _update(validatedWeightInfos);
+      return __updateWeights(validatedWeightInfos);
     }));
 }
 
 
-Future<http::Response> Master::WeightsHandler::_update(
+Future<http::Response> Master::WeightsHandler::__updateWeights(
     const vector<WeightInfo>& weightInfos) const
 {
   // Update the registry and acknowledge the request.

Reply via email to