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

Function clusterGenNodesDescription

app/redis-6.2.6/src/cluster.c:4296–4322  ·  view source on GitHub ↗

Generate a csv-alike representation of the nodes we are aware of, * including the "myself" node, and return an SDS string containing the * representation (it is up to the caller to free it). * * All the nodes matching at least one of the node flags specified in * "filter" are excluded from the output, so using zero as a filter will * include all the known nodes in the representation, includi

Source from the content-addressed store, hash-verified

4294 * of the CLUSTER NODES function, and as format for the cluster
4295 * configuration file (nodes.conf) for a given node. */
4296sds clusterGenNodesDescription(int filter, int use_pport) {
4297 sds ci = sdsempty(), ni;
4298 dictIterator *di;
4299 dictEntry *de;
4300
4301 /* Generate all nodes slots info firstly. */
4302 clusterGenNodesSlotsInfo(filter);
4303
4304 di = dictGetSafeIterator(server.cluster->nodes);
4305 while((de = dictNext(di)) != NULL) {
4306 clusterNode *node = dictGetVal(de);
4307
4308 if (node->flags & filter) continue;
4309 ni = clusterGenNodeDescription(node, use_pport);
4310 ci = sdscatsds(ci,ni);
4311 sdsfree(ni);
4312 ci = sdscatlen(ci,"\n",1);
4313
4314 /* Release slots info. */
4315 if (node->slots_info) {
4316 sdsfree(node->slots_info);
4317 node->slots_info = NULL;
4318 }
4319 }
4320 dictReleaseIterator(di);
4321 return ci;
4322}
4323
4324/* -----------------------------------------------------------------------------
4325 * CLUSTER command

Callers 2

clusterSaveConfigFunction · 0.85
clusterCommandFunction · 0.85

Calls 9

sdsemptyFunction · 0.85
clusterGenNodesSlotsInfoFunction · 0.85
dictGetSafeIteratorFunction · 0.85
sdscatsdsFunction · 0.85
sdsfreeFunction · 0.85
sdscatlenFunction · 0.85
dictNextFunction · 0.70
dictReleaseIteratorFunction · 0.70

Tested by

no test coverage detected