Rename public types and constants in monitor.h
Preparing to split monitor.h into module and core sections. Also changed a few comments in monitor.h.
This commit is contained in:
@ -42,7 +42,7 @@ typedef struct aurora_monitor
|
||||
* @param monitor Monitor object
|
||||
* @param database Server whose status should be updated
|
||||
*/
|
||||
void update_server_status(MONITOR *monitor, MONITOR_SERVERS *database)
|
||||
void update_server_status(MXS_MONITOR *monitor, MXS_MONITOR_SERVERS *database)
|
||||
{
|
||||
if (!SERVER_IN_MAINT(database->server))
|
||||
{
|
||||
@ -51,7 +51,7 @@ void update_server_status(MONITOR *monitor, MONITOR_SERVERS *database)
|
||||
database->mon_prev_status = database->server->status;
|
||||
|
||||
/** Try to connect to or ping the database */
|
||||
connect_result_t rval = mon_connect_to_db(monitor, database);
|
||||
mxs_connect_result_t rval = mon_connect_to_db(monitor, database);
|
||||
|
||||
if (rval == MONITOR_CONN_OK)
|
||||
{
|
||||
@ -111,7 +111,7 @@ void update_server_status(MONITOR *monitor, MONITOR_SERVERS *database)
|
||||
static void
|
||||
monitorMain(void *arg)
|
||||
{
|
||||
MONITOR *monitor = (MONITOR*)arg;
|
||||
MXS_MONITOR *monitor = (MXS_MONITOR*)arg;
|
||||
AURORA_MONITOR *handle = monitor->handle;
|
||||
|
||||
if (mysql_thread_init())
|
||||
@ -125,7 +125,7 @@ monitorMain(void *arg)
|
||||
lock_monitor_servers(monitor);
|
||||
servers_status_pending_to_current(monitor);
|
||||
|
||||
for (MONITOR_SERVERS *ptr = monitor->databases; ptr; ptr = ptr->next)
|
||||
for (MXS_MONITOR_SERVERS *ptr = monitor->databases; ptr; ptr = ptr->next)
|
||||
{
|
||||
update_server_status(monitor, ptr);
|
||||
|
||||
@ -154,8 +154,8 @@ monitorMain(void *arg)
|
||||
// Admin has changed something, skip sleep
|
||||
break;
|
||||
}
|
||||
thread_millisleep(MON_BASE_INTERVAL_MS);
|
||||
ms += MON_BASE_INTERVAL_MS;
|
||||
thread_millisleep(MXS_MON_BASE_INTERVAL_MS);
|
||||
ms += MXS_MON_BASE_INTERVAL_MS;
|
||||
}
|
||||
}
|
||||
|
||||
@ -184,7 +184,7 @@ static void auroramon_free(AURORA_MONITOR *handle)
|
||||
* @return Monitor handle
|
||||
*/
|
||||
static void *
|
||||
startMonitor(MONITOR *mon, const CONFIG_PARAMETER *params)
|
||||
startMonitor(MXS_MONITOR *mon, const CONFIG_PARAMETER *params)
|
||||
{
|
||||
AURORA_MONITOR *handle = mon->handle;
|
||||
|
||||
@ -213,7 +213,7 @@ startMonitor(MONITOR *mon, const CONFIG_PARAMETER *params)
|
||||
}
|
||||
|
||||
handle->script = config_copy_string(params, "script");
|
||||
handle->events = config_get_enum(params, "events", monitor_event_enum_values);
|
||||
handle->events = config_get_enum(params, "events", mxs_monitor_event_enum_values);
|
||||
|
||||
if (thread_start(&handle->thread, monitorMain, mon) == NULL)
|
||||
{
|
||||
@ -231,7 +231,7 @@ startMonitor(MONITOR *mon, const CONFIG_PARAMETER *params)
|
||||
* @param arg Handle on thr running monior
|
||||
*/
|
||||
static void
|
||||
stopMonitor(MONITOR *mon)
|
||||
stopMonitor(MXS_MONITOR *mon)
|
||||
{
|
||||
AURORA_MONITOR *handle = (AURORA_MONITOR *) mon->handle;
|
||||
|
||||
@ -246,7 +246,7 @@ stopMonitor(MONITOR *mon)
|
||||
* @param mon The monitor
|
||||
*/
|
||||
static void
|
||||
diagnostics(DCB *dcb, const MONITOR *mon)
|
||||
diagnostics(DCB *dcb, const MXS_MONITOR *mon)
|
||||
{
|
||||
}
|
||||
|
||||
@ -259,7 +259,7 @@ diagnostics(DCB *dcb, const MONITOR *mon)
|
||||
*/
|
||||
MXS_MODULE* MXS_CREATE_MODULE()
|
||||
{
|
||||
static MONITOR_OBJECT MyObject =
|
||||
static MXS_MONITOR_OBJECT MyObject =
|
||||
{
|
||||
startMonitor,
|
||||
stopMonitor,
|
||||
@ -270,7 +270,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
||||
{
|
||||
MXS_MODULE_API_MONITOR,
|
||||
MXS_MODULE_BETA_RELEASE,
|
||||
MONITOR_VERSION,
|
||||
MXS_MONITOR_VERSION,
|
||||
"Aurora monitor",
|
||||
"V1.0.0",
|
||||
&MyObject,
|
||||
@ -288,9 +288,9 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
||||
{
|
||||
"events",
|
||||
MXS_MODULE_PARAM_ENUM,
|
||||
MONITOR_EVENT_DEFAULT_VALUE,
|
||||
MXS_MONITOR_EVENT_DEFAULT_VALUE,
|
||||
MXS_MODULE_OPT_NONE,
|
||||
monitor_event_enum_values
|
||||
mxs_monitor_event_enum_values
|
||||
},
|
||||
{MXS_END_MODULE_PARAMS}
|
||||
}
|
||||
|
@ -47,14 +47,14 @@ static void monitorMain(void *);
|
||||
/** Log a warning when a bad 'wsrep_local_index' is found */
|
||||
static bool warn_erange_on_local_index = true;
|
||||
|
||||
static void *startMonitor(MONITOR *, const CONFIG_PARAMETER *params);
|
||||
static void stopMonitor(MONITOR *);
|
||||
static void diagnostics(DCB *, const MONITOR *);
|
||||
static MONITOR_SERVERS *get_candidate_master(MONITOR*);
|
||||
static MONITOR_SERVERS *set_cluster_master(MONITOR_SERVERS *, MONITOR_SERVERS *, int);
|
||||
static void *startMonitor(MXS_MONITOR *, const CONFIG_PARAMETER *params);
|
||||
static void stopMonitor(MXS_MONITOR *);
|
||||
static void diagnostics(DCB *, 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 void disableMasterFailback(void *, int);
|
||||
bool isGaleraEvent(monitor_event_t event);
|
||||
static void update_sst_donor_nodes(MONITOR*, int);
|
||||
bool isGaleraEvent(mxs_monitor_event_t event);
|
||||
static void update_sst_donor_nodes(MXS_MONITOR*, int);
|
||||
|
||||
/**
|
||||
* The module entry point routine. It is this routine that
|
||||
@ -68,7 +68,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
||||
{
|
||||
MXS_NOTICE("Initialise the MySQL Galera Monitor module.");
|
||||
|
||||
static MONITOR_OBJECT MyObject =
|
||||
static MXS_MONITOR_OBJECT MyObject =
|
||||
{
|
||||
startMonitor,
|
||||
stopMonitor,
|
||||
@ -79,7 +79,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
||||
{
|
||||
MXS_MODULE_API_MONITOR,
|
||||
MXS_MODULE_GA,
|
||||
MONITOR_VERSION,
|
||||
MXS_MONITOR_VERSION,
|
||||
"A Galera cluster monitor",
|
||||
"V2.0.0",
|
||||
&MyObject,
|
||||
@ -102,9 +102,9 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
||||
{
|
||||
"events",
|
||||
MXS_MODULE_PARAM_ENUM,
|
||||
MONITOR_EVENT_DEFAULT_VALUE,
|
||||
MXS_MONITOR_EVENT_DEFAULT_VALUE,
|
||||
MXS_MODULE_OPT_NONE,
|
||||
monitor_event_enum_values
|
||||
mxs_monitor_event_enum_values
|
||||
},
|
||||
{"set_donor_nodes", MXS_MODULE_PARAM_BOOL, "false"},
|
||||
{MXS_END_MODULE_PARAMS}
|
||||
@ -122,7 +122,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
||||
* @return A handle to use when interacting with the monitor
|
||||
*/
|
||||
static void *
|
||||
startMonitor(MONITOR *mon, const CONFIG_PARAMETER *params)
|
||||
startMonitor(MXS_MONITOR *mon, const CONFIG_PARAMETER *params)
|
||||
{
|
||||
GALERA_MONITOR *handle = mon->handle;
|
||||
if (handle != NULL)
|
||||
@ -137,7 +137,7 @@ startMonitor(MONITOR *mon, const CONFIG_PARAMETER *params)
|
||||
return NULL;
|
||||
}
|
||||
handle->shutdown = 0;
|
||||
handle->id = MONITOR_DEFAULT_ID;
|
||||
handle->id = MXS_MONITOR_DEFAULT_ID;
|
||||
handle->master = NULL;
|
||||
spinlock_init(&handle->lock);
|
||||
}
|
||||
@ -148,7 +148,7 @@ startMonitor(MONITOR *mon, const CONFIG_PARAMETER *params)
|
||||
handle->root_node_as_master = config_get_bool(params, "root_node_as_master");
|
||||
handle->use_priority = config_get_bool(params, "use_priority");
|
||||
handle->script = config_copy_string(params, "script");
|
||||
handle->events = config_get_enum(params, "events", monitor_event_enum_values);
|
||||
handle->events = config_get_enum(params, "events", mxs_monitor_event_enum_values);
|
||||
handle->set_donor_nodes = config_get_bool(params, "set_donor_nodes");
|
||||
|
||||
/** SHOW STATUS doesn't require any special permissions */
|
||||
@ -174,7 +174,7 @@ startMonitor(MONITOR *mon, const CONFIG_PARAMETER *params)
|
||||
* @param arg Handle on thr running monior
|
||||
*/
|
||||
static void
|
||||
stopMonitor(MONITOR *mon)
|
||||
stopMonitor(MXS_MONITOR *mon)
|
||||
{
|
||||
GALERA_MONITOR *handle = (GALERA_MONITOR *) mon->handle;
|
||||
|
||||
@ -189,7 +189,7 @@ stopMonitor(MONITOR *mon)
|
||||
* @param arg The monitor handle
|
||||
*/
|
||||
static void
|
||||
diagnostics(DCB *dcb, const MONITOR *mon)
|
||||
diagnostics(DCB *dcb, const MXS_MONITOR *mon)
|
||||
{
|
||||
const GALERA_MONITOR *handle = (const GALERA_MONITOR *) mon->handle;
|
||||
|
||||
@ -209,7 +209,7 @@ diagnostics(DCB *dcb, const MONITOR *mon)
|
||||
* @param database The database to probe
|
||||
*/
|
||||
static void
|
||||
monitorDatabase(MONITOR *mon, MONITOR_SERVERS *database)
|
||||
monitorDatabase(MXS_MONITOR *mon, MXS_MONITOR_SERVERS *database)
|
||||
{
|
||||
GALERA_MONITOR* handle = (GALERA_MONITOR*) mon->handle;
|
||||
MYSQL_ROW row;
|
||||
@ -232,7 +232,7 @@ monitorDatabase(MONITOR *mon, MONITOR_SERVERS *database)
|
||||
/* Also clear Joined */
|
||||
server_clear_status_nolock(&temp_server, SERVER_JOINED);
|
||||
|
||||
connect_result_t rval = mon_connect_to_db(mon, database);
|
||||
mxs_connect_result_t rval = mon_connect_to_db(mon, database);
|
||||
if (rval != MONITOR_CONN_OK)
|
||||
{
|
||||
if (mysql_errno(database->con) == ER_ACCESS_DENIED_ERROR)
|
||||
@ -380,15 +380,15 @@ monitorDatabase(MONITOR *mon, MONITOR_SERVERS *database)
|
||||
static void
|
||||
monitorMain(void *arg)
|
||||
{
|
||||
MONITOR* mon = (MONITOR*) arg;
|
||||
MXS_MONITOR* mon = (MXS_MONITOR*) arg;
|
||||
GALERA_MONITOR *handle;
|
||||
MONITOR_SERVERS *ptr;
|
||||
MXS_MONITOR_SERVERS *ptr;
|
||||
size_t nrounds = 0;
|
||||
MONITOR_SERVERS *candidate_master = NULL;
|
||||
MXS_MONITOR_SERVERS *candidate_master = NULL;
|
||||
int master_stickiness;
|
||||
int is_cluster = 0;
|
||||
int log_no_members = 1;
|
||||
monitor_event_t evtype;
|
||||
mxs_monitor_event_t evtype;
|
||||
|
||||
spinlock_acquire(&mon->lock);
|
||||
handle = (GALERA_MONITOR *) mon->handle;
|
||||
@ -399,20 +399,20 @@ monitorMain(void *arg)
|
||||
MXS_ERROR("mysql_thread_init failed in monitor module. Exiting.");
|
||||
return;
|
||||
}
|
||||
handle->status = MONITOR_RUNNING;
|
||||
handle->status = MXS_MONITOR_RUNNING;
|
||||
|
||||
while (1)
|
||||
{
|
||||
if (handle->shutdown)
|
||||
{
|
||||
handle->status = MONITOR_STOPPING;
|
||||
handle->status = MXS_MONITOR_STOPPING;
|
||||
mysql_thread_end();
|
||||
handle->status = MONITOR_STOPPED;
|
||||
handle->status = MXS_MONITOR_STOPPED;
|
||||
return;
|
||||
}
|
||||
|
||||
/** Wait base interval */
|
||||
thread_millisleep(MON_BASE_INTERVAL_MS);
|
||||
thread_millisleep(MXS_MON_BASE_INTERVAL_MS);
|
||||
|
||||
/**
|
||||
* Calculate how far away the monitor interval is from its full
|
||||
@ -421,8 +421,8 @@ monitorMain(void *arg)
|
||||
* round.
|
||||
*/
|
||||
if (nrounds != 0 &&
|
||||
(((nrounds * MON_BASE_INTERVAL_MS) % mon->interval) >=
|
||||
MON_BASE_INTERVAL_MS) && (!mon->server_pending_changes))
|
||||
(((nrounds * MXS_MON_BASE_INTERVAL_MS) % mon->interval) >=
|
||||
MXS_MON_BASE_INTERVAL_MS) && (!mon->server_pending_changes))
|
||||
{
|
||||
nrounds += 1;
|
||||
continue;
|
||||
@ -562,10 +562,10 @@ monitorMain(void *arg)
|
||||
* @param servers The monitored servers list
|
||||
* @return The candidate master on success, NULL on failure
|
||||
*/
|
||||
static MONITOR_SERVERS *get_candidate_master(MONITOR* mon)
|
||||
static MXS_MONITOR_SERVERS *get_candidate_master(MXS_MONITOR* mon)
|
||||
{
|
||||
MONITOR_SERVERS *moitor_servers = mon->databases;
|
||||
MONITOR_SERVERS *candidate_master = NULL;
|
||||
MXS_MONITOR_SERVERS *moitor_servers = mon->databases;
|
||||
MXS_MONITOR_SERVERS *candidate_master = NULL;
|
||||
GALERA_MONITOR* handle = mon->handle;
|
||||
long min_id = -1;
|
||||
int minval = INT_MAX;
|
||||
@ -635,8 +635,9 @@ static MONITOR_SERVERS *get_candidate_master(MONITOR* mon)
|
||||
* @param candidate_master The candidate master server accordingly to the selection rule
|
||||
* @return The master node pointer (could be NULL)
|
||||
*/
|
||||
static MONITOR_SERVERS *set_cluster_master(MONITOR_SERVERS *current_master, MONITOR_SERVERS *candidate_master,
|
||||
int master_stickiness)
|
||||
static MXS_MONITOR_SERVERS *set_cluster_master(MXS_MONITOR_SERVERS *current_master,
|
||||
MXS_MONITOR_SERVERS *candidate_master,
|
||||
int master_stickiness)
|
||||
{
|
||||
/*
|
||||
* if current master is not set or master_stickiness is not enable
|
||||
@ -682,9 +683,9 @@ static MONITOR_SERVERS *set_cluster_master(MONITOR_SERVERS *current_master, MONI
|
||||
* @param mon The monitor handler
|
||||
* @param is_cluster The number of joined nodes
|
||||
*/
|
||||
static void update_sst_donor_nodes(MONITOR *mon, int is_cluster)
|
||||
static void update_sst_donor_nodes(MXS_MONITOR *mon, int is_cluster)
|
||||
{
|
||||
MONITOR_SERVERS *ptr;
|
||||
MXS_MONITOR_SERVERS *ptr;
|
||||
MYSQL_ROW row;
|
||||
MYSQL_RES *result;
|
||||
if (is_cluster == 1)
|
||||
|
@ -56,7 +56,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 */
|
||||
MONITOR_SERVERS *master; /**< Master server for MySQL Master/Slave replication */
|
||||
MXS_MONITOR_SERVERS *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 */
|
||||
|
@ -41,18 +41,18 @@ MXS_MODULE info =
|
||||
{
|
||||
MXS_MODULE_API_MONITOR,
|
||||
MXS_MODULE_BETA_RELEASE,
|
||||
MONITOR_VERSION,
|
||||
MXS_MONITOR_VERSION,
|
||||
"A Multi-Master Multi Master monitor",
|
||||
"V1.1.1"
|
||||
};
|
||||
/*lint +e14 */
|
||||
|
||||
static void *startMonitor(MONITOR *, const CONFIG_PARAMETER *);
|
||||
static void stopMonitor(MONITOR *);
|
||||
static void diagnostics(DCB *, const MONITOR *);
|
||||
static void *startMonitor(MXS_MONITOR *, const CONFIG_PARAMETER *);
|
||||
static void stopMonitor(MXS_MONITOR *);
|
||||
static void diagnostics(DCB *, const MXS_MONITOR *);
|
||||
static void detectStaleMaster(void *, int);
|
||||
static MONITOR_SERVERS *get_current_master(MONITOR *);
|
||||
static bool isMySQLEvent(monitor_event_t event);
|
||||
static MXS_MONITOR_SERVERS *get_current_master(MXS_MONITOR *);
|
||||
static bool isMySQLEvent(mxs_monitor_event_t event);
|
||||
|
||||
/**
|
||||
* The module entry point routine. It is this routine that
|
||||
@ -66,7 +66,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
||||
{
|
||||
MXS_NOTICE("Initialise the Multi-Master Monitor module.");
|
||||
|
||||
static MONITOR_OBJECT MyObject =
|
||||
static MXS_MONITOR_OBJECT MyObject =
|
||||
{
|
||||
startMonitor,
|
||||
stopMonitor,
|
||||
@ -77,7 +77,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
||||
{
|
||||
MXS_MODULE_API_MONITOR,
|
||||
MXS_MODULE_BETA_RELEASE,
|
||||
MONITOR_VERSION,
|
||||
MXS_MONITOR_VERSION,
|
||||
"A Multi-Master Multi Master monitor",
|
||||
"V1.1.1",
|
||||
&MyObject,
|
||||
@ -96,9 +96,9 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
||||
{
|
||||
"events",
|
||||
MXS_MODULE_PARAM_ENUM,
|
||||
MONITOR_EVENT_DEFAULT_VALUE,
|
||||
MXS_MONITOR_EVENT_DEFAULT_VALUE,
|
||||
MXS_MODULE_OPT_NONE,
|
||||
monitor_event_enum_values
|
||||
mxs_monitor_event_enum_values
|
||||
},
|
||||
{MXS_END_MODULE_PARAMS}
|
||||
}
|
||||
@ -117,7 +117,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
||||
* @return A handle to use when interacting with the monitor
|
||||
*/
|
||||
static void *
|
||||
startMonitor(MONITOR *mon, const CONFIG_PARAMETER *params)
|
||||
startMonitor(MXS_MONITOR *mon, const CONFIG_PARAMETER *params)
|
||||
{
|
||||
MM_MONITOR *handle = mon->handle;
|
||||
|
||||
@ -133,14 +133,14 @@ startMonitor(MONITOR *mon, const CONFIG_PARAMETER *params)
|
||||
return NULL;
|
||||
}
|
||||
handle->shutdown = 0;
|
||||
handle->id = MONITOR_DEFAULT_ID;
|
||||
handle->id = MXS_MONITOR_DEFAULT_ID;
|
||||
handle->master = NULL;
|
||||
spinlock_init(&handle->lock);
|
||||
}
|
||||
|
||||
handle->detectStaleMaster = config_get_bool(params, "detect_stale_master");
|
||||
handle->script = config_copy_string(params, "script");
|
||||
handle->events = config_get_enum(params, "events", monitor_event_enum_values);
|
||||
handle->events = config_get_enum(params, "events", mxs_monitor_event_enum_values);
|
||||
|
||||
if (!check_monitor_permissions(mon, "SHOW SLAVE STATUS"))
|
||||
{
|
||||
@ -164,7 +164,7 @@ startMonitor(MONITOR *mon, const CONFIG_PARAMETER *params)
|
||||
* @param arg Handle on thr running monior
|
||||
*/
|
||||
static void
|
||||
stopMonitor(MONITOR *mon)
|
||||
stopMonitor(MXS_MONITOR *mon)
|
||||
{
|
||||
MM_MONITOR *handle = (MM_MONITOR *) mon->handle;
|
||||
|
||||
@ -178,7 +178,7 @@ stopMonitor(MONITOR *mon)
|
||||
* @param dcb DCB to print diagnostics
|
||||
* @param arg The monitor handle
|
||||
*/
|
||||
static void diagnostics(DCB *dcb, const MONITOR *mon)
|
||||
static void diagnostics(DCB *dcb, const MXS_MONITOR *mon)
|
||||
{
|
||||
const MM_MONITOR *handle = (const MM_MONITOR *) mon->handle;
|
||||
|
||||
@ -192,7 +192,7 @@ static void diagnostics(DCB *dcb, const MONITOR *mon)
|
||||
* @param database The database to probe
|
||||
*/
|
||||
static void
|
||||
monitorDatabase(MONITOR* mon, MONITOR_SERVERS *database)
|
||||
monitorDatabase(MXS_MONITOR* mon, MXS_MONITOR_SERVERS *database)
|
||||
{
|
||||
MYSQL_ROW row;
|
||||
MYSQL_RES *result;
|
||||
@ -209,7 +209,7 @@ monitorDatabase(MONITOR* mon, MONITOR_SERVERS *database)
|
||||
|
||||
/** Store previous status */
|
||||
database->mon_prev_status = database->server->status;
|
||||
connect_result_t rval = mon_connect_to_db(mon, database);
|
||||
mxs_connect_result_t rval = mon_connect_to_db(mon, database);
|
||||
|
||||
if (rval != MONITOR_CONN_OK)
|
||||
{
|
||||
@ -475,11 +475,11 @@ monitorDatabase(MONITOR* mon, MONITOR_SERVERS *database)
|
||||
static void
|
||||
monitorMain(void *arg)
|
||||
{
|
||||
MONITOR* mon = (MONITOR*) arg;
|
||||
MXS_MONITOR* mon = (MXS_MONITOR*) arg;
|
||||
MM_MONITOR *handle;
|
||||
MONITOR_SERVERS *ptr;
|
||||
MXS_MONITOR_SERVERS *ptr;
|
||||
int detect_stale_master = false;
|
||||
MONITOR_SERVERS *root_master = NULL;
|
||||
MXS_MONITOR_SERVERS *root_master = NULL;
|
||||
size_t nrounds = 0;
|
||||
|
||||
spinlock_acquire(&mon->lock);
|
||||
@ -493,19 +493,19 @@ monitorMain(void *arg)
|
||||
return;
|
||||
}
|
||||
|
||||
handle->status = MONITOR_RUNNING;
|
||||
handle->status = MXS_MONITOR_RUNNING;
|
||||
while (1)
|
||||
{
|
||||
if (handle->shutdown)
|
||||
{
|
||||
handle->status = MONITOR_STOPPING;
|
||||
handle->status = MXS_MONITOR_STOPPING;
|
||||
mysql_thread_end();
|
||||
handle->status = MONITOR_STOPPED;
|
||||
handle->status = MXS_MONITOR_STOPPED;
|
||||
return;
|
||||
}
|
||||
|
||||
/** Wait base interval */
|
||||
thread_millisleep(MON_BASE_INTERVAL_MS);
|
||||
thread_millisleep(MXS_MON_BASE_INTERVAL_MS);
|
||||
/**
|
||||
* Calculate how far away the monitor interval is from its full
|
||||
* cycle and if monitor interval time further than the base
|
||||
@ -513,8 +513,8 @@ monitorMain(void *arg)
|
||||
* round.
|
||||
*/
|
||||
if (nrounds != 0 &&
|
||||
(((nrounds * MON_BASE_INTERVAL_MS) % mon->interval) >=
|
||||
MON_BASE_INTERVAL_MS) && (!mon->server_pending_changes))
|
||||
(((nrounds * MXS_MON_BASE_INTERVAL_MS) % mon->interval) >=
|
||||
MXS_MON_BASE_INTERVAL_MS) && (!mon->server_pending_changes))
|
||||
{
|
||||
nrounds += 1;
|
||||
continue;
|
||||
@ -628,10 +628,10 @@ detectStaleMaster(void *arg, int enable)
|
||||
* @return The server at root level with SERVER_MASTER bit
|
||||
*/
|
||||
|
||||
static MONITOR_SERVERS *get_current_master(MONITOR *mon)
|
||||
static MXS_MONITOR_SERVERS *get_current_master(MXS_MONITOR *mon)
|
||||
{
|
||||
MM_MONITOR* handle = mon->handle;
|
||||
MONITOR_SERVERS *ptr;
|
||||
MXS_MONITOR_SERVERS *ptr;
|
||||
|
||||
ptr = mon->databases;
|
||||
|
||||
|
@ -47,7 +47,7 @@ typedef struct
|
||||
int status; /**< Monitor status */
|
||||
unsigned long id; /**< Monitor ID */
|
||||
int detectStaleMaster; /**< Monitor flag for Stale Master detection */
|
||||
MONITOR_SERVERS *master; /**< Master server for Master/Slave replication */
|
||||
MXS_MONITOR_SERVERS *master; /**< Master server for Master/Slave replication */
|
||||
char* script; /*< Script to call when state changes occur on servers */
|
||||
uint64_t events; /*< enabled events */
|
||||
} MM_MONITOR;
|
||||
|
@ -71,7 +71,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 */
|
||||
MONITOR_SERVERS *master; /**< Master server for MySQL Master/Slave replication */
|
||||
MXS_MONITOR_SERVERS *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 */
|
||||
|
@ -74,17 +74,17 @@
|
||||
|
||||
static void monitorMain(void *);
|
||||
|
||||
static void *startMonitor(MONITOR *, const CONFIG_PARAMETER*);
|
||||
static void stopMonitor(MONITOR *);
|
||||
static void diagnostics(DCB *, const MONITOR *);
|
||||
static MONITOR_SERVERS *getServerByNodeId(MONITOR_SERVERS *, long);
|
||||
static MONITOR_SERVERS *getSlaveOfNodeId(MONITOR_SERVERS *, long);
|
||||
static MONITOR_SERVERS *get_replication_tree(MONITOR *, int);
|
||||
static void set_master_heartbeat(MYSQL_MONITOR *, MONITOR_SERVERS *);
|
||||
static void set_slave_heartbeat(MONITOR *, MONITOR_SERVERS *);
|
||||
static void *startMonitor(MXS_MONITOR *, const CONFIG_PARAMETER*);
|
||||
static void stopMonitor(MXS_MONITOR *);
|
||||
static void diagnostics(DCB *, 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 int add_slave_to_master(long *, int, long);
|
||||
static bool isMySQLEvent(monitor_event_t event);
|
||||
void check_maxscale_schema_replication(MONITOR *monitor);
|
||||
static bool isMySQLEvent(mxs_monitor_event_t event);
|
||||
void check_maxscale_schema_replication(MXS_MONITOR *monitor);
|
||||
static bool report_version_err = true;
|
||||
static const char* hb_table_name = "maxscale_schema.replication_heartbeat";
|
||||
|
||||
@ -100,7 +100,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
||||
{
|
||||
MXS_NOTICE("Initialise the MySQL Monitor module.");
|
||||
|
||||
static MONITOR_OBJECT MyObject =
|
||||
static MXS_MONITOR_OBJECT MyObject =
|
||||
{
|
||||
startMonitor,
|
||||
stopMonitor,
|
||||
@ -111,7 +111,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
||||
{
|
||||
MXS_MODULE_API_MONITOR,
|
||||
MXS_MODULE_GA,
|
||||
MONITOR_VERSION,
|
||||
MXS_MONITOR_VERSION,
|
||||
"A MySQL Master/Slave replication monitor",
|
||||
"V1.5.0",
|
||||
&MyObject,
|
||||
@ -136,9 +136,9 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
||||
{
|
||||
"events",
|
||||
MXS_MODULE_PARAM_ENUM,
|
||||
MONITOR_EVENT_DEFAULT_VALUE,
|
||||
MXS_MONITOR_EVENT_DEFAULT_VALUE,
|
||||
MXS_MODULE_OPT_NONE,
|
||||
monitor_event_enum_values
|
||||
mxs_monitor_event_enum_values
|
||||
},
|
||||
{MXS_END_MODULE_PARAMS}
|
||||
}
|
||||
@ -207,7 +207,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, MONITOR_SERVERS *database)
|
||||
bool init_server_info(MYSQL_MONITOR *handle, MXS_MONITOR_SERVERS *database)
|
||||
{
|
||||
MYSQL_SERVER_INFO info = MYSQL_SERVER_INFO_INIT;
|
||||
bool rval = true;
|
||||
@ -241,7 +241,7 @@ bool init_server_info(MYSQL_MONITOR *handle, MONITOR_SERVERS *database)
|
||||
* @return A handle to use when interacting with the monitor
|
||||
*/
|
||||
static void *
|
||||
startMonitor(MONITOR *monitor, const CONFIG_PARAMETER* params)
|
||||
startMonitor(MXS_MONITOR *monitor, const CONFIG_PARAMETER* params)
|
||||
{
|
||||
MYSQL_MONITOR *handle = (MYSQL_MONITOR*) monitor->handle;
|
||||
|
||||
@ -282,7 +282,7 @@ startMonitor(MONITOR *monitor, const CONFIG_PARAMETER* params)
|
||||
handle->failcount = config_get_integer(params, "failcount");
|
||||
handle->mysql51_replication = config_get_bool(params, "mysql51_replication");
|
||||
handle->script = config_copy_string(params, "script");
|
||||
handle->events = config_get_enum(params, "events", monitor_event_enum_values);
|
||||
handle->events = config_get_enum(params, "events", mxs_monitor_event_enum_values);
|
||||
|
||||
bool error = false;
|
||||
|
||||
@ -318,7 +318,7 @@ startMonitor(MONITOR *monitor, const CONFIG_PARAMETER* params)
|
||||
* @param arg Handle on thr running monior
|
||||
*/
|
||||
static void
|
||||
stopMonitor(MONITOR *mon)
|
||||
stopMonitor(MXS_MONITOR *mon)
|
||||
{
|
||||
MYSQL_MONITOR *handle = (MYSQL_MONITOR *) mon->handle;
|
||||
|
||||
@ -332,7 +332,7 @@ stopMonitor(MONITOR *mon)
|
||||
* @param dcb DCB to print diagnostics
|
||||
* @param arg The monitor handle
|
||||
*/
|
||||
static void diagnostics(DCB *dcb, const MONITOR *mon)
|
||||
static void diagnostics(DCB *dcb, const MXS_MONITOR *mon)
|
||||
{
|
||||
const MYSQL_MONITOR *handle = (const MYSQL_MONITOR *)mon->handle;
|
||||
|
||||
@ -341,7 +341,7 @@ static void diagnostics(DCB *dcb, const MONITOR *mon)
|
||||
dcb_printf(dcb, "Detect Stale Master:\t%s\n", (handle->detectStaleMaster == 1) ? "enabled" : "disabled");
|
||||
dcb_printf(dcb, "Server information\n\n");
|
||||
|
||||
for (MONITOR_SERVERS *db = mon->databases; db; db = db->next)
|
||||
for (MXS_MONITOR_SERVERS *db = mon->databases; db; db = db->next)
|
||||
{
|
||||
MYSQL_SERVER_INFO *serv_info = hashtable_fetch(handle->server_info, db->server->unique_name);
|
||||
dcb_printf(dcb, "Server: %s\n", db->server->unique_name);
|
||||
@ -370,7 +370,7 @@ enum mysql_server_version
|
||||
MYSQL_SERVER_VERSION_51
|
||||
};
|
||||
|
||||
static inline void monitor_mysql_db(MONITOR_SERVERS* database, MYSQL_SERVER_INFO *serv_info,
|
||||
static inline void monitor_mysql_db(MXS_MONITOR_SERVERS* database, MYSQL_SERVER_INFO *serv_info,
|
||||
enum mysql_server_version server_version)
|
||||
{
|
||||
int columns, i_io_thread, i_sql_thread, i_binlog_pos, i_master_id, i_binlog_name;
|
||||
@ -500,10 +500,10 @@ static inline void monitor_mysql_db(MONITOR_SERVERS* database, MYSQL_SERVER_INFO
|
||||
* @param mon Monitor
|
||||
* @return Lowest server ID master in the monitor
|
||||
*/
|
||||
static MONITOR_SERVERS *build_mysql51_replication_tree(MONITOR *mon)
|
||||
static MXS_MONITOR_SERVERS *build_mysql51_replication_tree(MXS_MONITOR *mon)
|
||||
{
|
||||
MONITOR_SERVERS* database = mon->databases;
|
||||
MONITOR_SERVERS *ptr, *rval = NULL;
|
||||
MXS_MONITOR_SERVERS* database = mon->databases;
|
||||
MXS_MONITOR_SERVERS *ptr, *rval = NULL;
|
||||
int i;
|
||||
while (database)
|
||||
{
|
||||
@ -594,7 +594,7 @@ static MONITOR_SERVERS *build_mysql51_replication_tree(MONITOR *mon)
|
||||
* @param database The database to probe
|
||||
*/
|
||||
static void
|
||||
monitorDatabase(MONITOR *mon, MONITOR_SERVERS *database)
|
||||
monitorDatabase(MXS_MONITOR *mon, MXS_MONITOR_SERVERS *database)
|
||||
{
|
||||
MYSQL_MONITOR* handle = mon->handle;
|
||||
MYSQL_ROW row;
|
||||
@ -613,7 +613,7 @@ monitorDatabase(MONITOR *mon, MONITOR_SERVERS *database)
|
||||
|
||||
if (database->con == NULL || mysql_ping(database->con) != 0)
|
||||
{
|
||||
connect_result_t rval;
|
||||
mxs_connect_result_t rval;
|
||||
if ((rval = mon_connect_to_db(mon, database)) == MONITOR_CONN_OK)
|
||||
{
|
||||
server_clear_status_nolock(database->server, SERVER_AUTH_ERROR);
|
||||
@ -743,7 +743,7 @@ struct graph_node
|
||||
bool active;
|
||||
struct graph_node *parent;
|
||||
MYSQL_SERVER_INFO *info;
|
||||
MONITOR_SERVERS *db;
|
||||
MXS_MONITOR_SERVERS *db;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -853,13 +853,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, MONITOR_SERVERS *database, int nservers)
|
||||
void find_graph_cycles(MYSQL_MONITOR *handle, MXS_MONITOR_SERVERS *database, int nservers)
|
||||
{
|
||||
struct graph_node graph[nservers];
|
||||
struct graph_node *stack[nservers];
|
||||
int nodes = 0;
|
||||
|
||||
for (MONITOR_SERVERS *db = database; db; db = db->next)
|
||||
for (MXS_MONITOR_SERVERS *db = database; db; db = db->next)
|
||||
{
|
||||
graph[nodes].info = hashtable_fetch(handle->server_info, db->server->unique_name);
|
||||
graph[nodes].db = db;
|
||||
@ -960,7 +960,7 @@ void find_graph_cycles(MYSQL_MONITOR *handle, MONITOR_SERVERS *database, int nse
|
||||
*
|
||||
* @return True if failover is required
|
||||
*/
|
||||
bool failover_required(MYSQL_MONITOR *handle, MONITOR_SERVERS *db)
|
||||
bool failover_required(MYSQL_MONITOR *handle, MXS_MONITOR_SERVERS *db)
|
||||
{
|
||||
int candidates = 0;
|
||||
|
||||
@ -998,7 +998,7 @@ bool failover_required(MYSQL_MONITOR *handle, MONITOR_SERVERS *db)
|
||||
* @param handle Monitor instance
|
||||
* @param db Monitor servers
|
||||
*/
|
||||
void do_failover(MYSQL_MONITOR *handle, MONITOR_SERVERS *db)
|
||||
void do_failover(MYSQL_MONITOR *handle, MXS_MONITOR_SERVERS *db)
|
||||
{
|
||||
while (db)
|
||||
{
|
||||
@ -1033,13 +1033,13 @@ void do_failover(MYSQL_MONITOR *handle, MONITOR_SERVERS *db)
|
||||
static void
|
||||
monitorMain(void *arg)
|
||||
{
|
||||
MONITOR* mon = (MONITOR*) arg;
|
||||
MXS_MONITOR* mon = (MXS_MONITOR*) arg;
|
||||
MYSQL_MONITOR *handle;
|
||||
MONITOR_SERVERS *ptr;
|
||||
MXS_MONITOR_SERVERS *ptr;
|
||||
int replication_heartbeat;
|
||||
bool detect_stale_master;
|
||||
int num_servers = 0;
|
||||
MONITOR_SERVERS *root_master = NULL;
|
||||
MXS_MONITOR_SERVERS *root_master = NULL;
|
||||
size_t nrounds = 0;
|
||||
int log_no_master = 1;
|
||||
bool heartbeat_checked = false;
|
||||
@ -1055,19 +1055,19 @@ monitorMain(void *arg)
|
||||
MXS_ERROR("mysql_thread_init failed in monitor module. Exiting.");
|
||||
return;
|
||||
}
|
||||
handle->status = MONITOR_RUNNING;
|
||||
handle->status = MXS_MONITOR_RUNNING;
|
||||
|
||||
while (1)
|
||||
{
|
||||
if (handle->shutdown)
|
||||
{
|
||||
handle->status = MONITOR_STOPPING;
|
||||
handle->status = MXS_MONITOR_STOPPING;
|
||||
mysql_thread_end();
|
||||
handle->status = MONITOR_STOPPED;
|
||||
handle->status = MXS_MONITOR_STOPPED;
|
||||
return;
|
||||
}
|
||||
/** Wait base interval */
|
||||
thread_millisleep(MON_BASE_INTERVAL_MS);
|
||||
thread_millisleep(MXS_MON_BASE_INTERVAL_MS);
|
||||
|
||||
if (handle->replicationHeartbeat && !heartbeat_checked)
|
||||
{
|
||||
@ -1082,8 +1082,8 @@ monitorMain(void *arg)
|
||||
* round.
|
||||
*/
|
||||
if (nrounds != 0 &&
|
||||
(((nrounds * MON_BASE_INTERVAL_MS) % mon->interval) >=
|
||||
MON_BASE_INTERVAL_MS) && (!mon->server_pending_changes))
|
||||
(((nrounds * MXS_MON_BASE_INTERVAL_MS) % mon->interval) >=
|
||||
MXS_MON_BASE_INTERVAL_MS) && (!mon->server_pending_changes))
|
||||
{
|
||||
nrounds += 1;
|
||||
continue;
|
||||
@ -1383,8 +1383,8 @@ monitorMain(void *arg)
|
||||
* @param node_id The MySQL server_id to fetch
|
||||
* @return The server with the required server_id
|
||||
*/
|
||||
static MONITOR_SERVERS *
|
||||
getServerByNodeId(MONITOR_SERVERS *ptr, long node_id)
|
||||
static MXS_MONITOR_SERVERS *
|
||||
getServerByNodeId(MXS_MONITOR_SERVERS *ptr, long node_id)
|
||||
{
|
||||
SERVER *current;
|
||||
while (ptr)
|
||||
@ -1406,8 +1406,8 @@ getServerByNodeId(MONITOR_SERVERS *ptr, long node_id)
|
||||
* @param node_id The MySQL server_id to fetch
|
||||
* @return The slave server of this node_id
|
||||
*/
|
||||
static MONITOR_SERVERS *
|
||||
getSlaveOfNodeId(MONITOR_SERVERS *ptr, long node_id)
|
||||
static MXS_MONITOR_SERVERS *
|
||||
getSlaveOfNodeId(MXS_MONITOR_SERVERS *ptr, long node_id)
|
||||
{
|
||||
SERVER *current;
|
||||
while (ptr)
|
||||
@ -1430,7 +1430,7 @@ getSlaveOfNodeId(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, MONITOR_SERVERS *database)
|
||||
static void set_master_heartbeat(MYSQL_MONITOR *handle, MXS_MONITOR_SERVERS *database)
|
||||
{
|
||||
unsigned long id = handle->id;
|
||||
time_t heartbeat;
|
||||
@ -1565,7 +1565,7 @@ static void set_master_heartbeat(MYSQL_MONITOR *handle, MONITOR_SERVERS *databas
|
||||
* @param handle The monitor handle
|
||||
* @param database The number database server
|
||||
*/
|
||||
static void set_slave_heartbeat(MONITOR* mon, MONITOR_SERVERS *database)
|
||||
static void set_slave_heartbeat(MXS_MONITOR* mon, MXS_MONITOR_SERVERS *database)
|
||||
{
|
||||
MYSQL_MONITOR *handle = (MYSQL_MONITOR*) mon->handle;
|
||||
unsigned long id = handle->id;
|
||||
@ -1676,11 +1676,11 @@ static void set_slave_heartbeat(MONITOR* mon, MONITOR_SERVERS *database)
|
||||
* @return The server at root level with SERVER_MASTER bit
|
||||
*/
|
||||
|
||||
static MONITOR_SERVERS *get_replication_tree(MONITOR *mon, int num_servers)
|
||||
static MXS_MONITOR_SERVERS *get_replication_tree(MXS_MONITOR *mon, int num_servers)
|
||||
{
|
||||
MYSQL_MONITOR* handle = (MYSQL_MONITOR*) mon->handle;
|
||||
MONITOR_SERVERS *ptr;
|
||||
MONITOR_SERVERS *backend;
|
||||
MXS_MONITOR_SERVERS *ptr;
|
||||
MXS_MONITOR_SERVERS *backend;
|
||||
SERVER *current;
|
||||
int depth = 0;
|
||||
long node_id;
|
||||
@ -1706,7 +1706,7 @@ static MONITOR_SERVERS *get_replication_tree(MONITOR *mon, int num_servers)
|
||||
node_id = current->master_id;
|
||||
if (node_id < 1)
|
||||
{
|
||||
MONITOR_SERVERS *find_slave;
|
||||
MXS_MONITOR_SERVERS *find_slave;
|
||||
find_slave = getSlaveOfNodeId(mon->databases, current->node_id);
|
||||
|
||||
if (find_slave == NULL)
|
||||
@ -1753,7 +1753,7 @@ static MONITOR_SERVERS *get_replication_tree(MONITOR *mon, int num_servers)
|
||||
}
|
||||
else
|
||||
{
|
||||
MONITOR_SERVERS *master;
|
||||
MXS_MONITOR_SERVERS *master;
|
||||
current->depth = depth;
|
||||
|
||||
master = getServerByNodeId(mon->databases, current->master_id);
|
||||
@ -1849,7 +1849,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(MONITOR_SERVERS* database)
|
||||
bool check_replicate_ignore_table(MXS_MONITOR_SERVERS* database)
|
||||
{
|
||||
MYSQL_RES *result;
|
||||
bool rval = true;
|
||||
@ -1893,7 +1893,7 @@ bool check_replicate_ignore_table(MONITOR_SERVERS* database)
|
||||
* @return False if the table is not replicated or an error occurred when querying
|
||||
* the server
|
||||
*/
|
||||
bool check_replicate_do_table(MONITOR_SERVERS* database)
|
||||
bool check_replicate_do_table(MXS_MONITOR_SERVERS* database)
|
||||
{
|
||||
MYSQL_RES *result;
|
||||
bool rval = true;
|
||||
@ -1936,7 +1936,7 @@ bool check_replicate_do_table(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(MONITOR_SERVERS* database)
|
||||
bool check_replicate_wild_do_table(MXS_MONITOR_SERVERS* database)
|
||||
{
|
||||
MYSQL_RES *result;
|
||||
bool rval = true;
|
||||
@ -1983,7 +1983,7 @@ bool check_replicate_wild_do_table(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(MONITOR_SERVERS* database)
|
||||
bool check_replicate_wild_ignore_table(MXS_MONITOR_SERVERS* database)
|
||||
{
|
||||
MYSQL_RES *result;
|
||||
bool rval = true;
|
||||
@ -2028,14 +2028,14 @@ bool check_replicate_wild_ignore_table(MONITOR_SERVERS* database)
|
||||
* servers and log a warning if problems were found.
|
||||
* @param monitor Monitor structure
|
||||
*/
|
||||
void check_maxscale_schema_replication(MONITOR *monitor)
|
||||
void check_maxscale_schema_replication(MXS_MONITOR *monitor)
|
||||
{
|
||||
MONITOR_SERVERS* database = monitor->databases;
|
||||
MXS_MONITOR_SERVERS* database = monitor->databases;
|
||||
bool err = false;
|
||||
|
||||
while (database)
|
||||
{
|
||||
connect_result_t rval = mon_connect_to_db(monitor, database);
|
||||
mxs_connect_result_t rval = mon_connect_to_db(monitor, database);
|
||||
if (rval == MONITOR_CONN_OK)
|
||||
{
|
||||
if (!check_replicate_ignore_table(database) ||
|
||||
|
@ -39,10 +39,10 @@ static void monitorMain(void *);
|
||||
|
||||
/*lint +e14 */
|
||||
|
||||
static void *startMonitor(MONITOR *, const CONFIG_PARAMETER *params);
|
||||
static void stopMonitor(MONITOR *);
|
||||
static void diagnostics(DCB *, const MONITOR *);
|
||||
bool isNdbEvent(monitor_event_t event);
|
||||
static void *startMonitor(MXS_MONITOR *, const CONFIG_PARAMETER *params);
|
||||
static void stopMonitor(MXS_MONITOR *);
|
||||
static void diagnostics(DCB *, const MXS_MONITOR *);
|
||||
bool isNdbEvent(mxs_monitor_event_t event);
|
||||
|
||||
|
||||
|
||||
@ -58,7 +58,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
||||
{
|
||||
MXS_NOTICE("Initialise the MySQL Cluster Monitor module.");
|
||||
|
||||
static MONITOR_OBJECT MyObject =
|
||||
static MXS_MONITOR_OBJECT MyObject =
|
||||
{
|
||||
startMonitor,
|
||||
stopMonitor,
|
||||
@ -69,7 +69,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
||||
{
|
||||
MXS_MODULE_API_MONITOR,
|
||||
MXS_MODULE_BETA_RELEASE,
|
||||
MONITOR_VERSION,
|
||||
MXS_MONITOR_VERSION,
|
||||
"A MySQL cluster SQL node monitor",
|
||||
"V2.1.0",
|
||||
&MyObject,
|
||||
@ -87,9 +87,9 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
||||
{
|
||||
"events",
|
||||
MXS_MODULE_PARAM_ENUM,
|
||||
MONITOR_EVENT_DEFAULT_VALUE,
|
||||
MXS_MONITOR_EVENT_DEFAULT_VALUE,
|
||||
MXS_MODULE_OPT_NONE,
|
||||
monitor_event_enum_values
|
||||
mxs_monitor_event_enum_values
|
||||
},
|
||||
{MXS_END_MODULE_PARAMS} // No parameters
|
||||
}
|
||||
@ -107,7 +107,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
||||
* @return A handle to use when interacting with the monitor
|
||||
*/
|
||||
static void *
|
||||
startMonitor(MONITOR *mon, const CONFIG_PARAMETER *params)
|
||||
startMonitor(MXS_MONITOR *mon, const CONFIG_PARAMETER *params)
|
||||
{
|
||||
MYSQL_MONITOR *handle = mon->handle;
|
||||
bool have_events = false, script_error = false;
|
||||
@ -124,13 +124,13 @@ startMonitor(MONITOR *mon, const CONFIG_PARAMETER *params)
|
||||
return NULL;
|
||||
}
|
||||
handle->shutdown = 0;
|
||||
handle->id = MONITOR_DEFAULT_ID;
|
||||
handle->id = MXS_MONITOR_DEFAULT_ID;
|
||||
handle->master = NULL;
|
||||
spinlock_init(&handle->lock);
|
||||
}
|
||||
|
||||
handle->script = config_copy_string(params, "script");
|
||||
handle->events = config_get_enum(params, "events", monitor_event_enum_values);
|
||||
handle->events = config_get_enum(params, "events", mxs_monitor_event_enum_values);
|
||||
|
||||
/** SHOW STATUS doesn't require any special permissions */
|
||||
if (!check_monitor_permissions(mon, "SHOW STATUS LIKE 'Ndb_number_of_ready_data_nodes'"))
|
||||
@ -155,7 +155,7 @@ startMonitor(MONITOR *mon, const CONFIG_PARAMETER *params)
|
||||
* @param arg Handle on thr running monior
|
||||
*/
|
||||
static void
|
||||
stopMonitor(MONITOR *mon)
|
||||
stopMonitor(MXS_MONITOR *mon)
|
||||
{
|
||||
MYSQL_MONITOR *handle = (MYSQL_MONITOR *) mon->handle;
|
||||
|
||||
@ -170,7 +170,7 @@ stopMonitor(MONITOR *mon)
|
||||
* @param arg The monitor handle
|
||||
*/
|
||||
static void
|
||||
diagnostics(DCB *dcb, const MONITOR *mon)
|
||||
diagnostics(DCB *dcb, const MXS_MONITOR *mon)
|
||||
{
|
||||
}
|
||||
|
||||
@ -180,7 +180,7 @@ diagnostics(DCB *dcb, const MONITOR *mon)
|
||||
* @param database The database to probe
|
||||
*/
|
||||
static void
|
||||
monitorDatabase(MONITOR_SERVERS *database, char *defaultUser, char *defaultPasswd, MONITOR *mon)
|
||||
monitorDatabase(MXS_MONITOR_SERVERS *database, char *defaultUser, char *defaultPasswd, MXS_MONITOR *mon)
|
||||
{
|
||||
MYSQL_ROW row;
|
||||
MYSQL_RES *result;
|
||||
@ -193,7 +193,7 @@ monitorDatabase(MONITOR_SERVERS *database, char *defaultUser, char *defaultPassw
|
||||
return;
|
||||
}
|
||||
|
||||
connect_result_t rval = mon_connect_to_db(mon, database);
|
||||
mxs_connect_result_t rval = mon_connect_to_db(mon, database);
|
||||
if (rval != MONITOR_CONN_OK)
|
||||
{
|
||||
server_clear_status_nolock(database->server, SERVER_RUNNING);
|
||||
@ -293,9 +293,9 @@ monitorDatabase(MONITOR_SERVERS *database, char *defaultUser, char *defaultPassw
|
||||
static void
|
||||
monitorMain(void *arg)
|
||||
{
|
||||
MONITOR* mon = arg;
|
||||
MXS_MONITOR* mon = arg;
|
||||
MYSQL_MONITOR *handle;
|
||||
MONITOR_SERVERS *ptr;
|
||||
MXS_MONITOR_SERVERS *ptr;
|
||||
size_t nrounds = 0;
|
||||
|
||||
spinlock_acquire(&mon->lock);
|
||||
@ -307,20 +307,20 @@ monitorMain(void *arg)
|
||||
MXS_ERROR("Fatal : mysql_thread_init failed in monitor module. Exiting.");
|
||||
return;
|
||||
}
|
||||
handle->status = MONITOR_RUNNING;
|
||||
handle->status = MXS_MONITOR_RUNNING;
|
||||
|
||||
while (1)
|
||||
{
|
||||
if (handle->shutdown)
|
||||
{
|
||||
handle->status = MONITOR_STOPPING;
|
||||
handle->status = MXS_MONITOR_STOPPING;
|
||||
mysql_thread_end();
|
||||
handle->status = MONITOR_STOPPED;
|
||||
handle->status = MXS_MONITOR_STOPPED;
|
||||
return;
|
||||
}
|
||||
|
||||
/** Wait base interval */
|
||||
thread_millisleep(MON_BASE_INTERVAL_MS);
|
||||
thread_millisleep(MXS_MON_BASE_INTERVAL_MS);
|
||||
/**
|
||||
* Calculate how far away the monitor interval is from its full
|
||||
* cycle and if monitor interval time further than the base
|
||||
@ -328,8 +328,8 @@ monitorMain(void *arg)
|
||||
* round.
|
||||
*/
|
||||
if (nrounds != 0 &&
|
||||
((nrounds * MON_BASE_INTERVAL_MS) % mon->interval) >=
|
||||
MON_BASE_INTERVAL_MS)
|
||||
((nrounds * MXS_MON_BASE_INTERVAL_MS) % mon->interval) >=
|
||||
MXS_MON_BASE_INTERVAL_MS)
|
||||
{
|
||||
nrounds += 1;
|
||||
continue;
|
||||
|
@ -426,7 +426,7 @@ static void shutdown_server()
|
||||
}
|
||||
|
||||
static void shutdown_service(DCB *dcb, SERVICE *service);
|
||||
static void shutdown_monitor(DCB *dcb, MONITOR *monitor);
|
||||
static void shutdown_monitor(DCB *dcb, MXS_MONITOR *monitor);
|
||||
|
||||
static void
|
||||
shutdown_listener(DCB *dcb, SERVICE *service, const char *name)
|
||||
@ -512,7 +512,7 @@ struct subcommand syncoptions[] =
|
||||
};
|
||||
|
||||
static void restart_service(DCB *dcb, SERVICE *service);
|
||||
static void restart_monitor(DCB *dcb, MONITOR *monitor);
|
||||
static void restart_monitor(DCB *dcb, MXS_MONITOR *monitor);
|
||||
|
||||
static void
|
||||
restart_listener(DCB *dcb, SERVICE *service, const char *name)
|
||||
@ -1183,7 +1183,7 @@ static void destroyListener(DCB *dcb, SERVICE *service, const char *name)
|
||||
}
|
||||
|
||||
|
||||
static void destroyMonitor(DCB *dcb, MONITOR *monitor)
|
||||
static void destroyMonitor(DCB *dcb, MXS_MONITOR *monitor)
|
||||
{
|
||||
char name[strlen(monitor->name) + 1];
|
||||
strcpy(name, monitor->name);
|
||||
@ -1312,9 +1312,9 @@ static void alterServer(DCB *dcb, SERVER *server, char *v1, char *v2, char *v3,
|
||||
}
|
||||
}
|
||||
|
||||
static void alterMonitor(DCB *dcb, MONITOR *monitor, char *v1, char *v2, char *v3,
|
||||
char *v4, char *v5, char *v6, char *v7, char *v8, char *v9,
|
||||
char *v10, char *v11)
|
||||
static void alterMonitor(DCB *dcb, MXS_MONITOR *monitor, char *v1, char *v2, char *v3,
|
||||
char *v4, char *v5, char *v6, char *v7, char *v8, char *v9,
|
||||
char *v10, char *v11)
|
||||
{
|
||||
char *values[11] = {v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11};
|
||||
const int items = sizeof(values) / sizeof(values[0]);
|
||||
@ -2056,7 +2056,7 @@ show_log_throttling(DCB *dcb)
|
||||
* @param monitor The monitor to shutdown
|
||||
*/
|
||||
static void
|
||||
shutdown_monitor(DCB *dcb, MONITOR *monitor)
|
||||
shutdown_monitor(DCB *dcb, MXS_MONITOR *monitor)
|
||||
{
|
||||
monitorStop(monitor);
|
||||
}
|
||||
@ -2068,7 +2068,7 @@ shutdown_monitor(DCB *dcb, MONITOR *monitor)
|
||||
* @param monitor The monitor to restart
|
||||
*/
|
||||
static void
|
||||
restart_monitor(DCB *dcb, MONITOR *monitor)
|
||||
restart_monitor(DCB *dcb, MXS_MONITOR *monitor)
|
||||
{
|
||||
monitorStart(monitor, monitor->parameters);
|
||||
}
|
||||
|
@ -550,7 +550,7 @@ void exec_shutdown_monitor(DCB *dcb, MAXINFO_TREE *tree)
|
||||
char errmsg[120];
|
||||
if (tree && tree->value)
|
||||
{
|
||||
MONITOR* monitor = monitor_find(tree->value);
|
||||
MXS_MONITOR* monitor = monitor_find(tree->value);
|
||||
if (monitor)
|
||||
{
|
||||
monitorStop(monitor);
|
||||
@ -660,7 +660,7 @@ void exec_restart_monitor(DCB *dcb, MAXINFO_TREE *tree)
|
||||
char errmsg[120];
|
||||
if (tree && tree->value)
|
||||
{
|
||||
MONITOR* monitor = monitor_find(tree->value);
|
||||
MXS_MONITOR* monitor = monitor_find(tree->value);
|
||||
if (monitor)
|
||||
{
|
||||
monitorStart(monitor, monitor->parameters);
|
||||
|
Reference in New Issue
Block a user