You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ji...@apache.org on 2014/10/26 06:25:45 UTC

git commit: Reordered functions in type_utils and added an equal comparator for Volume.

Repository: mesos
Updated Branches:
  refs/heads/master 1beacb8f2 -> 4bbf72740


Reordered functions in type_utils and added an equal comparator for
Volume.

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


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

Branch: refs/heads/master
Commit: 4bbf72740c239ed2b63ead2566ea7a033e8fa6b1
Parents: 1beacb8
Author: Jie Yu <yu...@gmail.com>
Authored: Sat Oct 25 22:22:40 2014 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Sat Oct 25 22:25:34 2014 -0700

----------------------------------------------------------------------
 src/common/type_utils.cpp |  94 ++++++++------
 src/common/type_utils.hpp | 278 ++++++++++++++++++++---------------------
 2 files changed, 192 insertions(+), 180 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/4bbf7274/src/common/type_utils.cpp
----------------------------------------------------------------------
diff --git a/src/common/type_utils.cpp b/src/common/type_utils.cpp
index 4f8d6ec..fcc9eb0 100644
--- a/src/common/type_utils.cpp
+++ b/src/common/type_utils.cpp
@@ -24,32 +24,6 @@
 
 namespace mesos {
 
-bool operator == (const Environment& left, const Environment& right)
-{
-  if (left.variables().size() != right.variables().size()) {
-    return false;
-  }
-
-  for (int i = 0; i < left.variables().size(); i++) {
-    const std::string& name = left.variables().Get(i).name();
-    const std::string& value = left.variables().Get(i).value();
-    bool found = false;
-    for (int j = 0; j < right.variables().size(); j++) {
-      if (name == right.variables().Get(j).name() &&
-          value == right.variables().Get(j).value()) {
-        found = true;
-        break;
-      }
-    }
-    if (!found) {
-      return false;
-    }
-  }
-
-  return true;
-}
-
-
 bool operator == (const CommandInfo& left, const CommandInfo& right)
 {
   if (left.uris().size() != right.uris().size()) {
@@ -89,6 +63,48 @@ bool operator == (const CommandInfo& left, const CommandInfo& right)
 }
 
 
+bool operator == (const CommandInfo::URI& left, const CommandInfo::URI& right)
+{
+  return left.has_executable() == right.has_executable() &&
+    (!left.has_executable() || (left.executable() == right.executable())) &&
+    left.value() == right.value();
+}
+
+
+bool operator == (const Credential& left, const Credential& right)
+{
+  return left.principal() == right.principal() &&
+         left.has_secret() == right.has_secret() &&
+         (!left.has_secret() || (left.secret() == right.secret()));
+}
+
+
+bool operator == (const Environment& left, const Environment& right)
+{
+  if (left.variables().size() != right.variables().size()) {
+    return false;
+  }
+
+  for (int i = 0; i < left.variables().size(); i++) {
+    const std::string& name = left.variables().Get(i).name();
+    const std::string& value = left.variables().Get(i).value();
+    bool found = false;
+    for (int j = 0; j < right.variables().size(); j++) {
+      if (name == right.variables().Get(j).name() &&
+          value == right.variables().Get(j).value()) {
+        found = true;
+        break;
+      }
+    }
+    if (!found) {
+      return false;
+    }
+  }
+
+  return true;
+}
+
+
 bool operator == (const ExecutorInfo& left, const ExecutorInfo& right)
 {
   return left.executor_id() == right.executor_id() &&
@@ -106,6 +122,18 @@ bool operator == (const ExecutorInfo& left, const ExecutorInfo& right)
 }
 
 
+bool operator == (const MasterInfo& left, const MasterInfo& right)
+{
+  return left.id() == right.id() &&
+    left.ip() == right.ip() &&
+    left.port() == right.port() &&
+    left.has_pid() == right.has_pid() &&
+    (!left.has_pid() || (left.pid() == right.pid())) &&
+    left.has_hostname() == right.has_hostname() &&
+    (!left.has_hostname() || (left.hostname() == right.hostname()));
+}
+
+
 bool operator == (const SlaveInfo& left, const SlaveInfo& right)
 {
   return left.hostname() == right.hostname() &&
@@ -119,15 +147,12 @@ bool operator == (const SlaveInfo& left, const SlaveInfo& right)
 }
 
 
-bool operator == (const MasterInfo& left, const MasterInfo& right)
+bool operator == (const Volume& left, const Volume& right)
 {
-  return left.id() == right.id() &&
-    left.ip() == right.ip() &&
-    left.port() == right.port() &&
-    left.has_pid() == right.has_pid() &&
-    (!left.has_pid() || (left.pid() == right.pid())) &&
-    left.has_hostname() == right.has_hostname() &&
-    (!left.has_hostname() || (left.hostname() == right.hostname()));
+  return left.container_path() == right.container_path() &&
+    left.mode() == right.mode() &&
+    left.has_host_path() == right.has_host_path() &&
+    (!left.has_host_path() || (left.host_path() == right.host_path()));
 }
 
 
@@ -166,5 +191,4 @@ std::ostream& operator << (
 }
 
 } // namespace internal {
-
 } // namespace mesos {

http://git-wip-us.apache.org/repos/asf/mesos/blob/4bbf7274/src/common/type_utils.hpp
----------------------------------------------------------------------
diff --git a/src/common/type_utils.hpp b/src/common/type_utils.hpp
index f10b2d3..f16beb8 100644
--- a/src/common/type_utils.hpp
+++ b/src/common/type_utils.hpp
@@ -33,293 +33,285 @@
 
 namespace mesos {
 
-inline std::ostream& operator << (
-    std::ostream& stream,
-    const FrameworkID& frameworkId)
-{
-  return stream << frameworkId.value();
-}
-
-
-inline std::ostream& operator << (std::ostream& stream, const OfferID& offerId)
-{
-  return stream << offerId.value();
-}
+bool operator == (const CommandInfo& left, const CommandInfo& right);
+bool operator == (const CommandInfo::URI& left, const CommandInfo::URI& right);
+bool operator == (const Credential& left, const Credential& right);
+bool operator == (const Environment& left, const Environment& right);
+bool operator == (const ExecutorInfo& left, const ExecutorInfo& right);
+bool operator == (const MasterInfo& left, const MasterInfo& right);
+bool operator == (const SlaveInfo& left, const SlaveInfo& right);
+bool operator == (const Volume& left, const Volume& right);
 
 
-inline std::ostream& operator << (std::ostream& stream, const SlaveID& slaveId)
+inline bool operator == (const ContainerID& left, const ContainerID& right)
 {
-  return stream << slaveId.value();
+  return left.value() == right.value();
 }
 
 
-inline std::ostream& operator << (std::ostream& stream, const TaskID& taskId)
+inline bool operator == (const ExecutorID& left, const ExecutorID& right)
 {
-  return stream << taskId.value();
+  return left.value() == right.value();
 }
 
 
-inline std::ostream& operator << (
-    std::ostream& stream,
-    const ExecutorID& executorId)
+inline bool operator == (const FrameworkID& left, const FrameworkID& right)
 {
-  return stream << executorId.value();
+  return left.value() == right.value();
 }
 
 
-inline std::ostream& operator << (
-    std::ostream& stream,
-    const ContainerID& containerId)
+inline bool operator == (const FrameworkInfo& left, const FrameworkInfo& right)
 {
-  return stream << containerId.value();
+  return (left.name() == right.name()) && (left.user() == right.user());
 }
 
 
-inline std::ostream& operator << (std::ostream& stream, const TaskState& state)
+inline bool operator == (const OfferID& left, const OfferID& right)
 {
-  return stream << TaskState_descriptor()->FindValueByNumber(state)->name();
+  return left.value() == right.value();
 }
 
 
-inline std::ostream& operator << (std::ostream& stream, const TaskInfo& task)
+inline bool operator == (const SlaveID& left, const SlaveID& right)
 {
-  return stream << task.DebugString();
+  return left.value() == right.value();
 }
 
 
-inline std::ostream& operator << (std::ostream& stream, const SlaveInfo& slave)
+inline bool operator == (const TaskID& left, const TaskID& right)
 {
-  return stream << slave.DebugString();
+  return left.value() == right.value();
 }
 
 
-inline std::ostream& operator << (
-    std::ostream& stream,
-    const ExecutorInfo& executor)
+inline bool operator == (const ContainerID& left, const std::string& right)
 {
-  return stream << executor.DebugString();
+  return left.value() == right;
 }
 
 
-inline std::ostream& operator << (
-    std::ostream& stream,
-    const MasterInfo& master)
+inline bool operator == (const ExecutorID& left, const std::string& right)
 {
-  return stream << master.DebugString();
+  return left.value() == right;
 }
 
 
-inline std::ostream& operator << (
-    std::ostream& stream,
-    const ACLs& acls)
+inline bool operator == (const FrameworkID& left, const std::string& right)
 {
-  return stream << acls.DebugString();
+  return left.value() == right;
 }
 
 
-inline std::ostream& operator << (
-    std::ostream& stream,
-    const RateLimits& limits)
+inline bool operator == (const OfferID& left, const std::string& right)
 {
-  return stream << limits.DebugString();
+  return left.value() == right;
 }
 
 
-inline bool operator == (const FrameworkID& left, const FrameworkID& right)
+inline bool operator == (const SlaveID& left, const std::string& right)
 {
-  return left.value() == right.value();
+  return left.value() == right;
 }
 
 
-inline bool operator == (const FrameworkInfo& left, const FrameworkInfo& right)
+inline bool operator == (const TaskID& left, const std::string& right)
 {
-  return (left.name() == right.name()) && (left.user() == right.user());
+  return left.value() == right;
 }
 
 
-inline bool operator == (const Credential& left, const Credential& right)
+inline bool operator != (const ContainerID& left, const ContainerID& right)
 {
-  return left.principal() == right.principal() &&
-         left.has_secret() == right.has_secret() &&
-         (!left.has_secret() || (left.secret() == right.secret()));
+  return left.value() != right.value();
 }
 
 
-inline bool operator == (const OfferID& left, const OfferID& right)
+inline bool operator < (const ContainerID& left, const ContainerID& right)
 {
-  return left.value() == right.value();
+  return left.value() < right.value();
 }
 
 
-inline bool operator == (const SlaveID& left, const SlaveID& right)
+inline bool operator < (const ExecutorID& left, const ExecutorID& right)
 {
-  return left.value() == right.value();
+  return left.value() < right.value();
 }
 
 
-inline bool operator == (const TaskID& left, const TaskID& right)
+inline bool operator < (const FrameworkID& left, const FrameworkID& right)
 {
-  return left.value() == right.value();
+  return left.value() < right.value();
 }
 
 
-inline bool operator == (const ExecutorID& left, const ExecutorID& right)
+inline bool operator < (const OfferID& left, const OfferID& right)
 {
-  return left.value() == right.value();
+  return left.value() < right.value();
 }
 
 
-inline bool operator == (const ContainerID& left, const ContainerID& right)
+inline bool operator < (const SlaveID& left, const SlaveID& right)
 {
-  return left.value() == right.value();
+  return left.value() < right.value();
 }
 
 
-inline bool operator != (const ContainerID& left, const ContainerID& right)
+inline bool operator < (const TaskID& left, const TaskID& right)
 {
-  return left.value() != right.value();
+  return left.value() < right.value();
 }
 
 
-inline bool operator == (const FrameworkID& left, const std::string& right)
+inline std::size_t hash_value(const ContainerID& containerId)
 {
-  return left.value() == right;
+  size_t seed = 0;
+  boost::hash_combine(seed, containerId.value());
+  return seed;
 }
 
 
-inline bool operator == (const OfferID& left, const std::string& right)
+inline std::size_t hash_value(const ExecutorID& executorId)
 {
-  return left.value() == right;
+  size_t seed = 0;
+  boost::hash_combine(seed, executorId.value());
+  return seed;
 }
 
 
-inline bool operator == (const SlaveID& left, const std::string& right)
+inline std::size_t hash_value(const FrameworkID& frameworkId)
 {
-  return left.value() == right;
+  size_t seed = 0;
+  boost::hash_combine(seed, frameworkId.value());
+  return seed;
 }
 
 
-inline bool operator == (const TaskID& left, const std::string& right)
+inline std::size_t hash_value(const OfferID& offerId)
 {
-  return left.value() == right;
+  size_t seed = 0;
+  boost::hash_combine(seed, offerId.value());
+  return seed;
 }
 
 
-inline bool operator == (const ExecutorID& left, const std::string& right)
+inline std::size_t hash_value(const SlaveID& slaveId)
 {
-  return left.value() == right;
+  size_t seed = 0;
+  boost::hash_combine(seed, slaveId.value());
+  return seed;
 }
 
 
-inline bool operator == (const ContainerID& left, const std::string& right)
+inline std::size_t hash_value(const TaskID& taskId)
 {
-  return left.value() == right;
+  size_t seed = 0;
+  boost::hash_combine(seed, taskId.value());
+  return seed;
 }
 
 
-inline bool operator < (const FrameworkID& left, const FrameworkID& right)
+inline std::ostream& operator << (
+    std::ostream& stream,
+    const ACLs& acls)
 {
-  return left.value() < right.value();
+  return stream << acls.DebugString();
 }
 
 
-inline bool operator < (const OfferID& left, const OfferID& right)
+inline std::ostream& operator << (
+    std::ostream& stream,
+    const ContainerID& containerId)
 {
-  return left.value() < right.value();
+  return stream << containerId.value();
 }
 
 
-inline bool operator < (const SlaveID& left, const SlaveID& right)
+inline std::ostream& operator << (
+    std::ostream& stream,
+    const ExecutorID& executorId)
 {
-  return left.value() < right.value();
+  return stream << executorId.value();
 }
 
 
-inline bool operator < (const TaskID& left, const TaskID& right)
+inline std::ostream& operator << (
+    std::ostream& stream,
+    const ExecutorInfo& executor)
 {
-  return left.value() < right.value();
+  return stream << executor.DebugString();
 }
 
 
-inline bool operator < (const ExecutorID& left, const ExecutorID& right)
+inline std::ostream& operator << (
+    std::ostream& stream,
+    const FrameworkID& frameworkId)
 {
-  return left.value() < right.value();
+  return stream << frameworkId.value();
 }
 
 
-inline bool operator < (const ContainerID& left, const ContainerID& right)
+inline std::ostream& operator << (
+    std::ostream& stream,
+    const MasterInfo& master)
 {
-  return left.value() < right.value();
+  return stream << master.DebugString();
 }
 
 
-bool operator == (const Environment& left, const Environment& right);
-
-
-inline bool operator == (
-    const CommandInfo::URI& left,
-    const CommandInfo::URI& right)
+inline std::ostream& operator << (
+    std::ostream& stream,
+    const OfferID& offerId)
 {
-  return left.has_executable() == right.has_executable() &&
-    (!left.has_executable() || (left.executable() == right.executable())) &&
-    left.value() == right.value();
+  return stream << offerId.value();
 }
 
 
-bool operator == (const CommandInfo& left, const CommandInfo& right);
-
-bool operator == (const ExecutorInfo& left, const ExecutorInfo& right);
-
-bool operator == (const SlaveInfo& left, const SlaveInfo& right);
-
-bool operator == (const MasterInfo& left, const MasterInfo& right);
-
-
-inline std::size_t hash_value(const FrameworkID& frameworkId)
+inline std::ostream& operator << (
+    std::ostream& stream,
+    const RateLimits& limits)
 {
-  size_t seed = 0;
-  boost::hash_combine(seed, frameworkId.value());
-  return seed;
+  return stream << limits.DebugString();
 }
 
 
-inline std::size_t hash_value(const OfferID& offerId)
+inline std::ostream& operator << (
+    std::ostream& stream,
+    const SlaveID& slaveId)
 {
-  size_t seed = 0;
-  boost::hash_combine(seed, offerId.value());
-  return seed;
+  return stream << slaveId.value();
 }
 
 
-inline std::size_t hash_value(const SlaveID& slaveId)
+inline std::ostream& operator << (
+    std::ostream& stream,
+    const SlaveInfo& slave)
 {
-  size_t seed = 0;
-  boost::hash_combine(seed, slaveId.value());
-  return seed;
+  return stream << slave.DebugString();
 }
 
 
-inline std::size_t hash_value(const TaskID& taskId)
+inline std::ostream& operator << (
+    std::ostream& stream,
+    const TaskID& taskId)
 {
-  size_t seed = 0;
-  boost::hash_combine(seed, taskId.value());
-  return seed;
+  return stream << taskId.value();
 }
 
 
-inline std::size_t hash_value(const ExecutorID& executorId)
+inline std::ostream& operator << (
+    std::ostream& stream,
+    const TaskInfo& task)
 {
-  size_t seed = 0;
-  boost::hash_combine(seed, executorId.value());
-  return seed;
+  return stream << task.DebugString();
 }
 
 
-inline std::size_t hash_value(const ContainerID& containerId)
+inline std::ostream& operator << (
+    std::ostream& stream,
+    const TaskState& state)
 {
-  size_t seed = 0;
-  boost::hash_combine(seed, containerId.value());
-  return seed;
+  return stream << TaskState_descriptor()->FindValueByNumber(state)->name();
 }
 
 
@@ -327,6 +319,15 @@ namespace internal {
 
 bool operator == (const Task& left, const Task& right);
 
+
+inline std::ostream& operator << (
+    std::ostream& stream,
+    const Modules& modules)
+{
+  return stream << modules.DebugString();
+}
+
+
 std::ostream& operator << (
     std::ostream& stream,
     const StatusUpdate& update);
@@ -341,19 +342,6 @@ inline std::ostream& operator << (
 }
 
 
-inline std::ostream& operator << (
-    std::ostream& stream,
-    const Modules& modules)
-{
-  return stream << modules.DebugString();
-}
-
-} // namespace internal {
-} // namespace mesos {
-
-
-namespace mesos {
-namespace internal {
 namespace log {
 
 inline std::ostream& operator << (