Repository: mesos Updated Branches: refs/heads/master 2b952a76b -> 18e1351b3
Published MasterInfo to ZK in JSON format. As part of the support for non-libmesos linked client to interact with the HTTP API, we also provide the Master information stored in ZooKeeper in a way that is deserializable also for clients that do not necessarily know how to decode a MasterInfo protocol buffer. This patch publishes the data in JSON format and has been tested, summarily, with 2 masters running this patch alongside a 0.23 Master and one each of 0.24 and 0.23 Agent nodes. Please note this patch does not require specific unit testing, as the functionality is already widely tested in existing `ZooKeeper*` tests, as well as `MasterDetector*` ones. Review: https://reviews.apache.org/r/36900 Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/18e1351b Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/18e1351b Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/18e1351b Branch: refs/heads/master Commit: 18e1351b3c5c24f7f65be66ee56889a6378ba97f Parents: 2b952a7 Author: Marco Massenzio <[email protected]> Authored: Wed Jul 29 17:20:22 2015 -0700 Committer: Vinod Kone <[email protected]> Committed: Wed Jul 29 17:20:22 2015 -0700 ---------------------------------------------------------------------- src/master/contender.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/18e1351b/src/master/contender.cpp ---------------------------------------------------------------------- diff --git a/src/master/contender.cpp b/src/master/contender.cpp index 2af70c7..67562f1 100644 --- a/src/master/contender.cpp +++ b/src/master/contender.cpp @@ -22,6 +22,7 @@ #include <stout/check.hpp> #include <stout/lambda.hpp> +#include <stout/protobuf.hpp> #include "master/constants.hpp" #include "master/contender.hpp" @@ -234,13 +235,13 @@ Future<Future<Nothing> > ZooKeeperMasterContenderProcess::contend() delete contender; } - // Serialize the MasterInfo to string. - string data; - if (!masterInfo.get().SerializeToString(&data)) { - return Failure("Failed to serialize data to MasterInfo"); - } + // Serialize the MasterInfo to JSON. + JSON::Object json = JSON::Protobuf(masterInfo.get()); - contender = new LeaderContender(group.get(), data, master::MASTER_INFO_LABEL); + contender = new LeaderContender( + group.get(), + stringify(json), + master::MASTER_INFO_JSON_LABEL); candidacy = contender->contend(); return candidacy.get(); }
