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

Function sentinelGetCurrentMasterAddress

src/sentinel.cpp:1701–1715  ·  view source on GitHub ↗

Return the current master address, that is, its address or the address * of the promoted slave if already operational. */

Source from the content-addressed store, hash-verified

1699/* Return the current master address, that is, its address or the address
1700 * of the promoted slave if already operational. */
1701sentinelAddr *sentinelGetCurrentMasterAddress(sentinelRedisInstance *master) {
1702 /* If we are failing over the master, and the state is already
1703 * SENTINEL_FAILOVER_STATE_RECONF_SLAVES or greater, it means that we
1704 * already have the new configuration epoch in the master, and the
1705 * slave acknowledged the configuration switch. Advertise the new
1706 * address. */
1707 if ((master->flags & SRI_FAILOVER_IN_PROGRESS) &&
1708 master->promoted_slave &&
1709 master->failover_state >= SENTINEL_FAILOVER_STATE_RECONF_SLAVES)
1710 {
1711 return master->promoted_slave->addr;
1712 } else {
1713 return master->addr;
1714 }
1715}
1716
1717/* This function sets the down_after_period field value in 'master' to all
1718 * the slaves and sentinel instances connected to this master. */

Callers 3

sentinelSendHelloFunction · 0.85
sentinelCommandFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected