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

Function clusterManagerNodeInfo

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

Return a string representation of the cluster node. */

Source from the content-addressed store, hash-verified

3302
3303/* Return a string representation of the cluster node. */
3304static sds clusterManagerNodeInfo(clusterManagerNode *node, int indent) {
3305 sds info = sdsempty();
3306 sds spaces = sdsempty();
3307 int i;
3308 for (i = 0; i < indent; i++) spaces = sdscat(spaces, " ");
3309 if (indent) info = sdscat(info, spaces);
3310 int is_master = !(node->flags & CLUSTER_MANAGER_FLAG_SLAVE);
3311 char *role = (is_master ? "M" : "S");
3312 sds slots = NULL;
3313 if (node->dirty && node->replicate != NULL)
3314 info = sdscatfmt(info, "S: %S %s:%u", node->name, node->ip, node->port);
3315 else {
3316 slots = clusterManagerNodeSlotsString(node);
3317 sds flags = clusterManagerNodeFlagString(node);
3318 info = sdscatfmt(info, "%s: %S %s:%u\n"
3319 "%s slots:%S (%u slots) "
3320 "%S",
3321 role, node->name, node->ip, node->port, spaces,
3322 slots, node->slots_count, flags);
3323 sdsfree(slots);
3324 sdsfree(flags);
3325 }
3326 if (node->replicate != NULL)
3327 info = sdscatfmt(info, "\n%s replicates %S", spaces, node->replicate);
3328 else if (node->replicas_count)
3329 info = sdscatfmt(info, "\n%s %U additional replica(s)",
3330 spaces, node->replicas_count);
3331 sdsfree(spaces);
3332 return info;
3333}
3334
3335static void clusterManagerShowNodes(void) {
3336 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