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

Function clusterManagerNodeIsEmpty

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

Checks whether the node is empty. Node is considered not-empty if it has * some key or if it already knows other nodes */

Source from the content-addressed store, hash-verified

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 */
2949static 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);
2966result:
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

Callers 2

Calls 5

strstrFunction · 0.85
freeReplyObjectFunction · 0.85
getLongInfoFieldFunction · 0.85

Tested by

no test coverage detected