Return a string representation of the cluster node. */
| 2913 | |
| 2914 | /* Return a string representation of the cluster node. */ |
| 2915 | static 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 | |
| 2946 | void clusterManagerShowNodes(void) { |
| 2947 | listIter li; |
no test coverage detected