This is an automated email from the ASF dual-hosted git repository.

mzhu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git

commit 8fd52f1ad41c7aa131ceaac1b83a5bd1d06eca21
Author: Meng Zhu <[email protected]>
AuthorDate: Tue Jun 4 09:51:00 2019 -0700

    Moved `class ResourceQuantities` to public header.
    
    Some public facing classes such as `Resources` already depends
    on `ResourceQuantities` and more are coming.
    
    Review: https://reviews.apache.org/r/70786
---
 include/mesos/allocator/allocator.hpp                 |  5 ++---
 {src/common => include/mesos}/resource_quantities.hpp |  6 +++---
 include/mesos/resources.hpp                           |  6 ++----
 include/mesos/v1/resources.hpp                        |  9 ++++-----
 src/Makefile.am                                       |  2 +-
 src/common/resource_quantities.cpp                    | 10 ++++------
 src/common/resources.cpp                              |  4 +---
 src/common/resources_utils.cpp                        |  3 ---
 src/common/resources_utils.hpp                        |  7 +++----
 src/master/allocator/mesos/hierarchical.cpp           |  2 +-
 src/master/allocator/sorter/drf/sorter.hpp            |  3 +--
 src/master/allocator/sorter/random/sorter.hpp         |  3 +--
 src/master/master.cpp                                 |  4 +---
 src/master/quota.cpp                                  |  2 +-
 src/master/validation.cpp                             |  2 +-
 src/tests/hierarchical_allocator_benchmarks.cpp       |  4 ----
 src/tests/hierarchical_allocator_tests.cpp            |  4 ----
 src/tests/resource_quantities_tests.cpp               |  6 ++----
 src/tests/resources_tests.cpp                         |  5 +----
 src/v1/resources.cpp                                  |  4 +---
 20 files changed, 30 insertions(+), 61 deletions(-)

diff --git a/include/mesos/allocator/allocator.hpp 
b/include/mesos/allocator/allocator.hpp
index f186838..eafcdfd 100644
--- a/include/mesos/allocator/allocator.hpp
+++ b/include/mesos/allocator/allocator.hpp
@@ -27,6 +27,7 @@
 
 #include <mesos/quota/quota.hpp>
 
+#include <mesos/resource_quantities.hpp>
 #include <mesos/resources.hpp>
 
 #include <process/future.hpp>
@@ -38,7 +39,6 @@
 #include <stout/option.hpp>
 #include <stout/try.hpp>
 
-#include "common/resource_quantities.hpp"
 
 namespace mesos {
 namespace allocator {
@@ -60,8 +60,7 @@ struct Options
   Option<DomainInfo> domain = None();
 
   // The minimum allocatable resource quantities, if any.
-  Option<std::vector<mesos::internal::ResourceQuantities>>
-    minAllocatableResources = None();
+  Option<std::vector<ResourceQuantities>> minAllocatableResources = None();
 
   size_t maxCompletedFrameworks = 0;
 
diff --git a/src/common/resource_quantities.hpp 
b/include/mesos/resource_quantities.hpp
similarity index 99%
rename from src/common/resource_quantities.hpp
rename to include/mesos/resource_quantities.hpp
index af7da8b..c861df8 100644
--- a/src/common/resource_quantities.hpp
+++ b/include/mesos/resource_quantities.hpp
@@ -22,14 +22,15 @@
 #include <vector>
 
 #include <mesos/mesos.hpp>
-#include <mesos/resources.hpp>
 
+#include <stout/hashmap.hpp>
 #include <stout/try.hpp>
 
 namespace mesos {
-namespace internal {
 
 // Forward declaration.
+class Resources;
+
 class ResourceLimits;
 
 
@@ -260,7 +261,6 @@ private:
 std::ostream& operator<<(std::ostream& stream, const ResourceLimits& limits);
 
 
-} // namespace internal {
 } // namespace mesos {
 
 #endif //  __COMMON_RESOURCE_QUANTITIES_HPP__
diff --git a/include/mesos/resources.hpp b/include/mesos/resources.hpp
index 609ca61..3fc2c34 100644
--- a/include/mesos/resources.hpp
+++ b/include/mesos/resources.hpp
@@ -28,6 +28,7 @@
 #include <google/protobuf/repeated_field.h>
 
 #include <mesos/mesos.hpp>
+#include <mesos/resource_quantities.hpp>
 #include <mesos/type_utils.hpp>
 #include <mesos/values.hpp>
 
@@ -59,8 +60,6 @@ namespace mesos {
 // Forward declaration.
 class ResourceConversion;
 
-namespace internal { class ResourceQuantities; }
-
 
 // Helper functions.
 bool operator==(
@@ -446,8 +445,7 @@ public:
   // quantities are the number of different instances in the range or set.
   // For example, "range:[1-5]" has a quantity of 5 and "set:{a,b}" has a
   // quantity of 2.
-  bool contains(
-      const mesos::internal::ResourceQuantities& quantities) const;
+  bool contains(const ResourceQuantities& quantities) const;
 
   // Count the Resource objects that match the specified value.
   //
diff --git a/include/mesos/v1/resources.hpp b/include/mesos/v1/resources.hpp
index 8afccbe..39c0403 100644
--- a/include/mesos/v1/resources.hpp
+++ b/include/mesos/v1/resources.hpp
@@ -27,6 +27,8 @@
 
 #include <google/protobuf/repeated_field.h>
 
+#include <mesos/resource_quantities.hpp>
+
 #include <mesos/v1/mesos.hpp>
 #include <mesos/v1/values.hpp>
 
@@ -54,9 +56,6 @@
 // but instead just written for correct semantics.
 
 namespace mesos {
-
-namespace internal { class ResourceQuantities; }
-
 namespace v1 {
 
 // Forward declaration.
@@ -446,8 +445,8 @@ public:
   // quantities are the number of different instances in the range or set.
   // For example, "range:[1-5]" has a quantity of 5 and "set:{a,b}" has a
   // quantity of 2.
-  bool contains(
-      const mesos::internal::ResourceQuantities& quantities) const;
+  bool contains(const ResourceQuantities& quantities) const;
+
   // Count the Resource objects that match the specified value.
   //
   // NOTE:
diff --git a/src/Makefile.am b/src/Makefile.am
index 5f97523..93b2606 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -647,6 +647,7 @@ pkginclude_HEADERS =                                        
                \
   $(top_srcdir)/include/mesos/mesos.proto                              \
   $(top_srcdir)/include/mesos/module.hpp                               \
   $(top_srcdir)/include/mesos/resources.hpp                            \
+  $(top_srcdir)/include/mesos/resource_quantities.hpp                          
\
   $(top_srcdir)/include/mesos/roles.hpp                                        
\
   $(top_srcdir)/include/mesos/scheduler.hpp                            \
   $(top_srcdir)/include/mesos/type_utils.hpp                           \
@@ -1075,7 +1076,6 @@ libmesos_no_3rdparty_la_SOURCES +=                        
                \
   common/recordio.hpp                                                  \
   common/resources.cpp                                                 \
   common/resource_quantities.cpp                                       \
-  common/resource_quantities.hpp                                       \
   common/resources_utils.cpp                                           \
   common/resources_utils.hpp                                           \
   common/roles.cpp                                                     \
diff --git a/src/common/resource_quantities.cpp 
b/src/common/resource_quantities.cpp
index 1aaa0d7..9577181 100644
--- a/src/common/resource_quantities.cpp
+++ b/src/common/resource_quantities.cpp
@@ -18,6 +18,8 @@
 #include <string>
 #include <vector>
 
+#include <mesos/resource_quantities.hpp>
+#include <mesos/resources.hpp>
 #include <mesos/values.hpp>
 
 #include <stout/check.hpp>
@@ -25,15 +27,12 @@
 #include <stout/foreach.hpp>
 #include <stout/numify.hpp>
 
-#include "common/resource_quantities.hpp"
-
 using std::ostream;
 using std::pair;
 using std::string;
 using std::vector;
 
 namespace mesos {
-namespace internal {
 
 // This function tries to be consistent with `Resources::fromSimpleString()`.
 // We trim the whitespace around the pair and in the number but whitespace in
@@ -48,7 +47,7 @@ Try<ResourceQuantities> ResourceQuantities::fromString(const 
string& text)
       return Error("Failed to parse '" + token + "': missing or extra ':'");
     }
 
-    Try<Value> value = values::parse(pair[1]);
+    Try<Value> value = internal::values::parse(pair[1]);
     if (value.isError()) {
       return Error(
           "Failed to parse '" + pair[1] + "' to quantity: " + value.error());
@@ -363,7 +362,7 @@ Try<ResourceLimits> ResourceLimits::fromString(const 
string& text)
       return Error("Failed to parse '" + token + "': missing or extra ':'");
     }
 
-    Try<Value> value = values::parse(pair[1]);
+    Try<Value> value = internal::values::parse(pair[1]);
     if (value.isError()) {
       return Error(
           "Failed to parse '" + pair[1] + "' to limit: " + value.error());
@@ -620,5 +619,4 @@ ostream& operator<<(
 }
 
 
-} // namespace internal {
 } // namespace mesos {
diff --git a/src/common/resources.cpp b/src/common/resources.cpp
index 543820d..6e02d5c 100644
--- a/src/common/resources.cpp
+++ b/src/common/resources.cpp
@@ -25,6 +25,7 @@
 
 #include <google/protobuf/repeated_field.h>
 
+#include <mesos/resource_quantities.hpp>
 #include <mesos/resources.hpp>
 #include <mesos/roles.hpp>
 #include <mesos/values.hpp>
@@ -38,7 +39,6 @@
 #include <stout/strings.hpp>
 #include <stout/unreachable.hpp>
 
-#include "common/resource_quantities.hpp"
 #include "common/resources_utils.hpp"
 
 using std::make_shared;
@@ -52,8 +52,6 @@ using std::vector;
 
 using google::protobuf::RepeatedPtrField;
 
-using mesos::internal::ResourceQuantities;
-
 namespace mesos {
 
 /////////////////////////////////////////////////
diff --git a/src/common/resources_utils.cpp b/src/common/resources_utils.cpp
index 58fdb31..720b954 100644
--- a/src/common/resources_utils.cpp
+++ b/src/common/resources_utils.cpp
@@ -25,9 +25,6 @@ using google::protobuf::Descriptor;
 using google::protobuf::Message;
 using google::protobuf::RepeatedPtrField;
 
-using mesos::internal::ResourceLimits;
-using mesos::internal::ResourceQuantities;
-
 namespace mesos {
 
 bool needCheckpointing(const Resource& resource)
diff --git a/src/common/resources_utils.hpp b/src/common/resources_utils.hpp
index 9b78ca2..a50e67e 100644
--- a/src/common/resources_utils.hpp
+++ b/src/common/resources_utils.hpp
@@ -22,6 +22,7 @@
 #include <google/protobuf/repeated_field.h>
 
 #include <mesos/mesos.hpp>
+#include <mesos/resource_quantities.hpp>
 #include <mesos/resources.hpp>
 
 #include <mesos/v1/mesos.hpp>
@@ -32,8 +33,6 @@
 #include <stout/option.hpp>
 #include <stout/try.hpp>
 
-#include "resource_quantities.hpp"
-
 namespace mesos {
 
 // Tests if the given Resource needs to be checkpointed on the slave.
@@ -240,9 +239,9 @@ Try<Nothing> downgradeResources(google::protobuf::Message* 
message);
 // the target sizes (e.g. need to exclude 1 of 2 disks); this function
 // will make a random choice in these cases.
 Resources shrinkResources(
-    const Resources& resources, mesos::internal::ResourceQuantities target);
+    const Resources& resources, ResourceQuantities target);
 Resources shrinkResources(
-    const Resources& resources, mesos::internal::ResourceLimits target);
+    const Resources& resources, ResourceLimits target);
 
 
 } // namespace mesos {
diff --git a/src/master/allocator/mesos/hierarchical.cpp 
b/src/master/allocator/mesos/hierarchical.cpp
index d587696..dff1eab 100644
--- a/src/master/allocator/mesos/hierarchical.cpp
+++ b/src/master/allocator/mesos/hierarchical.cpp
@@ -23,6 +23,7 @@
 #include <vector>
 
 #include <mesos/attributes.hpp>
+#include <mesos/resource_quantities.hpp>
 #include <mesos/resources.hpp>
 #include <mesos/roles.hpp>
 #include <mesos/type_utils.hpp>
@@ -42,7 +43,6 @@
 #include <stout/stringify.hpp>
 
 #include "common/protobuf_utils.hpp"
-#include "common/resource_quantities.hpp"
 #include "common/resources_utils.hpp"
 
 using std::set;
diff --git a/src/master/allocator/sorter/drf/sorter.hpp 
b/src/master/allocator/sorter/drf/sorter.hpp
index 91a9d66..84c33ca 100644
--- a/src/master/allocator/sorter/drf/sorter.hpp
+++ b/src/master/allocator/sorter/drf/sorter.hpp
@@ -23,6 +23,7 @@
 #include <vector>
 
 #include <mesos/mesos.hpp>
+#include <mesos/resource_quantities.hpp>
 #include <mesos/resources.hpp>
 #include <mesos/values.hpp>
 
@@ -30,8 +31,6 @@
 #include <stout/hashmap.hpp>
 #include <stout/option.hpp>
 
-#include "common/resource_quantities.hpp"
-
 #include "master/allocator/sorter/drf/metrics.hpp"
 
 #include "master/allocator/sorter/sorter.hpp"
diff --git a/src/master/allocator/sorter/random/sorter.hpp 
b/src/master/allocator/sorter/random/sorter.hpp
index 55e22d7..ca687d4 100644
--- a/src/master/allocator/sorter/random/sorter.hpp
+++ b/src/master/allocator/sorter/random/sorter.hpp
@@ -25,6 +25,7 @@
 
 #include <mesos/mesos.hpp>
 #include <mesos/resources.hpp>
+#include <mesos/resource_quantities.hpp>
 #include <mesos/values.hpp>
 
 #include <stout/check.hpp>
@@ -32,8 +33,6 @@
 #include <stout/hashset.hpp>
 #include <stout/option.hpp>
 
-#include "common/resource_quantities.hpp"
-
 #include "master/allocator/sorter/sorter.hpp"
 
 
diff --git a/src/master/master.cpp b/src/master/master.cpp
index cb7c902..c41d912 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -30,6 +30,7 @@
 #include <utility>
 
 #include <mesos/module.hpp>
+#include <mesos/resource_quantities.hpp>
 #include <mesos/roles.hpp>
 
 #include <mesos/authentication/authenticator.hpp>
@@ -80,7 +81,6 @@
 #include "common/build.hpp"
 #include "common/http.hpp"
 #include "common/protobuf_utils.hpp"
-#include "common/resource_quantities.hpp"
 #include "common/status_utils.hpp"
 
 #include "credentials/credentials.hpp"
@@ -150,8 +150,6 @@ using mesos::master::contender::MasterContender;
 
 using mesos::master::detector::MasterDetector;
 
-using mesos::internal::ResourceQuantities;
-
 static bool isValidFailoverTimeout(const FrameworkInfo& frameworkInfo);
 
 
diff --git a/src/master/quota.cpp b/src/master/quota.cpp
index bad19a2..001c240 100644
--- a/src/master/quota.cpp
+++ b/src/master/quota.cpp
@@ -19,6 +19,7 @@
 #include <string>
 
 #include <mesos/mesos.hpp>
+#include <mesos/resource_quantities.hpp>
 #include <mesos/resources.hpp>
 #include <mesos/roles.hpp>
 #include <mesos/values.hpp>
@@ -27,7 +28,6 @@
 #include <stout/option.hpp>
 #include <stout/set.hpp>
 
-#include "common/resource_quantities.hpp"
 #include "common/resources_utils.hpp"
 #include "common/validation.hpp"
 
diff --git a/src/master/validation.cpp b/src/master/validation.cpp
index 65af1a7..af2d04a 100644
--- a/src/master/validation.cpp
+++ b/src/master/validation.cpp
@@ -24,6 +24,7 @@
 
 #include <glog/logging.h>
 
+#include <mesos/resource_quantities.hpp>
 #include <mesos/roles.hpp>
 #include <mesos/type_utils.hpp>
 
@@ -40,7 +41,6 @@
 #include "checks/health_checker.hpp"
 
 #include "common/protobuf_utils.hpp"
-#include "common/resource_quantities.hpp"
 #include "common/validation.hpp"
 
 #include "master/master.hpp"
diff --git a/src/tests/hierarchical_allocator_benchmarks.cpp 
b/src/tests/hierarchical_allocator_benchmarks.cpp
index 797cf7e..04c1249 100644
--- a/src/tests/hierarchical_allocator_benchmarks.cpp
+++ b/src/tests/hierarchical_allocator_benchmarks.cpp
@@ -32,8 +32,6 @@
 #include <stout/hashmap.hpp>
 #include <stout/stopwatch.hpp>
 
-#include "common/resource_quantities.hpp"
-
 #include "master/constants.hpp"
 
 #include "master/allocator/mesos/hierarchical.hpp"
@@ -46,8 +44,6 @@ using mesos::internal::master::MIN_MEM;
 
 using mesos::internal::master::allocator::HierarchicalDRFAllocator;
 
-using mesos::internal::ResourceQuantities;
-
 using mesos::internal::slave::AGENT_CAPABILITIES;
 
 using mesos::allocator::Allocator;
diff --git a/src/tests/hierarchical_allocator_tests.cpp 
b/src/tests/hierarchical_allocator_tests.cpp
index 7221a64..1e4b01e 100644
--- a/src/tests/hierarchical_allocator_tests.cpp
+++ b/src/tests/hierarchical_allocator_tests.cpp
@@ -40,8 +40,6 @@
 #include <stout/stopwatch.hpp>
 #include <stout/utils.hpp>
 
-#include "common/resource_quantities.hpp"
-
 #include "master/constants.hpp"
 #include "master/flags.hpp"
 
@@ -63,8 +61,6 @@ using mesos::internal::protobuf::createLabel;
 
 using mesos::internal::slave::AGENT_CAPABILITIES;
 
-using mesos::internal::ResourceQuantities;
-
 using mesos::allocator::Allocator;
 
 using process::Clock;
diff --git a/src/tests/resource_quantities_tests.cpp 
b/src/tests/resource_quantities_tests.cpp
index f018c8a..69fb78a 100644
--- a/src/tests/resource_quantities_tests.cpp
+++ b/src/tests/resource_quantities_tests.cpp
@@ -24,16 +24,14 @@
 #include <stout/stringify.hpp>
 #include <stout/try.hpp>
 
+#include <mesos/resources.hpp>
+#include <mesos/resource_quantities.hpp>
 #include <mesos/values.hpp>
 
-#include "common/resource_quantities.hpp"
-
 using std::pair;
 using std::string;
 using std::vector;
 
-using mesos::internal::ResourceQuantities;
-
 namespace mesos {
 namespace internal {
 namespace tests {
diff --git a/src/tests/resources_tests.cpp b/src/tests/resources_tests.cpp
index bbac851..b585465 100644
--- a/src/tests/resources_tests.cpp
+++ b/src/tests/resources_tests.cpp
@@ -28,11 +28,11 @@
 #include <stout/json.hpp>
 #include <stout/protobuf.hpp>
 
+#include <mesos/resource_quantities.hpp>
 #include <mesos/resources.hpp>
 
 #include <mesos/v1/resources.hpp>
 
-#include "common/resource_quantities.hpp"
 #include "common/resources_utils.hpp"
 
 #include "internal/evolve.hpp"
@@ -59,9 +59,6 @@ using mesos::internal::evolve;
 
 using mesos::internal::protobuf::createLabel;
 
-using mesos::internal::ResourceLimits;
-using mesos::internal::ResourceQuantities;
-
 namespace mesos {
 namespace internal {
 namespace tests {
diff --git a/src/v1/resources.cpp b/src/v1/resources.cpp
index 7d6113f..25fb213 100644
--- a/src/v1/resources.cpp
+++ b/src/v1/resources.cpp
@@ -26,6 +26,7 @@
 #include <google/protobuf/repeated_field.h>
 
 #include <mesos/roles.hpp>
+#include <mesos/resource_quantities.hpp>
 
 #include <mesos/v1/mesos.hpp>
 #include <mesos/v1/resources.hpp>
@@ -39,7 +40,6 @@
 #include <stout/strings.hpp>
 #include <stout/unreachable.hpp>
 
-#include "common/resource_quantities.hpp"
 #include "common/resources_utils.hpp"
 
 using std::make_shared;
@@ -53,8 +53,6 @@ using std::vector;
 
 using google::protobuf::RepeatedPtrField;
 
-using mesos::internal::ResourceQuantities;
-
 namespace mesos {
 namespace v1 {
 

Reply via email to