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

Function clusterGenNodesDescription

src/cluster.cpp:4355–4381  ·  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

4353 * of the CLUSTER NODES function, and as format for the cluster
4354 * configuration file (nodes.conf) for a given node. */
4355sds clusterGenNodesDescription(int filter, int use_pport) {
4356 sds ci = sdsempty(), ni;
4357 dictIterator *di;
4358 dictEntry *de;
4359
4360 /* Generate all nodes slots info firstly. */
4361 clusterGenNodesSlotsInfo(filter);
4362
4363 di = dictGetSafeIterator(g_pserver->cluster->nodes);
4364 while((de = dictNext(di)) != NULL) {
4365 clusterNode *node = (clusterNode*)dictGetVal(de);
4366
4367 if (node->flags & filter) continue;
4368 ni = clusterGenNodeDescription(node, use_pport);
4369 ci = sdscatsds(ci,ni);
4370 sdsfree(ni);
4371 ci = sdscatlen(ci,"\n",1);
4372
4373 /* Release slots info. */
4374 if (node->slots_info) {
4375 sdsfree(node->slots_info);
4376 node->slots_info = NULL;
4377 }
4378 }
4379 dictReleaseIterator(di);
4380 return ci;
4381}
4382
4383/* -----------------------------------------------------------------------------
4384 * 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