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

Function clusterMastersHaveSlaves

src/cluster.cpp:3889–3901  ·  view source on GitHub ↗

Return non-zero if there is at least one master with slaves in the cluster. * Otherwise zero is returned. Used by clusterNodeSetSlotBit() to set the * MIGRATE_TO flag the when a master gets the first slot. */

Source from the content-addressed store, hash-verified

3887 * Otherwise zero is returned. Used by clusterNodeSetSlotBit() to set the
3888 * MIGRATE_TO flag the when a master gets the first slot. */
3889int clusterMastersHaveSlaves(void) {
3890 dictIterator *di = dictGetSafeIterator(g_pserver->cluster->nodes);
3891 dictEntry *de;
3892 int slaves = 0;
3893 while((de = dictNext(di)) != NULL) {
3894 clusterNode *node = (clusterNode*)dictGetVal(de);
3895
3896 if (nodeIsSlave(node)) continue;
3897 slaves += node->numslaves;
3898 }
3899 dictReleaseIterator(di);
3900 return slaves != 0;
3901}
3902
3903/* Set the slot bit and return the old value. */
3904int clusterNodeSetSlotBit(clusterNode *n, int slot) {

Callers 1

clusterNodeSetSlotBitFunction · 0.85

Calls 3

dictGetSafeIteratorFunction · 0.85
dictNextFunction · 0.70
dictReleaseIteratorFunction · 0.70

Tested by

no test coverage detected