Fixed some nits in libprocess firewall initialization.

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


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

Branch: refs/heads/master
Commit: b6187a3b2b206088c4b90cd0187a54240dbde588
Parents: 70dfe87
Author: Alexander Rojas <[email protected]>
Authored: Wed Jun 24 17:36:24 2015 +0200
Committer: Till Toenshoff <[email protected]>
Committed: Wed Jun 24 17:36:25 2015 +0200

----------------------------------------------------------------------
 src/master/main.cpp    | 16 +++++++++-------
 src/messages/flags.hpp |  2 +-
 src/slave/main.cpp     | 23 ++++++++++++++++-------
 3 files changed, 26 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/b6187a3b/src/master/main.cpp
----------------------------------------------------------------------
diff --git a/src/master/main.cpp b/src/master/main.cpp
index 1c33e3b..2624b7e 100644
--- a/src/master/main.cpp
+++ b/src/master/main.cpp
@@ -21,6 +21,7 @@
 #include <memory>
 #include <set>
 #include <string>
+#include <utility>
 #include <vector>
 
 #include <mesos/mesos.hpp>
@@ -95,6 +96,7 @@ using process::firewall::FirewallRule;
 using std::cerr;
 using std::cout;
 using std::endl;
+using std::move;
 using std::set;
 using std::shared_ptr;
 using std::string;
@@ -344,21 +346,21 @@ int main(int argc, char** argv)
   }
 
   if (flags.firewall_rules.isSome()) {
-    const Firewall rules = flags.firewall_rules.get();
+    vector<Owned<FirewallRule>> rules;
 
-    std::vector<Owned<FirewallRule>> _rules;
+    const Firewall firewall = flags.firewall_rules.get();
 
-    if (rules.has_disabled_endpoints()) {
+    if (firewall.has_disabled_endpoints()) {
       hashset<string> paths;
 
-      for (int i = 0; i < rules.disabled_endpoints().paths_size(); ++i) {
-        paths.insert(rules.disabled_endpoints().paths(i));
+      foreach (const string& path, firewall.disabled_endpoints().paths()) {
+        paths.insert(path);
       }
 
-      _rules.emplace_back(new DisabledEndpointsFirewallRule(paths));
+      rules.emplace_back(new DisabledEndpointsFirewallRule(paths));
     }
 
-    process::firewall::install(std::move(_rules));
+    process::firewall::install(move(rules));
   }
 
   // Create anonymous modules.

http://git-wip-us.apache.org/repos/asf/mesos/blob/b6187a3b/src/messages/flags.hpp
----------------------------------------------------------------------
diff --git a/src/messages/flags.hpp b/src/messages/flags.hpp
index 41be419..17f8bf3 100644
--- a/src/messages/flags.hpp
+++ b/src/messages/flags.hpp
@@ -20,6 +20,7 @@
 #define __MESSAGES_FLAGS_HPP__
 
 #include <string>
+#include <ostream>
 
 #include <stout/error.hpp>
 #include <stout/json.hpp>
@@ -43,7 +44,6 @@ inline Try<mesos::internal::Firewall> parse(const 
std::string& value)
     return Error(json.error());
   }
 
-  // Convert from JSON to Protobuf.
   return protobuf::parse<mesos::internal::Firewall>(json.get());
 }
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/b6187a3b/src/slave/main.cpp
----------------------------------------------------------------------
diff --git a/src/slave/main.cpp b/src/slave/main.cpp
index c379243..8008430 100644
--- a/src/slave/main.cpp
+++ b/src/slave/main.cpp
@@ -18,12 +18,17 @@
 
 #include <stdint.h>
 
+#include <vector>
+#include <utility>
+
 #include <mesos/mesos.hpp>
 
 #include <mesos/module/anonymous.hpp>
 
 #include <mesos/slave/resource_estimator.hpp>
 
+#include <process/owned.hpp>
+
 #include <stout/check.hpp>
 #include <stout/flags.hpp>
 #include <stout/hashset.hpp>
@@ -60,13 +65,17 @@ using mesos::slave::ResourceEstimator;
 
 using mesos::SlaveInfo;
 
+using process::Owned;
+
 using process::firewall::DisabledEndpointsFirewallRule;
 using process::firewall::FirewallRule;
 
 using std::cerr;
 using std::cout;
 using std::endl;
+using std::move;
 using std::string;
+using std::vector;
 
 
 void version()
@@ -180,21 +189,21 @@ int main(int argc, char** argv)
   }
 
   if (flags.firewall_rules.isSome()) {
-    const Firewall rules = flags.firewall_rules.get();
+    vector<Owned<FirewallRule>> rules;
 
-    std::vector<Owned<FirewallRule>> _rules;
+    const Firewall firewall = flags.firewall_rules.get();
 
-    if (rules.has_disabled_endpoints()) {
+    if (firewall.has_disabled_endpoints()) {
       hashset<string> paths;
 
-      for (int i = 0; i < rules.disabled_endpoints().paths_size(); ++i) {
-        paths.insert(rules.disabled_endpoints().paths(i));
+      foreach (const string& path, firewall.disabled_endpoints().paths()) {
+        paths.insert(path);
       }
 
-      _rules.emplace_back(new DisabledEndpointsFirewallRule(paths));
+      rules.emplace_back(new DisabledEndpointsFirewallRule(paths));
     }
 
-    process::firewall::install(std::move(_rules));
+    process::firewall::install(move(rules));
   }
 
   // Create anonymous modules.

Reply via email to