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

Function clusterManagerNodeByName

src/redis-cli.c:2581–2599  ·  view source on GitHub ↗

Return the node with the specified name (ID) or NULL. */

Source from the content-addressed store, hash-verified

2579
2580/* Return the node with the specified name (ID) or NULL. */
2581static clusterManagerNode *clusterManagerNodeByName(const char *name) {
2582 if (cluster_manager.nodes == NULL) return NULL;
2583 clusterManagerNode *found = NULL;
2584 sds lcname = sdsempty();
2585 lcname = sdscpy(lcname, name);
2586 sdstolower(lcname);
2587 listIter li;
2588 listNode *ln;
2589 listRewind(cluster_manager.nodes, &li);
2590 while ((ln = listNext(&li)) != NULL) {
2591 clusterManagerNode *n = ln->value;
2592 if (n->name && !sdscmp(n->name, lcname)) {
2593 found = n;
2594 break;
2595 }
2596 }
2597 sdsfree(lcname);
2598 return found;
2599}
2600
2601/* Like clusterManagerNodeByName but the specified name can be just the first
2602 * part of the node ID as long as the prefix in unique across the

Calls 7

sdsemptyFunction · 0.85
sdscpyFunction · 0.85
sdstolowerFunction · 0.85
listRewindFunction · 0.85
listNextFunction · 0.85
sdscmpFunction · 0.85
sdsfreeFunction · 0.85

Tested by

no test coverage detected