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

Function clusterSetNodeAsMaster

app/redis-6.2.6/src/cluster.c:1608–1622  ·  view source on GitHub ↗

Reconfigure the specified node 'n' as a master. This function is called when * a node that we believed to be a slave is now acting as master in order to * update the state of the node. */

Source from the content-addressed store, hash-verified

1606 * a node that we believed to be a slave is now acting as master in order to
1607 * update the state of the node. */
1608void clusterSetNodeAsMaster(clusterNode *n) {
1609 if (nodeIsMaster(n)) return;
1610
1611 if (n->slaveof) {
1612 clusterNodeRemoveSlave(n->slaveof,n);
1613 if (n != myself) n->flags |= CLUSTER_NODE_MIGRATE_TO;
1614 }
1615 n->flags &= ~CLUSTER_NODE_SLAVE;
1616 n->flags |= CLUSTER_NODE_MASTER;
1617 n->slaveof = NULL;
1618
1619 /* Update config and state. */
1620 clusterDoBeforeSleep(CLUSTER_TODO_SAVE_CONFIG|
1621 CLUSTER_TODO_UPDATE_STATE);
1622}
1623
1624/* This function is called when we receive a master configuration via a
1625 * PING, PONG or UPDATE packet. What we receive is a node, a configEpoch of the

Callers 3

clusterResetFunction · 0.85
clusterProcessPacketFunction · 0.85

Calls 2

clusterNodeRemoveSlaveFunction · 0.85
clusterDoBeforeSleepFunction · 0.85

Tested by

no test coverage detected