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
| 4294 | * of the CLUSTER NODES function, and as format for the cluster |
| 4295 | * configuration file (nodes.conf) for a given node. */ |
| 4296 | sds 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 |
no test coverage detected