| 4117 | * number of replicas, one at random is returned. */ |
| 4118 | |
| 4119 | static clusterManagerNode *clusterManagerNodeWithLeastReplicas() { |
| 4120 | clusterManagerNode *node = NULL; |
| 4121 | int lowest_count = 0; |
| 4122 | listIter li; |
| 4123 | listNode *ln; |
| 4124 | listRewind(cluster_manager.nodes, &li); |
| 4125 | while ((ln = listNext(&li)) != NULL) { |
| 4126 | clusterManagerNode *n = ln->value; |
| 4127 | if (n->flags & CLUSTER_MANAGER_FLAG_SLAVE) continue; |
| 4128 | if (node == NULL || n->replicas_count < lowest_count) { |
| 4129 | node = n; |
| 4130 | lowest_count = n->replicas_count; |
| 4131 | } |
| 4132 | } |
| 4133 | return node; |
| 4134 | } |
| 4135 | |
| 4136 | /* Slot 'slot' was found to be in importing or migrating state in one or |
| 4137 | * more nodes. This function fixes this condition by migrating keys where |
no test coverage detected