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 2016/08/17 18:05:28 UTC
mesos git commit: Introduce parsing and stringification of
`CapabilityInfo`s.
Repository: mesos
Updated Branches:
refs/heads/master 4a703b911 -> 1366abb0f
Introduce parsing and stringification of `CapabilityInfo`s.
Review: https://reviews.apache.org/r/50889/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/1366abb0
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/1366abb0
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/1366abb0
Branch: refs/heads/master
Commit: 1366abb0f2f1c3ce63fd9f1696450b8b77cc3443
Parents: 4a703b9
Author: Benjamin Bannier <be...@mesosphere.io>
Authored: Wed Aug 17 11:05:06 2016 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Wed Aug 17 11:05:23 2016 -0700
----------------------------------------------------------------------
include/mesos/type_utils.hpp | 5 +++++
src/common/parse.hpp | 12 ++++++++++++
src/common/type_utils.cpp | 8 ++++++++
3 files changed, 25 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/1366abb0/include/mesos/type_utils.hpp
----------------------------------------------------------------------
diff --git a/include/mesos/type_utils.hpp b/include/mesos/type_utils.hpp
index 5826eff..d10b663 100644
--- a/include/mesos/type_utils.hpp
+++ b/include/mesos/type_utils.hpp
@@ -241,6 +241,11 @@ inline bool operator<(const TaskID& left, const TaskID& right)
}
+std::ostream& operator<<(
+ std::ostream& stream,
+ const CapabilityInfo& capabilityInfo);
+
+
std::ostream& operator<<(std::ostream& stream, const ContainerID& containerId);
http://git-wip-us.apache.org/repos/asf/mesos/blob/1366abb0/src/common/parse.hpp
----------------------------------------------------------------------
diff --git a/src/common/parse.hpp b/src/common/parse.hpp
index 5dc795d..51582a4 100644
--- a/src/common/parse.hpp
+++ b/src/common/parse.hpp
@@ -162,6 +162,18 @@ inline Try<std::set<std::string>> parse(const std::string& value)
return result;
}
+
+template <>
+inline Try<mesos::CapabilityInfo> parse(const std::string& value)
+{
+ Try<JSON::Object> json = parse<JSON::Object>(value);
+ if (json.isError()) {
+ return Error(json.error());
+ }
+
+ return protobuf::parse<mesos::CapabilityInfo>(json.get());
+}
+
} // namespace flags {
#endif // __COMMON_PARSE_HPP__
http://git-wip-us.apache.org/repos/asf/mesos/blob/1366abb0/src/common/type_utils.cpp
----------------------------------------------------------------------
diff --git a/src/common/type_utils.cpp b/src/common/type_utils.cpp
index a8a9d90..c7d5033 100644
--- a/src/common/type_utils.cpp
+++ b/src/common/type_utils.cpp
@@ -21,6 +21,8 @@
#include <mesos/resources.hpp>
#include <mesos/type_utils.hpp>
+#include <stout/protobuf.hpp>
+
#include "messages/messages.hpp"
using std::ostream;
@@ -427,6 +429,12 @@ ostream& operator<<(ostream& stream, const ExecutorID& executorId)
}
+ostream& operator<<(std::ostream& stream, const CapabilityInfo& capabilityInfo)
+{
+ return stream << stringify(JSON::protobuf(capabilityInfo));
+}
+
+
ostream& operator<<(ostream& stream, const ExecutorInfo& executor)
{
return stream << executor.DebugString();