Merge branch '2.2' of github.com:mariadb-corporation/MaxScale into 2.2
This commit is contained in:
@ -161,7 +161,7 @@ typedef enum
|
|||||||
/**
|
/**
|
||||||
* The linked list of servers that are being monitored by the monitor module.
|
* 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 */
|
SERVER *server; /**< The server being monitored */
|
||||||
MYSQL *con; /**< The MySQL connection */
|
MYSQL *con; /**< The MySQL connection */
|
||||||
@ -169,8 +169,8 @@ typedef struct monitor_servers
|
|||||||
int mon_err_count;
|
int mon_err_count;
|
||||||
unsigned int mon_prev_status;
|
unsigned int mon_prev_status;
|
||||||
unsigned int pending_status; /**< Pending Status flag bitmap */
|
unsigned int pending_status; /**< Pending Status flag bitmap */
|
||||||
struct monitor_servers *next; /**< The next server in the list */
|
struct monitored_server *next; /**< The next server in the list */
|
||||||
} MXS_MONITOR_SERVERS;
|
} MXS_MONITORED_SERVER;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Representation of the running monitor.
|
* Representation of the running monitor.
|
||||||
@ -182,7 +182,7 @@ struct mxs_monitor
|
|||||||
char password[MAX_MONITOR_PASSWORD_LEN]; /*< Monitor password */
|
char password[MAX_MONITOR_PASSWORD_LEN]; /*< Monitor password */
|
||||||
SPINLOCK lock;
|
SPINLOCK lock;
|
||||||
MXS_CONFIG_PARAMETER* parameters; /*< configuration parameters */
|
MXS_CONFIG_PARAMETER* parameters; /*< configuration parameters */
|
||||||
MXS_MONITOR_SERVERS* databases; /*< List of databases the monitor monitors */
|
MXS_MONITORED_SERVER* monitored_servers; /*< List of servers the monitor monitors */
|
||||||
monitor_state_t state; /**< The state of the monitor */
|
monitor_state_t state; /**< The state of the monitor */
|
||||||
int connect_timeout; /**< Connect timeout in seconds for mysql_real_connect */
|
int connect_timeout; /**< Connect timeout in seconds for mysql_real_connect */
|
||||||
int connect_attempts; /**< How many times a connection is attempted */
|
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);
|
bool check_monitor_permissions(MXS_MONITOR* monitor, const char* query);
|
||||||
|
|
||||||
void monitor_clear_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_MONITOR_SERVERS *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_pending_to_current(MXS_MONITOR *monitor);
|
||||||
void servers_status_current_to_pending(MXS_MONITOR *monitor);
|
void servers_status_current_to_pending(MXS_MONITOR *monitor);
|
||||||
|
|
||||||
bool mon_status_changed(MXS_MONITOR_SERVERS* mon_srv);
|
bool mon_status_changed(MXS_MONITORED_SERVER* mon_srv);
|
||||||
bool mon_print_fail_status(MXS_MONITOR_SERVERS* 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);
|
mxs_connect_result_t mon_ping_or_connect_to_db(MXS_MONITOR* mon, MXS_MONITORED_SERVER *database);
|
||||||
void mon_log_connect_error(MXS_MONITOR_SERVERS* database, mxs_connect_result_t rval);
|
void mon_log_connect_error(MXS_MONITORED_SERVER* database, mxs_connect_result_t rval);
|
||||||
|
|
||||||
void lock_monitor_servers(MXS_MONITOR *monitor);
|
void lock_monitor_servers(MXS_MONITOR *monitor);
|
||||||
void release_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
|
* @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
|
* @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 monitor Monitor to journal
|
||||||
* @param master The current master server or NULL if no master exists
|
* @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
|
* @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 monitor Monitor where journal is loaded
|
||||||
* @param master Set to point to the current master
|
* @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
|
MXS_END_DECLS
|
||||||
|
@ -960,9 +960,9 @@ bool runtime_destroy_monitor(MXS_MONITOR *monitor)
|
|||||||
{
|
{
|
||||||
monitorStop(monitor);
|
monitorStop(monitor);
|
||||||
|
|
||||||
while (monitor->databases)
|
while (monitor->monitored_servers)
|
||||||
{
|
{
|
||||||
monitorRemoveServer(monitor, monitor->databases->server);
|
monitorRemoveServer(monitor, monitor->monitored_servers->server);
|
||||||
}
|
}
|
||||||
monitorDestroy(monitor);
|
monitorDestroy(monitor);
|
||||||
MXS_NOTICE("Destroyed monitor '%s'", monitor->name);
|
MXS_NOTICE("Destroyed monitor '%s'", monitor->name);
|
||||||
|
@ -76,7 +76,7 @@ const char CN_EVENTS[] = "events";
|
|||||||
static MXS_MONITOR *allMonitors = NULL;
|
static MXS_MONITOR *allMonitors = NULL;
|
||||||
static SPINLOCK monLock = SPINLOCK_INIT;
|
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 void remove_server_journal(MXS_MONITOR *monitor);
|
||||||
static bool journal_is_stale(MXS_MONITOR *monitor, time_t max_age);
|
static bool journal_is_stale(MXS_MONITOR *monitor, time_t max_age);
|
||||||
|
|
||||||
@ -123,7 +123,7 @@ MXS_MONITOR* monitor_alloc(const char *name, const char *module)
|
|||||||
mon->name = my_name;
|
mon->name = my_name;
|
||||||
mon->module_name = my_module;
|
mon->module_name = my_module;
|
||||||
mon->handle = NULL;
|
mon->handle = NULL;
|
||||||
mon->databases = NULL;
|
mon->monitored_servers = NULL;
|
||||||
*mon->password = '\0';
|
*mon->password = '\0';
|
||||||
*mon->user = '\0';
|
*mon->user = '\0';
|
||||||
mon->read_timeout = DEFAULT_READ_TIMEOUT;
|
mon->read_timeout = DEFAULT_READ_TIMEOUT;
|
||||||
@ -176,7 +176,7 @@ monitor_free(MXS_MONITOR *mon)
|
|||||||
}
|
}
|
||||||
spinlock_release(&monLock);
|
spinlock_release(&monLock);
|
||||||
config_parameter_free(mon->parameters);
|
config_parameter_free(mon->parameters);
|
||||||
monitor_server_free_all(mon->databases);
|
monitor_server_free_all(mon->monitored_servers);
|
||||||
MXS_FREE(mon->name);
|
MXS_FREE(mon->name);
|
||||||
MXS_FREE(mon->module_name);
|
MXS_FREE(mon->module_name);
|
||||||
MXS_FREE(mon);
|
MXS_FREE(mon);
|
||||||
@ -253,7 +253,7 @@ monitorStop(MXS_MONITOR *monitor)
|
|||||||
monitor->module->stopMonitor(monitor);
|
monitor->module->stopMonitor(monitor);
|
||||||
monitor->state = MONITOR_STATE_STOPPED;
|
monitor->state = MONITOR_STATE_STOPPED;
|
||||||
|
|
||||||
MXS_MONITOR_SERVERS* db = monitor->databases;
|
MXS_MONITORED_SERVER* db = monitor->monitored_servers;
|
||||||
while (db)
|
while (db)
|
||||||
{
|
{
|
||||||
// TODO: Create a generic entry point for this or move it inside stopMonitor
|
// 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
|
else
|
||||||
{
|
{
|
||||||
rval = true;
|
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);
|
MXS_ABORT_IF_NULL(db);
|
||||||
|
|
||||||
db->server = server;
|
db->server = server;
|
||||||
@ -335,13 +335,13 @@ bool monitorAddServer(MXS_MONITOR *mon, SERVER *server)
|
|||||||
|
|
||||||
spinlock_acquire(&mon->lock);
|
spinlock_acquire(&mon->lock);
|
||||||
|
|
||||||
if (mon->databases == NULL)
|
if (mon->monitored_servers == NULL)
|
||||||
{
|
{
|
||||||
mon->databases = db;
|
mon->monitored_servers = db;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MXS_MONITOR_SERVERS *ptr = mon->databases;
|
MXS_MONITORED_SERVER *ptr = mon->monitored_servers;
|
||||||
while (ptr->next != NULL)
|
while (ptr->next != NULL)
|
||||||
{
|
{
|
||||||
ptr = ptr->next;
|
ptr = ptr->next;
|
||||||
@ -359,7 +359,7 @@ bool monitorAddServer(MXS_MONITOR *mon, SERVER *server)
|
|||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void monitor_server_free(MXS_MONITOR_SERVERS *tofree)
|
static void monitor_server_free(MXS_MONITORED_SERVER *tofree)
|
||||||
{
|
{
|
||||||
if (tofree)
|
if (tofree)
|
||||||
{
|
{
|
||||||
@ -375,11 +375,11 @@ static void monitor_server_free(MXS_MONITOR_SERVERS *tofree)
|
|||||||
* Free monitor server list
|
* Free monitor server list
|
||||||
* @param servers Servers to free
|
* @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)
|
while (servers)
|
||||||
{
|
{
|
||||||
MXS_MONITOR_SERVERS *tofree = servers;
|
MXS_MONITORED_SERVER *tofree = servers;
|
||||||
servers = servers->next;
|
servers = servers->next;
|
||||||
monitor_server_free(tofree);
|
monitor_server_free(tofree);
|
||||||
}
|
}
|
||||||
@ -402,15 +402,15 @@ void monitorRemoveServer(MXS_MONITOR *mon, SERVER *server)
|
|||||||
|
|
||||||
spinlock_acquire(&mon->lock);
|
spinlock_acquire(&mon->lock);
|
||||||
|
|
||||||
MXS_MONITOR_SERVERS *ptr = mon->databases;
|
MXS_MONITORED_SERVER *ptr = mon->monitored_servers;
|
||||||
|
|
||||||
if (ptr && ptr->server == server)
|
if (ptr && ptr->server == server)
|
||||||
{
|
{
|
||||||
mon->databases = mon->databases->next;
|
mon->monitored_servers = mon->monitored_servers->next;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MXS_MONITOR_SERVERS *prev = ptr;
|
MXS_MONITORED_SERVER *prev = ptr;
|
||||||
|
|
||||||
while (ptr)
|
while (ptr)
|
||||||
{
|
{
|
||||||
@ -522,7 +522,7 @@ monitorShow(DCB *dcb, MXS_MONITOR *monitor)
|
|||||||
|
|
||||||
const char *sep = "";
|
const char *sep = "";
|
||||||
|
|
||||||
for (MXS_MONITOR_SERVERS *db = monitor->databases; db; db = db->next)
|
for (MXS_MONITORED_SERVER *db = monitor->monitored_servers; db; db = db->next)
|
||||||
{
|
{
|
||||||
dcb_printf(dcb, "%s[%s]:%d", sep, db->server->name, db->server->port);
|
dcb_printf(dcb, "%s[%s]:%d", sep, db->server->name, db->server->port);
|
||||||
sep = ", ";
|
sep = ", ";
|
||||||
@ -782,7 +782,7 @@ monitorGetList()
|
|||||||
*/
|
*/
|
||||||
bool check_monitor_permissions(MXS_MONITOR* monitor, const char* query)
|
bool check_monitor_permissions(MXS_MONITOR* monitor, const char* query)
|
||||||
{
|
{
|
||||||
if (monitor->databases == NULL || // No servers to check
|
if (monitor->monitored_servers == NULL || // No servers to check
|
||||||
config_get_global_options()->skip_permission_checks)
|
config_get_global_options()->skip_permission_checks)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
@ -793,7 +793,7 @@ bool check_monitor_permissions(MXS_MONITOR* monitor, const char* query)
|
|||||||
MXS_CONFIG* cnf = config_get_global_options();
|
MXS_CONFIG* cnf = config_get_global_options();
|
||||||
bool rval = false;
|
bool rval = false;
|
||||||
|
|
||||||
for (MXS_MONITOR_SERVERS *mondb = monitor->databases; mondb; mondb = mondb->next)
|
for (MXS_MONITORED_SERVER *mondb = monitor->monitored_servers; mondb; mondb = mondb->next)
|
||||||
{
|
{
|
||||||
if (mon_ping_or_connect_to_db(monitor, mondb) != MONITOR_CONN_OK)
|
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
|
* @param bit The bit to clear for the server
|
||||||
*/
|
*/
|
||||||
void
|
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;
|
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
|
* @param bit The bit to clear for the server
|
||||||
*/
|
*/
|
||||||
void
|
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;
|
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
|
* @param node The monitor server data for a particular server
|
||||||
* @result monitor_event_t A monitor event (enum)
|
* @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
|
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
|
* @param node The monitor server data whose event is wanted
|
||||||
* @result string The name of the monitor event for the server
|
* @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);
|
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 dest Destination where the string is appended, must be null terminated
|
||||||
* @param len Length of @c dest
|
* @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 = "";
|
const char *separator = "";
|
||||||
char arr[MAX_SERVER_ADDRESS_LEN + 64]; // Some extra space for port and 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
|
* @param mon_srv The monitored server
|
||||||
* @return true if status has changed or false
|
* @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;
|
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
|
* @return true if failed status can be logged or false
|
||||||
*/
|
*/
|
||||||
bool
|
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);
|
return (SERVER_IS_DOWN(mon_srv->server) && mon_srv->mon_err_count == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static MXS_MONITOR_SERVERS* find_parent_node(MXS_MONITOR_SERVERS* servers,
|
static MXS_MONITORED_SERVER* find_parent_node(MXS_MONITORED_SERVER* servers,
|
||||||
MXS_MONITOR_SERVERS* target)
|
MXS_MONITORED_SERVER* target)
|
||||||
{
|
{
|
||||||
MXS_MONITOR_SERVERS* rval = NULL;
|
MXS_MONITORED_SERVER* rval = NULL;
|
||||||
|
|
||||||
if (target->server->master_id > 0)
|
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)
|
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;
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string child_nodes(MXS_MONITOR_SERVERS* servers,
|
static std::string child_nodes(MXS_MONITORED_SERVER* servers,
|
||||||
MXS_MONITOR_SERVERS* parent)
|
MXS_MONITORED_SERVER* parent)
|
||||||
{
|
{
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
|
|
||||||
@ -1174,7 +1174,7 @@ static std::string child_nodes(MXS_MONITOR_SERVERS* servers,
|
|||||||
{
|
{
|
||||||
bool have_content = false;
|
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)
|
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
|
* @param script Script to execute
|
||||||
*/
|
*/
|
||||||
void
|
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];
|
char arg[strlen(script) + 1];
|
||||||
strcpy(arg, script);
|
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"))
|
if (externcmd_matches(cmd, "$PARENT"))
|
||||||
{
|
{
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
MXS_MONITOR_SERVERS* parent = find_parent_node(mon->databases, ptr);
|
MXS_MONITORED_SERVER* parent = find_parent_node(mon->monitored_servers, ptr);
|
||||||
|
|
||||||
if (parent)
|
if (parent)
|
||||||
{
|
{
|
||||||
@ -1234,7 +1234,7 @@ monitor_launch_script(MXS_MONITOR* mon, MXS_MONITOR_SERVERS* ptr, const char* sc
|
|||||||
|
|
||||||
if (externcmd_matches(cmd, "$CHILDREN"))
|
if (externcmd_matches(cmd, "$CHILDREN"))
|
||||||
{
|
{
|
||||||
externcmd_substitute_arg(cmd, "[$]CHILDREN", child_nodes(mon->databases, ptr).c_str());
|
externcmd_substitute_arg(cmd, "[$]CHILDREN", child_nodes(mon->monitored_servers, ptr).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (externcmd_matches(cmd, "$EVENT"))
|
if (externcmd_matches(cmd, "$EVENT"))
|
||||||
@ -1246,31 +1246,31 @@ monitor_launch_script(MXS_MONITOR* mon, MXS_MONITOR_SERVERS* ptr, const char* sc
|
|||||||
|
|
||||||
if (externcmd_matches(cmd, "$NODELIST"))
|
if (externcmd_matches(cmd, "$NODELIST"))
|
||||||
{
|
{
|
||||||
mon_append_node_names(mon->databases, nodelist, sizeof(nodelist), SERVER_RUNNING);
|
mon_append_node_names(mon->monitored_servers, nodelist, sizeof(nodelist), SERVER_RUNNING);
|
||||||
externcmd_substitute_arg(cmd, "[$]NODELIST", nodelist);
|
externcmd_substitute_arg(cmd, "[$]NODELIST", nodelist);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (externcmd_matches(cmd, "$LIST"))
|
if (externcmd_matches(cmd, "$LIST"))
|
||||||
{
|
{
|
||||||
mon_append_node_names(mon->databases, nodelist, sizeof(nodelist), 0);
|
mon_append_node_names(mon->monitored_servers, nodelist, sizeof(nodelist), 0);
|
||||||
externcmd_substitute_arg(cmd, "[$]LIST", nodelist);
|
externcmd_substitute_arg(cmd, "[$]LIST", nodelist);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (externcmd_matches(cmd, "$MASTERLIST"))
|
if (externcmd_matches(cmd, "$MASTERLIST"))
|
||||||
{
|
{
|
||||||
mon_append_node_names(mon->databases, nodelist, sizeof(nodelist), SERVER_MASTER);
|
mon_append_node_names(mon->monitored_servers, nodelist, sizeof(nodelist), SERVER_MASTER);
|
||||||
externcmd_substitute_arg(cmd, "[$]MASTERLIST", nodelist);
|
externcmd_substitute_arg(cmd, "[$]MASTERLIST", nodelist);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (externcmd_matches(cmd, "$SLAVELIST"))
|
if (externcmd_matches(cmd, "$SLAVELIST"))
|
||||||
{
|
{
|
||||||
mon_append_node_names(mon->databases, nodelist, sizeof(nodelist), SERVER_SLAVE);
|
mon_append_node_names(mon->monitored_servers, nodelist, sizeof(nodelist), SERVER_SLAVE);
|
||||||
externcmd_substitute_arg(cmd, "[$]SLAVELIST", nodelist);
|
externcmd_substitute_arg(cmd, "[$]SLAVELIST", nodelist);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (externcmd_matches(cmd, "$SYNCEDLIST"))
|
if (externcmd_matches(cmd, "$SYNCEDLIST"))
|
||||||
{
|
{
|
||||||
mon_append_node_names(mon->databases, nodelist, sizeof(nodelist), SERVER_JOINED);
|
mon_append_node_names(mon->monitored_servers, nodelist, sizeof(nodelist), SERVER_JOINED);
|
||||||
externcmd_substitute_arg(cmd, "[$]SYNCEDLIST", nodelist);
|
externcmd_substitute_arg(cmd, "[$]SYNCEDLIST", nodelist);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -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
|
* @return MONITOR_CONN_OK if the connection is OK, else the reason for the failure
|
||||||
*/
|
*/
|
||||||
mxs_connect_result_t
|
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 */
|
/** Return if the connection is OK */
|
||||||
if (database->con && mysql_ping(database->con) == 0)
|
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
|
* @param rval Return value of mon_connect_to_db
|
||||||
*/
|
*/
|
||||||
void
|
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 ?
|
MXS_ERROR(rval == MONITOR_CONN_TIMEOUT ?
|
||||||
"Monitor timed out when connecting to server [%s]:%d : \"%s\"" :
|
"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));
|
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;
|
SERVER srv;
|
||||||
srv.status = ptr->mon_prev_status;
|
srv.status = ptr->mon_prev_status;
|
||||||
@ -1451,7 +1451,7 @@ MXS_MONITOR* monitor_server_in_use(const SERVER *server)
|
|||||||
|
|
||||||
if (mon->active)
|
if (mon->active)
|
||||||
{
|
{
|
||||||
for (MXS_MONITOR_SERVERS *db = mon->databases; db && !rval; db = db->next)
|
for (MXS_MONITORED_SERVER *db = mon->monitored_servers; db && !rval; db = db->next)
|
||||||
{
|
{
|
||||||
if (db->server == server)
|
if (db->server == server)
|
||||||
{
|
{
|
||||||
@ -1492,12 +1492,12 @@ static bool create_monitor_config(const MXS_MONITOR *monitor, const char *filena
|
|||||||
dprintf(file, "%s=%ld\n", CN_JOURNAL_MAX_AGE, monitor->journal_max_age);
|
dprintf(file, "%s=%ld\n", CN_JOURNAL_MAX_AGE, monitor->journal_max_age);
|
||||||
dprintf(file, "%s=%d\n", CN_SCRIPT_TIMEOUT, monitor->script_timeout);
|
dprintf(file, "%s=%d\n", CN_SCRIPT_TIMEOUT, monitor->script_timeout);
|
||||||
|
|
||||||
if (monitor->databases)
|
if (monitor->monitored_servers)
|
||||||
{
|
{
|
||||||
dprintf(file, "%s=", CN_SERVERS);
|
dprintf(file, "%s=", CN_SERVERS);
|
||||||
for (MXS_MONITOR_SERVERS *db = monitor->databases; db; db = db->next)
|
for (MXS_MONITORED_SERVER *db = monitor->monitored_servers; db; db = db->next)
|
||||||
{
|
{
|
||||||
if (db != monitor->databases)
|
if (db != monitor->monitored_servers)
|
||||||
{
|
{
|
||||||
dprintf(file, ",");
|
dprintf(file, ",");
|
||||||
}
|
}
|
||||||
@ -1575,7 +1575,7 @@ bool monitor_serialize(const MXS_MONITOR *monitor)
|
|||||||
|
|
||||||
void mon_hangup_failed_servers(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->monitored_servers; ptr; ptr = ptr->next)
|
||||||
{
|
{
|
||||||
if (mon_status_changed(ptr) &&
|
if (mon_status_changed(ptr) &&
|
||||||
(!(SERVER_IS_RUNNING(ptr->server)) ||
|
(!(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",
|
MXS_ERROR("Failed to execute query on server '%s' ([%s]:%d): %s",
|
||||||
db->server->unique_name, db->server->name,
|
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)
|
void lock_monitor_servers(MXS_MONITOR *monitor)
|
||||||
{
|
{
|
||||||
MXS_MONITOR_SERVERS *ptr = monitor->databases;
|
MXS_MONITORED_SERVER *ptr = monitor->monitored_servers;
|
||||||
while (ptr)
|
while (ptr)
|
||||||
{
|
{
|
||||||
spinlock_acquire(&ptr->server->lock);
|
spinlock_acquire(&ptr->server->lock);
|
||||||
@ -1614,7 +1614,7 @@ void lock_monitor_servers(MXS_MONITOR *monitor)
|
|||||||
*/
|
*/
|
||||||
void release_monitor_servers(MXS_MONITOR *monitor)
|
void release_monitor_servers(MXS_MONITOR *monitor)
|
||||||
{
|
{
|
||||||
MXS_MONITOR_SERVERS *ptr = monitor->databases;
|
MXS_MONITORED_SERVER *ptr = monitor->monitored_servers;
|
||||||
while (ptr)
|
while (ptr)
|
||||||
{
|
{
|
||||||
spinlock_release(&ptr->server->lock);
|
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)
|
void servers_status_pending_to_current(MXS_MONITOR *monitor)
|
||||||
{
|
{
|
||||||
MXS_MONITOR_SERVERS *ptr = monitor->databases;
|
MXS_MONITORED_SERVER *ptr = monitor->monitored_servers;
|
||||||
while (ptr)
|
while (ptr)
|
||||||
{
|
{
|
||||||
ptr->server->status = ptr->server->status_pending;
|
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)
|
void servers_status_current_to_pending(MXS_MONITOR *monitor)
|
||||||
{
|
{
|
||||||
MXS_MONITOR_SERVERS *ptr = monitor->databases;
|
MXS_MONITORED_SERVER *ptr = monitor->monitored_servers;
|
||||||
while (ptr)
|
while (ptr)
|
||||||
{
|
{
|
||||||
ptr->server->status_pending = ptr->server->status;
|
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)
|
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->monitored_servers; ptr; ptr = ptr->next)
|
||||||
{
|
{
|
||||||
if (mon_status_changed(ptr))
|
if (mon_status_changed(ptr))
|
||||||
{
|
{
|
||||||
@ -1748,11 +1748,11 @@ json_t* monitor_json_data(const MXS_MONITOR* monitor, const char* host)
|
|||||||
json_t* rel = json_object();
|
json_t* rel = json_object();
|
||||||
|
|
||||||
|
|
||||||
if (monitor->databases)
|
if (monitor->monitored_servers)
|
||||||
{
|
{
|
||||||
json_t* mon_rel = mxs_json_relationship(host, MXS_JSON_API_SERVERS);
|
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->monitored_servers; db; db = db->next)
|
||||||
{
|
{
|
||||||
mxs_json_add_relation(mon_rel, db->server->unique_name, CN_SERVERS);
|
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)
|
if (mon->active)
|
||||||
{
|
{
|
||||||
for (MXS_MONITOR_SERVERS* db = mon->databases; db; db = db->next)
|
for (MXS_MONITORED_SERVER* db = mon->monitored_servers; db; db = db->next)
|
||||||
{
|
{
|
||||||
if (db->server == server)
|
if (db->server == server)
|
||||||
{
|
{
|
||||||
@ -1900,7 +1900,7 @@ static FILE* open_tmp_file(MXS_MONITOR *monitor, char *path)
|
|||||||
* PATH_MAX bytes long
|
* PATH_MAX bytes long
|
||||||
* @param size Size of @c data
|
* @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;
|
uint8_t* ptr = data;
|
||||||
|
|
||||||
@ -1912,7 +1912,7 @@ static void store_data(MXS_MONITOR *monitor, MXS_MONITOR_SERVERS *master, uint8_
|
|||||||
*ptr++ = MMB_SCHEMA_VERSION;
|
*ptr++ = MMB_SCHEMA_VERSION;
|
||||||
|
|
||||||
/** Store the states of all servers */
|
/** Store the states of all servers */
|
||||||
for (MXS_MONITOR_SERVERS* db = monitor->databases; db; db = db->next)
|
for (MXS_MONITORED_SERVER* db = monitor->monitored_servers; db; db = db->next)
|
||||||
{
|
{
|
||||||
*ptr++ = (char)SVT_SERVER; // Value type
|
*ptr++ = (char)SVT_SERVER; // Value type
|
||||||
memcpy(ptr, db->server->unique_name, strlen(db->server->unique_name)); // Name of the server
|
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)
|
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->monitored_servers; db; db = db->next)
|
||||||
{
|
{
|
||||||
if (strcmp(db->server->unique_name, data) == 0)
|
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
|
* 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)
|
const char *end)
|
||||||
{
|
{
|
||||||
if (master)
|
if (master)
|
||||||
{
|
{
|
||||||
for (MXS_MONITOR_SERVERS* db = monitor->databases; db; db = db->next)
|
for (MXS_MONITORED_SERVER* db = monitor->monitored_servers; db; db = db->next)
|
||||||
{
|
{
|
||||||
if (strcmp(db->server->unique_name, data) == 0)
|
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
|
* 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 *crc_ptr)
|
||||||
{
|
{
|
||||||
const char *ptr = data;
|
const char *ptr = data;
|
||||||
@ -2097,12 +2097,12 @@ static bool process_data_file(MXS_MONITOR *monitor, MXS_MONITOR_SERVERS **master
|
|||||||
return true;
|
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 */
|
/** Calculate how much memory we need to allocate */
|
||||||
uint32_t size = MMB_LEN_SCHEMA_VERSION + MMB_LEN_CRC32;
|
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->monitored_servers; db; db = db->next)
|
||||||
{
|
{
|
||||||
/** Each server is stored as a type byte and a null-terminated string
|
/** Each server is stored as a type byte and a null-terminated string
|
||||||
* followed by eight byte server status. */
|
* followed by eight byte server status. */
|
||||||
@ -2148,7 +2148,7 @@ void store_server_journal(MXS_MONITOR *monitor, MXS_MONITOR_SERVERS *master)
|
|||||||
MXS_FREE(data);
|
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];
|
char path[PATH_MAX];
|
||||||
FILE *file = open_data_file(monitor, path);
|
FILE *file = open_data_file(monitor, path);
|
||||||
|
@ -44,7 +44,7 @@ typedef struct aurora_monitor
|
|||||||
* @param monitor Monitor object
|
* @param monitor Monitor object
|
||||||
* @param database Server whose status should be updated
|
* @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))
|
if (!SERVER_IN_MAINT(database->server))
|
||||||
{
|
{
|
||||||
@ -126,7 +126,7 @@ monitorMain(void *arg)
|
|||||||
lock_monitor_servers(monitor);
|
lock_monitor_servers(monitor);
|
||||||
servers_status_pending_to_current(monitor);
|
servers_status_pending_to_current(monitor);
|
||||||
|
|
||||||
for (MXS_MONITOR_SERVERS *ptr = monitor->databases; ptr; ptr = ptr->next)
|
for (MXS_MONITORED_SERVER *ptr = monitor->monitored_servers; ptr; ptr = ptr->next)
|
||||||
{
|
{
|
||||||
update_server_status(monitor, ptr);
|
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 stopMonitor(MXS_MONITOR *);
|
||||||
static void diagnostics(DCB *, const MXS_MONITOR *);
|
static void diagnostics(DCB *, const MXS_MONITOR *);
|
||||||
static json_t* diagnostics_json(const MXS_MONITOR *);
|
static json_t* diagnostics_json(const MXS_MONITOR *);
|
||||||
static MXS_MONITOR_SERVERS *get_candidate_master(MXS_MONITOR*);
|
static MXS_MONITORED_SERVER *get_candidate_master(MXS_MONITOR*);
|
||||||
static MXS_MONITOR_SERVERS *set_cluster_master(MXS_MONITOR_SERVERS *, MXS_MONITOR_SERVERS *, int);
|
static MXS_MONITORED_SERVER *set_cluster_master(MXS_MONITORED_SERVER *, MXS_MONITORED_SERVER *, int);
|
||||||
static void disableMasterFailback(void *, int);
|
static void disableMasterFailback(void *, int);
|
||||||
bool isGaleraEvent(mxs_monitor_event_t event);
|
bool isGaleraEvent(mxs_monitor_event_t event);
|
||||||
static void update_sst_donor_nodes(MXS_MONITOR*, int);
|
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
|
* @param database The database to probe
|
||||||
*/
|
*/
|
||||||
static void
|
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;
|
GALERA_MONITOR* handle = (GALERA_MONITOR*) mon->handle;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -483,9 +483,9 @@ monitorMain(void *arg)
|
|||||||
{
|
{
|
||||||
GALERA_MONITOR *handle = (GALERA_MONITOR*)arg;
|
GALERA_MONITOR *handle = (GALERA_MONITOR*)arg;
|
||||||
MXS_MONITOR* mon = handle->monitor;
|
MXS_MONITOR* mon = handle->monitor;
|
||||||
MXS_MONITOR_SERVERS *ptr;
|
MXS_MONITORED_SERVER *ptr;
|
||||||
size_t nrounds = 0;
|
size_t nrounds = 0;
|
||||||
MXS_MONITOR_SERVERS *candidate_master = NULL;
|
MXS_MONITORED_SERVER *candidate_master = NULL;
|
||||||
int master_stickiness;
|
int master_stickiness;
|
||||||
int is_cluster = 0;
|
int is_cluster = 0;
|
||||||
int log_no_members = 1;
|
int log_no_members = 1;
|
||||||
@ -534,7 +534,7 @@ monitorMain(void *arg)
|
|||||||
lock_monitor_servers(mon);
|
lock_monitor_servers(mon);
|
||||||
servers_status_pending_to_current(mon);
|
servers_status_pending_to_current(mon);
|
||||||
|
|
||||||
ptr = mon->databases;
|
ptr = mon->monitored_servers;
|
||||||
while (ptr)
|
while (ptr)
|
||||||
{
|
{
|
||||||
ptr->mon_prev_status = ptr->server->status;
|
ptr->mon_prev_status = ptr->server->status;
|
||||||
@ -583,7 +583,7 @@ monitorMain(void *arg)
|
|||||||
|
|
||||||
handle->master = set_cluster_master(handle->master, candidate_master, master_stickiness);
|
handle->master = set_cluster_master(handle->master, candidate_master, master_stickiness);
|
||||||
|
|
||||||
ptr = mon->databases;
|
ptr = mon->monitored_servers;
|
||||||
|
|
||||||
while (ptr)
|
while (ptr)
|
||||||
{
|
{
|
||||||
@ -666,10 +666,10 @@ monitorMain(void *arg)
|
|||||||
* @param servers The monitored servers list
|
* @param servers The monitored servers list
|
||||||
* @return The candidate master on success, NULL on failure
|
* @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_MONITORED_SERVER *moitor_servers = mon->monitored_servers;
|
||||||
MXS_MONITOR_SERVERS *candidate_master = NULL;
|
MXS_MONITORED_SERVER *candidate_master = NULL;
|
||||||
GALERA_MONITOR* handle = mon->handle;
|
GALERA_MONITOR* handle = mon->handle;
|
||||||
long min_id = -1;
|
long min_id = -1;
|
||||||
int minval = INT_MAX;
|
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
|
* @param candidate_master The candidate master server accordingly to the selection rule
|
||||||
* @return The master node pointer (could be NULL)
|
* @return The master node pointer (could be NULL)
|
||||||
*/
|
*/
|
||||||
static MXS_MONITOR_SERVERS *set_cluster_master(MXS_MONITOR_SERVERS *current_master,
|
static MXS_MONITORED_SERVER *set_cluster_master(MXS_MONITORED_SERVER *current_master,
|
||||||
MXS_MONITOR_SERVERS *candidate_master,
|
MXS_MONITORED_SERVER *candidate_master,
|
||||||
int master_stickiness)
|
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)
|
static void update_sst_donor_nodes(MXS_MONITOR *mon, int is_cluster)
|
||||||
{
|
{
|
||||||
MXS_MONITOR_SERVERS *ptr;
|
MXS_MONITORED_SERVER *ptr;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
GALERA_MONITOR *handle = mon->handle;
|
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;
|
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 */
|
/* 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) +
|
char *donor_list = MXS_CALLOC(1, strlen(DONOR_LIST_SET_VAR) +
|
||||||
@ -819,14 +819,14 @@ static void update_sst_donor_nodes(MXS_MONITOR *mon, int is_cluster)
|
|||||||
|
|
||||||
strcpy(donor_list, DONOR_LIST_SET_VAR);
|
strcpy(donor_list, DONOR_LIST_SET_VAR);
|
||||||
|
|
||||||
ptr = mon->databases;
|
ptr = mon->monitored_servers;
|
||||||
|
|
||||||
/* Create an array of slave nodes */
|
/* Create an array of slave nodes */
|
||||||
while (ptr)
|
while (ptr)
|
||||||
{
|
{
|
||||||
if (SERVER_IS_JOINED(ptr->server) && SERVER_IS_SLAVE(ptr->server))
|
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++;
|
found_slaves++;
|
||||||
|
|
||||||
/* Check the server parameter "priority"
|
/* Check the server parameter "priority"
|
||||||
@ -854,13 +854,13 @@ static void update_sst_donor_nodes(MXS_MONITOR *mon, int is_cluster)
|
|||||||
/* Sort the array */
|
/* Sort the array */
|
||||||
qsort(node_list,
|
qsort(node_list,
|
||||||
found_slaves,
|
found_slaves,
|
||||||
sizeof(MXS_MONITOR_SERVERS *),
|
sizeof(MXS_MONITORED_SERVER *),
|
||||||
sort_order ? compare_node_priority : compare_node_index);
|
sort_order ? compare_node_priority : compare_node_index);
|
||||||
|
|
||||||
/* Select nodename from each server and append it to node_list */
|
/* Select nodename from each server and append it to node_list */
|
||||||
for (int k = 0; k < found_slaves; k++)
|
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 */
|
/* Get the Galera node name */
|
||||||
if (mxs_mysql_query(ptr->con, "SHOW VARIABLES LIKE 'wsrep_node_name'") == 0
|
if (mxs_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 */
|
/* Set now rep_sst_donor in each slave node */
|
||||||
for (int k = 0; k < found_slaves; k++)
|
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 */
|
/* Set the Galera SST donor node list */
|
||||||
if (mxs_mysql_query(ptr->con, donor_list) == 0)
|
if (mxs_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)
|
static int compare_node_index (const void *a, const void *b)
|
||||||
{
|
{
|
||||||
const MXS_MONITOR_SERVERS *s_a = *(MXS_MONITOR_SERVERS * const *)a;
|
const MXS_MONITORED_SERVER *s_a = *(MXS_MONITORED_SERVER * const *)a;
|
||||||
const MXS_MONITOR_SERVERS *s_b = *(MXS_MONITOR_SERVERS * const *)b;
|
const MXS_MONITORED_SERVER *s_b = *(MXS_MONITORED_SERVER * const *)b;
|
||||||
|
|
||||||
// Order is DESC: b - a
|
// Order is DESC: b - a
|
||||||
return s_b->server->node_id - s_a->server->node_id;
|
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)
|
static int compare_node_priority (const void *a, const void *b)
|
||||||
{
|
{
|
||||||
const MXS_MONITOR_SERVERS *s_a = *(MXS_MONITOR_SERVERS * const *)a;
|
const MXS_MONITORED_SERVER *s_a = *(MXS_MONITORED_SERVER * const *)a;
|
||||||
const MXS_MONITOR_SERVERS *s_b = *(MXS_MONITOR_SERVERS * const *)b;
|
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_a = server_get_parameter(s_a->server, "priority");
|
||||||
const char *pri_b = server_get_parameter(s_b->server, "priority");
|
const char *pri_b = server_get_parameter(s_b->server, "priority");
|
||||||
@ -1195,11 +1195,11 @@ static void set_cluster_members(MXS_MONITOR *mon)
|
|||||||
{
|
{
|
||||||
GALERA_MONITOR *handle = mon->handle;
|
GALERA_MONITOR *handle = mon->handle;
|
||||||
GALERA_NODE_INFO *value;
|
GALERA_NODE_INFO *value;
|
||||||
MXS_MONITOR_SERVERS *ptr;
|
MXS_MONITORED_SERVER *ptr;
|
||||||
char *c_uuid = handle->cluster_info.c_uuid;
|
char *c_uuid = handle->cluster_info.c_uuid;
|
||||||
int c_size = handle->cluster_info.c_size;
|
int c_size = handle->cluster_info.c_size;
|
||||||
|
|
||||||
ptr = mon->databases;
|
ptr = mon->monitored_servers;
|
||||||
while (ptr)
|
while (ptr)
|
||||||
{
|
{
|
||||||
/* Fetch cluster info for this server, if any */
|
/* Fetch cluster info for this server, if any */
|
||||||
|
@ -85,7 +85,7 @@ typedef struct
|
|||||||
int disableMasterFailback; /**< Monitor flag for Galera Cluster Master failback */
|
int disableMasterFailback; /**< Monitor flag for Galera Cluster Master failback */
|
||||||
int availableWhenDonor; /**< Monitor flag for Galera Cluster Donor availability */
|
int availableWhenDonor; /**< Monitor flag for Galera Cluster Donor availability */
|
||||||
bool disableMasterRoleSetting; /**< Monitor flag to disable setting master role */
|
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;
|
char* script;
|
||||||
bool root_node_as_master; /**< Whether we require that the Master should
|
bool root_node_as_master; /**< Whether we require that the Master should
|
||||||
* have a wsrep_local_index of 0 */
|
* have a wsrep_local_index of 0 */
|
||||||
|
@ -40,12 +40,12 @@ public:
|
|||||||
~GRMon();
|
~GRMon();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
THREAD m_thread; /**< Monitor thread */
|
THREAD m_thread; /**< Monitor thread */
|
||||||
int m_shutdown; /**< Flag to shutdown the monitor thread */
|
int m_shutdown; /**< Flag to shutdown the monitor thread */
|
||||||
MXS_MONITOR_SERVERS* m_master; /**< The master server */
|
MXS_MONITORED_SERVER* m_master; /**< The master server */
|
||||||
std::string m_script;
|
std::string m_script;
|
||||||
uint64_t m_events; /**< Enabled events */
|
uint64_t m_events; /**< Enabled events */
|
||||||
MXS_MONITOR* m_monitor;
|
MXS_MONITOR* m_monitor;
|
||||||
|
|
||||||
GRMon(MXS_MONITOR* monitor, const MXS_CONFIG_PARAMETER *params);
|
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;
|
strcasecmp(value, "false") == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool is_master(MXS_MONITOR_SERVERS* server)
|
static bool is_master(MXS_MONITORED_SERVER* server)
|
||||||
{
|
{
|
||||||
bool rval = false;
|
bool rval = false;
|
||||||
MYSQL_RES* result;
|
MYSQL_RES* result;
|
||||||
@ -175,7 +175,7 @@ static bool is_master(MXS_MONITOR_SERVERS* server)
|
|||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool is_slave(MXS_MONITOR_SERVERS* server)
|
static bool is_slave(MXS_MONITORED_SERVER* server)
|
||||||
{
|
{
|
||||||
bool rval = false;
|
bool rval = false;
|
||||||
MYSQL_RES* result;
|
MYSQL_RES* result;
|
||||||
@ -202,7 +202,7 @@ static bool is_slave(MXS_MONITOR_SERVERS* server)
|
|||||||
return rval;
|
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 */
|
/* Don't even probe server flagged as in maintenance */
|
||||||
if (SERVER_IN_MAINT(server->server))
|
if (SERVER_IN_MAINT(server->server))
|
||||||
@ -273,7 +273,7 @@ void GRMon::main()
|
|||||||
lock_monitor_servers(m_monitor);
|
lock_monitor_servers(m_monitor);
|
||||||
servers_status_pending_to_current(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->monitored_servers; ptr; ptr = ptr->next)
|
||||||
{
|
{
|
||||||
update_server_status(m_monitor, ptr);
|
update_server_status(m_monitor, ptr);
|
||||||
}
|
}
|
||||||
@ -362,4 +362,4 @@ extern "C"
|
|||||||
return &info;
|
return &info;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ static void stopMonitor(MXS_MONITOR *);
|
|||||||
static void diagnostics(DCB *, const MXS_MONITOR *);
|
static void diagnostics(DCB *, const MXS_MONITOR *);
|
||||||
static json_t* diagnostics_json(const MXS_MONITOR *);
|
static json_t* diagnostics_json(const MXS_MONITOR *);
|
||||||
static void detectStaleMaster(void *, int);
|
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);
|
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
|
* @param database The database to probe
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
monitorDatabase(MXS_MONITOR* mon, MXS_MONITOR_SERVERS *database)
|
monitorDatabase(MXS_MONITOR* mon, MXS_MONITORED_SERVER *database)
|
||||||
{
|
{
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
@ -500,9 +500,9 @@ monitorMain(void *arg)
|
|||||||
{
|
{
|
||||||
MM_MONITOR *handle = (MM_MONITOR *)arg;
|
MM_MONITOR *handle = (MM_MONITOR *)arg;
|
||||||
MXS_MONITOR* mon = handle->monitor;
|
MXS_MONITOR* mon = handle->monitor;
|
||||||
MXS_MONITOR_SERVERS *ptr;
|
MXS_MONITORED_SERVER *ptr;
|
||||||
int detect_stale_master = false;
|
int detect_stale_master = false;
|
||||||
MXS_MONITOR_SERVERS *root_master = NULL;
|
MXS_MONITORED_SERVER *root_master = NULL;
|
||||||
size_t nrounds = 0;
|
size_t nrounds = 0;
|
||||||
|
|
||||||
detect_stale_master = handle->detectStaleMaster;
|
detect_stale_master = handle->detectStaleMaster;
|
||||||
@ -547,7 +547,7 @@ monitorMain(void *arg)
|
|||||||
servers_status_pending_to_current(mon);
|
servers_status_pending_to_current(mon);
|
||||||
|
|
||||||
/* start from the first server in the list */
|
/* start from the first server in the list */
|
||||||
ptr = mon->databases;
|
ptr = mon->monitored_servers;
|
||||||
|
|
||||||
while (ptr)
|
while (ptr)
|
||||||
{
|
{
|
||||||
@ -584,7 +584,7 @@ monitorMain(void *arg)
|
|||||||
|
|
||||||
/* Update server status from monitor pending status on that server*/
|
/* Update server status from monitor pending status on that server*/
|
||||||
|
|
||||||
ptr = mon->databases;
|
ptr = mon->monitored_servers;
|
||||||
while (ptr)
|
while (ptr)
|
||||||
{
|
{
|
||||||
if (!SERVER_IN_MAINT(ptr->server))
|
if (!SERVER_IN_MAINT(ptr->server))
|
||||||
@ -651,12 +651,12 @@ detectStaleMaster(void *arg, int enable)
|
|||||||
* @return The server at root level with SERVER_MASTER bit
|
* @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;
|
MM_MONITOR* handle = mon->handle;
|
||||||
MXS_MONITOR_SERVERS *ptr;
|
MXS_MONITORED_SERVER *ptr;
|
||||||
|
|
||||||
ptr = mon->databases;
|
ptr = mon->monitored_servers;
|
||||||
|
|
||||||
while (ptr)
|
while (ptr)
|
||||||
{
|
{
|
||||||
|
@ -45,7 +45,7 @@ typedef struct
|
|||||||
int status; /**< Monitor status */
|
int status; /**< Monitor status */
|
||||||
unsigned long id; /**< Monitor ID */
|
unsigned long id; /**< Monitor ID */
|
||||||
int detectStaleMaster; /**< Monitor flag for Stale Master detection */
|
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 */
|
char* script; /*< Script to call when state changes occur on servers */
|
||||||
uint64_t events; /*< enabled events */
|
uint64_t events; /*< enabled events */
|
||||||
MXS_MONITOR* monitor;
|
MXS_MONITOR* monitor;
|
||||||
|
@ -69,7 +69,7 @@ typedef struct
|
|||||||
int availableWhenDonor; /**< Monitor flag for Galera Cluster Donor availability */
|
int availableWhenDonor; /**< Monitor flag for Galera Cluster Donor availability */
|
||||||
int disableMasterRoleSetting; /**< Monitor flag to disable setting master role */
|
int disableMasterRoleSetting; /**< Monitor flag to disable setting master role */
|
||||||
bool mysql51_replication; /**< Use MySQL 5.1 replication */
|
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 */
|
char* script; /*< Script to call when state changes occur on servers */
|
||||||
uint64_t events; /*< enabled events */
|
uint64_t events; /*< enabled events */
|
||||||
HASHTABLE *server_info; /**< Contains server specific information */
|
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 stopMonitor(MXS_MONITOR *);
|
||||||
static void diagnostics(DCB *, const MXS_MONITOR *);
|
static void diagnostics(DCB *, const MXS_MONITOR *);
|
||||||
static json_t* diagnostics_json(const MXS_MONITOR *);
|
static json_t* diagnostics_json(const MXS_MONITOR *);
|
||||||
static MXS_MONITOR_SERVERS *getServerByNodeId(MXS_MONITOR_SERVERS *, long);
|
static MXS_MONITORED_SERVER *getServerByNodeId(MXS_MONITORED_SERVER *, long);
|
||||||
static MXS_MONITOR_SERVERS *getSlaveOfNodeId(MXS_MONITOR_SERVERS *, long);
|
static MXS_MONITORED_SERVER *getSlaveOfNodeId(MXS_MONITORED_SERVER *, long);
|
||||||
static MXS_MONITOR_SERVERS *get_replication_tree(MXS_MONITOR *, int);
|
static MXS_MONITORED_SERVER *get_replication_tree(MXS_MONITOR *, int);
|
||||||
static void set_master_heartbeat(MYSQL_MONITOR *, MXS_MONITOR_SERVERS *);
|
static void set_master_heartbeat(MYSQL_MONITOR *, MXS_MONITORED_SERVER *);
|
||||||
static void set_slave_heartbeat(MXS_MONITOR *, MXS_MONITOR_SERVERS *);
|
static void set_slave_heartbeat(MXS_MONITOR *, MXS_MONITORED_SERVER *);
|
||||||
static int add_slave_to_master(long *, int, long);
|
static int add_slave_to_master(long *, int, long);
|
||||||
static bool isMySQLEvent(mxs_monitor_event_t event);
|
static bool isMySQLEvent(mxs_monitor_event_t event);
|
||||||
void check_maxscale_schema_replication(MXS_MONITOR *monitor);
|
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
|
* @return True on success, false if initialization failed. At the moment
|
||||||
* initialization can only fail if memory allocation fails.
|
* 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;
|
bool rval = true;
|
||||||
|
|
||||||
@ -275,7 +275,7 @@ startMonitor(MXS_MONITOR *monitor, const MXS_CONFIG_PARAMETER* params)
|
|||||||
error = true;
|
error = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!init_server_info(handle, monitor->databases))
|
if (!init_server_info(handle, monitor->monitored_servers))
|
||||||
{
|
{
|
||||||
error = true;
|
error = 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, "Detect Stale Master:\t%s\n", (handle->detectStaleMaster == 1) ? "enabled" : "disabled");
|
||||||
dcb_printf(dcb, "Server information\n\n");
|
dcb_printf(dcb, "Server information\n\n");
|
||||||
|
|
||||||
for (MXS_MONITOR_SERVERS *db = mon->databases; db; db = db->next)
|
for (MXS_MONITORED_SERVER *db = mon->monitored_servers; db; db = db->next)
|
||||||
{
|
{
|
||||||
MYSQL_SERVER_INFO *serv_info =
|
MYSQL_SERVER_INFO *serv_info =
|
||||||
static_cast<MYSQL_SERVER_INFO*>(hashtable_fetch(handle->server_info, db->server->unique_name));
|
static_cast<MYSQL_SERVER_INFO*>(hashtable_fetch(handle->server_info, db->server->unique_name));
|
||||||
@ -376,11 +376,11 @@ static json_t* diagnostics_json(const MXS_MONITOR *mon)
|
|||||||
json_object_set_new(rval, "script", json_string(handle->script));
|
json_object_set_new(rval, "script", json_string(handle->script));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mon->databases)
|
if (mon->monitored_servers)
|
||||||
{
|
{
|
||||||
json_t* arr = json_array();
|
json_t* arr = json_array();
|
||||||
|
|
||||||
for (MXS_MONITOR_SERVERS *db = mon->databases; db; db = db->next)
|
for (MXS_MONITORED_SERVER *db = mon->monitored_servers; db; db = db->next)
|
||||||
{
|
{
|
||||||
json_t* srv = json_object();
|
json_t* srv = json_object();
|
||||||
MYSQL_SERVER_INFO *serv_info =
|
MYSQL_SERVER_INFO *serv_info =
|
||||||
@ -419,7 +419,7 @@ enum mysql_server_version
|
|||||||
MYSQL_SERVER_VERSION_51
|
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)
|
enum mysql_server_version server_version)
|
||||||
{
|
{
|
||||||
unsigned int columns;
|
unsigned int columns;
|
||||||
@ -554,10 +554,10 @@ static inline void monitor_mysql_db(MXS_MONITOR_SERVERS* database, MYSQL_SERVER_
|
|||||||
* @param mon Monitor
|
* @param mon Monitor
|
||||||
* @return Lowest server ID master in the 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_MONITORED_SERVER* database = mon->monitored_servers;
|
||||||
MXS_MONITOR_SERVERS *ptr, *rval = NULL;
|
MXS_MONITORED_SERVER *ptr, *rval = NULL;
|
||||||
int i;
|
int i;
|
||||||
MYSQL_MONITOR *handle = static_cast<MYSQL_MONITOR*>(mon->handle);
|
MYSQL_MONITOR *handle = static_cast<MYSQL_MONITOR*>(mon->handle);
|
||||||
|
|
||||||
@ -623,12 +623,12 @@ static MXS_MONITOR_SERVERS *build_mysql51_replication_tree(MXS_MONITOR *mon)
|
|||||||
database = database->next;
|
database = database->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
database = mon->databases;
|
database = mon->monitored_servers;
|
||||||
|
|
||||||
/** Set master server IDs */
|
/** Set master server IDs */
|
||||||
while (database)
|
while (database)
|
||||||
{
|
{
|
||||||
ptr = mon->databases;
|
ptr = mon->monitored_servers;
|
||||||
|
|
||||||
while (ptr)
|
while (ptr)
|
||||||
{
|
{
|
||||||
@ -669,7 +669,7 @@ static MXS_MONITOR_SERVERS *build_mysql51_replication_tree(MXS_MONITOR *mon)
|
|||||||
* @param database The database to probe
|
* @param database The database to probe
|
||||||
*/
|
*/
|
||||||
static void
|
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_MONITOR* handle = static_cast<MYSQL_MONITOR*>(mon->handle);
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -830,7 +830,7 @@ struct graph_node
|
|||||||
bool active;
|
bool active;
|
||||||
struct graph_node *parent;
|
struct graph_node *parent;
|
||||||
MYSQL_SERVER_INFO *info;
|
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
|
* member. Nodes in a group get a positive group ID where the nodes not in a
|
||||||
* group get a group ID of 0.
|
* 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 graph[nservers];
|
||||||
struct graph_node *stack[nservers];
|
struct graph_node *stack[nservers];
|
||||||
int nodes = 0;
|
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 =
|
graph[nodes].info =
|
||||||
static_cast<MYSQL_SERVER_INFO*>(hashtable_fetch(handle->server_info, db->server->unique_name));
|
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
|
* @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;
|
int candidates = 0;
|
||||||
|
|
||||||
@ -1091,7 +1091,7 @@ bool failover_required(MYSQL_MONITOR *handle, MXS_MONITOR_SERVERS *db)
|
|||||||
* @param handle Monitor instance
|
* @param handle Monitor instance
|
||||||
* @param db Monitor servers
|
* @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)
|
while (db)
|
||||||
{
|
{
|
||||||
@ -1130,11 +1130,11 @@ monitorMain(void *arg)
|
|||||||
{
|
{
|
||||||
MYSQL_MONITOR *handle = (MYSQL_MONITOR *) arg;
|
MYSQL_MONITOR *handle = (MYSQL_MONITOR *) arg;
|
||||||
MXS_MONITOR* mon = handle->monitor;
|
MXS_MONITOR* mon = handle->monitor;
|
||||||
MXS_MONITOR_SERVERS *ptr;
|
MXS_MONITORED_SERVER *ptr;
|
||||||
int replication_heartbeat;
|
int replication_heartbeat;
|
||||||
bool detect_stale_master;
|
bool detect_stale_master;
|
||||||
int num_servers = 0;
|
int num_servers = 0;
|
||||||
MXS_MONITOR_SERVERS *root_master = NULL;
|
MXS_MONITORED_SERVER *root_master = NULL;
|
||||||
size_t nrounds = 0;
|
size_t nrounds = 0;
|
||||||
int log_no_master = 1;
|
int log_no_master = 1;
|
||||||
bool heartbeat_checked = false;
|
bool heartbeat_checked = false;
|
||||||
@ -1190,7 +1190,7 @@ monitorMain(void *arg)
|
|||||||
servers_status_pending_to_current(mon);
|
servers_status_pending_to_current(mon);
|
||||||
|
|
||||||
/* start from the first server in the list */
|
/* start from the first server in the list */
|
||||||
ptr = mon->databases;
|
ptr = mon->monitored_servers;
|
||||||
|
|
||||||
while (ptr)
|
while (ptr)
|
||||||
{
|
{
|
||||||
@ -1247,7 +1247,7 @@ monitorMain(void *arg)
|
|||||||
ptr = ptr->next;
|
ptr = ptr->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
ptr = mon->databases;
|
ptr = mon->monitored_servers;
|
||||||
/* if only one server is configured, that's is Master */
|
/* if only one server is configured, that's is Master */
|
||||||
if (num_servers == 1)
|
if (num_servers == 1)
|
||||||
{
|
{
|
||||||
@ -1283,10 +1283,10 @@ monitorMain(void *arg)
|
|||||||
/** Find all the master server cycles in the cluster graph. If
|
/** Find all the master server cycles in the cluster graph. If
|
||||||
multiple masters are found, the servers with the read_only
|
multiple masters are found, the servers with the read_only
|
||||||
variable set to ON will be assigned the slave status. */
|
variable set to ON will be assigned the slave status. */
|
||||||
find_graph_cycles(handle, mon->databases, num_servers);
|
find_graph_cycles(handle, mon->monitored_servers, num_servers);
|
||||||
}
|
}
|
||||||
|
|
||||||
ptr = mon->databases;
|
ptr = mon->monitored_servers;
|
||||||
while (ptr)
|
while (ptr)
|
||||||
{
|
{
|
||||||
MYSQL_SERVER_INFO *serv_info =
|
MYSQL_SERVER_INFO *serv_info =
|
||||||
@ -1295,8 +1295,8 @@ monitorMain(void *arg)
|
|||||||
ss_dassert(serv_info);
|
ss_dassert(serv_info);
|
||||||
|
|
||||||
if (ptr->server->node_id > 0 && ptr->server->master_id > 0 &&
|
if (ptr->server->node_id > 0 && ptr->server->master_id > 0 &&
|
||||||
getSlaveOfNodeId(mon->databases, ptr->server->node_id) &&
|
getSlaveOfNodeId(mon->monitored_servers, ptr->server->node_id) &&
|
||||||
getServerByNodeId(mon->databases, ptr->server->master_id) &&
|
getServerByNodeId(mon->monitored_servers, ptr->server->master_id) &&
|
||||||
(!handle->multimaster || serv_info->group == 0))
|
(!handle->multimaster || serv_info->group == 0))
|
||||||
{
|
{
|
||||||
/** This server is both a slave and a master i.e. a relay master */
|
/** This server is both a slave and a master i.e. a relay master */
|
||||||
@ -1315,7 +1315,7 @@ monitorMain(void *arg)
|
|||||||
|
|
||||||
/* Update server status from monitor pending status on that server*/
|
/* Update server status from monitor pending status on that server*/
|
||||||
|
|
||||||
ptr = mon->databases;
|
ptr = mon->monitored_servers;
|
||||||
while (ptr)
|
while (ptr)
|
||||||
{
|
{
|
||||||
if (!SERVER_IN_MAINT(ptr->server))
|
if (!SERVER_IN_MAINT(ptr->server))
|
||||||
@ -1401,10 +1401,10 @@ monitorMain(void *arg)
|
|||||||
if we need to do a failover */
|
if we need to do a failover */
|
||||||
if (handle->detect_standalone_master)
|
if (handle->detect_standalone_master)
|
||||||
{
|
{
|
||||||
if (failover_required(handle, mon->databases))
|
if (failover_required(handle, mon->monitored_servers))
|
||||||
{
|
{
|
||||||
/** Other servers have died, initiate a failover to the last remaining server */
|
/** Other servers have died, initiate a failover to the last remaining server */
|
||||||
do_failover(handle, mon->databases);
|
do_failover(handle, mon->monitored_servers);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1457,7 +1457,7 @@ monitorMain(void *arg)
|
|||||||
SERVER_IS_RELAY_SERVER(root_master->server)))
|
SERVER_IS_RELAY_SERVER(root_master->server)))
|
||||||
{
|
{
|
||||||
set_master_heartbeat(handle, root_master);
|
set_master_heartbeat(handle, root_master);
|
||||||
ptr = mon->databases;
|
ptr = mon->monitored_servers;
|
||||||
|
|
||||||
while (ptr)
|
while (ptr)
|
||||||
{
|
{
|
||||||
@ -1494,8 +1494,8 @@ monitorMain(void *arg)
|
|||||||
* @param node_id The MySQL server_id to fetch
|
* @param node_id The MySQL server_id to fetch
|
||||||
* @return The server with the required server_id
|
* @return The server with the required server_id
|
||||||
*/
|
*/
|
||||||
static MXS_MONITOR_SERVERS *
|
static MXS_MONITORED_SERVER *
|
||||||
getServerByNodeId(MXS_MONITOR_SERVERS *ptr, long node_id)
|
getServerByNodeId(MXS_MONITORED_SERVER *ptr, long node_id)
|
||||||
{
|
{
|
||||||
SERVER *current;
|
SERVER *current;
|
||||||
while (ptr)
|
while (ptr)
|
||||||
@ -1517,8 +1517,8 @@ getServerByNodeId(MXS_MONITOR_SERVERS *ptr, long node_id)
|
|||||||
* @param node_id The MySQL server_id to fetch
|
* @param node_id The MySQL server_id to fetch
|
||||||
* @return The slave server of this node_id
|
* @return The slave server of this node_id
|
||||||
*/
|
*/
|
||||||
static MXS_MONITOR_SERVERS *
|
static MXS_MONITORED_SERVER *
|
||||||
getSlaveOfNodeId(MXS_MONITOR_SERVERS *ptr, long node_id)
|
getSlaveOfNodeId(MXS_MONITORED_SERVER *ptr, long node_id)
|
||||||
{
|
{
|
||||||
SERVER *current;
|
SERVER *current;
|
||||||
while (ptr)
|
while (ptr)
|
||||||
@ -1541,7 +1541,7 @@ getSlaveOfNodeId(MXS_MONITOR_SERVERS *ptr, long node_id)
|
|||||||
* @param handle The monitor handle
|
* @param handle The monitor handle
|
||||||
* @param database The number database server
|
* @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;
|
unsigned long id = handle->id;
|
||||||
time_t heartbeat;
|
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 handle The monitor handle
|
||||||
* @param database The number database server
|
* @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;
|
MYSQL_MONITOR *handle = (MYSQL_MONITOR*) mon->handle;
|
||||||
unsigned long id = handle->id;
|
unsigned long id = handle->id;
|
||||||
@ -1786,17 +1786,17 @@ static void set_slave_heartbeat(MXS_MONITOR* mon, MXS_MONITOR_SERVERS *database)
|
|||||||
* @return The server at root level with SERVER_MASTER bit
|
* @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;
|
MYSQL_MONITOR* handle = (MYSQL_MONITOR*) mon->handle;
|
||||||
MXS_MONITOR_SERVERS *ptr;
|
MXS_MONITORED_SERVER *ptr;
|
||||||
MXS_MONITOR_SERVERS *backend;
|
MXS_MONITORED_SERVER *backend;
|
||||||
SERVER *current;
|
SERVER *current;
|
||||||
int depth = 0;
|
int depth = 0;
|
||||||
long node_id;
|
long node_id;
|
||||||
int root_level;
|
int root_level;
|
||||||
|
|
||||||
ptr = mon->databases;
|
ptr = mon->monitored_servers;
|
||||||
root_level = num_servers;
|
root_level = num_servers;
|
||||||
|
|
||||||
while (ptr)
|
while (ptr)
|
||||||
@ -1816,8 +1816,8 @@ static MXS_MONITOR_SERVERS *get_replication_tree(MXS_MONITOR *mon, int num_serve
|
|||||||
node_id = current->master_id;
|
node_id = current->master_id;
|
||||||
if (node_id < 1)
|
if (node_id < 1)
|
||||||
{
|
{
|
||||||
MXS_MONITOR_SERVERS *find_slave;
|
MXS_MONITORED_SERVER *find_slave;
|
||||||
find_slave = getSlaveOfNodeId(mon->databases, current->node_id);
|
find_slave = getSlaveOfNodeId(mon->monitored_servers, current->node_id);
|
||||||
|
|
||||||
if (find_slave == NULL)
|
if (find_slave == NULL)
|
||||||
{
|
{
|
||||||
@ -1844,7 +1844,7 @@ static MXS_MONITOR_SERVERS *get_replication_tree(MXS_MONITOR *mon, int num_serve
|
|||||||
root_level = current->depth;
|
root_level = current->depth;
|
||||||
handle->master = ptr;
|
handle->master = ptr;
|
||||||
}
|
}
|
||||||
backend = getServerByNodeId(mon->databases, node_id);
|
backend = getServerByNodeId(mon->monitored_servers, node_id);
|
||||||
|
|
||||||
if (backend)
|
if (backend)
|
||||||
{
|
{
|
||||||
@ -1863,10 +1863,10 @@ static MXS_MONITOR_SERVERS *get_replication_tree(MXS_MONITOR *mon, int num_serve
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MXS_MONITOR_SERVERS *master;
|
MXS_MONITORED_SERVER *master;
|
||||||
current->depth = depth;
|
current->depth = depth;
|
||||||
|
|
||||||
master = getServerByNodeId(mon->databases, current->master_id);
|
master = getServerByNodeId(mon->monitored_servers, current->master_id);
|
||||||
if (master && master->server && master->server->node_id > 0)
|
if (master && master->server && master->server->node_id > 0)
|
||||||
{
|
{
|
||||||
add_slave_to_master(master->server->slaves, sizeof(master->server->slaves),
|
add_slave_to_master(master->server->slaves, sizeof(master->server->slaves),
|
||||||
@ -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
|
* @return False if the table is not replicated or an error occurred when querying
|
||||||
* the server
|
* the server
|
||||||
*/
|
*/
|
||||||
bool check_replicate_ignore_table(MXS_MONITOR_SERVERS* database)
|
bool check_replicate_ignore_table(MXS_MONITORED_SERVER* database)
|
||||||
{
|
{
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
bool rval = true;
|
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
|
* @return False if the table is not replicated or an error occurred when querying
|
||||||
* the server
|
* the server
|
||||||
*/
|
*/
|
||||||
bool check_replicate_do_table(MXS_MONITOR_SERVERS* database)
|
bool check_replicate_do_table(MXS_MONITORED_SERVER* database)
|
||||||
{
|
{
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
bool rval = true;
|
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
|
* @return False if the table is not replicated or an error occurred when trying to
|
||||||
* query the server.
|
* 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;
|
MYSQL_RES *result;
|
||||||
bool rval = true;
|
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
|
* @return False if the table is not replicated or an error occurred when trying to
|
||||||
* query the server.
|
* 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;
|
MYSQL_RES *result;
|
||||||
bool rval = true;
|
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)
|
void check_maxscale_schema_replication(MXS_MONITOR *monitor)
|
||||||
{
|
{
|
||||||
MXS_MONITOR_SERVERS* database = monitor->databases;
|
MXS_MONITORED_SERVER* database = monitor->monitored_servers;
|
||||||
bool err = false;
|
bool err = false;
|
||||||
|
|
||||||
while (database)
|
while (database)
|
||||||
|
@ -188,7 +188,7 @@ static json_t* diagnostics_json(const MXS_MONITOR *mon)
|
|||||||
* @param database The database to probe
|
* @param database The database to probe
|
||||||
*/
|
*/
|
||||||
static void
|
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_ROW row;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
@ -308,7 +308,7 @@ monitorMain(void *arg)
|
|||||||
{
|
{
|
||||||
MYSQL_MONITOR *handle = (MYSQL_MONITOR*)arg;
|
MYSQL_MONITOR *handle = (MYSQL_MONITOR*)arg;
|
||||||
MXS_MONITOR* mon = handle->monitor;
|
MXS_MONITOR* mon = handle->monitor;
|
||||||
MXS_MONITOR_SERVERS *ptr;
|
MXS_MONITORED_SERVER *ptr;
|
||||||
size_t nrounds = 0;
|
size_t nrounds = 0;
|
||||||
|
|
||||||
if (mysql_thread_init())
|
if (mysql_thread_init())
|
||||||
@ -350,7 +350,7 @@ monitorMain(void *arg)
|
|||||||
lock_monitor_servers(mon);
|
lock_monitor_servers(mon);
|
||||||
servers_status_pending_to_current(mon);
|
servers_status_pending_to_current(mon);
|
||||||
|
|
||||||
ptr = mon->databases;
|
ptr = mon->monitored_servers;
|
||||||
while (ptr)
|
while (ptr)
|
||||||
{
|
{
|
||||||
ptr->mon_prev_status = ptr->server->status;
|
ptr->mon_prev_status = ptr->server->status;
|
||||||
|
Reference in New Issue
Block a user