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