Remove depth field from SERVER
It was not really used anymore.
This commit is contained in:
@ -856,42 +856,28 @@ static uint64_t getCapabilities(MXS_ROUTER* instance)
|
||||
return RCAP_TYPE_NONE;
|
||||
}
|
||||
|
||||
/********************************
|
||||
* This routine returns the root master server from MySQL replication tree
|
||||
* Get the root Master rule:
|
||||
/*
|
||||
* This routine returns the master server from a MariaDB replication tree. The server must be
|
||||
* running, not in maintenance and have the master bit set. If multiple masters are found,
|
||||
* the one with the highest weight is chosen.
|
||||
*
|
||||
* find server with the lowest replication depth level
|
||||
* and the SERVER_MASTER bitval
|
||||
* Servers are checked even if they are in 'maintenance'
|
||||
*
|
||||
* @param servers The list of servers
|
||||
* @return The Master found
|
||||
* @param servers The list of servers
|
||||
* @return The Master server
|
||||
*
|
||||
*/
|
||||
|
||||
static SERVER_REF *get_root_master(SERVER_REF *servers)
|
||||
{
|
||||
int i = 0;
|
||||
SERVER_REF *master_host = NULL;
|
||||
|
||||
for (SERVER_REF *ref = servers; ref; ref = ref->next)
|
||||
{
|
||||
if (ref->active && SERVER_IS_MASTER(ref->server))
|
||||
{
|
||||
if (master_host == NULL)
|
||||
// No master found yet or this one has higher weight.
|
||||
if (master_host == NULL || ref->weight > master_host->weight)
|
||||
{
|
||||
master_host = ref;
|
||||
}
|
||||
else if (ref->server->depth < master_host->server->depth ||
|
||||
(ref->server->depth == master_host->server->depth &&
|
||||
ref->weight > master_host->weight))
|
||||
{
|
||||
/**
|
||||
* This master has a lower depth than the candidate master or
|
||||
* the depths are equal but this master has a higher weight
|
||||
*/
|
||||
master_host = ref;
|
||||
}
|
||||
}
|
||||
}
|
||||
return master_host;
|
||||
|
@ -244,14 +244,12 @@ static void log_server_connections(select_criteria_t criteria, const SRWBackendL
|
||||
SRWBackend get_root_master(const SRWBackendList& backends)
|
||||
{
|
||||
SRWBackend master;
|
||||
|
||||
for (auto it = backends.begin(); it != backends.end(); it++)
|
||||
for (auto candidate : backends)
|
||||
{
|
||||
auto b = *it;
|
||||
|
||||
if (b->is_master() && (!master || b->server()->depth < master->server()->depth))
|
||||
if (candidate->is_master())
|
||||
{
|
||||
master = b;
|
||||
master = candidate;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user