MCPcopy Create free account
hub / github.com/F-Stack/f-stack / clusterMastersHaveSlaves

Function clusterMastersHaveSlaves

app/redis-6.2.6/src/cluster.c:3830–3842  ·  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

3828 * Otherwise zero is returned. Used by clusterNodeSetSlotBit() to set the
3829 * MIGRATE_TO flag the when a master gets the first slot. */
3830int clusterMastersHaveSlaves(void) {
3831 dictIterator *di = dictGetSafeIterator(server.cluster->nodes);
3832 dictEntry *de;
3833 int slaves = 0;
3834 while((de = dictNext(di)) != NULL) {
3835 clusterNode *node = dictGetVal(de);
3836
3837 if (nodeIsSlave(node)) continue;
3838 slaves += node->numslaves;
3839 }
3840 dictReleaseIterator(di);
3841 return slaves != 0;
3842}
3843
3844/* Set the slot bit and return the old value. */
3845int 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