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

Function clusterManagerNodeWithLeastReplicas

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

Source from the content-addressed store, hash-verified

4639 * number of replicas, one at random is returned. */
4640
4641static clusterManagerNode *clusterManagerNodeWithLeastReplicas() {
4642 clusterManagerNode *node = NULL;
4643 int lowest_count = 0;
4644 listIter li;
4645 listNode *ln;
4646 listRewind(cluster_manager.nodes, &li);
4647 while ((ln = listNext(&li)) != NULL) {
4648 clusterManagerNode *n = ln->value;
4649 if (n->flags & CLUSTER_MANAGER_FLAG_SLAVE) continue;
4650 if (node == NULL || n->replicas_count < lowest_count) {
4651 node = n;
4652 lowest_count = n->replicas_count;
4653 }
4654 }
4655 return node;
4656}
4657
4658/* This function returns a random master node, return NULL if none */
4659

Callers 2

Calls 2

listRewindFunction · 0.85
listNextFunction · 0.85

Tested by

no test coverage detected