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

Function clusterSetNodeAsMaster

src/cluster.cpp:1653–1667  ·  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

1651 * a node that we believed to be a slave is now acting as master in order to
1652 * update the state of the node. */
1653void clusterSetNodeAsMaster(clusterNode *n) {
1654 if (nodeIsMaster(n)) return;
1655
1656 if (n->slaveof) {
1657 clusterNodeRemoveSlave(n->slaveof,n);
1658 if (n != myself) n->flags |= CLUSTER_NODE_MIGRATE_TO;
1659 }
1660 n->flags &= ~CLUSTER_NODE_SLAVE;
1661 n->flags |= CLUSTER_NODE_MASTER;
1662 n->slaveof = NULL;
1663
1664 /* Update config and state. */
1665 clusterDoBeforeSleep(CLUSTER_TODO_SAVE_CONFIG|
1666 CLUSTER_TODO_UPDATE_STATE);
1667}
1668
1669/* This function is called when we receive a master configuration via a
1670 * PING, PONG or UPDATE packet. What we receive is a node, a configEpoch of the

Callers 4

clusterResetFunction · 0.85
clusterProcessPacketFunction · 0.85
clusterCommandFunction · 0.85

Calls 2

clusterNodeRemoveSlaveFunction · 0.85
clusterDoBeforeSleepFunction · 0.85

Tested by

no test coverage detected