MXS-1848 Rename monitor types and instance variable
The following type name changes MXS_MONITOR_OBJECT -> MXS_MONITOR_API MXS_SPECIFIC_MONITOR -> MXS_MONITOR_INSTANCE Further, the 'handle' instance variable of what used to be called MXS_MONITOR_OBJECT has been renamed to 'api'. An example, what used to look like mon->module->stopMonitor(mon->handle); now looks like mon->api->stopMonitor(mon->instance); which makes it more obvious what is going on.
This commit is contained in:
@ -35,9 +35,9 @@ typedef struct mxs_monitor MXS_MONITOR;
|
|||||||
* An opaque type from which types specific for a particular
|
* An opaque type from which types specific for a particular
|
||||||
* monitor can be derived.
|
* monitor can be derived.
|
||||||
*/
|
*/
|
||||||
typedef struct mxs_specific_monitor
|
typedef struct mxs_monitor_instance
|
||||||
{
|
{
|
||||||
} MXS_SPECIFIC_MONITOR;
|
} MXS_MONITOR_INSTANCE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @verbatim
|
* @verbatim
|
||||||
@ -62,7 +62,7 @@ typedef struct mxs_specific_monitor
|
|||||||
*
|
*
|
||||||
* @see load_module
|
* @see load_module
|
||||||
*/
|
*/
|
||||||
typedef struct mxs_monitor_object
|
typedef struct mxs_monitor_api
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @brief Create the monitor.
|
* @brief Create the monitor.
|
||||||
@ -82,7 +82,7 @@ typedef struct mxs_monitor_object
|
|||||||
* @return Pointer to the monitor specific data. Will be stored
|
* @return Pointer to the monitor specific data. Will be stored
|
||||||
* in @c monitor->handle.
|
* in @c monitor->handle.
|
||||||
*/
|
*/
|
||||||
MXS_SPECIFIC_MONITOR *(*createInstance)(MXS_MONITOR *monitor,
|
MXS_MONITOR_INSTANCE *(*createInstance)(MXS_MONITOR *monitor,
|
||||||
const MXS_CONFIG_PARAMETER *params);
|
const MXS_CONFIG_PARAMETER *params);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -94,7 +94,7 @@ typedef struct mxs_monitor_object
|
|||||||
*
|
*
|
||||||
* @param monitor The monitor object.
|
* @param monitor The monitor object.
|
||||||
*/
|
*/
|
||||||
void (*destroyInstance)(MXS_SPECIFIC_MONITOR *monitor);
|
void (*destroyInstance)(MXS_MONITOR_INSTANCE *monitor);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Start the monitor
|
* @brief Start the monitor
|
||||||
@ -109,7 +109,7 @@ typedef struct mxs_monitor_object
|
|||||||
* @return Pointer to the monitor specific data. Will be stored
|
* @return Pointer to the monitor specific data. Will be stored
|
||||||
* in @c monitor->handle.
|
* in @c monitor->handle.
|
||||||
*/
|
*/
|
||||||
MXS_SPECIFIC_MONITOR *(*startMonitor)(MXS_MONITOR *monitor,
|
MXS_MONITOR_INSTANCE *(*startMonitor)(MXS_MONITOR *monitor,
|
||||||
const MXS_CONFIG_PARAMETER *params);
|
const MXS_CONFIG_PARAMETER *params);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -120,7 +120,7 @@ typedef struct mxs_monitor_object
|
|||||||
*
|
*
|
||||||
* @param monitor The monitor object
|
* @param monitor The monitor object
|
||||||
*/
|
*/
|
||||||
void (*stopMonitor)(MXS_SPECIFIC_MONITOR *monitor);
|
void (*stopMonitor)(MXS_MONITOR_INSTANCE *monitor);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Write diagnostic information to a DCB.
|
* @brief Write diagnostic information to a DCB.
|
||||||
@ -128,7 +128,7 @@ typedef struct mxs_monitor_object
|
|||||||
* @param monitor The monitor object.
|
* @param monitor The monitor object.
|
||||||
* @param dcb The dcb to write to.
|
* @param dcb The dcb to write to.
|
||||||
*/
|
*/
|
||||||
void (*diagnostics)(const MXS_SPECIFIC_MONITOR* monitor, DCB* dcb);
|
void (*diagnostics)(const MXS_MONITOR_INSTANCE* monitor, DCB* dcb);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Return diagnostic information about the monitor
|
* @brief Return diagnostic information about the monitor
|
||||||
@ -139,8 +139,8 @@ typedef struct mxs_monitor_object
|
|||||||
*
|
*
|
||||||
* @see jansson.h
|
* @see jansson.h
|
||||||
*/
|
*/
|
||||||
json_t* (*diagnostics_json)(const MXS_SPECIFIC_MONITOR *monitor);
|
json_t* (*diagnostics_json)(const MXS_MONITOR_INSTANCE *monitor);
|
||||||
} MXS_MONITOR_OBJECT;
|
} MXS_MONITOR_API;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The monitor API version number. Any change to the monitor module API
|
* The monitor API version number. Any change to the monitor module API
|
||||||
@ -260,9 +260,9 @@ struct mxs_monitor
|
|||||||
* There are retries and the total effective timeout value is
|
* There are retries and the total effective timeout value is
|
||||||
* two times the option value.
|
* two times the option value.
|
||||||
*/
|
*/
|
||||||
MXS_MONITOR_OBJECT *module; /**< The "monitor object" */
|
MXS_MONITOR_API *api; /**< The monitor api */
|
||||||
char *module_name; /**< Name of the monitor module */
|
char *module_name; /**< Name of the monitor module */
|
||||||
MXS_SPECIFIC_MONITOR *handle; /**< Handle returned from startMonitor */
|
MXS_MONITOR_INSTANCE *instance; /**< Instance returned from startMonitor */
|
||||||
size_t interval; /**< The monitor interval */
|
size_t interval; /**< The monitor interval */
|
||||||
volatile bool server_pending_changes;
|
volatile bool server_pending_changes;
|
||||||
/**< Are there any pending changes to a server?
|
/**< Are there any pending changes to a server?
|
||||||
|
|||||||
@ -113,7 +113,7 @@ MXS_MONITOR* monitor_create(const char *name, const char *module)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((mon->module = (MXS_MONITOR_OBJECT*)load_module(module, MODULE_MONITOR)) == NULL)
|
if ((mon->api = (MXS_MONITOR_API*)load_module(module, MODULE_MONITOR)) == NULL)
|
||||||
{
|
{
|
||||||
MXS_ERROR("Unable to load monitor module '%s'.", my_name);
|
MXS_ERROR("Unable to load monitor module '%s'.", my_name);
|
||||||
MXS_FREE(my_name);
|
MXS_FREE(my_name);
|
||||||
@ -124,7 +124,7 @@ MXS_MONITOR* monitor_create(const char *name, const char *module)
|
|||||||
mon->state = MONITOR_STATE_ALLOC;
|
mon->state = MONITOR_STATE_ALLOC;
|
||||||
mon->name = my_name;
|
mon->name = my_name;
|
||||||
mon->module_name = my_module;
|
mon->module_name = my_module;
|
||||||
mon->handle = NULL;
|
mon->instance = NULL;
|
||||||
mon->monitored_servers = NULL;
|
mon->monitored_servers = NULL;
|
||||||
*mon->password = '\0';
|
*mon->password = '\0';
|
||||||
*mon->user = '\0';
|
*mon->user = '\0';
|
||||||
@ -154,11 +154,11 @@ MXS_MONITOR* monitor_create(const char *name, const char *module)
|
|||||||
* @param mon The monitor to free
|
* @param mon The monitor to free
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
monitor_free(MXS_MONITOR *mon)
|
monitor_destroy(MXS_MONITOR *mon)
|
||||||
{
|
{
|
||||||
MXS_MONITOR *ptr;
|
MXS_MONITOR *ptr;
|
||||||
|
|
||||||
mon->module->stopMonitor(mon->handle);
|
mon->api->stopMonitor(mon->instance);
|
||||||
mon->state = MONITOR_STATE_FREED;
|
mon->state = MONITOR_STATE_FREED;
|
||||||
spinlock_acquire(&monLock);
|
spinlock_acquire(&monLock);
|
||||||
if (allMonitors == mon)
|
if (allMonitors == mon)
|
||||||
@ -204,7 +204,7 @@ monitor_start(MXS_MONITOR *monitor, const MXS_CONFIG_PARAMETER* params)
|
|||||||
remove_server_journal(monitor);
|
remove_server_journal(monitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((monitor->handle = (*monitor->module->startMonitor)(monitor, params)))
|
if ((monitor->instance = (*monitor->api->startMonitor)(monitor, params)))
|
||||||
{
|
{
|
||||||
monitor->state = MONITOR_STATE_RUNNING;
|
monitor->state = MONITOR_STATE_RUNNING;
|
||||||
}
|
}
|
||||||
@ -253,7 +253,7 @@ monitor_stop(MXS_MONITOR *monitor)
|
|||||||
if (monitor->state == MONITOR_STATE_RUNNING)
|
if (monitor->state == MONITOR_STATE_RUNNING)
|
||||||
{
|
{
|
||||||
monitor->state = MONITOR_STATE_STOPPING;
|
monitor->state = MONITOR_STATE_STOPPING;
|
||||||
monitor->module->stopMonitor(monitor->handle);
|
monitor->api->stopMonitor(monitor->instance);
|
||||||
monitor->state = MONITOR_STATE_STOPPED;
|
monitor->state = MONITOR_STATE_STOPPED;
|
||||||
|
|
||||||
MXS_MONITORED_SERVER* db = monitor->monitored_servers;
|
MXS_MONITORED_SERVER* db = monitor->monitored_servers;
|
||||||
@ -535,11 +535,11 @@ monitor_show(DCB *dcb, MXS_MONITOR *monitor)
|
|||||||
|
|
||||||
dcb_printf(dcb, "\n");
|
dcb_printf(dcb, "\n");
|
||||||
|
|
||||||
if (monitor->handle)
|
if (monitor->instance)
|
||||||
{
|
{
|
||||||
if (monitor->module->diagnostics)
|
if (monitor->api->diagnostics)
|
||||||
{
|
{
|
||||||
monitor->module->diagnostics(monitor->handle, dcb);
|
monitor->api->diagnostics(monitor->instance, dcb);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1852,9 +1852,9 @@ json_t* monitor_json_data(const MXS_MONITOR* monitor, const char* host)
|
|||||||
/** Monitor parameters */
|
/** Monitor parameters */
|
||||||
json_object_set_new(attr, CN_PARAMETERS, monitor_parameters_to_json(monitor));
|
json_object_set_new(attr, CN_PARAMETERS, monitor_parameters_to_json(monitor));
|
||||||
|
|
||||||
if (monitor->handle && monitor->module->diagnostics_json)
|
if (monitor->instance && monitor->api->diagnostics_json)
|
||||||
{
|
{
|
||||||
json_t* diag = monitor->module->diagnostics_json(monitor->handle);
|
json_t* diag = monitor->api->diagnostics_json(monitor->instance);
|
||||||
|
|
||||||
if (diag)
|
if (diag)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -25,7 +25,7 @@
|
|||||||
#include <maxscale/debug.h>
|
#include <maxscale/debug.h>
|
||||||
#include <maxscale/mysql_utils.h>
|
#include <maxscale/mysql_utils.h>
|
||||||
|
|
||||||
struct AURORA_MONITOR : public MXS_SPECIFIC_MONITOR
|
struct AURORA_MONITOR : public MXS_MONITOR_INSTANCE
|
||||||
{
|
{
|
||||||
bool shutdown; /**< True if the monitor is stopped */
|
bool shutdown; /**< True if the monitor is stopped */
|
||||||
THREAD thread; /**< Monitor thread */
|
THREAD thread; /**< Monitor thread */
|
||||||
@ -179,7 +179,7 @@ static void auroramon_free(AURORA_MONITOR *handle)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
MXS_SPECIFIC_MONITOR* createInstance(MXS_MONITOR* mon, const MXS_CONFIG_PARAMETER* params)
|
MXS_MONITOR_INSTANCE* createInstance(MXS_MONITOR* mon, const MXS_CONFIG_PARAMETER* params)
|
||||||
{
|
{
|
||||||
AURORA_MONITOR* handle = static_cast<AURORA_MONITOR*>(MXS_CALLOC(1, sizeof(AURORA_MONITOR)));
|
AURORA_MONITOR* handle = static_cast<AURORA_MONITOR*>(MXS_CALLOC(1, sizeof(AURORA_MONITOR)));
|
||||||
|
|
||||||
@ -208,7 +208,7 @@ MXS_SPECIFIC_MONITOR* createInstance(MXS_MONITOR* mon, const MXS_CONFIG_PARAMETE
|
|||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void destroyInstance(MXS_SPECIFIC_MONITOR* mon)
|
static void destroyInstance(MXS_MONITOR_INSTANCE* mon)
|
||||||
{
|
{
|
||||||
AURORA_MONITOR* handle = static_cast<AURORA_MONITOR*>(mon);
|
AURORA_MONITOR* handle = static_cast<AURORA_MONITOR*>(mon);
|
||||||
|
|
||||||
@ -225,10 +225,10 @@ static void destroyInstance(MXS_SPECIFIC_MONITOR* mon)
|
|||||||
* @param opt The configuration parameters for this monitor
|
* @param opt The configuration parameters for this monitor
|
||||||
* @return Monitor handle
|
* @return Monitor handle
|
||||||
*/
|
*/
|
||||||
static MXS_SPECIFIC_MONITOR *
|
static MXS_MONITOR_INSTANCE *
|
||||||
startMonitor(MXS_MONITOR *mon, const MXS_CONFIG_PARAMETER *params)
|
startMonitor(MXS_MONITOR *mon, const MXS_CONFIG_PARAMETER *params)
|
||||||
{
|
{
|
||||||
AURORA_MONITOR *handle = static_cast<AURORA_MONITOR*>(mon->handle);
|
AURORA_MONITOR *handle = static_cast<AURORA_MONITOR*>(mon->instance);
|
||||||
|
|
||||||
if (handle)
|
if (handle)
|
||||||
{
|
{
|
||||||
@ -277,7 +277,7 @@ startMonitor(MXS_MONITOR *mon, const MXS_CONFIG_PARAMETER *params)
|
|||||||
* @param arg Handle on thr running monior
|
* @param arg Handle on thr running monior
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
stopMonitor(MXS_SPECIFIC_MONITOR *mon)
|
stopMonitor(MXS_MONITOR_INSTANCE *mon)
|
||||||
{
|
{
|
||||||
AURORA_MONITOR *handle = static_cast<AURORA_MONITOR*>(mon);
|
AURORA_MONITOR *handle = static_cast<AURORA_MONITOR*>(mon);
|
||||||
|
|
||||||
@ -292,7 +292,7 @@ stopMonitor(MXS_SPECIFIC_MONITOR *mon)
|
|||||||
* @param mon The monitor
|
* @param mon The monitor
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
diagnostics(const MXS_SPECIFIC_MONITOR *mon, DCB *dcb)
|
diagnostics(const MXS_MONITOR_INSTANCE *mon, DCB *dcb)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -302,7 +302,7 @@ diagnostics(const MXS_SPECIFIC_MONITOR *mon, DCB *dcb)
|
|||||||
* @param dcb DCB to send output
|
* @param dcb DCB to send output
|
||||||
* @param mon The monitor
|
* @param mon The monitor
|
||||||
*/
|
*/
|
||||||
static json_t* diagnostics_json(const MXS_SPECIFIC_MONITOR *mon)
|
static json_t* diagnostics_json(const MXS_MONITOR_INSTANCE *mon)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -318,7 +318,7 @@ extern "C"
|
|||||||
*/
|
*/
|
||||||
MXS_MODULE* MXS_CREATE_MODULE()
|
MXS_MODULE* MXS_CREATE_MODULE()
|
||||||
{
|
{
|
||||||
static MXS_MONITOR_OBJECT MyObject =
|
static MXS_MONITOR_API MyObject =
|
||||||
{
|
{
|
||||||
createInstance,
|
createInstance,
|
||||||
destroyInstance,
|
destroyInstance,
|
||||||
|
|||||||
@ -30,14 +30,14 @@ static void monitorMain(void *);
|
|||||||
/** Log a warning when a bad 'wsrep_local_index' is found */
|
/** Log a warning when a bad 'wsrep_local_index' is found */
|
||||||
static bool warn_erange_on_local_index = true;
|
static bool warn_erange_on_local_index = true;
|
||||||
|
|
||||||
static MXS_SPECIFIC_MONITOR *createInstance(MXS_MONITOR *mon,
|
static MXS_MONITOR_INSTANCE *createInstance(MXS_MONITOR *mon,
|
||||||
const MXS_CONFIG_PARAMETER *params);
|
const MXS_CONFIG_PARAMETER *params);
|
||||||
static void destroyInstance(MXS_SPECIFIC_MONITOR* monitor);
|
static void destroyInstance(MXS_MONITOR_INSTANCE* monitor);
|
||||||
static MXS_SPECIFIC_MONITOR *startMonitor(MXS_MONITOR *,
|
static MXS_MONITOR_INSTANCE *startMonitor(MXS_MONITOR *,
|
||||||
const MXS_CONFIG_PARAMETER *params);
|
const MXS_CONFIG_PARAMETER *params);
|
||||||
static void stopMonitor(MXS_SPECIFIC_MONITOR *);
|
static void stopMonitor(MXS_MONITOR_INSTANCE *);
|
||||||
static void diagnostics(const MXS_SPECIFIC_MONITOR *, DCB *);
|
static void diagnostics(const MXS_MONITOR_INSTANCE *, DCB *);
|
||||||
static json_t* diagnostics_json(const MXS_SPECIFIC_MONITOR *);
|
static json_t* diagnostics_json(const MXS_MONITOR_INSTANCE *);
|
||||||
static MXS_MONITORED_SERVER *get_candidate_master(MXS_MONITOR*);
|
static MXS_MONITORED_SERVER *get_candidate_master(MXS_MONITOR*);
|
||||||
static MXS_MONITORED_SERVER *set_cluster_master(MXS_MONITORED_SERVER *, MXS_MONITORED_SERVER *, int);
|
static MXS_MONITORED_SERVER *set_cluster_master(MXS_MONITORED_SERVER *, MXS_MONITORED_SERVER *, int);
|
||||||
static void disableMasterFailback(void *, int);
|
static void disableMasterFailback(void *, int);
|
||||||
@ -66,7 +66,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
|||||||
{
|
{
|
||||||
MXS_NOTICE("Initialise the MySQL Galera Monitor module.");
|
MXS_NOTICE("Initialise the MySQL Galera Monitor module.");
|
||||||
|
|
||||||
static MXS_MONITOR_OBJECT MyObject =
|
static MXS_MONITOR_API MyObject =
|
||||||
{
|
{
|
||||||
createInstance,
|
createInstance,
|
||||||
destroyInstance,
|
destroyInstance,
|
||||||
@ -118,7 +118,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static MXS_SPECIFIC_MONITOR *createInstance(MXS_MONITOR *mon,
|
static MXS_MONITOR_INSTANCE *createInstance(MXS_MONITOR *mon,
|
||||||
const MXS_CONFIG_PARAMETER *params)
|
const MXS_CONFIG_PARAMETER *params)
|
||||||
{
|
{
|
||||||
GALERA_MONITOR* handle = static_cast<GALERA_MONITOR*>(MXS_CALLOC(1, sizeof(GALERA_MONITOR)));
|
GALERA_MONITOR* handle = static_cast<GALERA_MONITOR*>(MXS_CALLOC(1, sizeof(GALERA_MONITOR)));
|
||||||
@ -164,7 +164,7 @@ static MXS_SPECIFIC_MONITOR *createInstance(MXS_MONITOR *mon,
|
|||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void destroyInstance(MXS_SPECIFIC_MONITOR* monitor)
|
static void destroyInstance(MXS_MONITOR_INSTANCE* monitor)
|
||||||
{
|
{
|
||||||
GALERA_MONITOR* handle = static_cast<GALERA_MONITOR*>(monitor);
|
GALERA_MONITOR* handle = static_cast<GALERA_MONITOR*>(monitor);
|
||||||
|
|
||||||
@ -180,10 +180,10 @@ static void destroyInstance(MXS_SPECIFIC_MONITOR* monitor)
|
|||||||
*
|
*
|
||||||
* @return A handle to use when interacting with the monitor
|
* @return A handle to use when interacting with the monitor
|
||||||
*/
|
*/
|
||||||
static MXS_SPECIFIC_MONITOR *
|
static MXS_MONITOR_INSTANCE *
|
||||||
startMonitor(MXS_MONITOR *mon, const MXS_CONFIG_PARAMETER *params)
|
startMonitor(MXS_MONITOR *mon, const MXS_CONFIG_PARAMETER *params)
|
||||||
{
|
{
|
||||||
GALERA_MONITOR *handle = static_cast<GALERA_MONITOR*>(mon->handle);
|
GALERA_MONITOR *handle = static_cast<GALERA_MONITOR*>(mon->instance);
|
||||||
if (handle != NULL)
|
if (handle != NULL)
|
||||||
{
|
{
|
||||||
handle->shutdown = 0;
|
handle->shutdown = 0;
|
||||||
@ -262,7 +262,7 @@ startMonitor(MXS_MONITOR *mon, const MXS_CONFIG_PARAMETER *params)
|
|||||||
* @param arg Handle on thr running monior
|
* @param arg Handle on thr running monior
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
stopMonitor(MXS_SPECIFIC_MONITOR *mon)
|
stopMonitor(MXS_MONITOR_INSTANCE *mon)
|
||||||
{
|
{
|
||||||
GALERA_MONITOR *handle = static_cast<GALERA_MONITOR*>(mon);
|
GALERA_MONITOR *handle = static_cast<GALERA_MONITOR*>(mon);
|
||||||
|
|
||||||
@ -277,7 +277,7 @@ stopMonitor(MXS_SPECIFIC_MONITOR *mon)
|
|||||||
* @param arg The monitor handle
|
* @param arg The monitor handle
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
diagnostics(const MXS_SPECIFIC_MONITOR *mon, DCB *dcb)
|
diagnostics(const MXS_MONITOR_INSTANCE *mon, DCB *dcb)
|
||||||
{
|
{
|
||||||
const GALERA_MONITOR *handle = static_cast<const GALERA_MONITOR*>(mon);
|
const GALERA_MONITOR *handle = static_cast<const GALERA_MONITOR*>(mon);
|
||||||
|
|
||||||
@ -302,7 +302,7 @@ diagnostics(const MXS_SPECIFIC_MONITOR *mon, DCB *dcb)
|
|||||||
*
|
*
|
||||||
* @param arg The monitor handle
|
* @param arg The monitor handle
|
||||||
*/
|
*/
|
||||||
static json_t* diagnostics_json(const MXS_SPECIFIC_MONITOR *mon)
|
static json_t* diagnostics_json(const MXS_MONITOR_INSTANCE *mon)
|
||||||
{
|
{
|
||||||
json_t* rval = json_object();
|
json_t* rval = json_object();
|
||||||
const GALERA_MONITOR *handle = static_cast<const GALERA_MONITOR*>(mon);
|
const GALERA_MONITOR *handle = static_cast<const GALERA_MONITOR*>(mon);
|
||||||
@ -373,7 +373,7 @@ static bool using_xtrabackup(MXS_MONITORED_SERVER *database, const char* server_
|
|||||||
static void
|
static void
|
||||||
monitorDatabase(MXS_MONITOR *mon, MXS_MONITORED_SERVER *database)
|
monitorDatabase(MXS_MONITOR *mon, MXS_MONITORED_SERVER *database)
|
||||||
{
|
{
|
||||||
GALERA_MONITOR* handle = (GALERA_MONITOR*) mon->handle;
|
GALERA_MONITOR* handle = static_cast<GALERA_MONITOR*>(mon->instance);
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
char *server_string;
|
char *server_string;
|
||||||
@ -752,7 +752,7 @@ static MXS_MONITORED_SERVER *get_candidate_master(MXS_MONITOR* mon)
|
|||||||
{
|
{
|
||||||
MXS_MONITORED_SERVER *moitor_servers = mon->monitored_servers;
|
MXS_MONITORED_SERVER *moitor_servers = mon->monitored_servers;
|
||||||
MXS_MONITORED_SERVER *candidate_master = NULL;
|
MXS_MONITORED_SERVER *candidate_master = NULL;
|
||||||
GALERA_MONITOR* handle = static_cast<GALERA_MONITOR*>(mon->handle);
|
GALERA_MONITOR* handle = static_cast<GALERA_MONITOR*>(mon->instance);
|
||||||
long min_id = -1;
|
long min_id = -1;
|
||||||
int minval = INT_MAX;
|
int minval = INT_MAX;
|
||||||
int currval;
|
int currval;
|
||||||
@ -876,7 +876,7 @@ static void update_sst_donor_nodes(MXS_MONITOR *mon, int is_cluster)
|
|||||||
MXS_MONITORED_SERVER *ptr;
|
MXS_MONITORED_SERVER *ptr;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
GALERA_MONITOR *handle = static_cast<GALERA_MONITOR*>(mon->handle);
|
GALERA_MONITOR *handle = static_cast<GALERA_MONITOR*>(mon->instance);
|
||||||
bool ignore_priority = true;
|
bool ignore_priority = true;
|
||||||
|
|
||||||
if (is_cluster == 1)
|
if (is_cluster == 1)
|
||||||
@ -1190,7 +1190,7 @@ static void nodeval_free(GALERA_NODE_INFO *in)
|
|||||||
*/
|
*/
|
||||||
static void set_galera_cluster(MXS_MONITOR *mon)
|
static void set_galera_cluster(MXS_MONITOR *mon)
|
||||||
{
|
{
|
||||||
GALERA_MONITOR *handle = static_cast<GALERA_MONITOR*>(mon->handle);
|
GALERA_MONITOR *handle = static_cast<GALERA_MONITOR*>(mon->instance);
|
||||||
int ret = false;
|
int ret = false;
|
||||||
int n_nodes = 0;
|
int n_nodes = 0;
|
||||||
HASHITERATOR *iterator;
|
HASHITERATOR *iterator;
|
||||||
@ -1277,7 +1277,7 @@ static void set_galera_cluster(MXS_MONITOR *mon)
|
|||||||
*/
|
*/
|
||||||
static void set_cluster_members(MXS_MONITOR *mon)
|
static void set_cluster_members(MXS_MONITOR *mon)
|
||||||
{
|
{
|
||||||
GALERA_MONITOR *handle = static_cast<GALERA_MONITOR*>(mon->handle);
|
GALERA_MONITOR *handle = static_cast<GALERA_MONITOR*>(mon->instance);
|
||||||
GALERA_NODE_INFO *value;
|
GALERA_NODE_INFO *value;
|
||||||
MXS_MONITORED_SERVER *ptr;
|
MXS_MONITORED_SERVER *ptr;
|
||||||
char *c_uuid = handle->cluster_info.c_uuid;
|
char *c_uuid = handle->cluster_info.c_uuid;
|
||||||
|
|||||||
@ -74,7 +74,7 @@ typedef struct galera_cluster_info
|
|||||||
/**
|
/**
|
||||||
* The handle for an instance of a Galera Monitor module
|
* The handle for an instance of a Galera Monitor module
|
||||||
*/
|
*/
|
||||||
struct GALERA_MONITOR : public MXS_SPECIFIC_MONITOR
|
struct GALERA_MONITOR : public MXS_MONITOR_INSTANCE
|
||||||
{
|
{
|
||||||
THREAD thread; /**< Monitor thread */
|
THREAD thread; /**< Monitor thread */
|
||||||
int shutdown; /**< Flag to shutdown the monitor thread */
|
int shutdown; /**< Flag to shutdown the monitor thread */
|
||||||
|
|||||||
@ -30,7 +30,7 @@
|
|||||||
/**
|
/**
|
||||||
* The instance of a Group Replication Monitor
|
* The instance of a Group Replication Monitor
|
||||||
*/
|
*/
|
||||||
struct GRMon : public MXS_SPECIFIC_MONITOR
|
struct GRMon : public MXS_MONITOR_INSTANCE
|
||||||
{
|
{
|
||||||
GRMon(const GRMon&);
|
GRMon(const GRMon&);
|
||||||
GRMon& operator&(const GRMon&);
|
GRMon& operator&(const GRMon&);
|
||||||
@ -103,13 +103,13 @@ void GRMon::stop()
|
|||||||
thread_wait(m_thread);
|
thread_wait(m_thread);
|
||||||
}
|
}
|
||||||
|
|
||||||
static MXS_SPECIFIC_MONITOR* createInstance(MXS_MONITOR *mon,
|
static MXS_MONITOR_INSTANCE* createInstance(MXS_MONITOR *mon,
|
||||||
const MXS_CONFIG_PARAMETER *params)
|
const MXS_CONFIG_PARAMETER *params)
|
||||||
{
|
{
|
||||||
return GRMon::create(mon, params);
|
return GRMon::create(mon, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void destroyInstance(MXS_SPECIFIC_MONITOR* mon)
|
static void destroyInstance(MXS_MONITOR_INSTANCE* mon)
|
||||||
{
|
{
|
||||||
GRMon* handle = static_cast<GRMon*>(mon);
|
GRMon* handle = static_cast<GRMon*>(mon);
|
||||||
delete handle;
|
delete handle;
|
||||||
@ -122,7 +122,7 @@ static void destroyInstance(MXS_SPECIFIC_MONITOR* mon)
|
|||||||
*
|
*
|
||||||
* @return A handle to use when interacting with the monitor
|
* @return A handle to use when interacting with the monitor
|
||||||
*/
|
*/
|
||||||
static MXS_SPECIFIC_MONITOR *
|
static MXS_MONITOR_INSTANCE *
|
||||||
startMonitor(MXS_MONITOR *mon, const MXS_CONFIG_PARAMETER *params)
|
startMonitor(MXS_MONITOR *mon, const MXS_CONFIG_PARAMETER *params)
|
||||||
{
|
{
|
||||||
return GRMon::create_and_start(mon, params);
|
return GRMon::create_and_start(mon, params);
|
||||||
@ -134,7 +134,7 @@ startMonitor(MXS_MONITOR *mon, const MXS_CONFIG_PARAMETER *params)
|
|||||||
* @param arg Handle on thr running monior
|
* @param arg Handle on thr running monior
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
stopMonitor(MXS_SPECIFIC_MONITOR *mon)
|
stopMonitor(MXS_MONITOR_INSTANCE *mon)
|
||||||
{
|
{
|
||||||
GRMon *handle = static_cast<GRMon*>(mon);
|
GRMon *handle = static_cast<GRMon*>(mon);
|
||||||
handle->stop();
|
handle->stop();
|
||||||
@ -148,7 +148,7 @@ stopMonitor(MXS_SPECIFIC_MONITOR *mon)
|
|||||||
* @param arg The monitor handle
|
* @param arg The monitor handle
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
diagnostics(const MXS_SPECIFIC_MONITOR *mon, DCB *dcb)
|
diagnostics(const MXS_MONITOR_INSTANCE *mon, DCB *dcb)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,7 +157,7 @@ diagnostics(const MXS_SPECIFIC_MONITOR *mon, DCB *dcb)
|
|||||||
*
|
*
|
||||||
* @param arg The monitor handle
|
* @param arg The monitor handle
|
||||||
*/
|
*/
|
||||||
static json_t* diagnostics_json(const MXS_SPECIFIC_MONITOR *mon)
|
static json_t* diagnostics_json(const MXS_MONITOR_INSTANCE *mon)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -342,7 +342,7 @@ extern "C"
|
|||||||
*/
|
*/
|
||||||
MXS_MODULE* MXS_CREATE_MODULE()
|
MXS_MODULE* MXS_CREATE_MODULE()
|
||||||
{
|
{
|
||||||
static MXS_MONITOR_OBJECT MyObject =
|
static MXS_MONITOR_API MyObject =
|
||||||
{
|
{
|
||||||
createInstance,
|
createInstance,
|
||||||
destroyInstance,
|
destroyInstance,
|
||||||
|
|||||||
@ -150,7 +150,7 @@ MariaDBMonitor* MariaDBMonitor::create(MXS_MONITOR *monitor, const MXS_CONFIG_PA
|
|||||||
MariaDBMonitor* MariaDBMonitor::create_and_start(MXS_MONITOR *monitor, const MXS_CONFIG_PARAMETER* params)
|
MariaDBMonitor* MariaDBMonitor::create_and_start(MXS_MONITOR *monitor, const MXS_CONFIG_PARAMETER* params)
|
||||||
{
|
{
|
||||||
bool error = false;
|
bool error = false;
|
||||||
MariaDBMonitor *handle = static_cast<MariaDBMonitor*>(monitor->handle);
|
MariaDBMonitor *handle = static_cast<MariaDBMonitor*>(monitor->instance);
|
||||||
if (handle == NULL)
|
if (handle == NULL)
|
||||||
{
|
{
|
||||||
handle = new MariaDBMonitor(monitor);
|
handle = new MariaDBMonitor(monitor);
|
||||||
@ -928,13 +928,13 @@ bool MariaDBMonitor::check_sql_files()
|
|||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
static MXS_SPECIFIC_MONITOR* createInstance(MXS_MONITOR *monitor,
|
static MXS_MONITOR_INSTANCE* createInstance(MXS_MONITOR *monitor,
|
||||||
const MXS_CONFIG_PARAMETER* params)
|
const MXS_CONFIG_PARAMETER* params)
|
||||||
{
|
{
|
||||||
return MariaDBMonitor::create(monitor, params);
|
return MariaDBMonitor::create(monitor, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void destroyInstance(MXS_SPECIFIC_MONITOR* monitor)
|
static void destroyInstance(MXS_MONITOR_INSTANCE* monitor)
|
||||||
{
|
{
|
||||||
MariaDBMonitor::destroy(static_cast<MariaDBMonitor*>(monitor));
|
MariaDBMonitor::destroy(static_cast<MariaDBMonitor*>(monitor));
|
||||||
}
|
}
|
||||||
@ -947,7 +947,7 @@ static void destroyInstance(MXS_SPECIFIC_MONITOR* monitor)
|
|||||||
* @param params Configuration parameters
|
* @param params Configuration parameters
|
||||||
* @return A pointer to MariaDBMonitor specific data. Should be stored in MXS_MONITOR's "handle"-field.
|
* @return A pointer to MariaDBMonitor specific data. Should be stored in MXS_MONITOR's "handle"-field.
|
||||||
*/
|
*/
|
||||||
static MXS_SPECIFIC_MONITOR* startMonitor(MXS_MONITOR *monitor,
|
static MXS_MONITOR_INSTANCE* startMonitor(MXS_MONITOR *monitor,
|
||||||
const MXS_CONFIG_PARAMETER* params)
|
const MXS_CONFIG_PARAMETER* params)
|
||||||
{
|
{
|
||||||
return MariaDBMonitor::create_and_start(monitor, params);
|
return MariaDBMonitor::create_and_start(monitor, params);
|
||||||
@ -958,7 +958,7 @@ static MXS_SPECIFIC_MONITOR* startMonitor(MXS_MONITOR *monitor,
|
|||||||
*
|
*
|
||||||
* @param mon The monitor that should be stopped.
|
* @param mon The monitor that should be stopped.
|
||||||
*/
|
*/
|
||||||
static void stopMonitor(MXS_SPECIFIC_MONITOR *mon)
|
static void stopMonitor(MXS_MONITOR_INSTANCE *mon)
|
||||||
{
|
{
|
||||||
auto handle = static_cast<MariaDBMonitor*>(mon);
|
auto handle = static_cast<MariaDBMonitor*>(mon);
|
||||||
handle->stop();
|
handle->stop();
|
||||||
@ -970,7 +970,7 @@ static void stopMonitor(MXS_SPECIFIC_MONITOR *mon)
|
|||||||
* @param dcb DCB to print diagnostics
|
* @param dcb DCB to print diagnostics
|
||||||
* @param arg The monitor handle
|
* @param arg The monitor handle
|
||||||
*/
|
*/
|
||||||
static void diagnostics(const MXS_SPECIFIC_MONITOR *mon, DCB *dcb)
|
static void diagnostics(const MXS_MONITOR_INSTANCE *mon, DCB *dcb)
|
||||||
{
|
{
|
||||||
const MariaDBMonitor* handle = static_cast<const MariaDBMonitor*>(mon);
|
const MariaDBMonitor* handle = static_cast<const MariaDBMonitor*>(mon);
|
||||||
handle->diagnostics(dcb);
|
handle->diagnostics(dcb);
|
||||||
@ -981,7 +981,7 @@ static void diagnostics(const MXS_SPECIFIC_MONITOR *mon, DCB *dcb)
|
|||||||
*
|
*
|
||||||
* @param arg The monitor handle
|
* @param arg The monitor handle
|
||||||
*/
|
*/
|
||||||
static json_t* diagnostics_json(const MXS_SPECIFIC_MONITOR *mon)
|
static json_t* diagnostics_json(const MXS_MONITOR_INSTANCE *mon)
|
||||||
{
|
{
|
||||||
const MariaDBMonitor *handle = static_cast<const MariaDBMonitor*>(mon);
|
const MariaDBMonitor *handle = static_cast<const MariaDBMonitor*>(mon);
|
||||||
return handle->diagnostics_json();
|
return handle->diagnostics_json();
|
||||||
@ -1011,7 +1011,7 @@ bool handle_manual_switchover(const MODULECMD_ARG* args, json_t** error_out)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
MXS_MONITOR* mon = args->argv[0].value.monitor;
|
MXS_MONITOR* mon = args->argv[0].value.monitor;
|
||||||
auto handle = static_cast<MariaDBMonitor*>(mon->handle);
|
auto handle = static_cast<MariaDBMonitor*>(mon->instance);
|
||||||
SERVER* new_master = (args->argc >= 2) ? args->argv[1].value.server : NULL;
|
SERVER* new_master = (args->argc >= 2) ? args->argv[1].value.server : NULL;
|
||||||
SERVER* current_master = (args->argc == 3) ? args->argv[2].value.server : NULL;
|
SERVER* current_master = (args->argc == 3) ? args->argv[2].value.server : NULL;
|
||||||
rval = handle->manual_switchover(new_master, current_master, error_out);
|
rval = handle->manual_switchover(new_master, current_master, error_out);
|
||||||
@ -1039,7 +1039,7 @@ bool handle_manual_failover(const MODULECMD_ARG* args, json_t** output)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
MXS_MONITOR* mon = args->argv[0].value.monitor;
|
MXS_MONITOR* mon = args->argv[0].value.monitor;
|
||||||
auto handle = static_cast<MariaDBMonitor*>(mon->handle);
|
auto handle = static_cast<MariaDBMonitor*>(mon->instance);
|
||||||
rv = handle->manual_failover(output);
|
rv = handle->manual_failover(output);
|
||||||
}
|
}
|
||||||
return rv;
|
return rv;
|
||||||
@ -1067,7 +1067,7 @@ bool handle_manual_rejoin(const MODULECMD_ARG* args, json_t** output)
|
|||||||
{
|
{
|
||||||
MXS_MONITOR* mon = args->argv[0].value.monitor;
|
MXS_MONITOR* mon = args->argv[0].value.monitor;
|
||||||
SERVER* server = args->argv[1].value.server;
|
SERVER* server = args->argv[1].value.server;
|
||||||
auto handle = static_cast<MariaDBMonitor*>(mon->handle);
|
auto handle = static_cast<MariaDBMonitor*>(mon->instance);
|
||||||
rv = handle->manual_rejoin(server, output);
|
rv = handle->manual_rejoin(server, output);
|
||||||
}
|
}
|
||||||
return rv;
|
return rv;
|
||||||
@ -1154,7 +1154,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
|||||||
handle_manual_rejoin, MXS_ARRAY_NELEMS(rejoin_argv),
|
handle_manual_rejoin, MXS_ARRAY_NELEMS(rejoin_argv),
|
||||||
rejoin_argv, "Rejoin server to a cluster");
|
rejoin_argv, "Rejoin server to a cluster");
|
||||||
|
|
||||||
static MXS_MONITOR_OBJECT MyObject =
|
static MXS_MONITOR_API MyObject =
|
||||||
{
|
{
|
||||||
createInstance,
|
createInstance,
|
||||||
destroyInstance,
|
destroyInstance,
|
||||||
|
|||||||
@ -35,7 +35,7 @@ typedef std::tr1::unordered_map<MXS_MONITORED_SERVER*, MariaDBServer*> ServerInf
|
|||||||
typedef std::vector<MariaDBServer*> ServerArray;
|
typedef std::vector<MariaDBServer*> ServerArray;
|
||||||
|
|
||||||
// MariaDB Monitor instance data
|
// MariaDB Monitor instance data
|
||||||
class MariaDBMonitor : public MXS_SPECIFIC_MONITOR
|
class MariaDBMonitor : public MXS_MONITOR_INSTANCE
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
MariaDBMonitor(const MariaDBMonitor&);
|
MariaDBMonitor(const MariaDBMonitor&);
|
||||||
|
|||||||
@ -38,12 +38,12 @@ MXS_MODULE info =
|
|||||||
};
|
};
|
||||||
/*lint +e14 */
|
/*lint +e14 */
|
||||||
|
|
||||||
static MXS_SPECIFIC_MONITOR *createInstance(MXS_MONITOR *, const MXS_CONFIG_PARAMETER *);
|
static MXS_MONITOR_INSTANCE *createInstance(MXS_MONITOR *, const MXS_CONFIG_PARAMETER *);
|
||||||
static void destroyInstance(MXS_SPECIFIC_MONITOR *);
|
static void destroyInstance(MXS_MONITOR_INSTANCE *);
|
||||||
static MXS_SPECIFIC_MONITOR *startMonitor(MXS_MONITOR *, const MXS_CONFIG_PARAMETER *);
|
static MXS_MONITOR_INSTANCE *startMonitor(MXS_MONITOR *, const MXS_CONFIG_PARAMETER *);
|
||||||
static void stopMonitor(MXS_SPECIFIC_MONITOR *);
|
static void stopMonitor(MXS_MONITOR_INSTANCE *);
|
||||||
static void diagnostics(const MXS_SPECIFIC_MONITOR *, DCB *);
|
static void diagnostics(const MXS_MONITOR_INSTANCE *, DCB *);
|
||||||
static json_t* diagnostics_json(const MXS_SPECIFIC_MONITOR *);
|
static json_t* diagnostics_json(const MXS_MONITOR_INSTANCE *);
|
||||||
static void detectStaleMaster(void *, int);
|
static void detectStaleMaster(void *, int);
|
||||||
static MXS_MONITORED_SERVER *get_current_master(MXS_MONITOR *);
|
static MXS_MONITORED_SERVER *get_current_master(MXS_MONITOR *);
|
||||||
static bool isMySQLEvent(mxs_monitor_event_t event);
|
static bool isMySQLEvent(mxs_monitor_event_t event);
|
||||||
@ -62,7 +62,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
|||||||
{
|
{
|
||||||
MXS_NOTICE("Initialise the Multi-Master Monitor module.");
|
MXS_NOTICE("Initialise the Multi-Master Monitor module.");
|
||||||
|
|
||||||
static MXS_MONITOR_OBJECT MyObject =
|
static MXS_MONITOR_API MyObject =
|
||||||
{
|
{
|
||||||
createInstance,
|
createInstance,
|
||||||
destroyInstance,
|
destroyInstance,
|
||||||
@ -110,7 +110,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
|||||||
}
|
}
|
||||||
/*lint +e14 */
|
/*lint +e14 */
|
||||||
|
|
||||||
static MXS_SPECIFIC_MONITOR* createInstance(MXS_MONITOR *mon,
|
static MXS_MONITOR_INSTANCE* createInstance(MXS_MONITOR *mon,
|
||||||
const MXS_CONFIG_PARAMETER *params)
|
const MXS_CONFIG_PARAMETER *params)
|
||||||
{
|
{
|
||||||
MM_MONITOR* handle = static_cast<MM_MONITOR*>(MXS_CALLOC(1, sizeof(MM_MONITOR)));
|
MM_MONITOR* handle = static_cast<MM_MONITOR*>(MXS_CALLOC(1, sizeof(MM_MONITOR)));
|
||||||
@ -140,7 +140,7 @@ static MXS_SPECIFIC_MONITOR* createInstance(MXS_MONITOR *mon,
|
|||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void destroyInstance(MXS_SPECIFIC_MONITOR* mon)
|
static void destroyInstance(MXS_MONITOR_INSTANCE* mon)
|
||||||
{
|
{
|
||||||
MM_MONITOR* handle = static_cast<MM_MONITOR*>(mon);
|
MM_MONITOR* handle = static_cast<MM_MONITOR*>(mon);
|
||||||
|
|
||||||
@ -156,10 +156,10 @@ static void destroyInstance(MXS_SPECIFIC_MONITOR* mon)
|
|||||||
* @param arg The current handle - NULL if first start
|
* @param arg The current handle - NULL if first start
|
||||||
* @return A handle to use when interacting with the monitor
|
* @return A handle to use when interacting with the monitor
|
||||||
*/
|
*/
|
||||||
static MXS_SPECIFIC_MONITOR *
|
static MXS_MONITOR_INSTANCE *
|
||||||
startMonitor(MXS_MONITOR *mon, const MXS_CONFIG_PARAMETER *params)
|
startMonitor(MXS_MONITOR *mon, const MXS_CONFIG_PARAMETER *params)
|
||||||
{
|
{
|
||||||
MM_MONITOR *handle = static_cast<MM_MONITOR*>(mon->handle);
|
MM_MONITOR *handle = static_cast<MM_MONITOR*>(mon->instance);
|
||||||
|
|
||||||
if (handle)
|
if (handle)
|
||||||
{
|
{
|
||||||
@ -209,7 +209,7 @@ startMonitor(MXS_MONITOR *mon, const MXS_CONFIG_PARAMETER *params)
|
|||||||
* @param arg Handle on thr running monior
|
* @param arg Handle on thr running monior
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
stopMonitor(MXS_SPECIFIC_MONITOR *mon)
|
stopMonitor(MXS_MONITOR_INSTANCE *mon)
|
||||||
{
|
{
|
||||||
MM_MONITOR *handle = static_cast<MM_MONITOR*>(mon);
|
MM_MONITOR *handle = static_cast<MM_MONITOR*>(mon);
|
||||||
|
|
||||||
@ -223,7 +223,7 @@ stopMonitor(MXS_SPECIFIC_MONITOR *mon)
|
|||||||
* @param dcb DCB to print diagnostics
|
* @param dcb DCB to print diagnostics
|
||||||
* @param arg The monitor handle
|
* @param arg The monitor handle
|
||||||
*/
|
*/
|
||||||
static void diagnostics(const MXS_SPECIFIC_MONITOR *mon, DCB *dcb)
|
static void diagnostics(const MXS_MONITOR_INSTANCE *mon, DCB *dcb)
|
||||||
{
|
{
|
||||||
const MM_MONITOR *handle = static_cast<const MM_MONITOR*>(mon);
|
const MM_MONITOR *handle = static_cast<const MM_MONITOR*>(mon);
|
||||||
|
|
||||||
@ -235,7 +235,7 @@ static void diagnostics(const MXS_SPECIFIC_MONITOR *mon, DCB *dcb)
|
|||||||
*
|
*
|
||||||
* @param arg The monitor handle
|
* @param arg The monitor handle
|
||||||
*/
|
*/
|
||||||
static json_t* diagnostics_json(const MXS_SPECIFIC_MONITOR *mon)
|
static json_t* diagnostics_json(const MXS_MONITOR_INSTANCE *mon)
|
||||||
{
|
{
|
||||||
const MM_MONITOR *handle = static_cast<const MM_MONITOR*>(mon);
|
const MM_MONITOR *handle = static_cast<const MM_MONITOR*>(mon);
|
||||||
|
|
||||||
@ -701,7 +701,7 @@ detectStaleMaster(void *arg, int enable)
|
|||||||
|
|
||||||
static MXS_MONITORED_SERVER *get_current_master(MXS_MONITOR *mon)
|
static MXS_MONITORED_SERVER *get_current_master(MXS_MONITOR *mon)
|
||||||
{
|
{
|
||||||
MM_MONITOR* handle = static_cast<MM_MONITOR*>(mon->handle);
|
MM_MONITOR* handle = static_cast<MM_MONITOR*>(mon->instance);
|
||||||
MXS_MONITORED_SERVER *ptr;
|
MXS_MONITORED_SERVER *ptr;
|
||||||
|
|
||||||
ptr = mon->monitored_servers;
|
ptr = mon->monitored_servers;
|
||||||
|
|||||||
@ -36,7 +36,7 @@
|
|||||||
/**
|
/**
|
||||||
* The handle for an instance of a Multi-Master Monitor module
|
* The handle for an instance of a Multi-Master Monitor module
|
||||||
*/
|
*/
|
||||||
struct MM_MONITOR : public MXS_SPECIFIC_MONITOR
|
struct MM_MONITOR : public MXS_MONITOR_INSTANCE
|
||||||
{
|
{
|
||||||
THREAD thread; /**< Monitor thread */
|
THREAD thread; /**< Monitor thread */
|
||||||
int shutdown; /**< Flag to shutdown the monitor thread */
|
int shutdown; /**< Flag to shutdown the monitor thread */
|
||||||
|
|||||||
@ -30,14 +30,14 @@ static void monitorMain(void *);
|
|||||||
|
|
||||||
/*lint +e14 */
|
/*lint +e14 */
|
||||||
|
|
||||||
static MXS_SPECIFIC_MONITOR *createInstance(MXS_MONITOR *,
|
static MXS_MONITOR_INSTANCE *createInstance(MXS_MONITOR *,
|
||||||
const MXS_CONFIG_PARAMETER *params);
|
const MXS_CONFIG_PARAMETER *params);
|
||||||
static void destroyInstance(MXS_SPECIFIC_MONITOR*);
|
static void destroyInstance(MXS_MONITOR_INSTANCE*);
|
||||||
static MXS_SPECIFIC_MONITOR *startMonitor(MXS_MONITOR *,
|
static MXS_MONITOR_INSTANCE *startMonitor(MXS_MONITOR *,
|
||||||
const MXS_CONFIG_PARAMETER *params);
|
const MXS_CONFIG_PARAMETER *params);
|
||||||
static void stopMonitor(MXS_SPECIFIC_MONITOR *);
|
static void stopMonitor(MXS_MONITOR_INSTANCE *);
|
||||||
static void diagnostics(const MXS_SPECIFIC_MONITOR *, DCB *);
|
static void diagnostics(const MXS_MONITOR_INSTANCE *, DCB *);
|
||||||
static json_t* diagnostics_json(const MXS_SPECIFIC_MONITOR *);
|
static json_t* diagnostics_json(const MXS_MONITOR_INSTANCE *);
|
||||||
bool isNdbEvent(mxs_monitor_event_t event);
|
bool isNdbEvent(mxs_monitor_event_t event);
|
||||||
|
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
|||||||
{
|
{
|
||||||
MXS_NOTICE("Initialise the MySQL Cluster Monitor module.");
|
MXS_NOTICE("Initialise the MySQL Cluster Monitor module.");
|
||||||
|
|
||||||
static MXS_MONITOR_OBJECT MyObject =
|
static MXS_MONITOR_API MyObject =
|
||||||
{
|
{
|
||||||
createInstance,
|
createInstance,
|
||||||
destroyInstance,
|
destroyInstance,
|
||||||
@ -104,7 +104,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
|||||||
}
|
}
|
||||||
/*lint +e14 */
|
/*lint +e14 */
|
||||||
|
|
||||||
static MXS_SPECIFIC_MONITOR* createInstance(MXS_MONITOR *mon,
|
static MXS_MONITOR_INSTANCE* createInstance(MXS_MONITOR *mon,
|
||||||
const MXS_CONFIG_PARAMETER *params)
|
const MXS_CONFIG_PARAMETER *params)
|
||||||
{
|
{
|
||||||
NDBC_MONITOR* handle = static_cast<NDBC_MONITOR*>(MXS_CALLOC(1, sizeof(NDBC_MONITOR)));
|
NDBC_MONITOR* handle = static_cast<NDBC_MONITOR*>(MXS_CALLOC(1, sizeof(NDBC_MONITOR)));
|
||||||
@ -134,7 +134,7 @@ static MXS_SPECIFIC_MONITOR* createInstance(MXS_MONITOR *mon,
|
|||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
void destroyInstance(MXS_SPECIFIC_MONITOR* mon)
|
void destroyInstance(MXS_MONITOR_INSTANCE* mon)
|
||||||
{
|
{
|
||||||
NDBC_MONITOR* handle = static_cast<NDBC_MONITOR*>(mon);
|
NDBC_MONITOR* handle = static_cast<NDBC_MONITOR*>(mon);
|
||||||
|
|
||||||
@ -149,10 +149,10 @@ void destroyInstance(MXS_SPECIFIC_MONITOR* mon)
|
|||||||
*
|
*
|
||||||
* @return A handle to use when interacting with the monitor
|
* @return A handle to use when interacting with the monitor
|
||||||
*/
|
*/
|
||||||
static MXS_SPECIFIC_MONITOR *
|
static MXS_MONITOR_INSTANCE *
|
||||||
startMonitor(MXS_MONITOR *mon, const MXS_CONFIG_PARAMETER *params)
|
startMonitor(MXS_MONITOR *mon, const MXS_CONFIG_PARAMETER *params)
|
||||||
{
|
{
|
||||||
NDBC_MONITOR *handle = static_cast<NDBC_MONITOR*>(mon->handle);
|
NDBC_MONITOR *handle = static_cast<NDBC_MONITOR*>(mon->instance);
|
||||||
bool have_events = false, script_error = false;
|
bool have_events = false, script_error = false;
|
||||||
|
|
||||||
if (handle != NULL)
|
if (handle != NULL)
|
||||||
@ -203,7 +203,7 @@ startMonitor(MXS_MONITOR *mon, const MXS_CONFIG_PARAMETER *params)
|
|||||||
* @param arg Handle on thr running monior
|
* @param arg Handle on thr running monior
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
stopMonitor(MXS_SPECIFIC_MONITOR *mon)
|
stopMonitor(MXS_MONITOR_INSTANCE *mon)
|
||||||
{
|
{
|
||||||
NDBC_MONITOR *handle = static_cast<NDBC_MONITOR*>(mon);
|
NDBC_MONITOR *handle = static_cast<NDBC_MONITOR*>(mon);
|
||||||
|
|
||||||
@ -218,7 +218,7 @@ stopMonitor(MXS_SPECIFIC_MONITOR *mon)
|
|||||||
* @param arg The monitor handle
|
* @param arg The monitor handle
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
diagnostics(const MXS_SPECIFIC_MONITOR *mon, DCB *dcb)
|
diagnostics(const MXS_MONITOR_INSTANCE *mon, DCB *dcb)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,7 +228,7 @@ diagnostics(const MXS_SPECIFIC_MONITOR *mon, DCB *dcb)
|
|||||||
* @param dcb DCB to send output
|
* @param dcb DCB to send output
|
||||||
* @param arg The monitor handle
|
* @param arg The monitor handle
|
||||||
*/
|
*/
|
||||||
static json_t* diagnostics_json(const MXS_SPECIFIC_MONITOR *mon)
|
static json_t* diagnostics_json(const MXS_MONITOR_INSTANCE *mon)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,7 +18,7 @@
|
|||||||
#include <maxscale/thread.h>
|
#include <maxscale/thread.h>
|
||||||
|
|
||||||
// The handle for an instance of a NDB Cluster Monitor module
|
// The handle for an instance of a NDB Cluster Monitor module
|
||||||
struct NDBC_MONITOR : public MXS_SPECIFIC_MONITOR
|
struct NDBC_MONITOR : public MXS_MONITOR_INSTANCE
|
||||||
{
|
{
|
||||||
THREAD thread; /**< Monitor thread */
|
THREAD thread; /**< Monitor thread */
|
||||||
SPINLOCK lock; /**< The monitor spinlock */
|
SPINLOCK lock; /**< The monitor spinlock */
|
||||||
|
|||||||
Reference in New Issue
Block a user