You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by jo...@apache.org on 2015/09/25 02:48:04 UTC

[3/5] mesos git commit: Make common resources symmetrical to v1 resources.

Make common resources symmetrical to v1 resources.

This aids in verifying the files are kept in sync.
diff src/common/resources.cpp src/v1/resources.cpp should result
in only include and namespace differences.

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


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

Branch: refs/heads/master
Commit: b7d48db4375b9a860f8ce35821b922faab8da370
Parents: 5926e9d
Author: Joris Van Remoortere <jo...@gmail.com>
Authored: Thu Sep 24 13:16:46 2015 -0700
Committer: Joris Van Remoortere <jo...@gmail.com>
Committed: Thu Sep 24 17:47:15 2015 -0700

----------------------------------------------------------------------
 src/common/resources.cpp | 28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/b7d48db4/src/common/resources.cpp
----------------------------------------------------------------------
diff --git a/src/common/resources.cpp b/src/common/resources.cpp
index abfc6f3..601388c 100644
--- a/src/common/resources.cpp
+++ b/src/common/resources.cpp
@@ -62,9 +62,7 @@ bool operator!=(
 }
 
 
-bool operator==(
-    const Resource::DiskInfo& left,
-    const Resource::DiskInfo& right)
+bool operator==(const Resource::DiskInfo& left, const Resource::DiskInfo& right)
 {
   // NOTE: We ignore 'volume' inside DiskInfo when doing comparison
   // because it describes how this resource will be used which has
@@ -83,9 +81,7 @@ bool operator==(
 }
 
 
-bool operator!=(
-    const Resource::DiskInfo& left,
-    const Resource::DiskInfo& right)
+bool operator!=(const Resource::DiskInfo& left, const Resource::DiskInfo& right)
 {
   return !(left == right);
 }
@@ -140,6 +136,8 @@ bool operator!=(const Resource& left, const Resource& right)
 }
 
 
+namespace internal {
+
 // Tests if we can add two Resource objects together resulting in one
 // valid Resource object. For example, two Resource objects with
 // different name, type or role are not addable.
@@ -256,6 +254,8 @@ static bool contains(const Resource& left, const Resource& right)
   }
 }
 
+} // namespace internal {
+
 
 Resource& operator+=(Resource& left, const Resource& right)
 {
@@ -599,7 +599,7 @@ bool Resources::contains(const Resource& that) const
 {
   // NOTE: We must validate 'that' because invalid resources can lead
   // to false positives here (e.g., "cpus:-1" will return true). This
-  // is because mesos::contains assumes resources are valid.
+  // is because 'contains' assumes resources are valid.
   return validate(that).isNone() && _contains(that);
 }
 
@@ -1037,7 +1037,7 @@ Option<Value::Ranges> Resources::ephemeral_ports() const
 bool Resources::_contains(const Resource& that) const
 {
   foreach (const Resource& resource, resources) {
-    if (mesos::contains(resource, that)) {
+    if (internal::contains(resource, that)) {
       return true;
     }
   }
@@ -1090,7 +1090,7 @@ Resources& Resources::operator+=(const Resource& that)
   if (validate(that).isNone() && !isEmpty(that)) {
     bool found = false;
     foreach (Resource& resource, resources) {
-      if (addable(resource, that)) {
+      if (internal::addable(resource, that)) {
         resource += that;
         found = true;
         break;
@@ -1139,7 +1139,7 @@ Resources& Resources::operator-=(const Resource& that)
     for (int i = 0; i < resources.size(); i++) {
       Resource* resource = resources.Mutable(i);
 
-      if (subtractable(*resource, that)) {
+      if (internal::subtractable(*resource, that)) {
         *resource -= that;
 
         // Remove the resource if it becomes invalid or zero. We need
@@ -1168,7 +1168,8 @@ Resources& Resources::operator-=(const Resources& that)
 }
 
 
-ostream& operator<<(ostream& stream, const Volume& volume) {
+ostream& operator<<(ostream& stream, const Volume& volume)
+{
   string volumeConfig = volume.container_path();
 
   if (volume.has_host_path()) {
@@ -1191,7 +1192,8 @@ ostream& operator<<(ostream& stream, const Volume& volume) {
 }
 
 
-ostream& operator<<(ostream& stream, const Resource::DiskInfo& disk) {
+ostream& operator<<(ostream& stream, const Resource::DiskInfo& disk)
+{
   if (disk.has_persistence()) {
     stream << disk.persistence().id();
   }
@@ -1243,7 +1245,7 @@ ostream& operator<<(ostream& stream, const Resource& resource)
 
 ostream& operator<<(ostream& stream, const Resources& resources)
 {
-  mesos::Resources::const_iterator it = resources.begin();
+  Resources::const_iterator it = resources.begin();
 
   while (it != resources.end()) {
     stream << *it;