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

Function clusterManagerNodeInfo

src/redis-cli.c:2915–2944  ·  view source on GitHub ↗

Return a string representation of the cluster node. */

Source from the content-addressed store, hash-verified

2913
2914/* Return a string representation of the cluster node. */
2915static sds clusterManagerNodeInfo(clusterManagerNode *node, int indent) {
2916 sds info = sdsempty();
2917 sds spaces = sdsempty();
2918 int i;
2919 for (i = 0; i < indent; i++) spaces = sdscat(spaces, " ");
2920 if (indent) info = sdscat(info, spaces);
2921 int is_master = !(node->flags & CLUSTER_MANAGER_FLAG_SLAVE);
2922 char *role = (is_master ? "M" : "S");
2923 sds slots = NULL;
2924 if (node->dirty && node->replicate != NULL)
2925 info = sdscatfmt(info, "S: %S %s:%u", node->name, node->ip, node->port);
2926 else {
2927 slots = clusterManagerNodeSlotsString(node);
2928 sds flags = clusterManagerNodeFlagString(node);
2929 info = sdscatfmt(info, "%s: %S %s:%u\n"
2930 "%s slots:%S (%u slots) "
2931 "%S",
2932 role, node->name, node->ip, node->port, spaces,
2933 slots, node->slots_count, flags);
2934 sdsfree(slots);
2935 sdsfree(flags);
2936 }
2937 if (node->replicate != NULL)
2938 info = sdscatfmt(info, "\n%s replicates %S", spaces, node->replicate);
2939 else if (node->replicas_count)
2940 info = sdscatfmt(info, "\n%s %U additional replica(s)",
2941 spaces, node->replicas_count);
2942 sdsfree(spaces);
2943 return info;
2944}
2945
2946void clusterManagerShowNodes(void) {
2947 listIter li;

Callers 2

clusterManagerShowNodesFunction · 0.85

Calls 6

sdsemptyFunction · 0.85
sdscatFunction · 0.85
sdscatfmtFunction · 0.85
sdsfreeFunction · 0.85

Tested by

no test coverage detected