MCPcopy Create free account
hub / github.com/apache/mesos / fetched

Method fetched

src/master/detector/zookeeper.cpp:189–266  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

187
188
189void ZooKeeperMasterDetectorProcess::fetched(
190 const Group::Membership& membership,
191 const Future<Option<string>>& data)
192{
193 CHECK(!data.isDiscarded());
194
195 if (data.isFailed()) {
196 leader = None();
197 failPromises(&promises, data.failure());
198 return;
199 } else if (data->isNone()) {
200 // Membership is gone before we can read its data.
201 leader = None();
202 setPromises(&promises, leader);
203 return;
204 }
205
206 // Parse the data based on the membership label and cache the
207 // leader for subsequent requests.
208 Option<string> label = membership.label();
209 if (label.isNone()) {
210 // If we are here it means some masters are still creating znodes
211 // with the old format.
212 UPID pid = UPID(data->get());
213 LOG(WARNING) << "Leading master " << pid << " has data in old format";
214 leader = mesos::internal::protobuf::createMasterInfo(pid);
215 } else if (label.isSome() &&
216 label.get() == internal::master::MASTER_INFO_LABEL) {
217 MasterInfo info;
218 if (!info.ParseFromString(data->get())) {
219 leader = None();
220 failPromises(&promises,
221 "Failed to parse data into MasterInfo");
222 return;
223 }
224 LOG(WARNING) << "Leading master " << info.pid()
225 << " is using a Protobuf binary format when registering with "
226 << "ZooKeeper (" << label.get() << "): this will be deprecated"
227 << " as of Mesos 0.24 (see MESOS-2340)";
228 leader = info;
229 } else if (label.isSome() &&
230 label.get() == internal::master::MASTER_INFO_JSON_LABEL) {
231 Try<JSON::Object> object = JSON::parse<JSON::Object>(data->get());
232
233 if (object.isError()) {
234 leader = None();
235 failPromises(
236 &promises,
237 "Failed to parse data into valid JSON: " + object.error());
238 return;
239 }
240
241 Try<mesos::MasterInfo> info =
242 ::protobuf::parse<mesos::MasterInfo>(object.get());
243
244 if (info.isError()) {
245 leader = None();
246 failPromises(

Callers

nothing calls this directly

Calls 15

NoneClass · 0.85
failPromisesFunction · 0.85
setPromisesFunction · 0.85
createMasterInfoFunction · 0.85
isDiscardedMethod · 0.80
isFailedMethod · 0.80
failureMethod · 0.80
labelMethod · 0.80
errorMethod · 0.65
UPIDClass · 0.50
isNoneMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected