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

Method connected

src/state/zookeeper.cpp:316–380  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

314
315
316void ZooKeeperStorageProcess::connected(int64_t sessionId, bool reconnect)
317{
318 if (sessionId != zk->getSessionId()) {
319 return;
320 }
321
322 if (!reconnect) {
323 // Authenticate if necessary (and we are connected for the first
324 // time, or after a session expiration).
325 if (auth.isSome()) {
326 LOG(INFO) << "Authenticating with ZooKeeper using " << auth->scheme;
327
328 int code = zk->authenticate(auth->scheme, auth->credentials);
329
330 if (code != ZOK) { // TODO(benh): Authentication retries?
331 error = "Failed to authenticate with ZooKeeper: " + zk->message(code);
332 return;
333 }
334 }
335 }
336
337 state = CONNECTED;
338
339 while (!pending.names.empty()) {
340 Names* names = pending.names.front();
341 Result<std::set<string>> result = doNames();
342 if (result.isNone()) {
343 return; // Try again later.
344 } else if (result.isError()) {
345 names->promise.fail(result.error());
346 } else {
347 names->promise.set(result.get());
348 }
349 pending.names.pop();
350 delete names;
351 }
352
353 while (!pending.gets.empty()) {
354 Get* get = pending.gets.front();
355 Result<Option<Entry>> result = doGet(get->name);
356 if (result.isNone()) {
357 return; // Try again later.
358 } else if (result.isError()) {
359 get->promise.fail(result.error());
360 } else {
361 get->promise.set(result.get());
362 }
363 pending.gets.pop();
364 delete get;
365 }
366
367 while (!pending.sets.empty()) {
368 Set* set = pending.sets.front();
369 Result<bool> result = doSet(set->entry, set->uuid);
370 if (result.isNone()) {
371 return; // Try again later.
372 } else if (result.isError()) {
373 set->promise.fail(result.error());

Callers

nothing calls this directly

Calls 11

errorMethod · 0.65
getSessionIdMethod · 0.45
isSomeMethod · 0.45
authenticateMethod · 0.45
messageMethod · 0.45
emptyMethod · 0.45
isNoneMethod · 0.45
isErrorMethod · 0.45
failMethod · 0.45
setMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected