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

Function clusterDelNode

src/cluster.cpp:1034–1061  ·  view source on GitHub ↗

Remove a node from the cluster. The function performs the high level * cleanup, calling freeClusterNode() for the low level cleanup. * Here we do the following: * * 1) Mark all the slots handled by it as unassigned. * 2) Remove all the failure reports sent by this node and referenced by * other nodes. * 3) Free the node with freeClusterNode() that will in turn remove it * from the ha

Source from the content-addressed store, hash-verified

1032 * it is a slave node.
1033 */
1034void clusterDelNode(clusterNode *delnode) {
1035 int j;
1036 dictIterator *di;
1037 dictEntry *de;
1038
1039 /* 1) Mark slots as unassigned. */
1040 for (j = 0; j < CLUSTER_SLOTS; j++) {
1041 if (g_pserver->cluster->importing_slots_from[j] == delnode)
1042 g_pserver->cluster->importing_slots_from[j] = NULL;
1043 if (g_pserver->cluster->migrating_slots_to[j] == delnode)
1044 g_pserver->cluster->migrating_slots_to[j] = NULL;
1045 if (g_pserver->cluster->slots[j] == delnode)
1046 clusterDelSlot(j);
1047 }
1048
1049 /* 2) Remove failure reports. */
1050 di = dictGetSafeIterator(g_pserver->cluster->nodes);
1051 while((de = dictNext(di)) != NULL) {
1052 clusterNode *node = (clusterNode*)dictGetVal(de);
1053
1054 if (node == delnode) continue;
1055 clusterNodeDelFailureReport(node,delnode);
1056 }
1057 dictReleaseIterator(di);
1058
1059 /* 3) Free the node, unlinking it from the cluster. */
1060 freeClusterNode(delnode);
1061}
1062
1063/* Node lookup by name */
1064clusterNode *clusterLookupNode(const char *name) {

Callers 4

clusterResetFunction · 0.85
clusterProcessPacketFunction · 0.85
clusterCronFunction · 0.85
clusterCommandFunction · 0.85

Calls 6

clusterDelSlotFunction · 0.85
dictGetSafeIteratorFunction · 0.85
dictNextFunction · 0.70
dictReleaseIteratorFunction · 0.70
freeClusterNodeFunction · 0.70

Tested by

no test coverage detected