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:50 UTC
[04/15] mesos git commit: Added a helper to test if a resource has
resource provider.
Added a helper to test if a resource has resource provider.
Review: https://reviews.apache.org/r/63255
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/4a67ee54
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/4a67ee54
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/4a67ee54
Branch: refs/heads/master
Commit: 4a67ee54462040611ad2197073a87ba18acd7148
Parents: 58d59e9
Author: Jie Yu <yu...@gmail.com>
Authored: Tue Oct 24 00:30:45 2017 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Mon Oct 30 16:18:31 2017 +0100
----------------------------------------------------------------------
include/mesos/resources.hpp | 3 +++
include/mesos/v1/resources.hpp | 3 +++
src/common/resources.cpp | 9 +++++++++
src/v1/resources.cpp | 9 +++++++++
4 files changed, 24 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/4a67ee54/include/mesos/resources.hpp
----------------------------------------------------------------------
diff --git a/include/mesos/resources.hpp b/include/mesos/resources.hpp
index 36ba00f..2f76ea7 100644
--- a/include/mesos/resources.hpp
+++ b/include/mesos/resources.hpp
@@ -311,6 +311,9 @@ public:
// Tests if the given Resource object has refined reservations.
static bool hasRefinedReservations(const Resource& resource);
+ // Tests if the given Resource object is provided by a resource provider.
+ static bool hasResourceProvider(const Resource& resource);
+
// Returns the role to which the given Resource object is reserved for.
// This must be called only when the resource is reserved!
static const std::string& reservationRole(const Resource& resource);
http://git-wip-us.apache.org/repos/asf/mesos/blob/4a67ee54/include/mesos/v1/resources.hpp
----------------------------------------------------------------------
diff --git a/include/mesos/v1/resources.hpp b/include/mesos/v1/resources.hpp
index 0a7361d..7666c76 100644
--- a/include/mesos/v1/resources.hpp
+++ b/include/mesos/v1/resources.hpp
@@ -311,6 +311,9 @@ public:
// Tests if the given Resource object has refined reservations.
static bool hasRefinedReservations(const Resource& resource);
+ // Tests if the given Resource object is provided by a resource provider.
+ static bool hasResourceProvider(const Resource& resource);
+
// Returns the role to which the given Resource object is reserved for.
// This must be called only when the resource is reserved!
static const std::string& reservationRole(const Resource& resource);
http://git-wip-us.apache.org/repos/asf/mesos/blob/4a67ee54/src/common/resources.cpp
----------------------------------------------------------------------
diff --git a/src/common/resources.cpp b/src/common/resources.cpp
index 472844d..e25f830 100644
--- a/src/common/resources.cpp
+++ b/src/common/resources.cpp
@@ -1232,6 +1232,15 @@ bool Resources::hasRefinedReservations(const Resource& resource)
}
+bool Resources::hasResourceProvider(const Resource& resource)
+{
+ CHECK(!resource.has_role()) << resource;
+ CHECK(!resource.has_reservation()) << resource;
+
+ return resource.has_provider_id();
+}
+
+
const string& Resources::reservationRole(const Resource& resource)
{
CHECK_GT(resource.reservations_size(), 0);
http://git-wip-us.apache.org/repos/asf/mesos/blob/4a67ee54/src/v1/resources.cpp
----------------------------------------------------------------------
diff --git a/src/v1/resources.cpp b/src/v1/resources.cpp
index 567caef..405bd9b 100644
--- a/src/v1/resources.cpp
+++ b/src/v1/resources.cpp
@@ -1263,6 +1263,15 @@ bool Resources::hasRefinedReservations(const Resource& resource)
}
+bool Resources::hasResourceProvider(const Resource& resource)
+{
+ CHECK(!resource.has_role()) << resource;
+ CHECK(!resource.has_reservation()) << resource;
+
+ return resource.has_provider_id();
+}
+
+
const string& Resources::reservationRole(const Resource& resource)
{
CHECK_GT(resource.reservations_size(), 0);