mirror of
https://github.com/fluencelabs/redis
synced 2025-04-10 03:06:05 +00:00
Cluster: clusterGenNodesDescription() refactored into two functions.
This commit is contained in:
parent
1cf532dc37
commit
603e480fd5
@ -2510,32 +2510,16 @@ void clusterSetMaster(clusterNode *n) {
|
|||||||
* CLUSTER command
|
* CLUSTER command
|
||||||
* -------------------------------------------------------------------------- */
|
* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
/* Generate a csv-alike representation of the nodes we are aware of,
|
/* Generate a csv-alike representation of the specified cluster node.
|
||||||
* including the "myself" node, and return an SDS string containing the
|
* See clusterGenNodesDescription() top comment for more information.
|
||||||
* representation (it is up to the caller to free it).
|
|
||||||
*
|
*
|
||||||
* All the nodes matching at least one of the node flags specified in
|
* The function returns the string representation as an SDS string. */
|
||||||
* "filter" are excluded from the output, so using zero as a filter will
|
sds clusterGenNodeDescription(clusterNode *node) {
|
||||||
* include all the known nodes in the representation, including nodes in
|
|
||||||
* the HANDSHAKE state.
|
|
||||||
*
|
|
||||||
* The representation obtained using this function is used for the output
|
|
||||||
* of the CLUSTER NODES function, and as format for the cluster
|
|
||||||
* configuration file (nodes.conf) for a given node. */
|
|
||||||
sds clusterGenNodesDescription(int filter) {
|
|
||||||
sds ci = sdsempty();
|
|
||||||
dictIterator *di;
|
|
||||||
dictEntry *de;
|
|
||||||
int j, start;
|
int j, start;
|
||||||
|
sds ci;
|
||||||
di = dictGetSafeIterator(server.cluster->nodes);
|
|
||||||
while((de = dictNext(di)) != NULL) {
|
|
||||||
clusterNode *node = dictGetVal(de);
|
|
||||||
|
|
||||||
if (node->flags & filter) continue;
|
|
||||||
|
|
||||||
/* Node coordinates */
|
/* Node coordinates */
|
||||||
ci = sdscatprintf(ci,"%.40s %s:%d ",
|
ci = sdscatprintf(sdsempty(),"%.40s %s:%d ",
|
||||||
node->name,
|
node->name,
|
||||||
node->ip,
|
node->ip,
|
||||||
node->port);
|
node->port);
|
||||||
@ -2599,6 +2583,34 @@ sds clusterGenNodesDescription(int filter) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return ci;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 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, including nodes in
|
||||||
|
* the HANDSHAKE state.
|
||||||
|
*
|
||||||
|
* The representation obtained using this function is used for the output
|
||||||
|
* of the CLUSTER NODES function, and as format for the cluster
|
||||||
|
* configuration file (nodes.conf) for a given node. */
|
||||||
|
sds clusterGenNodesDescription(int filter) {
|
||||||
|
sds ci = sdsempty(), ni;
|
||||||
|
dictIterator *di;
|
||||||
|
dictEntry *de;
|
||||||
|
|
||||||
|
di = dictGetSafeIterator(server.cluster->nodes);
|
||||||
|
while((de = dictNext(di)) != NULL) {
|
||||||
|
clusterNode *node = dictGetVal(de);
|
||||||
|
|
||||||
|
if (node->flags & filter) continue;
|
||||||
|
ni = clusterGenNodeDescription(node);
|
||||||
|
ci = sdscatsds(ci,ni);
|
||||||
|
sdsfree(ni);
|
||||||
ci = sdscatlen(ci,"\n",1);
|
ci = sdscatlen(ci,"\n",1);
|
||||||
}
|
}
|
||||||
dictReleaseIterator(di);
|
dictReleaseIterator(di);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user