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

Function clusterBlacklistAddNode

src/cluster.cpp:1269–1282  ·  view source on GitHub ↗

Cleanup the blacklist and add a new node ID to the black list. */

Source from the content-addressed store, hash-verified

1267
1268/* Cleanup the blacklist and add a new node ID to the black list. */
1269void clusterBlacklistAddNode(clusterNode *node) {
1270 dictEntry *de;
1271 sds id = sdsnewlen(node->name,CLUSTER_NAMELEN);
1272
1273 clusterBlacklistCleanup();
1274 if (dictAdd(g_pserver->cluster->nodes_black_list,id,NULL) == DICT_OK) {
1275 /* If the key was added, duplicate the sds string representation of
1276 * the key for the next lookup. We'll free it at the end. */
1277 id = sdsdup(id);
1278 }
1279 de = dictFind(g_pserver->cluster->nodes_black_list,id);
1280 dictSetUnsignedIntegerVal(de,time(NULL)+CLUSTER_BLACKLIST_TTL);
1281 sdsfree(id);
1282}
1283
1284/* Return non-zero if the specified node ID exists in the blacklist.
1285 * You don't need to pass an sds string here, any pointer to 40 bytes

Callers 1

clusterCommandFunction · 0.85

Calls 6

sdsnewlenFunction · 0.85
clusterBlacklistCleanupFunction · 0.85
sdsdupFunction · 0.85
sdsfreeFunction · 0.85
dictAddFunction · 0.70
dictFindFunction · 0.70

Tested by

no test coverage detected