MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / clusterManagerWaitForClusterJoin

Function clusterManagerWaitForClusterJoin

src/redis-cli-cpphelper.cpp:443–496  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

441
442/* Wait until the cluster configuration is consistent. */
443extern "C" void clusterManagerWaitForClusterJoin(void) {
444 printf("Waiting for the cluster to join\n");
445 int counter = 0,
446 check_after = CLUSTER_JOIN_CHECK_AFTER +
447 (int)(listLength(cluster_manager.nodes) * 0.15f);
448 while(!clusterManagerIsConfigConsistent(0 /*fLog*/)) {
449 printf(".");
450 fflush(stdout);
451 sleep(1);
452 if (++counter > check_after) {
453 dict *status = clusterManagerGetLinkStatus();
454 dictIterator *iter = NULL;
455 if (status != NULL && dictSize(status) > 0) {
456 printf("\n");
457 clusterManagerLogErr("Warning: %d node(s) may "
458 "be unreachable\n", dictSize(status));
459 iter = dictGetIterator(status);
460 dictEntry *entry;
461 while ((entry = dictNext(iter)) != NULL) {
462 sds nodeaddr = (sds) dictGetKey(entry);
463 char *node_ip = NULL;
464 int node_port = 0, node_bus_port = 0;
465 list *from = (list *) dictGetVal(entry);
466 if (parseClusterNodeAddress(nodeaddr, &node_ip,
467 &node_port, &node_bus_port) && node_bus_port) {
468 clusterManagerLogErr(" - The port %d of node %s may "
469 "be unreachable from:\n",
470 node_bus_port, node_ip);
471 } else {
472 clusterManagerLogErr(" - Node %s may be unreachable "
473 "from:\n", nodeaddr);
474 }
475 listIter li;
476 listNode *ln;
477 listRewind(from, &li);
478 while ((ln = listNext(&li)) != NULL) {
479 sds from_addr = (sds)ln->value;
480 clusterManagerLogErr(" %s\n", from_addr);
481 sdsfree(from_addr);
482 }
483 clusterManagerLogErr("Cluster bus ports must be reachable "
484 "by every node.\nRemember that "
485 "cluster bus ports are different "
486 "from standard instance ports.\n");
487 listEmpty(from);
488 }
489 }
490 if (iter != NULL) dictReleaseIterator(iter);
491 if (status != NULL) dictRelease(status);
492 counter = 0;
493 }
494 }
495 printf("\n");
496}
497
498list *clusterManagerGetDisconnectedLinks(clusterManagerNode *node) {
499 list *links = NULL;

Callers 2

Calls 11

parseClusterNodeAddressFunction · 0.85
listRewindFunction · 0.85
listNextFunction · 0.85
sdsfreeFunction · 0.85
listEmptyFunction · 0.85
dictGetIteratorFunction · 0.70
dictNextFunction · 0.70
dictReleaseIteratorFunction · 0.70
dictReleaseFunction · 0.70

Tested by

no test coverage detected