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/06/09 17:31:16 UTC
[2/2] mesos git commit: Moved the `serialize`/ `deserialize` calls to
`stout`.
Moved the `serialize`/ `deserialize` calls to `stout`.
Review: https://reviews.apache.org/r/48378/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/023bc081
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/023bc081
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/023bc081
Branch: refs/heads/master
Commit: 023bc0813d6b271a019fed2fe349a5fe529f29d8
Parents: 3181f36
Author: Avinash sridharan <av...@mesosphere.io>
Authored: Thu Jun 9 10:31:06 2016 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Thu Jun 9 10:31:06 2016 -0700
----------------------------------------------------------------------
include/mesos/state/protobuf.hpp | 7 +++----
src/messages/messages.hpp | 31 -------------------------------
2 files changed, 3 insertions(+), 35 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/023bc081/include/mesos/state/protobuf.hpp
----------------------------------------------------------------------
diff --git a/include/mesos/state/protobuf.hpp b/include/mesos/state/protobuf.hpp
index cde7b77..47beb45 100644
--- a/include/mesos/state/protobuf.hpp
+++ b/include/mesos/state/protobuf.hpp
@@ -26,12 +26,11 @@
#include <stout/lambda.hpp>
#include <stout/option.hpp>
+#include <stout/protobuf.hpp>
#include <stout/some.hpp>
#include <stout/try.hpp>
#include <stout/uuid.hpp>
-#include "messages/messages.hpp"
-
namespace mesos {
namespace state {
namespace protobuf {
@@ -116,7 +115,7 @@ template <typename T>
process::Future<Variable<T>> State::_fetch(
const mesos::state::Variable& variable)
{
- Try<T> t = messages::deserialize<T>(variable.value());
+ Try<T> t = ::protobuf::deserialize<T>(variable.value());
if (t.isError()) {
return process::Failure(t.error());
}
@@ -129,7 +128,7 @@ template <typename T>
process::Future<Option<Variable<T>>> State::store(
const Variable<T>& variable)
{
- Try<std::string> value = messages::serialize(variable.t);
+ Try<std::string> value = ::protobuf::serialize(variable.t);
if (value.isError()) {
return process::Failure(value.error());
http://git-wip-us.apache.org/repos/asf/mesos/blob/023bc081/src/messages/messages.hpp
----------------------------------------------------------------------
diff --git a/src/messages/messages.hpp b/src/messages/messages.hpp
index 695ed2d..59e6705 100644
--- a/src/messages/messages.hpp
+++ b/src/messages/messages.hpp
@@ -29,37 +29,6 @@
#include "messages/messages.pb.h"
-namespace messages {
-
-template <typename T>
-Try<T> deserialize(const std::string& value)
-{
- T t;
- (void) static_cast<google::protobuf::Message*>(&t);
-
- google::protobuf::io::ArrayInputStream stream(value.data(), value.size());
- if (!t.ParseFromZeroCopyStream(&stream)) {
- return Error("Failed to deserialize " + t.GetDescriptor()->full_name());
- }
- return t;
-}
-
-
-template <typename T>
-Try<std::string> serialize(const T& t)
-{
- (void) static_cast<const google::protobuf::Message*>(&t);
-
- std::string value;
- if (!t.SerializeToString(&value)) {
- return Error("Failed to serialize " + t.GetDescriptor()->full_name());
- }
- return value;
-}
-
-} // namespace messages {
-
-
// Definitions for operators on protobuf classes that don't have these
// operators generated by the protobuf compiler.