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 2017/10/30 15:18:51 UTC

[05/15] mesos git commit: Added a helper to test if a resource is a disk of a given type.

Added a helper to test if a resource is a disk of a given type.

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


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

Branch: refs/heads/master
Commit: 58d59e9d90ce7eb56989cac135b29b6bf47e376d
Parents: c0e1b41
Author: Jie Yu <yu...@gmail.com>
Authored: Tue Oct 24 00:29:14 2017 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Mon Oct 30 16:18:31 2017 +0100

----------------------------------------------------------------------
 include/mesos/resources.hpp    |  5 +++++
 include/mesos/v1/resources.hpp |  5 +++++
 src/common/resources.cpp       | 13 +++++++++++++
 src/v1/resources.cpp           | 13 +++++++++++++
 4 files changed, 36 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/58d59e9d/include/mesos/resources.hpp
----------------------------------------------------------------------
diff --git a/include/mesos/resources.hpp b/include/mesos/resources.hpp
index 9f95949..36ba00f 100644
--- a/include/mesos/resources.hpp
+++ b/include/mesos/resources.hpp
@@ -276,6 +276,11 @@ public:
   // Tests if the given Resource object is a persistent volume.
   static bool isPersistentVolume(const Resource& resource);
 
+  // Tests if the given Resource object is a disk of the specified type.
+  static bool isDisk(
+      const Resource& resource,
+      const Resource::DiskInfo::Source::Type& type);
+
   // Tests if the given Resource object is reserved. If the role is
   // specified, tests that it's reserved for the given role.
   static bool isReserved(

http://git-wip-us.apache.org/repos/asf/mesos/blob/58d59e9d/include/mesos/v1/resources.hpp
----------------------------------------------------------------------
diff --git a/include/mesos/v1/resources.hpp b/include/mesos/v1/resources.hpp
index a621685..0a7361d 100644
--- a/include/mesos/v1/resources.hpp
+++ b/include/mesos/v1/resources.hpp
@@ -276,6 +276,11 @@ public:
   // Tests if the given Resource object is a persistent volume.
   static bool isPersistentVolume(const Resource& resource);
 
+  // Tests if the given Resource object is a disk of the specified type.
+  static bool isDisk(
+      const Resource& resource,
+      const Resource::DiskInfo::Source::Type& type);
+
   // Tests if the given Resource object is reserved. If the role is
   // specified, tests that it's reserved for the given role.
   static bool isReserved(

http://git-wip-us.apache.org/repos/asf/mesos/blob/58d59e9d/src/common/resources.cpp
----------------------------------------------------------------------
diff --git a/src/common/resources.cpp b/src/common/resources.cpp
index 7ee4dae..472844d 100644
--- a/src/common/resources.cpp
+++ b/src/common/resources.cpp
@@ -1148,6 +1148,19 @@ bool Resources::isPersistentVolume(const Resource& resource)
 }
 
 
+bool Resources::isDisk(
+    const Resource& resource,
+    const Resource::DiskInfo::Source::Type& type)
+{
+  CHECK(!resource.has_role()) << resource;
+  CHECK(!resource.has_reservation()) << resource;
+
+  return resource.has_disk() &&
+         resource.disk().has_source() &&
+         resource.disk().source().type() == type;
+}
+
+
 bool Resources::isReserved(
     const Resource& resource,
     const Option<string>& role)

http://git-wip-us.apache.org/repos/asf/mesos/blob/58d59e9d/src/v1/resources.cpp
----------------------------------------------------------------------
diff --git a/src/v1/resources.cpp b/src/v1/resources.cpp
index 5c0a196..567caef 100644
--- a/src/v1/resources.cpp
+++ b/src/v1/resources.cpp
@@ -1179,6 +1179,19 @@ bool Resources::isPersistentVolume(const Resource& resource)
 }
 
 
+bool Resources::isDisk(
+    const Resource& resource,
+    const Resource::DiskInfo::Source::Type& type)
+{
+  CHECK(!resource.has_role()) << resource;
+  CHECK(!resource.has_reservation()) << resource;
+
+  return resource.has_disk() &&
+         resource.disk().has_source() &&
+         resource.disk().source().type() == type;
+}
+
+
 bool Resources::isReserved(
     const Resource& resource,
     const Option<string>& role)