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

Function clusterSetMaster

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

Set the specified node 'n' as master for this node. * If this node is currently a master, it is turned into a slave. */

Source from the content-addressed store, hash-verified

4111/* Set the specified node 'n' as master for this node.
4112 * If this node is currently a master, it is turned into a slave. */
4113void clusterSetMaster(clusterNode *n) {
4114 serverAssert(n != myself);
4115 serverAssert(myself->numslots == 0);
4116
4117 if (nodeIsMaster(myself)) {
4118 myself->flags &= ~(CLUSTER_NODE_MASTER|CLUSTER_NODE_MIGRATE_TO);
4119 myself->flags |= CLUSTER_NODE_SLAVE;
4120 clusterCloseAllSlots();
4121 } else {
4122 if (myself->slaveof)
4123 clusterNodeRemoveSlave(myself->slaveof,myself);
4124 }
4125 myself->slaveof = n;
4126 clusterNodeAddSlave(n,myself);
4127 replicationSetMaster(n->ip, n->port);
4128 resetManualFailover();
4129}
4130
4131/* -----------------------------------------------------------------------------
4132 * Nodes to string representation functions.

Callers 3

clusterCommandFunction · 0.85

Calls 5

clusterCloseAllSlotsFunction · 0.85
clusterNodeRemoveSlaveFunction · 0.85
clusterNodeAddSlaveFunction · 0.85
replicationSetMasterFunction · 0.85
resetManualFailoverFunction · 0.85

Tested by

no test coverage detected