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 1acb38c27306326a53f866b5386b5e28a6dc9314
Author: Meng Zhu <[email protected]>
AuthorDate: Fri Mar 29 15:53:26 2019 -0700

    Removed unused function `Resources::isScalarQuantity`.
    
    The function was introduced when `class Resources` is
    used for resource quantities. In particular, it was
    used in API validation where users are asked to specify
    resource quantities using `Resources`. Since `ResourceQuantities`
    is introduced, the function is no longer needed.
    
    Review: https://reviews.apache.org/r/70346
---
 include/mesos/resources.hpp    |  5 -----
 include/mesos/v1/resources.hpp |  5 -----
 src/common/resources.cpp       | 11 -----------
 src/tests/resources_tests.cpp  | 31 -------------------------------
 src/v1/resources.cpp           | 11 -----------
 5 files changed, 63 deletions(-)

diff --git a/include/mesos/resources.hpp b/include/mesos/resources.hpp
index 62b6b0c..609ca61 100644
--- a/include/mesos/resources.hpp
+++ b/include/mesos/resources.hpp
@@ -349,11 +349,6 @@ public:
   // Tests if the given Resource object is shared.
   static bool isShared(const Resource& resource);
 
-  // Tests if the given Resources object is a "pure" scalar quantity which
-  // consists of resource objects with ONLY name, type (set to "Scalar")
-  // and scalar fields set.
-  static bool isScalarQuantity(const Resources& resources);
-
   // Tests if the given Resource object has refined reservations.
   static bool hasRefinedReservations(const Resource& resource);
 
diff --git a/include/mesos/v1/resources.hpp b/include/mesos/v1/resources.hpp
index eb23359..8afccbe 100644
--- a/include/mesos/v1/resources.hpp
+++ b/include/mesos/v1/resources.hpp
@@ -349,11 +349,6 @@ public:
   // Tests if the given Resource object is shared.
   static bool isShared(const Resource& resource);
 
-  // Tests if the given Resources object is a "pure" scalar quantity which
-  // only consists of resource object with ONLY name, type (set to "Scalar")
-  // and scalar fields set.
-  static bool isScalarQuantity(const Resources& resources);
-
   // Tests if the given Resource object has refined reservations.
   static bool hasRefinedReservations(const Resource& resource);
 
diff --git a/src/common/resources.cpp b/src/common/resources.cpp
index f50fe56..543820d 100644
--- a/src/common/resources.cpp
+++ b/src/common/resources.cpp
@@ -1262,17 +1262,6 @@ bool Resources::isShared(const Resource& resource)
 }
 
 
-bool Resources::isScalarQuantity(const Resources& resources)
-{
-  // Instead of checking the absence of non-scalar-quantity fields,
-  // we do an equality check between the original resources object and
-  // its stripped counterpart.
-  //
-  // We remove the static reservation metadata here via `toUnreserved()`.
-  return resources == resources.createStrippedScalarQuantity().toUnreserved();
-}
-
-
 bool Resources::hasRefinedReservations(const Resource& resource)
 {
   CHECK(!resource.has_role()) << resource;
diff --git a/src/tests/resources_tests.cpp b/src/tests/resources_tests.cpp
index e67057c..dbae0f6 100644
--- a/src/tests/resources_tests.cpp
+++ b/src/tests/resources_tests.cpp
@@ -2007,37 +2007,6 @@ TEST(ResourcesTest, AbsentResources)
 }
 
 
-TEST(ResourcesTest, isScalarQuantity)
-{
-  Resources scalarQuantity1 = Resources::parse("cpus:1").get();
-  EXPECT_TRUE(Resources::isScalarQuantity(scalarQuantity1));
-
-  Resources scalarQuantity2 = Resources::parse("cpus:1;mem:1").get();
-  EXPECT_TRUE(Resources::isScalarQuantity(scalarQuantity2));
-
-  Resources range = Resources::parse("ports", "[1-16000]", "*").get();
-  EXPECT_FALSE(Resources::isScalarQuantity(range));
-
-  Resources set = Resources::parse("names:{foo,bar}").get();
-  EXPECT_FALSE(Resources::isScalarQuantity(set));
-
-  Resources reserved = createReservedResource(
-      "cpus", "1", createDynamicReservationInfo("role", "principal"));
-  EXPECT_FALSE(Resources::isScalarQuantity(reserved));
-
-  Resources disk = createDiskResource("10", "role1", "1", "path");
-  EXPECT_FALSE(Resources::isScalarQuantity(disk));
-
-  Resources allocated = Resources::parse("cpus:1;mem:512").get();
-  allocated.allocate("role");
-  EXPECT_FALSE(Resources::isScalarQuantity(allocated));
-
-  Resource revocable = Resources::parse("cpus", "1", "*").get();
-  revocable.mutable_revocable();
-  EXPECT_FALSE(Resources::isScalarQuantity(revocable));
-}
-
-
 TEST(ResourcesTest, ContainsResourceQuantities)
 {
   auto resources = [](const string& s) {
diff --git a/src/v1/resources.cpp b/src/v1/resources.cpp
index d3a6194..7d6113f 100644
--- a/src/v1/resources.cpp
+++ b/src/v1/resources.cpp
@@ -1282,17 +1282,6 @@ bool Resources::isShared(const Resource& resource)
 }
 
 
-bool Resources::isScalarQuantity(const Resources& resources)
-{
-  // Instead of checking the absence of non-scalar-quantity fields,
-  // we do an equality check between the original `Resources` object and
-  // its stripped counterpart.
-  //
-  // We remove the static reservation metadata here via `toUnreserved()`.
-  return resources == resources.createStrippedScalarQuantity().toUnreserved();
-}
-
-
 bool Resources::hasRefinedReservations(const Resource& resource)
 {
   CHECK(!resource.has_role()) << resource;

Reply via email to