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:
Esa Korhonen 2017-01-17 13:10:02 +02:00
parent 20034b6fd6
commit 680401cf8e
17 changed files with 321 additions and 321 deletions

View File

@ -117,7 +117,7 @@ bool runtime_enable_server_ssl(SERVER *server, const char *key, const char *cert
* @param value New value
* @return True if @c key was one of the supported parameters
*/
bool runtime_alter_monitor(MONITOR *monitor, char *key, char *value);
bool runtime_alter_monitor(MXS_MONITOR *monitor, char *key, char *value);
/**
* @brief Create a new listener for a service
@ -176,4 +176,4 @@ bool runtime_create_monitor(const char *name, const char *module);
* @param monitor Monitor to destroy
* @return True if monitor was destroyed
*/
bool runtime_destroy_monitor(MONITOR *monitor);
bool runtime_destroy_monitor(MXS_MONITOR *monitor);

View File

@ -85,13 +85,13 @@ struct arg_node
modulecmd_arg_type_t type;
union
{
char *string;
bool boolean;
char *string;
bool boolean;
SERVICE *service;
SERVER *server;
SESSION *session;
DCB *dcb;
MONITOR *monitor;
MXS_MONITOR *monitor;
MXS_FILTER_DEF *filter;
} value;
};

View File

@ -61,28 +61,27 @@ MXS_BEGIN_DECLS
* The return from startMonitor is a void * handle that will be passed to all other monitor
* API calls.
*
* stopMonitor is responsible for shuting down and destroying a monitor, it is called
* with the void * handle that was returned by startMonitor.
* stopMonitor is responsible for shutting down and destroying a monitor.
*/
struct monitor;
typedef struct monitor MONITOR;
struct mxs_monitor;
typedef struct mxs_monitor MXS_MONITOR;
typedef struct
{
void *(*startMonitor)(MONITOR *monitor, const CONFIG_PARAMETER *params);
void (*stopMonitor)(MONITOR *monitor);
void (*diagnostics)(DCB *, const MONITOR *);
} MONITOR_OBJECT;
void *(*startMonitor)(MXS_MONITOR *monitor, const CONFIG_PARAMETER *params);
void (*stopMonitor)(MXS_MONITOR *monitor);
void (*diagnostics)(DCB *, const MXS_MONITOR *);
} MXS_MONITOR_OBJECT;
/**
* The monitor API version number. Any change to the monitor module API
* must change these versions usign the rules defined in modinfo.h
* must change these versions using the rules defined in modinfo.h
*/
#define MONITOR_VERSION {3, 0, 0}
#define MXS_MONITOR_VERSION {3, 0, 0}
/** Monitor's poll frequency */
#define MON_BASE_INTERVAL_MS 100
#define MXS_MON_BASE_INTERVAL_MS 100
/**
* Monitor state bit mask values
@ -114,7 +113,7 @@ typedef enum
MONITOR_CONN_OK,
MONITOR_CONN_REFUSED,
MONITOR_CONN_TIMEOUT
} connect_result_t;
} mxs_connect_result_t;
#define MON_ARG_MAX 8192
@ -123,12 +122,12 @@ typedef enum
#define DEFAULT_WRITE_TIMEOUT 2
#define MONITOR_RUNNING 1
#define MONITOR_STOPPING 2
#define MONITOR_STOPPED 3
#define MXS_MONITOR_RUNNING 1
#define MXS_MONITOR_STOPPING 2
#define MXS_MONITOR_STOPPED 3
#define MONITOR_INTERVAL 10000 // in milliseconds
#define MONITOR_DEFAULT_ID 1UL // unsigned long value
#define MONITOR_DEFAULT_INTERVAL 10000 // in milliseconds
#define MXS_MONITOR_DEFAULT_ID 1UL // unsigned long value
#define MAX_MONITOR_USER_LEN 512
#define MAX_MONITOR_PASSWORD_LEN 512
@ -159,9 +158,9 @@ typedef enum
NEW_SYNCED_EVENT = (1 << 19), /**< new_synced */
NEW_DONOR_EVENT = (1 << 20), /**< new_donor */
NEW_NDB_EVENT = (1 << 21), /**< new_ndb */
} monitor_event_t;
} mxs_monitor_event_t;
static const MXS_ENUM_VALUE monitor_event_enum_values[] =
static const MXS_ENUM_VALUE mxs_monitor_event_enum_values[] =
{
{"master_down", MASTER_DOWN_EVENT},
{"master_up", MASTER_UP_EVENT},
@ -189,10 +188,10 @@ static const MXS_ENUM_VALUE monitor_event_enum_values[] =
};
/** Default value for the `events` parameter */
static const char MONITOR_EVENT_DEFAULT_VALUE[] = "master_down,master_up,slave_down,"
"slave_up,server_down,server_up,synced_down,synced_up,donor_down,donor_up,"
"ndb_down,ndb_up,lost_master,lost_slave,lost_synced,lost_donor,lost_ndb,"
"new_master,new_slave,new_synced,new_donor,new_ndb";
static const char MXS_MONITOR_EVENT_DEFAULT_VALUE[] = "master_down,master_up,slave_down,"
"slave_up,server_down,server_up,synced_down,synced_up,donor_down,donor_up,"
"ndb_down,ndb_up,lost_master,lost_slave,lost_synced,lost_donor,lost_ndb,"
"new_master,new_slave,new_synced,new_donor,new_ndb";
/**
* The linked list of servers that are being monitored by the monitor module.
@ -206,19 +205,19 @@ typedef struct monitor_servers
unsigned int mon_prev_status;
unsigned int pending_status; /**< Pending Status flag bitmap */
struct monitor_servers *next; /**< The next server in the list */
} MONITOR_SERVERS;
} MXS_MONITOR_SERVERS;
/**
* Representation of the running monitor.
*/
struct monitor
struct mxs_monitor
{
char *name; /**< The name of the monitor module */
char user[MAX_MONITOR_USER_LEN]; /*< Monitor username */
char password[MAX_MONITOR_PASSWORD_LEN]; /*< Monitor password */
SPINLOCK lock;
CONFIG_PARAMETER* parameters; /*< configuration parameters */
MONITOR_SERVERS* databases; /*< List of databases the monitor monitors */
MXS_MONITOR_SERVERS* databases; /*< List of databases the monitor monitors */
monitor_state_t state; /**< The state of the monitor */
int connect_timeout; /**< Connect timeout in seconds for mysql_real_connect */
int read_timeout; /**< Timeout in seconds to read from the server.
@ -229,7 +228,7 @@ struct monitor
* There are retries and the total effective timeout value is
* two times the option value.
*/
MONITOR_OBJECT *module; /**< The "monitor object" */
MXS_MONITOR_OBJECT *module; /**< The "monitor object" */
char *module_name; /**< Name of the monitor module */
void *handle; /**< Handle returned from startMonitor */
size_t interval; /**< The monitor interval */
@ -237,42 +236,42 @@ struct monitor
volatile bool server_pending_changes;
/**< Are there any pending changes to a server?
* If yes, the next monitor loop starts early. */
struct monitor *next; /**< Next monitor in the linked list */
struct mxs_monitor *next; /**< Next monitor in the linked list */
};
extern MONITOR *monitor_alloc(char *, char *);
extern void monitor_free(MONITOR *);
extern MONITOR *monitor_find(const char *);
extern bool monitorAddServer(MONITOR *mon, SERVER *server);
extern void monitorRemoveServer(MONITOR *mon, SERVER *server);
extern void monitorAddUser(MONITOR *, char *, char *);
extern void monitorAddParameters(MONITOR *monitor, CONFIG_PARAMETER *params);
extern bool monitorRemoveParameter(MONITOR *monitor, const char *key);
extern void monitorStop(MONITOR *);
extern void monitorStart(MONITOR *, void*);
extern MXS_MONITOR *monitor_alloc(char *, char *);
extern void monitor_free(MXS_MONITOR *);
extern MXS_MONITOR *monitor_find(const char *);
extern bool monitorAddServer(MXS_MONITOR *mon, SERVER *server);
extern void monitorRemoveServer(MXS_MONITOR *mon, SERVER *server);
extern void monitorAddUser(MXS_MONITOR *, char *, char *);
extern void monitorAddParameters(MXS_MONITOR *monitor, CONFIG_PARAMETER *params);
extern bool monitorRemoveParameter(MXS_MONITOR *monitor, const char *key);
extern void monitorStop(MXS_MONITOR *);
extern void monitorStart(MXS_MONITOR *, void*);
extern void monitorStopAll();
extern void monitorStartAll();
extern void monitorShowAll(DCB *);
extern void monitorShow(DCB *, MONITOR *);
extern void monitorShow(DCB *, MXS_MONITOR *);
extern void monitorList(DCB *);
extern void monitorSetInterval (MONITOR *, unsigned long);
extern bool monitorSetNetworkTimeout(MONITOR *, int, int);
extern void monitorSetInterval (MXS_MONITOR *, unsigned long);
extern bool monitorSetNetworkTimeout(MXS_MONITOR *, int, int);
extern RESULTSET *monitorGetList();
extern bool check_monitor_permissions(MONITOR* monitor, const char* query);
extern bool check_monitor_permissions(MXS_MONITOR* monitor, const char* query);
monitor_event_t mon_get_event_type(MONITOR_SERVERS* node);
const char* mon_get_event_name(MONITOR_SERVERS* node);
void monitor_clear_pending_status(MONITOR_SERVERS *ptr, int bit);
void monitor_set_pending_status(MONITOR_SERVERS *ptr, int bit);
bool mon_status_changed(MONITOR_SERVERS* mon_srv);
bool mon_print_fail_status(MONITOR_SERVERS* mon_srv);
connect_result_t mon_connect_to_db(MONITOR* mon, MONITOR_SERVERS *database);
void mon_log_connect_error(MONITOR_SERVERS* database, connect_result_t rval);
void mon_log_state_change(MONITOR_SERVERS *ptr);
void lock_monitor_servers(MONITOR *monitor);
void release_monitor_servers(MONITOR *monitor);
void servers_status_pending_to_current(MONITOR *monitor);
void servers_status_current_to_pending(MONITOR *monitor);
mxs_monitor_event_t mon_get_event_type(MXS_MONITOR_SERVERS* node);
const char* mon_get_event_name(MXS_MONITOR_SERVERS* node);
void monitor_clear_pending_status(MXS_MONITOR_SERVERS *ptr, int bit);
void monitor_set_pending_status(MXS_MONITOR_SERVERS *ptr, int bit);
bool mon_status_changed(MXS_MONITOR_SERVERS* mon_srv);
bool mon_print_fail_status(MXS_MONITOR_SERVERS* mon_srv);
mxs_connect_result_t mon_connect_to_db(MXS_MONITOR* mon, MXS_MONITOR_SERVERS *database);
void mon_log_connect_error(MXS_MONITOR_SERVERS* database, mxs_connect_result_t rval);
void mon_log_state_change(MXS_MONITOR_SERVERS *ptr);
void lock_monitor_servers(MXS_MONITOR *monitor);
void release_monitor_servers(MXS_MONITOR *monitor);
void servers_status_pending_to_current(MXS_MONITOR *monitor);
void servers_status_current_to_pending(MXS_MONITOR *monitor);
/**
* @brief Handle state change events
@ -284,7 +283,7 @@ void servers_status_current_to_pending(MONITOR *monitor);
* @param script Script to execute or NULL for no script
* @param events Enabled events
*/
void mon_process_state_changes(MONITOR *monitor, const char *script, uint64_t events);
void mon_process_state_changes(MXS_MONITOR *monitor, const char *script, uint64_t events);
/**
* @brief Hangup connections to failed servers
@ -293,7 +292,7 @@ void mon_process_state_changes(MONITOR *monitor, const char *script, uint64_t ev
*
* @param monitor Monitor object
*/
void mon_hangup_failed_servers(MONITOR *monitor);
void mon_hangup_failed_servers(MXS_MONITOR *monitor);
/**
* @brief Serialize the servers of a monitor to a file
@ -309,7 +308,7 @@ void mon_hangup_failed_servers(MONITOR *monitor);
* @param monitor Monitor to serialize
* @return False if the serialization of the monitor fails, true if it was successful
*/
bool monitor_serialize_servers(const MONITOR *monitor);
bool monitor_serialize_servers(const MXS_MONITOR *monitor);
/**
* @brief Serialize a monitor to a file
@ -319,13 +318,13 @@ bool monitor_serialize_servers(const MONITOR *monitor);
* @param monitor Monitor to serialize
* @return True if serialization was successful
*/
bool monitor_serialize(const MONITOR *monitor);
bool monitor_serialize(const MXS_MONITOR *monitor);
/**
* Check if a server is being monitored and return the monitor.
* @param server Server that is queried
* @return The monitor watching this server, or NULL if not monitored
*/
MONITOR* monitor_server_in_use(const SERVER *server);
MXS_MONITOR* monitor_server_in_use(const SERVER *server);
MXS_END_DECLS

View File

@ -2878,7 +2878,7 @@ int create_new_monitor(CONFIG_CONTEXT *context, CONFIG_CONTEXT *obj, HASHTABLE*
{
/** Not the cleanest way of figuring out whether the configuration
* was stored but it should be OK for now */
((MONITOR*)obj->element)->created_online = true;
((MXS_MONITOR*)obj->element)->created_online = true;
}
}
else
@ -2919,14 +2919,14 @@ int create_new_monitor(CONFIG_CONTEXT *context, CONFIG_CONTEXT *obj, HASHTABLE*
{
MXS_NOTICE("Invalid 'monitor_interval' parameter for monitor '%s', "
"using default value of %d milliseconds.",
obj->object, MONITOR_INTERVAL);
obj->object, MONITOR_DEFAULT_INTERVAL);
}
}
else
{
MXS_NOTICE("Monitor '%s' is missing the 'monitor_interval' parameter, "
"using default value of %d milliseconds.",
obj->object, MONITOR_INTERVAL);
obj->object, MONITOR_DEFAULT_INTERVAL);
}
char *connect_timeout = config_get_value(obj->parameters, "backend_connect_timeout");

View File

@ -29,7 +29,7 @@ bool runtime_link_server(SERVER *server, const char *target)
bool rval = false;
SERVICE *service = service_find(target);
MONITOR *monitor = service ? NULL : monitor_find(target);
MXS_MONITOR *monitor = service ? NULL : monitor_find(target);
if (service)
{
@ -64,7 +64,7 @@ bool runtime_unlink_server(SERVER *server, const char *target)
bool rval = false;
SERVICE *service = service_find(target);
MONITOR *monitor = service ? NULL : monitor_find(target);
MXS_MONITOR *monitor = service ? NULL : monitor_find(target);
if (service || monitor)
{
@ -343,7 +343,7 @@ static long get_positive_int(const char *value)
*
* @param monitor Monitor to modify
*/
static void add_monitor_defaults(MONITOR *monitor)
static void add_monitor_defaults(MXS_MONITOR *monitor)
{
/** Inject the default module parameters in case we only deleted
* a parameter */
@ -363,7 +363,7 @@ static void add_monitor_defaults(MONITOR *monitor)
}
}
bool runtime_alter_monitor(MONITOR *monitor, char *key, char *value)
bool runtime_alter_monitor(MXS_MONITOR *monitor, char *key, char *value)
{
spinlock_acquire(&crt_lock);
bool valid = false;
@ -583,7 +583,7 @@ bool runtime_create_monitor(const char *name, const char *module)
if (monitor_find(name) == NULL)
{
MONITOR *monitor = monitor_alloc((char*)name, (char*)module);
MXS_MONITOR *monitor = monitor_alloc((char*)name, (char*)module);
if (monitor)
{
@ -603,7 +603,7 @@ bool runtime_create_monitor(const char *name, const char *module)
return rval;
}
bool runtime_destroy_monitor(MONITOR *monitor)
bool runtime_destroy_monitor(MXS_MONITOR *monitor)
{
bool rval = false;
char filename[PATH_MAX];

View File

@ -44,10 +44,10 @@
#include "maxscale/config.h"
static MONITOR *allMonitors = NULL;
static MXS_MONITOR *allMonitors = NULL;
static SPINLOCK monLock = SPINLOCK_INIT;
static void monitor_server_free_all(MONITOR_SERVERS *servers);
static void monitor_server_free_all(MXS_MONITOR_SERVERS *servers);
/**
* Allocate a new monitor, load the associated module for the monitor
@ -57,13 +57,13 @@ static void monitor_server_free_all(MONITOR_SERVERS *servers);
* @param module The module to load
* @return The newly created monitor
*/
MONITOR *
MXS_MONITOR *
monitor_alloc(char *name, char *module)
{
name = MXS_STRDUP(name);
char *my_module = MXS_STRDUP(module);
MONITOR *mon = (MONITOR *)MXS_MALLOC(sizeof(MONITOR));
MXS_MONITOR *mon = (MXS_MONITOR *)MXS_MALLOC(sizeof(MXS_MONITOR));
if (!name || !mon || !my_module)
{
@ -90,7 +90,7 @@ monitor_alloc(char *name, char *module)
mon->read_timeout = DEFAULT_READ_TIMEOUT;
mon->write_timeout = DEFAULT_WRITE_TIMEOUT;
mon->connect_timeout = DEFAULT_CONNECT_TIMEOUT;
mon->interval = MONITOR_INTERVAL;
mon->interval = MONITOR_DEFAULT_INTERVAL;
mon->parameters = NULL;
mon->created_online = false;
mon->server_pending_changes = false;
@ -110,9 +110,9 @@ monitor_alloc(char *name, char *module)
* @param mon The monitor to free
*/
void
monitor_free(MONITOR *mon)
monitor_free(MXS_MONITOR *mon)
{
MONITOR *ptr;
MXS_MONITOR *ptr;
mon->module->stopMonitor(mon);
mon->state = MONITOR_STATE_FREED;
@ -148,7 +148,7 @@ monitor_free(MONITOR *mon)
* @param monitor The Monitor that should be started
*/
void
monitorStart(MONITOR *monitor, void* params)
monitorStart(MXS_MONITOR *monitor, void* params)
{
spinlock_acquire(&monitor->lock);
@ -169,7 +169,7 @@ monitorStart(MONITOR *monitor, void* params)
*/
void monitorStartAll()
{
MONITOR *ptr;
MXS_MONITOR *ptr;
spinlock_acquire(&monLock);
ptr = allMonitors;
@ -187,7 +187,7 @@ void monitorStartAll()
* @param monitor The monitor to stop
*/
void
monitorStop(MONITOR *monitor)
monitorStop(MXS_MONITOR *monitor)
{
spinlock_acquire(&monitor->lock);
@ -198,7 +198,7 @@ monitorStop(MONITOR *monitor)
monitor->module->stopMonitor(monitor);
monitor->state = MONITOR_STATE_STOPPED;
MONITOR_SERVERS* db = monitor->databases;
MXS_MONITOR_SERVERS* db = monitor->databases;
while (db)
{
// TODO: Create a generic entry point for this or move it inside stopMonitor
@ -217,7 +217,7 @@ monitorStop(MONITOR *monitor)
void
monitorStopAll()
{
MONITOR *ptr;
MXS_MONITOR *ptr;
spinlock_acquire(&monLock);
ptr = allMonitors;
@ -236,7 +236,7 @@ monitorStopAll()
* @param mon The Monitor instance
* @param server The Server to add to the monitoring
*/
bool monitorAddServer(MONITOR *mon, SERVER *server)
bool monitorAddServer(MXS_MONITOR *mon, SERVER *server)
{
bool rval = false;
@ -247,7 +247,7 @@ bool monitorAddServer(MONITOR *mon, SERVER *server)
else
{
rval = true;
MONITOR_SERVERS *db = (MONITOR_SERVERS *)MXS_MALLOC(sizeof(MONITOR_SERVERS));
MXS_MONITOR_SERVERS *db = (MXS_MONITOR_SERVERS *)MXS_MALLOC(sizeof(MXS_MONITOR_SERVERS));
MXS_ABORT_IF_NULL(db);
db->server = server;
@ -275,7 +275,7 @@ bool monitorAddServer(MONITOR *mon, SERVER *server)
}
else
{
MONITOR_SERVERS *ptr = mon->databases;
MXS_MONITOR_SERVERS *ptr = mon->databases;
while (ptr->next != NULL)
{
ptr = ptr->next;
@ -293,7 +293,7 @@ bool monitorAddServer(MONITOR *mon, SERVER *server)
return rval;
}
static void monitor_server_free(MONITOR_SERVERS *tofree)
static void monitor_server_free(MXS_MONITOR_SERVERS *tofree)
{
if (tofree)
{
@ -309,11 +309,11 @@ static void monitor_server_free(MONITOR_SERVERS *tofree)
* Free monitor server list
* @param servers Servers to free
*/
static void monitor_server_free_all(MONITOR_SERVERS *servers)
static void monitor_server_free_all(MXS_MONITOR_SERVERS *servers)
{
while (servers)
{
MONITOR_SERVERS *tofree = servers;
MXS_MONITOR_SERVERS *tofree = servers;
servers = servers->next;
monitor_server_free(tofree);
}
@ -325,7 +325,7 @@ static void monitor_server_free_all(MONITOR_SERVERS *servers)
* @param mon The Monitor instance
* @param server The Server to remove
*/
void monitorRemoveServer(MONITOR *mon, SERVER *server)
void monitorRemoveServer(MXS_MONITOR *mon, SERVER *server)
{
monitor_state_t old_state = mon->state;
@ -336,7 +336,7 @@ void monitorRemoveServer(MONITOR *mon, SERVER *server)
spinlock_acquire(&mon->lock);
MONITOR_SERVERS *ptr = mon->databases;
MXS_MONITOR_SERVERS *ptr = mon->databases;
if (ptr && ptr->server == server)
{
@ -344,7 +344,7 @@ void monitorRemoveServer(MONITOR *mon, SERVER *server)
}
else
{
MONITOR_SERVERS *prev = ptr;
MXS_MONITOR_SERVERS *prev = ptr;
while (ptr)
{
@ -379,7 +379,7 @@ void monitorRemoveServer(MONITOR *mon, SERVER *server)
* @param passwd The default password associated to the default user.
*/
void
monitorAddUser(MONITOR *mon, char *user, char *passwd)
monitorAddUser(MXS_MONITOR *mon, char *user, char *passwd)
{
if (user != mon->user)
{
@ -400,7 +400,7 @@ monitorAddUser(MONITOR *mon, char *user, char *passwd)
void
monitorShowAll(DCB *dcb)
{
MONITOR *ptr;
MXS_MONITOR *ptr;
spinlock_acquire(&monLock);
ptr = allMonitors;
@ -418,7 +418,7 @@ monitorShowAll(DCB *dcb)
* @param dcb DCB for printing output
*/
void
monitorShow(DCB *dcb, MONITOR *monitor)
monitorShow(DCB *dcb, MXS_MONITOR *monitor)
{
const char *state;
@ -452,7 +452,7 @@ monitorShow(DCB *dcb, MONITOR *monitor)
const char *sep = "";
for (MONITOR_SERVERS *db = monitor->databases; db; db = db->next)
for (MXS_MONITOR_SERVERS *db = monitor->databases; db; db = db->next)
{
dcb_printf(dcb, "%s%s:%d", sep, db->server->name, db->server->port);
sep = ", ";
@ -486,7 +486,7 @@ monitorShow(DCB *dcb, MONITOR *monitor)
void
monitorList(DCB *dcb)
{
MONITOR *ptr;
MXS_MONITOR *ptr;
spinlock_acquire(&monLock);
ptr = allMonitors;
@ -510,10 +510,10 @@ monitorList(DCB *dcb)
* @param name The name of the monitor
* @return Pointer to the monitor or NULL
*/
MONITOR *
MXS_MONITOR *
monitor_find(const char *name)
{
MONITOR *ptr;
MXS_MONITOR *ptr;
spinlock_acquire(&monLock);
ptr = allMonitors;
@ -536,7 +536,7 @@ monitor_find(const char *name)
* @param interval The sampling interval in milliseconds
*/
void
monitorSetInterval(MONITOR *mon, unsigned long interval)
monitorSetInterval(MXS_MONITOR *mon, unsigned long interval)
{
mon->interval = interval;
}
@ -549,7 +549,7 @@ monitorSetInterval(MONITOR *mon, unsigned long interval)
* @param value The timeout to set
*/
bool
monitorSetNetworkTimeout(MONITOR *mon, int type, int value)
monitorSetNetworkTimeout(MXS_MONITOR *mon, int type, int value)
{
bool rval = true;
@ -597,7 +597,7 @@ monitorRowCallback(RESULTSET *set, void *data)
int i = 0;;
char buf[20];
RESULT_ROW *row;
MONITOR *ptr;
MXS_MONITOR *ptr;
spinlock_acquire(&monLock);
ptr = allMonitors;
@ -655,7 +655,7 @@ monitorGetList()
* @param query Query to execute
* @return True on success, false if monitor credentials lack permissions
*/
bool check_monitor_permissions(MONITOR* monitor, const char* query)
bool check_monitor_permissions(MXS_MONITOR* monitor, const char* query)
{
if (monitor->databases == NULL || // No servers to check
config_get_global_options()->skip_permission_checks)
@ -668,7 +668,7 @@ bool check_monitor_permissions(MONITOR* monitor, const char* query)
GATEWAY_CONF* cnf = config_get_global_options();
bool rval = false;
for (MONITOR_SERVERS *mondb = monitor->databases; mondb; mondb = mondb->next)
for (MXS_MONITOR_SERVERS *mondb = monitor->databases; mondb; mondb = mondb->next)
{
if (mon_connect_to_db(monitor, mondb) != MONITOR_CONN_OK)
{
@ -732,7 +732,7 @@ bool check_monitor_permissions(MONITOR* monitor, const char* query)
* @param monitor Monitor
* @param params Config parameters
*/
void monitorAddParameters(MONITOR *monitor, CONFIG_PARAMETER *params)
void monitorAddParameters(MXS_MONITOR *monitor, CONFIG_PARAMETER *params)
{
while (params)
{
@ -746,7 +746,7 @@ void monitorAddParameters(MONITOR *monitor, CONFIG_PARAMETER *params)
}
}
bool monitorRemoveParameter(MONITOR *monitor, const char *key)
bool monitorRemoveParameter(MXS_MONITOR *monitor, const char *key)
{
CONFIG_PARAMETER *prev = NULL;
@ -779,7 +779,7 @@ bool monitorRemoveParameter(MONITOR *monitor, const char *key)
* @param bit The bit to clear for the server
*/
void
monitor_set_pending_status(MONITOR_SERVERS *ptr, int bit)
monitor_set_pending_status(MXS_MONITOR_SERVERS *ptr, int bit)
{
ptr->pending_status |= bit;
}
@ -791,7 +791,7 @@ monitor_set_pending_status(MONITOR_SERVERS *ptr, int bit)
* @param bit The bit to clear for the server
*/
void
monitor_clear_pending_status(MONITOR_SERVERS *ptr, int bit)
monitor_clear_pending_status(MXS_MONITOR_SERVERS *ptr, int bit)
{
ptr->pending_status &= ~bit;
}
@ -803,8 +803,8 @@ monitor_clear_pending_status(MONITOR_SERVERS *ptr, int bit)
* @param node The monitor server data for a particular server
* @result monitor_event_t A monitor event (enum)
*/
monitor_event_t
mon_get_event_type(MONITOR_SERVERS* node)
mxs_monitor_event_t
mon_get_event_type(MXS_MONITOR_SERVERS* node)
{
typedef enum
{
@ -902,15 +902,15 @@ mon_get_event_type(MONITOR_SERVERS* node)
* @result string The name of the monitor event for the server
*/
const char*
mon_get_event_name(MONITOR_SERVERS* node)
mon_get_event_name(MXS_MONITOR_SERVERS* node)
{
monitor_event_t event = mon_get_event_type(node);
mxs_monitor_event_t event = mon_get_event_type(node);
for (int i = 0; monitor_event_enum_values[i].name; i++)
for (int i = 0; mxs_monitor_event_enum_values[i].name; i++)
{
if (monitor_event_enum_values[i].enum_value & event)
if (mxs_monitor_event_enum_values[i].enum_value & event)
{
return monitor_event_enum_values[i].name;
return mxs_monitor_event_enum_values[i].name;
}
}
@ -924,7 +924,7 @@ mon_get_event_name(MONITOR_SERVERS* node)
* @param dest Destination where the string is appended, must be null terminated
* @param len Length of @c dest
*/
static void mon_append_node_names(MONITOR_SERVERS* servers, char* dest, int len, int status)
static void mon_append_node_names(MXS_MONITOR_SERVERS* servers, char* dest, int len, int status)
{
char *separator = "";
char arr[MAX_SERVER_NAME_LEN + 32]; // Some extra space for port
@ -950,7 +950,7 @@ static void mon_append_node_names(MONITOR_SERVERS* servers, char* dest, int len,
* @return true if status has changed or false
*/
bool
mon_status_changed(MONITOR_SERVERS* mon_srv)
mon_status_changed(MXS_MONITOR_SERVERS* mon_srv)
{
/* Previous status is -1 if not yet set */
return (mon_srv->mon_prev_status != -1
@ -966,7 +966,7 @@ mon_status_changed(MONITOR_SERVERS* mon_srv)
* @return true if failed status can be logged or false
*/
bool
mon_print_fail_status(MONITOR_SERVERS* mon_srv)
mon_print_fail_status(MXS_MONITOR_SERVERS* mon_srv)
{
return (SERVER_IS_DOWN(mon_srv->server) && mon_srv->mon_err_count == 0);
}
@ -978,7 +978,7 @@ mon_print_fail_status(MONITOR_SERVERS* mon_srv)
* @param script Script to execute
*/
void
monitor_launch_script(MONITOR* mon, MONITOR_SERVERS* ptr, const char* script)
monitor_launch_script(MXS_MONITOR* mon, MXS_MONITOR_SERVERS* ptr, const char* script)
{
char arg[strlen(script) + 1];
strcpy(arg, script);
@ -1098,10 +1098,10 @@ monitor_launch_script(MONITOR* mon, MONITOR_SERVERS* ptr, const char* script)
* @param database Monitored database
* @return MONITOR_CONN_OK if the connection is OK else the reason for the failure
*/
connect_result_t
mon_connect_to_db(MONITOR* mon, MONITOR_SERVERS *database)
mxs_connect_result_t
mon_connect_to_db(MXS_MONITOR* mon, MXS_MONITOR_SERVERS *database)
{
connect_result_t rval = MONITOR_CONN_OK;
mxs_connect_result_t rval = MONITOR_CONN_OK;
/** Return if the connection is OK */
if (database->con && mysql_ping(database->con) == 0)
@ -1164,7 +1164,7 @@ mon_connect_to_db(MONITOR* mon, MONITOR_SERVERS *database)
* @param rval Return value of mon_connect_to_db
*/
void
mon_log_connect_error(MONITOR_SERVERS* database, connect_result_t rval)
mon_log_connect_error(MXS_MONITOR_SERVERS* database, mxs_connect_result_t rval)
{
MXS_ERROR(rval == MONITOR_CONN_TIMEOUT ?
"Monitor timed out when connecting to server %s:%d : \"%s\"" :
@ -1173,7 +1173,7 @@ mon_log_connect_error(MONITOR_SERVERS* database, connect_result_t rval)
mysql_error(database->con));
}
void mon_log_state_change(MONITOR_SERVERS *ptr)
void mon_log_state_change(MXS_MONITOR_SERVERS *ptr)
{
SERVER srv;
srv.status = ptr->mon_prev_status;
@ -1186,17 +1186,17 @@ void mon_log_state_change(MONITOR_SERVERS *ptr)
MXS_FREE(next);
}
MONITOR* monitor_server_in_use(const SERVER *server)
MXS_MONITOR* monitor_server_in_use(const SERVER *server)
{
MONITOR *rval = NULL;
MXS_MONITOR *rval = NULL;
spinlock_acquire(&monLock);
for (MONITOR *mon = allMonitors; mon && !rval; mon = mon->next)
for (MXS_MONITOR *mon = allMonitors; mon && !rval; mon = mon->next)
{
spinlock_acquire(&mon->lock);
for (MONITOR_SERVERS *db = mon->databases; db && !rval; db = db->next)
for (MXS_MONITOR_SERVERS *db = mon->databases; db && !rval; db = db->next)
{
if (db->server == server)
{
@ -1219,7 +1219,7 @@ MONITOR* monitor_server_in_use(const SERVER *server)
* @param filename Filename where configuration is written
* @return True on success, false on error
*/
static bool create_monitor_server_config(const MONITOR *monitor, const char *filename)
static bool create_monitor_server_config(const MXS_MONITOR *monitor, const char *filename)
{
int file = open(filename, O_EXCL | O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
@ -1242,7 +1242,7 @@ static bool create_monitor_server_config(const MONITOR *monitor, const char *fil
if (monitor->databases)
{
dprintf(file, "servers=");
for (MONITOR_SERVERS *db = monitor->databases; db; db = db->next)
for (MXS_MONITOR_SERVERS *db = monitor->databases; db; db = db->next)
{
if (db != monitor->databases)
{
@ -1258,7 +1258,7 @@ static bool create_monitor_server_config(const MONITOR *monitor, const char *fil
return true;
}
static bool create_monitor_config(const MONITOR *monitor, const char *filename)
static bool create_monitor_config(const MXS_MONITOR *monitor, const char *filename)
{
int file = open(filename, O_EXCL | O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
@ -1290,7 +1290,7 @@ static bool create_monitor_config(const MONITOR *monitor, const char *filename)
return true;
}
bool monitor_serialize_servers(const MONITOR *monitor)
bool monitor_serialize_servers(const MXS_MONITOR *monitor)
{
bool rval = false;
char filename[PATH_MAX];
@ -1327,7 +1327,7 @@ bool monitor_serialize_servers(const MONITOR *monitor)
return rval;
}
bool monitor_serialize(const MONITOR *monitor)
bool monitor_serialize(const MXS_MONITOR *monitor)
{
bool rval = false;
char filename[PATH_MAX];
@ -1364,9 +1364,9 @@ bool monitor_serialize(const MONITOR *monitor)
return rval;
}
void mon_hangup_failed_servers(MONITOR *monitor)
void mon_hangup_failed_servers(MXS_MONITOR *monitor)
{
for (MONITOR_SERVERS *ptr = monitor->databases; ptr; ptr = ptr->next)
for (MXS_MONITOR_SERVERS *ptr = monitor->databases; ptr; ptr = ptr->next)
{
if (mon_status_changed(ptr) &&
(!(SERVER_IS_RUNNING(ptr->server)) ||
@ -1381,9 +1381,9 @@ void mon_hangup_failed_servers(MONITOR *monitor)
* only be max 1 monitor per server.
* @param monitor The target monitor
*/
void lock_monitor_servers(MONITOR *monitor)
void lock_monitor_servers(MXS_MONITOR *monitor)
{
MONITOR_SERVERS *ptr = monitor->databases;
MXS_MONITOR_SERVERS *ptr = monitor->databases;
while (ptr)
{
spinlock_acquire(&ptr->server->lock);
@ -1395,9 +1395,9 @@ void lock_monitor_servers(MONITOR *monitor)
* only be max 1 monitor per server.
* @param monitor The target monitor
*/
void release_monitor_servers(MONITOR *monitor)
void release_monitor_servers(MXS_MONITOR *monitor)
{
MONITOR_SERVERS *ptr = monitor->databases;
MXS_MONITOR_SERVERS *ptr = monitor->databases;
while (ptr)
{
spinlock_release(&ptr->server->lock);
@ -1410,9 +1410,9 @@ void release_monitor_servers(MONITOR *monitor)
* a monitor loop, after the servers are locked.
* @param monitor The target monitor
*/
void servers_status_pending_to_current(MONITOR *monitor)
void servers_status_pending_to_current(MXS_MONITOR *monitor)
{
MONITOR_SERVERS *ptr = monitor->databases;
MXS_MONITOR_SERVERS *ptr = monitor->databases;
while (ptr)
{
ptr->server->status = ptr->server->status_pending;
@ -1426,9 +1426,9 @@ void servers_status_pending_to_current(MONITOR *monitor)
* a monitor loop, before the servers are released.
* @param monitor The target monitor
*/
void servers_status_current_to_pending(MONITOR *monitor)
void servers_status_current_to_pending(MXS_MONITOR *monitor)
{
MONITOR_SERVERS *ptr = monitor->databases;
MXS_MONITOR_SERVERS *ptr = monitor->databases;
while (ptr)
{
ptr->server->status_pending = ptr->server->status;
@ -1436,9 +1436,9 @@ void servers_status_current_to_pending(MONITOR *monitor)
}
}
void mon_process_state_changes(MONITOR *monitor, const char *script, uint64_t events)
void mon_process_state_changes(MXS_MONITOR *monitor, const char *script, uint64_t events)
{
for (MONITOR_SERVERS *ptr = monitor->databases; ptr; ptr = ptr->next)
for (MXS_MONITOR_SERVERS *ptr = monitor->databases; ptr; ptr = ptr->next)
{
if (mon_status_changed(ptr))
{

View File

@ -1311,7 +1311,7 @@ void server_set_status(SERVER *server, int bit)
* but the race condition cannot cause significant harm. Monitors are never
* freed so the pointer stays valid.
*/
MONITOR *mon = monitor_server_in_use(server);
MXS_MONITOR *mon = monitor_server_in_use(server);
spinlock_acquire(&server->lock);
if (mon && mon->state == MONITOR_STATE_RUNNING)
{
@ -1338,7 +1338,7 @@ void server_set_status(SERVER *server, int bit)
*/
void server_clear_status(SERVER *server, int bit)
{
MONITOR *mon = monitor_server_in_use(server);
MXS_MONITOR *mon = monitor_server_in_use(server);
spinlock_acquire(&server->lock);
if (mon && mon->state == MONITOR_STATE_RUNNING)
{

View File

@ -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}
}

View File

@ -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)

View File

@ -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 */

View File

@ -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;

View File

@ -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;

View File

@ -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 */

View File

@ -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) ||

View File

@ -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;

View File

@ -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);
}

View File

@ -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);