Skip to content

Commit 18e1351

Browse files
Marco Massenziovinodkone
authored andcommitted
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
1 parent 2b952a7 commit 18e1351

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/master/contender.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
#include <stout/check.hpp>
2424
#include <stout/lambda.hpp>
25+
#include <stout/protobuf.hpp>
2526

2627
#include "master/constants.hpp"
2728
#include "master/contender.hpp"
@@ -234,13 +235,13 @@ Future<Future<Nothing> > ZooKeeperMasterContenderProcess::contend()
234235
delete contender;
235236
}
236237

237-
// Serialize the MasterInfo to string.
238-
string data;
239-
if (!masterInfo.get().SerializeToString(&data)) {
240-
return Failure("Failed to serialize data to MasterInfo");
241-
}
238+
// Serialize the MasterInfo to JSON.
239+
JSON::Object json = JSON::Protobuf(masterInfo.get());
242240

243-
contender = new LeaderContender(group.get(), data, master::MASTER_INFO_LABEL);
241+
contender = new LeaderContender(
242+
group.get(),
243+
stringify(json),
244+
master::MASTER_INFO_JSON_LABEL);
244245
candidacy = contender->contend();
245246
return candidacy.get();
246247
}

0 commit comments

Comments
 (0)