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

Function clusterManagerNodeByAbbreviatedName

src/redis-cli.c:2605–2625  ·  view source on GitHub ↗

Like clusterManagerNodeByName but the specified name can be just the first * part of the node ID as long as the prefix in unique across the * cluster. */

Source from the content-addressed store, hash-verified

2603 * cluster.
2604 */
2605static clusterManagerNode *clusterManagerNodeByAbbreviatedName(const char*name)
2606{
2607 if (cluster_manager.nodes == NULL) return NULL;
2608 clusterManagerNode *found = NULL;
2609 sds lcname = sdsempty();
2610 lcname = sdscpy(lcname, name);
2611 sdstolower(lcname);
2612 listIter li;
2613 listNode *ln;
2614 listRewind(cluster_manager.nodes, &li);
2615 while ((ln = listNext(&li)) != NULL) {
2616 clusterManagerNode *n = ln->value;
2617 if (n->name &&
2618 strstr(n->name, lcname) == n->name) {
2619 found = n;
2620 break;
2621 }
2622 }
2623 sdsfree(lcname);
2624 return found;
2625}
2626
2627static void clusterManagerNodeResetSlots(clusterManagerNode *node) {
2628 memset(node->slots, 0, sizeof(node->slots));

Callers 1

Calls 6

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

Tested by

no test coverage detected