MCPcopy Create free account
hub / github.com/F-Stack/f-stack / clusterManagerWaitForClusterJoin

Function clusterManagerWaitForClusterJoin

app/redis-6.2.6/src/redis-cli.c:4016–4069  ·  view source on GitHub ↗

Wait until the cluster configuration is consistent. */

Source from the content-addressed store, hash-verified

4014
4015/* Wait until the cluster configuration is consistent. */
4016static void clusterManagerWaitForClusterJoin(void) {
4017 printf("Waiting for the cluster to join\n");
4018 int counter = 0,
4019 check_after = CLUSTER_JOIN_CHECK_AFTER +
4020 (int)(listLength(cluster_manager.nodes) * 0.15f);
4021 while(!clusterManagerIsConfigConsistent()) {
4022 printf(".");
4023 fflush(stdout);
4024 sleep(1);
4025 if (++counter > check_after) {
4026 dict *status = clusterManagerGetLinkStatus();
4027 dictIterator *iter = NULL;
4028 if (status != NULL && dictSize(status) > 0) {
4029 printf("\n");
4030 clusterManagerLogErr("Warning: %d node(s) may "
4031 "be unreachable\n", dictSize(status));
4032 iter = dictGetIterator(status);
4033 dictEntry *entry;
4034 while ((entry = dictNext(iter)) != NULL) {
4035 sds nodeaddr = (sds) dictGetKey(entry);
4036 char *node_ip = NULL;
4037 int node_port = 0, node_bus_port = 0;
4038 list *from = (list *) dictGetVal(entry);
4039 if (parseClusterNodeAddress(nodeaddr, &node_ip,
4040 &node_port, &node_bus_port) && node_bus_port) {
4041 clusterManagerLogErr(" - The port %d of node %s may "
4042 "be unreachable from:\n",
4043 node_bus_port, node_ip);
4044 } else {
4045 clusterManagerLogErr(" - Node %s may be unreachable "
4046 "from:\n", nodeaddr);
4047 }
4048 listIter li;
4049 listNode *ln;
4050 listRewind(from, &li);
4051 while ((ln = listNext(&li)) != NULL) {
4052 sds from_addr = ln->value;
4053 clusterManagerLogErr(" %s\n", from_addr);
4054 sdsfree(from_addr);
4055 }
4056 clusterManagerLogErr("Cluster bus ports must be reachable "
4057 "by every node.\nRemember that "
4058 "cluster bus ports are different "
4059 "from standard instance ports.\n");
4060 listEmpty(from);
4061 }
4062 }
4063 if (iter != NULL) dictReleaseIterator(iter);
4064 if (status != NULL) dictRelease(status);
4065 counter = 0;
4066 }
4067 }
4068 printf("\n");
4069}
4070
4071/* Load node's cluster configuration by calling "CLUSTER NODES" command.
4072 * Node's configuration (name, replicate, slots, ...) is then updated.

Callers 2

Calls 12

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
printfFunction · 0.50

Tested by

no test coverage detected