MXS-1845 New algorithm for finding the master server

Not yet used, as more is needed to replace the old code. The
algorithm is based on counting the total number of slave nodes
a server has, possibly in multiple layers and/or cycles.
This commit is contained in:
Esa Korhonen
2018-06-05 18:17:29 +03:00
parent 8094c67ac2
commit 3f82c25c62
5 changed files with 247 additions and 21 deletions

View File

@ -71,16 +71,28 @@ public:
};
/**
* Data required for checking replication topology cycles. Not all of the listed data is used yet.
* Data required for checking replication topology cycles and other graph algorithms. This data is mostly
* used by the monitor object, as the data only makes sense in relation to other nodes.
*/
struct NodeData
{
// Default values for index parameters
static const int INDEX_NOT_VISITED = 0;
static const int INDEX_FIRST = 1;
// Default values for the cycle
static const int CYCLE_NONE = 0;
static const int CYCLE_FIRST = 1;
// Default value for reach
static const int REACH_UNKNOWN = 0;
// Bookkeeping for graph searches. May be overwritten by multiple algorithms.
int index; /* Marks the order in which this node was visited. */
int lowest_index; /* The lowest index node this node has in its subtree. */
int cycle; /* Which cycle is this node part of, if any. */
bool in_stack; /* Is this node currently is the search stack. */
// Results from algorithm runs. Should only be overwritten when server data has been queried.
int cycle; /* Which cycle is this node part of, if any. */
int reach; /* How many servers replicate from this server or its children. */
ServerArray parents; /* Which nodes is this node replicating from. External masters excluded. */
ServerArray children;/* Which nodes are replicating from this node. */
std::vector<int64_t> external_masters; /* Server id:s of external masters. */
@ -88,9 +100,14 @@ struct NodeData
NodeData();
/**
* Reset the data to default values
* Reset result data to default values. Should be ran when starting an iteration.
*/
void reset();
void reset_results();
/**
* Reset index data. Should be ran before an algorithm run.
*/
void reset_indexes();
};
/**