Rename MXS_MONITOR_SERVERS to MXS_MONITORED_SERVER
An element in a linked list is not a list.
This commit is contained in:
@ -161,7 +161,7 @@ typedef enum
|
||||
/**
|
||||
* The linked list of servers that are being monitored by the monitor module.
|
||||
*/
|
||||
typedef struct monitor_servers
|
||||
typedef struct monitored_server
|
||||
{
|
||||
SERVER *server; /**< The server being monitored */
|
||||
MYSQL *con; /**< The MySQL connection */
|
||||
@ -169,8 +169,8 @@ typedef struct monitor_servers
|
||||
int mon_err_count;
|
||||
unsigned int mon_prev_status;
|
||||
unsigned int pending_status; /**< Pending Status flag bitmap */
|
||||
struct monitor_servers *next; /**< The next server in the list */
|
||||
} MXS_MONITOR_SERVERS;
|
||||
struct monitored_server *next; /**< The next server in the list */
|
||||
} MXS_MONITORED_SERVER;
|
||||
|
||||
/**
|
||||
* Representation of the running monitor.
|
||||
@ -182,7 +182,7 @@ struct mxs_monitor
|
||||
char password[MAX_MONITOR_PASSWORD_LEN]; /*< Monitor password */
|
||||
SPINLOCK lock;
|
||||
MXS_CONFIG_PARAMETER* parameters; /*< configuration parameters */
|
||||
MXS_MONITOR_SERVERS* databases; /*< List of databases the monitor monitors */
|
||||
MXS_MONITORED_SERVER* databases; /*< List of databases the monitor monitors */
|
||||
monitor_state_t state; /**< The state of the monitor */
|
||||
int connect_timeout; /**< Connect timeout in seconds for mysql_real_connect */
|
||||
int connect_attempts; /**< How many times a connection is attempted */
|
||||
@ -255,16 +255,16 @@ extern const char CN_EVENTS[];
|
||||
|
||||
bool check_monitor_permissions(MXS_MONITOR* monitor, const char* query);
|
||||
|
||||
void monitor_clear_pending_status(MXS_MONITOR_SERVERS *ptr, int bit);
|
||||
void monitor_set_pending_status(MXS_MONITOR_SERVERS *ptr, int bit);
|
||||
void monitor_clear_pending_status(MXS_MONITORED_SERVER *ptr, int bit);
|
||||
void monitor_set_pending_status(MXS_MONITORED_SERVER *ptr, int bit);
|
||||
void servers_status_pending_to_current(MXS_MONITOR *monitor);
|
||||
void servers_status_current_to_pending(MXS_MONITOR *monitor);
|
||||
|
||||
bool mon_status_changed(MXS_MONITOR_SERVERS* mon_srv);
|
||||
bool mon_print_fail_status(MXS_MONITOR_SERVERS* mon_srv);
|
||||
bool mon_status_changed(MXS_MONITORED_SERVER* mon_srv);
|
||||
bool mon_print_fail_status(MXS_MONITORED_SERVER* mon_srv);
|
||||
|
||||
mxs_connect_result_t mon_ping_or_connect_to_db(MXS_MONITOR* mon, MXS_MONITOR_SERVERS *database);
|
||||
void mon_log_connect_error(MXS_MONITOR_SERVERS* database, mxs_connect_result_t rval);
|
||||
mxs_connect_result_t mon_ping_or_connect_to_db(MXS_MONITOR* mon, MXS_MONITORED_SERVER *database);
|
||||
void mon_log_connect_error(MXS_MONITORED_SERVER* database, mxs_connect_result_t rval);
|
||||
|
||||
void lock_monitor_servers(MXS_MONITOR *monitor);
|
||||
void release_monitor_servers(MXS_MONITOR *monitor);
|
||||
@ -295,7 +295,7 @@ void mon_hangup_failed_servers(MXS_MONITOR *monitor);
|
||||
*
|
||||
* @param db Database where the query failed
|
||||
*/
|
||||
void mon_report_query_error(MXS_MONITOR_SERVERS* db);
|
||||
void mon_report_query_error(MXS_MONITORED_SERVER* db);
|
||||
|
||||
/**
|
||||
* @brief Convert monitor to JSON
|
||||
@ -332,7 +332,7 @@ json_t* monitor_relations_to_server(const SERVER* server, const char* host);
|
||||
* @param monitor Monitor to journal
|
||||
* @param master The current master server or NULL if no master exists
|
||||
*/
|
||||
void store_server_journal(MXS_MONITOR *monitor, MXS_MONITOR_SERVERS *master);
|
||||
void store_server_journal(MXS_MONITOR *monitor, MXS_MONITORED_SERVER *master);
|
||||
|
||||
/**
|
||||
* @brief Load a journal of server states
|
||||
@ -340,6 +340,6 @@ void store_server_journal(MXS_MONITOR *monitor, MXS_MONITOR_SERVERS *master);
|
||||
* @param monitor Monitor where journal is loaded
|
||||
* @param master Set to point to the current master
|
||||
*/
|
||||
void load_server_journal(MXS_MONITOR *monitor, MXS_MONITOR_SERVERS **master);
|
||||
void load_server_journal(MXS_MONITOR *monitor, MXS_MONITORED_SERVER **master);
|
||||
|
||||
MXS_END_DECLS
|
||||
|
@ -76,7 +76,7 @@ const char CN_EVENTS[] = "events";
|
||||
static MXS_MONITOR *allMonitors = NULL;
|
||||
static SPINLOCK monLock = SPINLOCK_INIT;
|
||||
|
||||
static void monitor_server_free_all(MXS_MONITOR_SERVERS *servers);
|
||||
static void monitor_server_free_all(MXS_MONITORED_SERVER *servers);
|
||||
static void remove_server_journal(MXS_MONITOR *monitor);
|
||||
static bool journal_is_stale(MXS_MONITOR *monitor, time_t max_age);
|
||||
|
||||
@ -253,7 +253,7 @@ monitorStop(MXS_MONITOR *monitor)
|
||||
monitor->module->stopMonitor(monitor);
|
||||
monitor->state = MONITOR_STATE_STOPPED;
|
||||
|
||||
MXS_MONITOR_SERVERS* db = monitor->databases;
|
||||
MXS_MONITORED_SERVER* db = monitor->databases;
|
||||
while (db)
|
||||
{
|
||||
// TODO: Create a generic entry point for this or move it inside stopMonitor
|
||||
@ -313,7 +313,7 @@ bool monitorAddServer(MXS_MONITOR *mon, SERVER *server)
|
||||
else
|
||||
{
|
||||
rval = true;
|
||||
MXS_MONITOR_SERVERS *db = (MXS_MONITOR_SERVERS *)MXS_MALLOC(sizeof(MXS_MONITOR_SERVERS));
|
||||
MXS_MONITORED_SERVER *db = (MXS_MONITORED_SERVER *)MXS_MALLOC(sizeof(MXS_MONITORED_SERVER));
|
||||
MXS_ABORT_IF_NULL(db);
|
||||
|
||||
db->server = server;
|
||||
@ -341,7 +341,7 @@ bool monitorAddServer(MXS_MONITOR *mon, SERVER *server)
|
||||
}
|
||||
else
|
||||
{
|
||||
MXS_MONITOR_SERVERS *ptr = mon->databases;
|
||||
MXS_MONITORED_SERVER *ptr = mon->databases;
|
||||
while (ptr->next != NULL)
|
||||
{
|
||||
ptr = ptr->next;
|
||||
@ -359,7 +359,7 @@ bool monitorAddServer(MXS_MONITOR *mon, SERVER *server)
|
||||
return rval;
|
||||
}
|
||||
|
||||
static void monitor_server_free(MXS_MONITOR_SERVERS *tofree)
|
||||
static void monitor_server_free(MXS_MONITORED_SERVER *tofree)
|
||||
{
|
||||
if (tofree)
|
||||
{
|
||||
@ -375,11 +375,11 @@ static void monitor_server_free(MXS_MONITOR_SERVERS *tofree)
|
||||
* Free monitor server list
|
||||
* @param servers Servers to free
|
||||
*/
|
||||
static void monitor_server_free_all(MXS_MONITOR_SERVERS *servers)
|
||||
static void monitor_server_free_all(MXS_MONITORED_SERVER *servers)
|
||||
{
|
||||
while (servers)
|
||||
{
|
||||
MXS_MONITOR_SERVERS *tofree = servers;
|
||||
MXS_MONITORED_SERVER *tofree = servers;
|
||||
servers = servers->next;
|
||||
monitor_server_free(tofree);
|
||||
}
|
||||
@ -402,7 +402,7 @@ void monitorRemoveServer(MXS_MONITOR *mon, SERVER *server)
|
||||
|
||||
spinlock_acquire(&mon->lock);
|
||||
|
||||
MXS_MONITOR_SERVERS *ptr = mon->databases;
|
||||
MXS_MONITORED_SERVER *ptr = mon->databases;
|
||||
|
||||
if (ptr && ptr->server == server)
|
||||
{
|
||||
@ -410,7 +410,7 @@ void monitorRemoveServer(MXS_MONITOR *mon, SERVER *server)
|
||||
}
|
||||
else
|
||||
{
|
||||
MXS_MONITOR_SERVERS *prev = ptr;
|
||||
MXS_MONITORED_SERVER *prev = ptr;
|
||||
|
||||
while (ptr)
|
||||
{
|
||||
@ -522,7 +522,7 @@ monitorShow(DCB *dcb, MXS_MONITOR *monitor)
|
||||
|
||||
const char *sep = "";
|
||||
|
||||
for (MXS_MONITOR_SERVERS *db = monitor->databases; db; db = db->next)
|
||||
for (MXS_MONITORED_SERVER *db = monitor->databases; db; db = db->next)
|
||||
{
|
||||
dcb_printf(dcb, "%s[%s]:%d", sep, db->server->name, db->server->port);
|
||||
sep = ", ";
|
||||
@ -793,7 +793,7 @@ bool check_monitor_permissions(MXS_MONITOR* monitor, const char* query)
|
||||
MXS_CONFIG* cnf = config_get_global_options();
|
||||
bool rval = false;
|
||||
|
||||
for (MXS_MONITOR_SERVERS *mondb = monitor->databases; mondb; mondb = mondb->next)
|
||||
for (MXS_MONITORED_SERVER *mondb = monitor->databases; mondb; mondb = mondb->next)
|
||||
{
|
||||
if (mon_ping_or_connect_to_db(monitor, mondb) != MONITOR_CONN_OK)
|
||||
{
|
||||
@ -912,7 +912,7 @@ bool monitorRemoveParameter(MXS_MONITOR *monitor, const char *key)
|
||||
* @param bit The bit to clear for the server
|
||||
*/
|
||||
void
|
||||
monitor_set_pending_status(MXS_MONITOR_SERVERS *ptr, int bit)
|
||||
monitor_set_pending_status(MXS_MONITORED_SERVER *ptr, int bit)
|
||||
{
|
||||
ptr->pending_status |= bit;
|
||||
}
|
||||
@ -924,7 +924,7 @@ monitor_set_pending_status(MXS_MONITOR_SERVERS *ptr, int bit)
|
||||
* @param bit The bit to clear for the server
|
||||
*/
|
||||
void
|
||||
monitor_clear_pending_status(MXS_MONITOR_SERVERS *ptr, int bit)
|
||||
monitor_clear_pending_status(MXS_MONITORED_SERVER *ptr, int bit)
|
||||
{
|
||||
ptr->pending_status &= ~bit;
|
||||
}
|
||||
@ -936,7 +936,7 @@ monitor_clear_pending_status(MXS_MONITOR_SERVERS *ptr, int bit)
|
||||
* @param node The monitor server data for a particular server
|
||||
* @result monitor_event_t A monitor event (enum)
|
||||
*/
|
||||
static mxs_monitor_event_t mon_get_event_type(MXS_MONITOR_SERVERS* node)
|
||||
static mxs_monitor_event_t mon_get_event_type(MXS_MONITORED_SERVER* node)
|
||||
{
|
||||
typedef enum
|
||||
{
|
||||
@ -1052,7 +1052,7 @@ static mxs_monitor_event_t mon_get_event_type(MXS_MONITOR_SERVERS* node)
|
||||
* @param node The monitor server data whose event is wanted
|
||||
* @result string The name of the monitor event for the server
|
||||
*/
|
||||
static const char* mon_get_event_name(MXS_MONITOR_SERVERS* node)
|
||||
static const char* mon_get_event_name(MXS_MONITORED_SERVER* node)
|
||||
{
|
||||
mxs_monitor_event_t event = mon_get_event_type(node);
|
||||
|
||||
@ -1075,7 +1075,7 @@ static const char* mon_get_event_name(MXS_MONITOR_SERVERS* node)
|
||||
* @param dest Destination where the string is appended, must be null terminated
|
||||
* @param len Length of @c dest
|
||||
*/
|
||||
static void mon_append_node_names(MXS_MONITOR_SERVERS* servers, char* dest, int len, int status)
|
||||
static void mon_append_node_names(MXS_MONITORED_SERVER* servers, char* dest, int len, int status)
|
||||
{
|
||||
const char *separator = "";
|
||||
char arr[MAX_SERVER_ADDRESS_LEN + 64]; // Some extra space for port and separator
|
||||
@ -1106,7 +1106,7 @@ static void mon_append_node_names(MXS_MONITOR_SERVERS* servers, char* dest, int
|
||||
* @param mon_srv The monitored server
|
||||
* @return true if status has changed or false
|
||||
*/
|
||||
bool mon_status_changed(MXS_MONITOR_SERVERS* mon_srv)
|
||||
bool mon_status_changed(MXS_MONITORED_SERVER* mon_srv)
|
||||
{
|
||||
bool rval = false;
|
||||
|
||||
@ -1140,19 +1140,19 @@ bool mon_status_changed(MXS_MONITOR_SERVERS* mon_srv)
|
||||
* @return true if failed status can be logged or false
|
||||
*/
|
||||
bool
|
||||
mon_print_fail_status(MXS_MONITOR_SERVERS* mon_srv)
|
||||
mon_print_fail_status(MXS_MONITORED_SERVER* mon_srv)
|
||||
{
|
||||
return (SERVER_IS_DOWN(mon_srv->server) && mon_srv->mon_err_count == 0);
|
||||
}
|
||||
|
||||
static MXS_MONITOR_SERVERS* find_parent_node(MXS_MONITOR_SERVERS* servers,
|
||||
MXS_MONITOR_SERVERS* target)
|
||||
static MXS_MONITORED_SERVER* find_parent_node(MXS_MONITORED_SERVER* servers,
|
||||
MXS_MONITORED_SERVER* target)
|
||||
{
|
||||
MXS_MONITOR_SERVERS* rval = NULL;
|
||||
MXS_MONITORED_SERVER* rval = NULL;
|
||||
|
||||
if (target->server->master_id > 0)
|
||||
{
|
||||
for (MXS_MONITOR_SERVERS* node = servers; node; node = node->next)
|
||||
for (MXS_MONITORED_SERVER* node = servers; node; node = node->next)
|
||||
{
|
||||
if (node->server->node_id == target->server->master_id)
|
||||
{
|
||||
@ -1165,8 +1165,8 @@ static MXS_MONITOR_SERVERS* find_parent_node(MXS_MONITOR_SERVERS* servers,
|
||||
return rval;
|
||||
}
|
||||
|
||||
static std::string child_nodes(MXS_MONITOR_SERVERS* servers,
|
||||
MXS_MONITOR_SERVERS* parent)
|
||||
static std::string child_nodes(MXS_MONITORED_SERVER* servers,
|
||||
MXS_MONITORED_SERVER* parent)
|
||||
{
|
||||
std::stringstream ss;
|
||||
|
||||
@ -1174,7 +1174,7 @@ static std::string child_nodes(MXS_MONITOR_SERVERS* servers,
|
||||
{
|
||||
bool have_content = false;
|
||||
|
||||
for (MXS_MONITOR_SERVERS* node = servers; node; node = node->next)
|
||||
for (MXS_MONITORED_SERVER* node = servers; node; node = node->next)
|
||||
{
|
||||
if (node->server->master_id == parent->server->node_id)
|
||||
{
|
||||
@ -1199,7 +1199,7 @@ static std::string child_nodes(MXS_MONITOR_SERVERS* servers,
|
||||
* @param script Script to execute
|
||||
*/
|
||||
void
|
||||
monitor_launch_script(MXS_MONITOR* mon, MXS_MONITOR_SERVERS* ptr, const char* script)
|
||||
monitor_launch_script(MXS_MONITOR* mon, MXS_MONITORED_SERVER* ptr, const char* script)
|
||||
{
|
||||
char arg[strlen(script) + 1];
|
||||
strcpy(arg, script);
|
||||
@ -1223,7 +1223,7 @@ monitor_launch_script(MXS_MONITOR* mon, MXS_MONITOR_SERVERS* ptr, const char* sc
|
||||
if (externcmd_matches(cmd, "$PARENT"))
|
||||
{
|
||||
std::stringstream ss;
|
||||
MXS_MONITOR_SERVERS* parent = find_parent_node(mon->databases, ptr);
|
||||
MXS_MONITORED_SERVER* parent = find_parent_node(mon->databases, ptr);
|
||||
|
||||
if (parent)
|
||||
{
|
||||
@ -1352,7 +1352,7 @@ monitor_launch_script(MXS_MONITOR* mon, MXS_MONITOR_SERVERS* ptr, const char* sc
|
||||
* @return MONITOR_CONN_OK if the connection is OK, else the reason for the failure
|
||||
*/
|
||||
mxs_connect_result_t
|
||||
mon_ping_or_connect_to_db(MXS_MONITOR* mon, MXS_MONITOR_SERVERS *database)
|
||||
mon_ping_or_connect_to_db(MXS_MONITOR* mon, MXS_MONITORED_SERVER *database)
|
||||
{
|
||||
/** Return if the connection is OK */
|
||||
if (database->con && mysql_ping(database->con) == 0)
|
||||
@ -1417,7 +1417,7 @@ mon_ping_or_connect_to_db(MXS_MONITOR* mon, MXS_MONITOR_SERVERS *database)
|
||||
* @param rval Return value of mon_connect_to_db
|
||||
*/
|
||||
void
|
||||
mon_log_connect_error(MXS_MONITOR_SERVERS* database, mxs_connect_result_t rval)
|
||||
mon_log_connect_error(MXS_MONITORED_SERVER* database, mxs_connect_result_t rval)
|
||||
{
|
||||
MXS_ERROR(rval == MONITOR_CONN_TIMEOUT ?
|
||||
"Monitor timed out when connecting to server [%s]:%d : \"%s\"" :
|
||||
@ -1426,7 +1426,7 @@ mon_log_connect_error(MXS_MONITOR_SERVERS* database, mxs_connect_result_t rval)
|
||||
mysql_error(database->con));
|
||||
}
|
||||
|
||||
static void mon_log_state_change(MXS_MONITOR_SERVERS *ptr)
|
||||
static void mon_log_state_change(MXS_MONITORED_SERVER *ptr)
|
||||
{
|
||||
SERVER srv;
|
||||
srv.status = ptr->mon_prev_status;
|
||||
@ -1451,7 +1451,7 @@ MXS_MONITOR* monitor_server_in_use(const SERVER *server)
|
||||
|
||||
if (mon->active)
|
||||
{
|
||||
for (MXS_MONITOR_SERVERS *db = mon->databases; db && !rval; db = db->next)
|
||||
for (MXS_MONITORED_SERVER *db = mon->databases; db && !rval; db = db->next)
|
||||
{
|
||||
if (db->server == server)
|
||||
{
|
||||
@ -1495,7 +1495,7 @@ static bool create_monitor_config(const MXS_MONITOR *monitor, const char *filena
|
||||
if (monitor->databases)
|
||||
{
|
||||
dprintf(file, "%s=", CN_SERVERS);
|
||||
for (MXS_MONITOR_SERVERS *db = monitor->databases; db; db = db->next)
|
||||
for (MXS_MONITORED_SERVER *db = monitor->databases; db; db = db->next)
|
||||
{
|
||||
if (db != monitor->databases)
|
||||
{
|
||||
@ -1575,7 +1575,7 @@ bool monitor_serialize(const MXS_MONITOR *monitor)
|
||||
|
||||
void mon_hangup_failed_servers(MXS_MONITOR *monitor)
|
||||
{
|
||||
for (MXS_MONITOR_SERVERS *ptr = monitor->databases; ptr; ptr = ptr->next)
|
||||
for (MXS_MONITORED_SERVER *ptr = monitor->databases; ptr; ptr = ptr->next)
|
||||
{
|
||||
if (mon_status_changed(ptr) &&
|
||||
(!(SERVER_IS_RUNNING(ptr->server)) ||
|
||||
@ -1586,7 +1586,7 @@ void mon_hangup_failed_servers(MXS_MONITOR *monitor)
|
||||
}
|
||||
}
|
||||
|
||||
void mon_report_query_error(MXS_MONITOR_SERVERS* db)
|
||||
void mon_report_query_error(MXS_MONITORED_SERVER* db)
|
||||
{
|
||||
MXS_ERROR("Failed to execute query on server '%s' ([%s]:%d): %s",
|
||||
db->server->unique_name, db->server->name,
|
||||
@ -1600,7 +1600,7 @@ void mon_report_query_error(MXS_MONITOR_SERVERS* db)
|
||||
*/
|
||||
void lock_monitor_servers(MXS_MONITOR *monitor)
|
||||
{
|
||||
MXS_MONITOR_SERVERS *ptr = monitor->databases;
|
||||
MXS_MONITORED_SERVER *ptr = monitor->databases;
|
||||
while (ptr)
|
||||
{
|
||||
spinlock_acquire(&ptr->server->lock);
|
||||
@ -1614,7 +1614,7 @@ void lock_monitor_servers(MXS_MONITOR *monitor)
|
||||
*/
|
||||
void release_monitor_servers(MXS_MONITOR *monitor)
|
||||
{
|
||||
MXS_MONITOR_SERVERS *ptr = monitor->databases;
|
||||
MXS_MONITORED_SERVER *ptr = monitor->databases;
|
||||
while (ptr)
|
||||
{
|
||||
spinlock_release(&ptr->server->lock);
|
||||
@ -1629,7 +1629,7 @@ void release_monitor_servers(MXS_MONITOR *monitor)
|
||||
*/
|
||||
void servers_status_pending_to_current(MXS_MONITOR *monitor)
|
||||
{
|
||||
MXS_MONITOR_SERVERS *ptr = monitor->databases;
|
||||
MXS_MONITORED_SERVER *ptr = monitor->databases;
|
||||
while (ptr)
|
||||
{
|
||||
ptr->server->status = ptr->server->status_pending;
|
||||
@ -1645,7 +1645,7 @@ void servers_status_pending_to_current(MXS_MONITOR *monitor)
|
||||
*/
|
||||
void servers_status_current_to_pending(MXS_MONITOR *monitor)
|
||||
{
|
||||
MXS_MONITOR_SERVERS *ptr = monitor->databases;
|
||||
MXS_MONITORED_SERVER *ptr = monitor->databases;
|
||||
while (ptr)
|
||||
{
|
||||
ptr->server->status_pending = ptr->server->status;
|
||||
@ -1655,7 +1655,7 @@ void servers_status_current_to_pending(MXS_MONITOR *monitor)
|
||||
|
||||
void mon_process_state_changes(MXS_MONITOR *monitor, const char *script, uint64_t events)
|
||||
{
|
||||
for (MXS_MONITOR_SERVERS *ptr = monitor->databases; ptr; ptr = ptr->next)
|
||||
for (MXS_MONITORED_SERVER *ptr = monitor->databases; ptr; ptr = ptr->next)
|
||||
{
|
||||
if (mon_status_changed(ptr))
|
||||
{
|
||||
@ -1752,7 +1752,7 @@ json_t* monitor_json_data(const MXS_MONITOR* monitor, const char* host)
|
||||
{
|
||||
json_t* mon_rel = mxs_json_relationship(host, MXS_JSON_API_SERVERS);
|
||||
|
||||
for (MXS_MONITOR_SERVERS *db = monitor->databases; db; db = db->next)
|
||||
for (MXS_MONITORED_SERVER *db = monitor->databases; db; db = db->next)
|
||||
{
|
||||
mxs_json_add_relation(mon_rel, db->server->unique_name, CN_SERVERS);
|
||||
}
|
||||
@ -1812,7 +1812,7 @@ json_t* monitor_relations_to_server(const SERVER* server, const char* host)
|
||||
|
||||
if (mon->active)
|
||||
{
|
||||
for (MXS_MONITOR_SERVERS* db = mon->databases; db; db = db->next)
|
||||
for (MXS_MONITORED_SERVER* db = mon->databases; db; db = db->next)
|
||||
{
|
||||
if (db->server == server)
|
||||
{
|
||||
@ -1900,7 +1900,7 @@ static FILE* open_tmp_file(MXS_MONITOR *monitor, char *path)
|
||||
* PATH_MAX bytes long
|
||||
* @param size Size of @c data
|
||||
*/
|
||||
static void store_data(MXS_MONITOR *monitor, MXS_MONITOR_SERVERS *master, uint8_t *data, uint32_t size)
|
||||
static void store_data(MXS_MONITOR *monitor, MXS_MONITORED_SERVER *master, uint8_t *data, uint32_t size)
|
||||
{
|
||||
uint8_t* ptr = data;
|
||||
|
||||
@ -1912,7 +1912,7 @@ static void store_data(MXS_MONITOR *monitor, MXS_MONITOR_SERVERS *master, uint8_
|
||||
*ptr++ = MMB_SCHEMA_VERSION;
|
||||
|
||||
/** Store the states of all servers */
|
||||
for (MXS_MONITOR_SERVERS* db = monitor->databases; db; db = db->next)
|
||||
for (MXS_MONITORED_SERVER* db = monitor->databases; db; db = db->next)
|
||||
{
|
||||
*ptr++ = (char)SVT_SERVER; // Value type
|
||||
memcpy(ptr, db->server->unique_name, strlen(db->server->unique_name)); // Name of the server
|
||||
@ -1998,7 +1998,7 @@ static bool has_null_terminator(const char *data, const char *end)
|
||||
*/
|
||||
static const char* process_server(MXS_MONITOR *monitor, const char *data, const char *end)
|
||||
{
|
||||
for (MXS_MONITOR_SERVERS* db = monitor->databases; db; db = db->next)
|
||||
for (MXS_MONITORED_SERVER* db = monitor->databases; db; db = db->next)
|
||||
{
|
||||
if (strcmp(db->server->unique_name, data) == 0)
|
||||
{
|
||||
@ -2023,12 +2023,12 @@ static const char* process_server(MXS_MONITOR *monitor, const char *data, const
|
||||
/**
|
||||
* Process a master
|
||||
*/
|
||||
static const char* process_master(MXS_MONITOR *monitor, MXS_MONITOR_SERVERS **master, const char *data,
|
||||
static const char* process_master(MXS_MONITOR *monitor, MXS_MONITORED_SERVER **master, const char *data,
|
||||
const char *end)
|
||||
{
|
||||
if (master)
|
||||
{
|
||||
for (MXS_MONITOR_SERVERS* db = monitor->databases; db; db = db->next)
|
||||
for (MXS_MONITORED_SERVER* db = monitor->databases; db; db = db->next)
|
||||
{
|
||||
if (strcmp(db->server->unique_name, data) == 0)
|
||||
{
|
||||
@ -2057,7 +2057,7 @@ static bool check_crc32(const uint8_t *data, uint32_t size, const uint8_t *crc_p
|
||||
/**
|
||||
* Process the stored journal data
|
||||
*/
|
||||
static bool process_data_file(MXS_MONITOR *monitor, MXS_MONITOR_SERVERS **master, const char *data,
|
||||
static bool process_data_file(MXS_MONITOR *monitor, MXS_MONITORED_SERVER **master, const char *data,
|
||||
const char *crc_ptr)
|
||||
{
|
||||
const char *ptr = data;
|
||||
@ -2097,12 +2097,12 @@ static bool process_data_file(MXS_MONITOR *monitor, MXS_MONITOR_SERVERS **master
|
||||
return true;
|
||||
}
|
||||
|
||||
void store_server_journal(MXS_MONITOR *monitor, MXS_MONITOR_SERVERS *master)
|
||||
void store_server_journal(MXS_MONITOR *monitor, MXS_MONITORED_SERVER *master)
|
||||
{
|
||||
/** Calculate how much memory we need to allocate */
|
||||
uint32_t size = MMB_LEN_SCHEMA_VERSION + MMB_LEN_CRC32;
|
||||
|
||||
for (MXS_MONITOR_SERVERS* db = monitor->databases; db; db = db->next)
|
||||
for (MXS_MONITORED_SERVER* db = monitor->databases; db; db = db->next)
|
||||
{
|
||||
/** Each server is stored as a type byte and a null-terminated string
|
||||
* followed by eight byte server status. */
|
||||
@ -2148,7 +2148,7 @@ void store_server_journal(MXS_MONITOR *monitor, MXS_MONITOR_SERVERS *master)
|
||||
MXS_FREE(data);
|
||||
}
|
||||
|
||||
void load_server_journal(MXS_MONITOR *monitor, MXS_MONITOR_SERVERS **master)
|
||||
void load_server_journal(MXS_MONITOR *monitor, MXS_MONITORED_SERVER **master)
|
||||
{
|
||||
char path[PATH_MAX];
|
||||
FILE *file = open_data_file(monitor, path);
|
||||
|
@ -43,7 +43,7 @@ typedef struct aurora_monitor
|
||||
* @param monitor Monitor object
|
||||
* @param database Server whose status should be updated
|
||||
*/
|
||||
void update_server_status(MXS_MONITOR *monitor, MXS_MONITOR_SERVERS *database)
|
||||
void update_server_status(MXS_MONITOR *monitor, MXS_MONITORED_SERVER *database)
|
||||
{
|
||||
if (!SERVER_IN_MAINT(database->server))
|
||||
{
|
||||
@ -125,7 +125,7 @@ monitorMain(void *arg)
|
||||
lock_monitor_servers(monitor);
|
||||
servers_status_pending_to_current(monitor);
|
||||
|
||||
for (MXS_MONITOR_SERVERS *ptr = monitor->databases; ptr; ptr = ptr->next)
|
||||
for (MXS_MONITORED_SERVER *ptr = monitor->databases; ptr; ptr = ptr->next)
|
||||
{
|
||||
update_server_status(monitor, ptr);
|
||||
|
||||
|
@ -34,8 +34,8 @@ static void *startMonitor(MXS_MONITOR *, const MXS_CONFIG_PARAMETER *params);
|
||||
static void stopMonitor(MXS_MONITOR *);
|
||||
static void diagnostics(DCB *, const MXS_MONITOR *);
|
||||
static json_t* diagnostics_json(const MXS_MONITOR *);
|
||||
static MXS_MONITOR_SERVERS *get_candidate_master(MXS_MONITOR*);
|
||||
static MXS_MONITOR_SERVERS *set_cluster_master(MXS_MONITOR_SERVERS *, MXS_MONITOR_SERVERS *, int);
|
||||
static MXS_MONITORED_SERVER *get_candidate_master(MXS_MONITOR*);
|
||||
static MXS_MONITORED_SERVER *set_cluster_master(MXS_MONITORED_SERVER *, MXS_MONITORED_SERVER *, int);
|
||||
static void disableMasterFailback(void *, int);
|
||||
bool isGaleraEvent(mxs_monitor_event_t event);
|
||||
static void update_sst_donor_nodes(MXS_MONITOR*, int);
|
||||
@ -269,7 +269,7 @@ static json_t* diagnostics_json(const MXS_MONITOR *mon)
|
||||
* @param database The database to probe
|
||||
*/
|
||||
static void
|
||||
monitorDatabase(MXS_MONITOR *mon, MXS_MONITOR_SERVERS *database)
|
||||
monitorDatabase(MXS_MONITOR *mon, MXS_MONITORED_SERVER *database)
|
||||
{
|
||||
GALERA_MONITOR* handle = (GALERA_MONITOR*) mon->handle;
|
||||
MYSQL_ROW row;
|
||||
@ -483,9 +483,9 @@ monitorMain(void *arg)
|
||||
{
|
||||
GALERA_MONITOR *handle = (GALERA_MONITOR*)arg;
|
||||
MXS_MONITOR* mon = handle->monitor;
|
||||
MXS_MONITOR_SERVERS *ptr;
|
||||
MXS_MONITORED_SERVER *ptr;
|
||||
size_t nrounds = 0;
|
||||
MXS_MONITOR_SERVERS *candidate_master = NULL;
|
||||
MXS_MONITORED_SERVER *candidate_master = NULL;
|
||||
int master_stickiness;
|
||||
int is_cluster = 0;
|
||||
int log_no_members = 1;
|
||||
@ -666,10 +666,10 @@ monitorMain(void *arg)
|
||||
* @param servers The monitored servers list
|
||||
* @return The candidate master on success, NULL on failure
|
||||
*/
|
||||
static MXS_MONITOR_SERVERS *get_candidate_master(MXS_MONITOR* mon)
|
||||
static MXS_MONITORED_SERVER *get_candidate_master(MXS_MONITOR* mon)
|
||||
{
|
||||
MXS_MONITOR_SERVERS *moitor_servers = mon->databases;
|
||||
MXS_MONITOR_SERVERS *candidate_master = NULL;
|
||||
MXS_MONITORED_SERVER *moitor_servers = mon->databases;
|
||||
MXS_MONITORED_SERVER *candidate_master = NULL;
|
||||
GALERA_MONITOR* handle = mon->handle;
|
||||
long min_id = -1;
|
||||
int minval = INT_MAX;
|
||||
@ -741,8 +741,8 @@ static MXS_MONITOR_SERVERS *get_candidate_master(MXS_MONITOR* mon)
|
||||
* @param candidate_master The candidate master server accordingly to the selection rule
|
||||
* @return The master node pointer (could be NULL)
|
||||
*/
|
||||
static MXS_MONITOR_SERVERS *set_cluster_master(MXS_MONITOR_SERVERS *current_master,
|
||||
MXS_MONITOR_SERVERS *candidate_master,
|
||||
static MXS_MONITORED_SERVER *set_cluster_master(MXS_MONITORED_SERVER *current_master,
|
||||
MXS_MONITORED_SERVER *candidate_master,
|
||||
int master_stickiness)
|
||||
{
|
||||
/*
|
||||
@ -791,7 +791,7 @@ static MXS_MONITOR_SERVERS *set_cluster_master(MXS_MONITOR_SERVERS *current_mast
|
||||
*/
|
||||
static void update_sst_donor_nodes(MXS_MONITOR *mon, int is_cluster)
|
||||
{
|
||||
MXS_MONITOR_SERVERS *ptr;
|
||||
MXS_MONITORED_SERVER *ptr;
|
||||
MYSQL_ROW row;
|
||||
MYSQL_RES *result;
|
||||
GALERA_MONITOR *handle = mon->handle;
|
||||
@ -804,7 +804,7 @@ static void update_sst_donor_nodes(MXS_MONITOR *mon, int is_cluster)
|
||||
}
|
||||
|
||||
unsigned int found_slaves = 0;
|
||||
MXS_MONITOR_SERVERS *node_list[is_cluster - 1];
|
||||
MXS_MONITORED_SERVER *node_list[is_cluster - 1];
|
||||
/* Donor list size = DONOR_LIST_SET_VAR + n_hosts * max_host_len + n_hosts + 1 */
|
||||
|
||||
char *donor_list = MXS_CALLOC(1, strlen(DONOR_LIST_SET_VAR) +
|
||||
@ -826,7 +826,7 @@ static void update_sst_donor_nodes(MXS_MONITOR *mon, int is_cluster)
|
||||
{
|
||||
if (SERVER_IS_JOINED(ptr->server) && SERVER_IS_SLAVE(ptr->server))
|
||||
{
|
||||
node_list[found_slaves] = (MXS_MONITOR_SERVERS *)ptr;
|
||||
node_list[found_slaves] = (MXS_MONITORED_SERVER *)ptr;
|
||||
found_slaves++;
|
||||
|
||||
/* Check the server parameter "priority"
|
||||
@ -854,13 +854,13 @@ static void update_sst_donor_nodes(MXS_MONITOR *mon, int is_cluster)
|
||||
/* Sort the array */
|
||||
qsort(node_list,
|
||||
found_slaves,
|
||||
sizeof(MXS_MONITOR_SERVERS *),
|
||||
sizeof(MXS_MONITORED_SERVER *),
|
||||
sort_order ? compare_node_priority : compare_node_index);
|
||||
|
||||
/* Select nodename from each server and append it to node_list */
|
||||
for (int k = 0; k < found_slaves; k++)
|
||||
{
|
||||
MXS_MONITOR_SERVERS *ptr = node_list[k];
|
||||
MXS_MONITORED_SERVER *ptr = node_list[k];
|
||||
|
||||
/* Get the Galera node name */
|
||||
if (mysql_query(ptr->con, "SHOW VARIABLES LIKE 'wsrep_node_name'") == 0
|
||||
@ -906,7 +906,7 @@ static void update_sst_donor_nodes(MXS_MONITOR *mon, int is_cluster)
|
||||
/* Set now rep_sst_donor in each slave node */
|
||||
for (int k = 0; k < found_slaves; k++)
|
||||
{
|
||||
MXS_MONITOR_SERVERS *ptr = node_list[k];
|
||||
MXS_MONITORED_SERVER *ptr = node_list[k];
|
||||
/* Set the Galera SST donor node list */
|
||||
if (mysql_query(ptr->con, donor_list) == 0)
|
||||
{
|
||||
@ -937,8 +937,8 @@ static void update_sst_donor_nodes(MXS_MONITOR *mon, int is_cluster)
|
||||
|
||||
static int compare_node_index (const void *a, const void *b)
|
||||
{
|
||||
const MXS_MONITOR_SERVERS *s_a = *(MXS_MONITOR_SERVERS * const *)a;
|
||||
const MXS_MONITOR_SERVERS *s_b = *(MXS_MONITOR_SERVERS * const *)b;
|
||||
const MXS_MONITORED_SERVER *s_a = *(MXS_MONITORED_SERVER * const *)a;
|
||||
const MXS_MONITORED_SERVER *s_b = *(MXS_MONITORED_SERVER * const *)b;
|
||||
|
||||
// Order is DESC: b - a
|
||||
return s_b->server->node_id - s_a->server->node_id;
|
||||
@ -965,8 +965,8 @@ static int compare_node_index (const void *a, const void *b)
|
||||
|
||||
static int compare_node_priority (const void *a, const void *b)
|
||||
{
|
||||
const MXS_MONITOR_SERVERS *s_a = *(MXS_MONITOR_SERVERS * const *)a;
|
||||
const MXS_MONITOR_SERVERS *s_b = *(MXS_MONITOR_SERVERS * const *)b;
|
||||
const MXS_MONITORED_SERVER *s_a = *(MXS_MONITORED_SERVER * const *)a;
|
||||
const MXS_MONITORED_SERVER *s_b = *(MXS_MONITORED_SERVER * const *)b;
|
||||
|
||||
const char *pri_a = server_get_parameter(s_a->server, "priority");
|
||||
const char *pri_b = server_get_parameter(s_b->server, "priority");
|
||||
@ -1195,7 +1195,7 @@ static void set_cluster_members(MXS_MONITOR *mon)
|
||||
{
|
||||
GALERA_MONITOR *handle = mon->handle;
|
||||
GALERA_NODE_INFO *value;
|
||||
MXS_MONITOR_SERVERS *ptr;
|
||||
MXS_MONITORED_SERVER *ptr;
|
||||
char *c_uuid = handle->cluster_info.c_uuid;
|
||||
int c_size = handle->cluster_info.c_size;
|
||||
|
||||
|
@ -85,7 +85,7 @@ typedef struct
|
||||
int disableMasterFailback; /**< Monitor flag for Galera Cluster Master failback */
|
||||
int availableWhenDonor; /**< Monitor flag for Galera Cluster Donor availability */
|
||||
bool disableMasterRoleSetting; /**< Monitor flag to disable setting master role */
|
||||
MXS_MONITOR_SERVERS *master; /**< Master server for MySQL Master/Slave replication */
|
||||
MXS_MONITORED_SERVER *master; /**< Master server for MySQL Master/Slave replication */
|
||||
char* script;
|
||||
bool root_node_as_master; /**< Whether we require that the Master should
|
||||
* have a wsrep_local_index of 0 */
|
||||
|
@ -40,12 +40,12 @@ public:
|
||||
~GRMon();
|
||||
|
||||
private:
|
||||
THREAD m_thread; /**< Monitor thread */
|
||||
int m_shutdown; /**< Flag to shutdown the monitor thread */
|
||||
MXS_MONITOR_SERVERS* m_master; /**< The master server */
|
||||
std::string m_script;
|
||||
uint64_t m_events; /**< Enabled events */
|
||||
MXS_MONITOR* m_monitor;
|
||||
THREAD m_thread; /**< Monitor thread */
|
||||
int m_shutdown; /**< Flag to shutdown the monitor thread */
|
||||
MXS_MONITORED_SERVER* m_master; /**< The master server */
|
||||
std::string m_script;
|
||||
uint64_t m_events; /**< Enabled events */
|
||||
MXS_MONITOR* m_monitor;
|
||||
|
||||
GRMon(MXS_MONITOR* monitor, const MXS_CONFIG_PARAMETER *params);
|
||||
|
||||
@ -148,7 +148,7 @@ static inline bool is_false(const char* value)
|
||||
strcasecmp(value, "false") == 0;
|
||||
}
|
||||
|
||||
static bool is_master(MXS_MONITOR_SERVERS* server)
|
||||
static bool is_master(MXS_MONITORED_SERVER* server)
|
||||
{
|
||||
bool rval = false;
|
||||
MYSQL_RES* result;
|
||||
@ -175,7 +175,7 @@ static bool is_master(MXS_MONITOR_SERVERS* server)
|
||||
return rval;
|
||||
}
|
||||
|
||||
static bool is_slave(MXS_MONITOR_SERVERS* server)
|
||||
static bool is_slave(MXS_MONITORED_SERVER* server)
|
||||
{
|
||||
bool rval = false;
|
||||
MYSQL_RES* result;
|
||||
@ -202,7 +202,7 @@ static bool is_slave(MXS_MONITOR_SERVERS* server)
|
||||
return rval;
|
||||
}
|
||||
|
||||
static void update_server_status(MXS_MONITOR* monitor, MXS_MONITOR_SERVERS* server)
|
||||
static void update_server_status(MXS_MONITOR* monitor, MXS_MONITORED_SERVER* server)
|
||||
{
|
||||
/* Don't even probe server flagged as in maintenance */
|
||||
if (SERVER_IN_MAINT(server->server))
|
||||
@ -273,7 +273,7 @@ void GRMon::main()
|
||||
lock_monitor_servers(m_monitor);
|
||||
servers_status_pending_to_current(m_monitor);
|
||||
|
||||
for (MXS_MONITOR_SERVERS *ptr = m_monitor->databases; ptr; ptr = ptr->next)
|
||||
for (MXS_MONITORED_SERVER *ptr = m_monitor->databases; ptr; ptr = ptr->next)
|
||||
{
|
||||
update_server_status(m_monitor, ptr);
|
||||
}
|
||||
@ -362,4 +362,4 @@ extern "C"
|
||||
return &info;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ static void stopMonitor(MXS_MONITOR *);
|
||||
static void diagnostics(DCB *, const MXS_MONITOR *);
|
||||
static json_t* diagnostics_json(const MXS_MONITOR *);
|
||||
static void detectStaleMaster(void *, int);
|
||||
static MXS_MONITOR_SERVERS *get_current_master(MXS_MONITOR *);
|
||||
static MXS_MONITORED_SERVER *get_current_master(MXS_MONITOR *);
|
||||
static bool isMySQLEvent(mxs_monitor_event_t event);
|
||||
|
||||
/**
|
||||
@ -203,7 +203,7 @@ static json_t* diagnostics_json(const MXS_MONITOR *mon)
|
||||
* @param database The database to probe
|
||||
*/
|
||||
static void
|
||||
monitorDatabase(MXS_MONITOR* mon, MXS_MONITOR_SERVERS *database)
|
||||
monitorDatabase(MXS_MONITOR* mon, MXS_MONITORED_SERVER *database)
|
||||
{
|
||||
MYSQL_ROW row;
|
||||
MYSQL_RES *result;
|
||||
@ -500,9 +500,9 @@ monitorMain(void *arg)
|
||||
{
|
||||
MM_MONITOR *handle = (MM_MONITOR *)arg;
|
||||
MXS_MONITOR* mon = handle->monitor;
|
||||
MXS_MONITOR_SERVERS *ptr;
|
||||
MXS_MONITORED_SERVER *ptr;
|
||||
int detect_stale_master = false;
|
||||
MXS_MONITOR_SERVERS *root_master = NULL;
|
||||
MXS_MONITORED_SERVER *root_master = NULL;
|
||||
size_t nrounds = 0;
|
||||
|
||||
detect_stale_master = handle->detectStaleMaster;
|
||||
@ -651,10 +651,10 @@ detectStaleMaster(void *arg, int enable)
|
||||
* @return The server at root level with SERVER_MASTER bit
|
||||
*/
|
||||
|
||||
static MXS_MONITOR_SERVERS *get_current_master(MXS_MONITOR *mon)
|
||||
static MXS_MONITORED_SERVER *get_current_master(MXS_MONITOR *mon)
|
||||
{
|
||||
MM_MONITOR* handle = mon->handle;
|
||||
MXS_MONITOR_SERVERS *ptr;
|
||||
MXS_MONITORED_SERVER *ptr;
|
||||
|
||||
ptr = mon->databases;
|
||||
|
||||
|
@ -45,7 +45,7 @@ typedef struct
|
||||
int status; /**< Monitor status */
|
||||
unsigned long id; /**< Monitor ID */
|
||||
int detectStaleMaster; /**< Monitor flag for Stale Master detection */
|
||||
MXS_MONITOR_SERVERS *master; /**< Master server for Master/Slave replication */
|
||||
MXS_MONITORED_SERVER *master; /**< Master server for Master/Slave replication */
|
||||
char* script; /*< Script to call when state changes occur on servers */
|
||||
uint64_t events; /*< enabled events */
|
||||
MXS_MONITOR* monitor;
|
||||
|
@ -69,7 +69,7 @@ typedef struct
|
||||
int availableWhenDonor; /**< Monitor flag for Galera Cluster Donor availability */
|
||||
int disableMasterRoleSetting; /**< Monitor flag to disable setting master role */
|
||||
bool mysql51_replication; /**< Use MySQL 5.1 replication */
|
||||
MXS_MONITOR_SERVERS *master; /**< Master server for MySQL Master/Slave replication */
|
||||
MXS_MONITORED_SERVER *master; /**< Master server for MySQL Master/Slave replication */
|
||||
char* script; /*< Script to call when state changes occur on servers */
|
||||
uint64_t events; /*< enabled events */
|
||||
HASHTABLE *server_info; /**< Contains server specific information */
|
||||
|
@ -49,11 +49,11 @@ static void *startMonitor(MXS_MONITOR *, const MXS_CONFIG_PARAMETER*);
|
||||
static void stopMonitor(MXS_MONITOR *);
|
||||
static void diagnostics(DCB *, const MXS_MONITOR *);
|
||||
static json_t* diagnostics_json(const MXS_MONITOR *);
|
||||
static MXS_MONITOR_SERVERS *getServerByNodeId(MXS_MONITOR_SERVERS *, long);
|
||||
static MXS_MONITOR_SERVERS *getSlaveOfNodeId(MXS_MONITOR_SERVERS *, long);
|
||||
static MXS_MONITOR_SERVERS *get_replication_tree(MXS_MONITOR *, int);
|
||||
static void set_master_heartbeat(MYSQL_MONITOR *, MXS_MONITOR_SERVERS *);
|
||||
static void set_slave_heartbeat(MXS_MONITOR *, MXS_MONITOR_SERVERS *);
|
||||
static MXS_MONITORED_SERVER *getServerByNodeId(MXS_MONITORED_SERVER *, long);
|
||||
static MXS_MONITORED_SERVER *getSlaveOfNodeId(MXS_MONITORED_SERVER *, long);
|
||||
static MXS_MONITORED_SERVER *get_replication_tree(MXS_MONITOR *, int);
|
||||
static void set_master_heartbeat(MYSQL_MONITOR *, MXS_MONITORED_SERVER *);
|
||||
static void set_slave_heartbeat(MXS_MONITOR *, MXS_MONITORED_SERVER *);
|
||||
static int add_slave_to_master(long *, int, long);
|
||||
static bool isMySQLEvent(mxs_monitor_event_t event);
|
||||
void check_maxscale_schema_replication(MXS_MONITOR *monitor);
|
||||
@ -186,7 +186,7 @@ void info_free_func(void *val)
|
||||
* @return True on success, false if initialization failed. At the moment
|
||||
* initialization can only fail if memory allocation fails.
|
||||
*/
|
||||
bool init_server_info(MYSQL_MONITOR *handle, MXS_MONITOR_SERVERS *database)
|
||||
bool init_server_info(MYSQL_MONITOR *handle, MXS_MONITORED_SERVER *database)
|
||||
{
|
||||
bool rval = true;
|
||||
|
||||
@ -328,7 +328,7 @@ static void diagnostics(DCB *dcb, const MXS_MONITOR *mon)
|
||||
dcb_printf(dcb, "Detect Stale Master:\t%s\n", (handle->detectStaleMaster == 1) ? "enabled" : "disabled");
|
||||
dcb_printf(dcb, "Server information\n\n");
|
||||
|
||||
for (MXS_MONITOR_SERVERS *db = mon->databases; db; db = db->next)
|
||||
for (MXS_MONITORED_SERVER *db = mon->databases; db; db = db->next)
|
||||
{
|
||||
MYSQL_SERVER_INFO *serv_info =
|
||||
static_cast<MYSQL_SERVER_INFO*>(hashtable_fetch(handle->server_info, db->server->unique_name));
|
||||
@ -380,7 +380,7 @@ static json_t* diagnostics_json(const MXS_MONITOR *mon)
|
||||
{
|
||||
json_t* arr = json_array();
|
||||
|
||||
for (MXS_MONITOR_SERVERS *db = mon->databases; db; db = db->next)
|
||||
for (MXS_MONITORED_SERVER *db = mon->databases; db; db = db->next)
|
||||
{
|
||||
json_t* srv = json_object();
|
||||
MYSQL_SERVER_INFO *serv_info =
|
||||
@ -419,7 +419,7 @@ enum mysql_server_version
|
||||
MYSQL_SERVER_VERSION_51
|
||||
};
|
||||
|
||||
static inline void monitor_mysql_db(MXS_MONITOR_SERVERS* database, MYSQL_SERVER_INFO *serv_info,
|
||||
static inline void monitor_mysql_db(MXS_MONITORED_SERVER* database, MYSQL_SERVER_INFO *serv_info,
|
||||
enum mysql_server_version server_version)
|
||||
{
|
||||
unsigned int columns;
|
||||
@ -554,10 +554,10 @@ static inline void monitor_mysql_db(MXS_MONITOR_SERVERS* database, MYSQL_SERVER_
|
||||
* @param mon Monitor
|
||||
* @return Lowest server ID master in the monitor
|
||||
*/
|
||||
static MXS_MONITOR_SERVERS *build_mysql51_replication_tree(MXS_MONITOR *mon)
|
||||
static MXS_MONITORED_SERVER *build_mysql51_replication_tree(MXS_MONITOR *mon)
|
||||
{
|
||||
MXS_MONITOR_SERVERS* database = mon->databases;
|
||||
MXS_MONITOR_SERVERS *ptr, *rval = NULL;
|
||||
MXS_MONITORED_SERVER* database = mon->databases;
|
||||
MXS_MONITORED_SERVER *ptr, *rval = NULL;
|
||||
int i;
|
||||
MYSQL_MONITOR *handle = static_cast<MYSQL_MONITOR*>(mon->handle);
|
||||
|
||||
@ -669,7 +669,7 @@ static MXS_MONITOR_SERVERS *build_mysql51_replication_tree(MXS_MONITOR *mon)
|
||||
* @param database The database to probe
|
||||
*/
|
||||
static void
|
||||
monitorDatabase(MXS_MONITOR *mon, MXS_MONITOR_SERVERS *database)
|
||||
monitorDatabase(MXS_MONITOR *mon, MXS_MONITORED_SERVER *database)
|
||||
{
|
||||
MYSQL_MONITOR* handle = static_cast<MYSQL_MONITOR*>(mon->handle);
|
||||
MYSQL_ROW row;
|
||||
@ -830,7 +830,7 @@ struct graph_node
|
||||
bool active;
|
||||
struct graph_node *parent;
|
||||
MYSQL_SERVER_INFO *info;
|
||||
MXS_MONITOR_SERVERS *db;
|
||||
MXS_MONITORED_SERVER *db;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -943,13 +943,13 @@ static void visit_node(struct graph_node *node, struct graph_node **stack,
|
||||
* member. Nodes in a group get a positive group ID where the nodes not in a
|
||||
* group get a group ID of 0.
|
||||
*/
|
||||
void find_graph_cycles(MYSQL_MONITOR *handle, MXS_MONITOR_SERVERS *database, int nservers)
|
||||
void find_graph_cycles(MYSQL_MONITOR *handle, MXS_MONITORED_SERVER *database, int nservers)
|
||||
{
|
||||
struct graph_node graph[nservers];
|
||||
struct graph_node *stack[nservers];
|
||||
int nodes = 0;
|
||||
|
||||
for (MXS_MONITOR_SERVERS *db = database; db; db = db->next)
|
||||
for (MXS_MONITORED_SERVER *db = database; db; db = db->next)
|
||||
{
|
||||
graph[nodes].info =
|
||||
static_cast<MYSQL_SERVER_INFO*>(hashtable_fetch(handle->server_info, db->server->unique_name));
|
||||
@ -1051,7 +1051,7 @@ void find_graph_cycles(MYSQL_MONITOR *handle, MXS_MONITOR_SERVERS *database, int
|
||||
*
|
||||
* @return True if failover is required
|
||||
*/
|
||||
bool failover_required(MYSQL_MONITOR *handle, MXS_MONITOR_SERVERS *db)
|
||||
bool failover_required(MYSQL_MONITOR *handle, MXS_MONITORED_SERVER *db)
|
||||
{
|
||||
int candidates = 0;
|
||||
|
||||
@ -1091,7 +1091,7 @@ bool failover_required(MYSQL_MONITOR *handle, MXS_MONITOR_SERVERS *db)
|
||||
* @param handle Monitor instance
|
||||
* @param db Monitor servers
|
||||
*/
|
||||
void do_failover(MYSQL_MONITOR *handle, MXS_MONITOR_SERVERS *db)
|
||||
void do_failover(MYSQL_MONITOR *handle, MXS_MONITORED_SERVER *db)
|
||||
{
|
||||
while (db)
|
||||
{
|
||||
@ -1130,11 +1130,11 @@ monitorMain(void *arg)
|
||||
{
|
||||
MYSQL_MONITOR *handle = (MYSQL_MONITOR *) arg;
|
||||
MXS_MONITOR* mon = handle->monitor;
|
||||
MXS_MONITOR_SERVERS *ptr;
|
||||
MXS_MONITORED_SERVER *ptr;
|
||||
int replication_heartbeat;
|
||||
bool detect_stale_master;
|
||||
int num_servers = 0;
|
||||
MXS_MONITOR_SERVERS *root_master = NULL;
|
||||
MXS_MONITORED_SERVER *root_master = NULL;
|
||||
size_t nrounds = 0;
|
||||
int log_no_master = 1;
|
||||
bool heartbeat_checked = false;
|
||||
@ -1494,8 +1494,8 @@ monitorMain(void *arg)
|
||||
* @param node_id The MySQL server_id to fetch
|
||||
* @return The server with the required server_id
|
||||
*/
|
||||
static MXS_MONITOR_SERVERS *
|
||||
getServerByNodeId(MXS_MONITOR_SERVERS *ptr, long node_id)
|
||||
static MXS_MONITORED_SERVER *
|
||||
getServerByNodeId(MXS_MONITORED_SERVER *ptr, long node_id)
|
||||
{
|
||||
SERVER *current;
|
||||
while (ptr)
|
||||
@ -1517,8 +1517,8 @@ getServerByNodeId(MXS_MONITOR_SERVERS *ptr, long node_id)
|
||||
* @param node_id The MySQL server_id to fetch
|
||||
* @return The slave server of this node_id
|
||||
*/
|
||||
static MXS_MONITOR_SERVERS *
|
||||
getSlaveOfNodeId(MXS_MONITOR_SERVERS *ptr, long node_id)
|
||||
static MXS_MONITORED_SERVER *
|
||||
getSlaveOfNodeId(MXS_MONITORED_SERVER *ptr, long node_id)
|
||||
{
|
||||
SERVER *current;
|
||||
while (ptr)
|
||||
@ -1541,7 +1541,7 @@ getSlaveOfNodeId(MXS_MONITOR_SERVERS *ptr, long node_id)
|
||||
* @param handle The monitor handle
|
||||
* @param database The number database server
|
||||
*/
|
||||
static void set_master_heartbeat(MYSQL_MONITOR *handle, MXS_MONITOR_SERVERS *database)
|
||||
static void set_master_heartbeat(MYSQL_MONITOR *handle, MXS_MONITORED_SERVER *database)
|
||||
{
|
||||
unsigned long id = handle->id;
|
||||
time_t heartbeat;
|
||||
@ -1675,7 +1675,7 @@ static void set_master_heartbeat(MYSQL_MONITOR *handle, MXS_MONITOR_SERVERS *dat
|
||||
* @param handle The monitor handle
|
||||
* @param database The number database server
|
||||
*/
|
||||
static void set_slave_heartbeat(MXS_MONITOR* mon, MXS_MONITOR_SERVERS *database)
|
||||
static void set_slave_heartbeat(MXS_MONITOR* mon, MXS_MONITORED_SERVER *database)
|
||||
{
|
||||
MYSQL_MONITOR *handle = (MYSQL_MONITOR*) mon->handle;
|
||||
unsigned long id = handle->id;
|
||||
@ -1786,11 +1786,11 @@ static void set_slave_heartbeat(MXS_MONITOR* mon, MXS_MONITOR_SERVERS *database)
|
||||
* @return The server at root level with SERVER_MASTER bit
|
||||
*/
|
||||
|
||||
static MXS_MONITOR_SERVERS *get_replication_tree(MXS_MONITOR *mon, int num_servers)
|
||||
static MXS_MONITORED_SERVER *get_replication_tree(MXS_MONITOR *mon, int num_servers)
|
||||
{
|
||||
MYSQL_MONITOR* handle = (MYSQL_MONITOR*) mon->handle;
|
||||
MXS_MONITOR_SERVERS *ptr;
|
||||
MXS_MONITOR_SERVERS *backend;
|
||||
MXS_MONITORED_SERVER *ptr;
|
||||
MXS_MONITORED_SERVER *backend;
|
||||
SERVER *current;
|
||||
int depth = 0;
|
||||
long node_id;
|
||||
@ -1816,7 +1816,7 @@ static MXS_MONITOR_SERVERS *get_replication_tree(MXS_MONITOR *mon, int num_serve
|
||||
node_id = current->master_id;
|
||||
if (node_id < 1)
|
||||
{
|
||||
MXS_MONITOR_SERVERS *find_slave;
|
||||
MXS_MONITORED_SERVER *find_slave;
|
||||
find_slave = getSlaveOfNodeId(mon->databases, current->node_id);
|
||||
|
||||
if (find_slave == NULL)
|
||||
@ -1863,7 +1863,7 @@ static MXS_MONITOR_SERVERS *get_replication_tree(MXS_MONITOR *mon, int num_serve
|
||||
}
|
||||
else
|
||||
{
|
||||
MXS_MONITOR_SERVERS *master;
|
||||
MXS_MONITORED_SERVER *master;
|
||||
current->depth = depth;
|
||||
|
||||
master = getServerByNodeId(mon->databases, current->master_id);
|
||||
@ -1967,7 +1967,7 @@ static int add_slave_to_master(long *slaves_list, int list_size, long node_id)
|
||||
* @return False if the table is not replicated or an error occurred when querying
|
||||
* the server
|
||||
*/
|
||||
bool check_replicate_ignore_table(MXS_MONITOR_SERVERS* database)
|
||||
bool check_replicate_ignore_table(MXS_MONITORED_SERVER* database)
|
||||
{
|
||||
MYSQL_RES *result;
|
||||
bool rval = true;
|
||||
@ -2011,7 +2011,7 @@ bool check_replicate_ignore_table(MXS_MONITOR_SERVERS* database)
|
||||
* @return False if the table is not replicated or an error occurred when querying
|
||||
* the server
|
||||
*/
|
||||
bool check_replicate_do_table(MXS_MONITOR_SERVERS* database)
|
||||
bool check_replicate_do_table(MXS_MONITORED_SERVER* database)
|
||||
{
|
||||
MYSQL_RES *result;
|
||||
bool rval = true;
|
||||
@ -2054,7 +2054,7 @@ bool check_replicate_do_table(MXS_MONITOR_SERVERS* database)
|
||||
* @return False if the table is not replicated or an error occurred when trying to
|
||||
* query the server.
|
||||
*/
|
||||
bool check_replicate_wild_do_table(MXS_MONITOR_SERVERS* database)
|
||||
bool check_replicate_wild_do_table(MXS_MONITORED_SERVER* database)
|
||||
{
|
||||
MYSQL_RES *result;
|
||||
bool rval = true;
|
||||
@ -2101,7 +2101,7 @@ bool check_replicate_wild_do_table(MXS_MONITOR_SERVERS* database)
|
||||
* @return False if the table is not replicated or an error occurred when trying to
|
||||
* query the server.
|
||||
*/
|
||||
bool check_replicate_wild_ignore_table(MXS_MONITOR_SERVERS* database)
|
||||
bool check_replicate_wild_ignore_table(MXS_MONITORED_SERVER* database)
|
||||
{
|
||||
MYSQL_RES *result;
|
||||
bool rval = true;
|
||||
@ -2148,7 +2148,7 @@ bool check_replicate_wild_ignore_table(MXS_MONITOR_SERVERS* database)
|
||||
*/
|
||||
void check_maxscale_schema_replication(MXS_MONITOR *monitor)
|
||||
{
|
||||
MXS_MONITOR_SERVERS* database = monitor->databases;
|
||||
MXS_MONITORED_SERVER* database = monitor->databases;
|
||||
bool err = false;
|
||||
|
||||
while (database)
|
||||
|
@ -188,7 +188,7 @@ static json_t* diagnostics_json(const MXS_MONITOR *mon)
|
||||
* @param database The database to probe
|
||||
*/
|
||||
static void
|
||||
monitorDatabase(MXS_MONITOR_SERVERS *database, char *defaultUser, char *defaultPasswd, MXS_MONITOR *mon)
|
||||
monitorDatabase(MXS_MONITORED_SERVER *database, char *defaultUser, char *defaultPasswd, MXS_MONITOR *mon)
|
||||
{
|
||||
MYSQL_ROW row;
|
||||
MYSQL_RES *result;
|
||||
@ -308,7 +308,7 @@ monitorMain(void *arg)
|
||||
{
|
||||
MYSQL_MONITOR *handle = (MYSQL_MONITOR*)arg;
|
||||
MXS_MONITOR* mon = handle->monitor;
|
||||
MXS_MONITOR_SERVERS *ptr;
|
||||
MXS_MONITORED_SERVER *ptr;
|
||||
size_t nrounds = 0;
|
||||
|
||||
if (mysql_thread_init())
|
||||
|
Reference in New Issue
Block a user