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

Function clusterBlacklistCleanup

src/cluster.cpp:1254–1266  ·  view source on GitHub ↗

Before of the addNode() or Exists() operations we always remove expired * entries from the black list. This is an O(N) operation but it is not a * problem since add / exists operations are called very infrequently and * the hash table is supposed to contain very little elements at max. * However without the cleanup during long uptime and with some automated * node add/removal procedures, entr

Source from the content-addressed store, hash-verified

1252 * However without the cleanup during long uptime and with some automated
1253 * node add/removal procedures, entries could accumulate. */
1254void clusterBlacklistCleanup(void) {
1255 dictIterator *di;
1256 dictEntry *de;
1257
1258 di = dictGetSafeIterator(g_pserver->cluster->nodes_black_list);
1259 while((de = dictNext(di)) != NULL) {
1260 int64_t expire = dictGetUnsignedIntegerVal(de);
1261
1262 if (expire < g_pserver->unixtime)
1263 dictDelete(g_pserver->cluster->nodes_black_list,dictGetKey(de));
1264 }
1265 dictReleaseIterator(di);
1266}
1267
1268/* Cleanup the blacklist and add a new node ID to the black list. */
1269void clusterBlacklistAddNode(clusterNode *node) {

Callers 2

clusterBlacklistAddNodeFunction · 0.85
clusterBlacklistExistsFunction · 0.85

Calls 4

dictGetSafeIteratorFunction · 0.85
dictNextFunction · 0.70
dictDeleteFunction · 0.70
dictReleaseIteratorFunction · 0.70

Tested by

no test coverage detected