MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / clusterManagerNodeIsEmpty

Function clusterManagerNodeIsEmpty

src/redis-cli.c:2660–2680  ·  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

2658/* Checks whether the node is empty. Node is considered not-empty if it has
2659 * some key or if it already knows other nodes */
2660static int clusterManagerNodeIsEmpty(clusterManagerNode *node, char **err) {
2661 redisReply *info = clusterManagerGetNodeRedisInfo(node, err);
2662 int is_empty = 1;
2663 if (info == NULL) return 0;
2664 if (strstr(info->str, "db0:") != NULL) {
2665 is_empty = 0;
2666 goto result;
2667 }
2668 freeReplyObject(info);
2669 info = CLUSTER_MANAGER_COMMAND(node, "CLUSTER INFO");
2670 if (err != NULL) *err = NULL;
2671 if (!clusterManagerCheckRedisReply(node, info, err)) {
2672 is_empty = 0;
2673 goto result;
2674 }
2675 long known_nodes = getLongInfoField(info->str, "cluster_known_nodes");
2676 is_empty = (known_nodes == 1);
2677result:
2678 freeReplyObject(info);
2679 return is_empty;
2680}
2681
2682static void clusterManagerOptimizeAntiAffinity(clusterManagerNodeArray *ipnodes,
2683 int ip_count)

Callers 2

Calls 4

freeReplyObjectFunction · 0.85
getLongInfoFieldFunction · 0.85

Tested by

no test coverage detected