Checks whether the node is empty. Node is considered not-empty if it has * some key or if it already knows other nodes */
| 2947 | /* Checks whether the node is empty. Node is considered not-empty if it has |
| 2948 | * some key or if it already knows other nodes */ |
| 2949 | static int clusterManagerNodeIsEmpty(clusterManagerNode *node, char **err) { |
| 2950 | redisReply *info = clusterManagerGetNodeRedisInfo(node, err); |
| 2951 | int is_empty = 1; |
| 2952 | if (info == NULL) return 0; |
| 2953 | if (strstr(info->str, "db0:") != NULL) { |
| 2954 | is_empty = 0; |
| 2955 | goto result; |
| 2956 | } |
| 2957 | freeReplyObject(info); |
| 2958 | info = CLUSTER_MANAGER_COMMAND(node, "CLUSTER INFO"); |
| 2959 | if (err != NULL) *err = NULL; |
| 2960 | if (!clusterManagerCheckRedisReply(node, info, err)) { |
| 2961 | is_empty = 0; |
| 2962 | goto result; |
| 2963 | } |
| 2964 | long known_nodes = getLongInfoField(info->str, "cluster_known_nodes"); |
| 2965 | is_empty = (known_nodes == 1); |
| 2966 | result: |
| 2967 | freeReplyObject(info); |
| 2968 | return is_empty; |
| 2969 | } |
| 2970 | |
| 2971 | /* Return the anti-affinity score, which is a measure of the amount of |
| 2972 | * violations of anti-affinity in the current cluster layout, that is, how |
no test coverage detected