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 2015/06/20 00:44:18 UTC
[2/3] mesos git commit: Added a helper in Resources to get all scalar
resources.
Added a helper in Resources to get all scalar resources.
Review: https://reviews.apache.org/r/35663
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/114d2aa5
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/114d2aa5
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/114d2aa5
Branch: refs/heads/master
Commit: 114d2aa568284eba98dad60f8265c573112bad49
Parents: e02ae0b
Author: Jie Yu <yu...@gmail.com>
Authored: Fri Jun 19 12:37:27 2015 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Fri Jun 19 15:43:59 2015 -0700
----------------------------------------------------------------------
include/mesos/resources.hpp | 3 +++
src/common/resources.cpp | 8 ++++++++
2 files changed, 11 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/114d2aa5/include/mesos/resources.hpp
----------------------------------------------------------------------
diff --git a/include/mesos/resources.hpp b/include/mesos/resources.hpp
index 0ccc337..d4d5caf 100644
--- a/include/mesos/resources.hpp
+++ b/include/mesos/resources.hpp
@@ -248,6 +248,9 @@ public:
// Get resources of the given name.
Resources get(const std::string& name) const;
+ // Get all the resources that are scalars.
+ Resources scalars() const;
+
// Get the set of unique resource names.
std::set<std::string> names() const;
http://git-wip-us.apache.org/repos/asf/mesos/blob/114d2aa5/src/common/resources.cpp
----------------------------------------------------------------------
diff --git a/src/common/resources.cpp b/src/common/resources.cpp
index 3b79243..eb5476a 100644
--- a/src/common/resources.cpp
+++ b/src/common/resources.cpp
@@ -949,6 +949,14 @@ Resources Resources::get(const string& name) const
}
+Resources Resources::scalars() const
+{
+ return filter([=](const Resource& resource) {
+ return resource.type() == Value::SCALAR;
+ });
+}
+
+
set<string> Resources::names() const
{
set<string> result;