MXS-1848 Use MXS_SPECIFIC_MONITOR type in monitor APIs
Now, all monitor functions but startMonitor takes a MXS_SPECIFIC_MONITOR instead of MXS_MONITOR. That is, startMonitor is now like a static factory member returning a new specific monitor instance and the other functions are like member functions of that instance.
This commit is contained in:
@ -235,9 +235,9 @@ startMonitor(MXS_MONITOR *mon, const MXS_CONFIG_PARAMETER *params)
|
||||
* @param arg Handle on thr running monior
|
||||
*/
|
||||
static void
|
||||
stopMonitor(MXS_MONITOR *mon)
|
||||
stopMonitor(MXS_SPECIFIC_MONITOR *mon)
|
||||
{
|
||||
AURORA_MONITOR *handle = (AURORA_MONITOR *) mon->handle;
|
||||
AURORA_MONITOR *handle = static_cast<AURORA_MONITOR*>(mon);
|
||||
|
||||
handle->shutdown = true;
|
||||
thread_wait(handle->thread);
|
||||
@ -250,7 +250,7 @@ stopMonitor(MXS_MONITOR *mon)
|
||||
* @param mon The monitor
|
||||
*/
|
||||
static void
|
||||
diagnostics(DCB *dcb, const MXS_MONITOR *mon)
|
||||
diagnostics(const MXS_SPECIFIC_MONITOR *mon, DCB *dcb)
|
||||
{
|
||||
}
|
||||
|
||||
@ -260,7 +260,7 @@ diagnostics(DCB *dcb, const MXS_MONITOR *mon)
|
||||
* @param dcb DCB to send output
|
||||
* @param mon The monitor
|
||||
*/
|
||||
static json_t* diagnostics_json(const MXS_MONITOR *mon)
|
||||
static json_t* diagnostics_json(const MXS_SPECIFIC_MONITOR *mon)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
@ -32,9 +32,9 @@ static bool warn_erange_on_local_index = true;
|
||||
|
||||
static MXS_SPECIFIC_MONITOR *startMonitor(MXS_MONITOR *,
|
||||
const MXS_CONFIG_PARAMETER *params);
|
||||
static void stopMonitor(MXS_MONITOR *);
|
||||
static void diagnostics(DCB *, const MXS_MONITOR *);
|
||||
static json_t* diagnostics_json(const MXS_MONITOR *);
|
||||
static void stopMonitor(MXS_SPECIFIC_MONITOR *);
|
||||
static void diagnostics(const MXS_SPECIFIC_MONITOR *, DCB *);
|
||||
static json_t* diagnostics_json(const MXS_SPECIFIC_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 void disableMasterFailback(void *, int);
|
||||
@ -200,9 +200,9 @@ startMonitor(MXS_MONITOR *mon, const MXS_CONFIG_PARAMETER *params)
|
||||
* @param arg Handle on thr running monior
|
||||
*/
|
||||
static void
|
||||
stopMonitor(MXS_MONITOR *mon)
|
||||
stopMonitor(MXS_SPECIFIC_MONITOR *mon)
|
||||
{
|
||||
GALERA_MONITOR *handle = (GALERA_MONITOR *) mon->handle;
|
||||
GALERA_MONITOR *handle = static_cast<GALERA_MONITOR*>(mon);
|
||||
|
||||
handle->shutdown = 1;
|
||||
thread_wait(handle->thread);
|
||||
@ -215,9 +215,9 @@ stopMonitor(MXS_MONITOR *mon)
|
||||
* @param arg The monitor handle
|
||||
*/
|
||||
static void
|
||||
diagnostics(DCB *dcb, const MXS_MONITOR *mon)
|
||||
diagnostics(const MXS_SPECIFIC_MONITOR *mon, DCB *dcb)
|
||||
{
|
||||
const GALERA_MONITOR *handle = (const GALERA_MONITOR *) mon->handle;
|
||||
const GALERA_MONITOR *handle = static_cast<const GALERA_MONITOR*>(mon);
|
||||
|
||||
dcb_printf(dcb, "Master Failback:\t%s\n", (handle->disableMasterFailback == 1) ? "off" : "on");
|
||||
dcb_printf(dcb, "Available when Donor:\t%s\n", (handle->availableWhenDonor == 1) ? "on" : "off");
|
||||
@ -240,10 +240,10 @@ diagnostics(DCB *dcb, const MXS_MONITOR *mon)
|
||||
*
|
||||
* @param arg The monitor handle
|
||||
*/
|
||||
static json_t* diagnostics_json(const MXS_MONITOR *mon)
|
||||
static json_t* diagnostics_json(const MXS_SPECIFIC_MONITOR *mon)
|
||||
{
|
||||
json_t* rval = json_object();
|
||||
const GALERA_MONITOR *handle = (const GALERA_MONITOR *)mon->handle;
|
||||
const GALERA_MONITOR *handle = static_cast<const GALERA_MONITOR*>(mon);
|
||||
|
||||
json_object_set_new(rval, "disable_master_failback", json_boolean(handle->disableMasterFailback));
|
||||
json_object_set_new(rval, "disable_master_role_setting", json_boolean(handle->disableMasterRoleSetting));
|
||||
|
@ -111,12 +111,11 @@ startMonitor(MXS_MONITOR *mon, const MXS_CONFIG_PARAMETER *params)
|
||||
* @param arg Handle on thr running monior
|
||||
*/
|
||||
static void
|
||||
stopMonitor(MXS_MONITOR *mon)
|
||||
stopMonitor(MXS_SPECIFIC_MONITOR *mon)
|
||||
{
|
||||
GRMon *handle = (GRMon *) mon->handle;
|
||||
GRMon *handle = static_cast<GRMon*>(mon);
|
||||
handle->stop();
|
||||
delete handle;
|
||||
mon->handle = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -126,7 +125,7 @@ stopMonitor(MXS_MONITOR *mon)
|
||||
* @param arg The monitor handle
|
||||
*/
|
||||
static void
|
||||
diagnostics(DCB *dcb, const MXS_MONITOR *mon)
|
||||
diagnostics(const MXS_SPECIFIC_MONITOR *mon, DCB *dcb)
|
||||
{
|
||||
}
|
||||
|
||||
@ -135,7 +134,7 @@ diagnostics(DCB *dcb, const MXS_MONITOR *mon)
|
||||
*
|
||||
* @param arg The monitor handle
|
||||
*/
|
||||
static json_t* diagnostics_json(const MXS_MONITOR *mon)
|
||||
static json_t* diagnostics_json(const MXS_SPECIFIC_MONITOR *mon)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
@ -923,9 +923,9 @@ static MXS_SPECIFIC_MONITOR* startMonitor(MXS_MONITOR *monitor,
|
||||
*
|
||||
* @param mon The monitor that should be stopped.
|
||||
*/
|
||||
static void stopMonitor(MXS_MONITOR *mon)
|
||||
static void stopMonitor(MXS_SPECIFIC_MONITOR *mon)
|
||||
{
|
||||
auto handle = static_cast<MariaDBMonitor*>(mon->handle);
|
||||
auto handle = static_cast<MariaDBMonitor*>(mon);
|
||||
handle->stop();
|
||||
}
|
||||
|
||||
@ -935,9 +935,9 @@ static void stopMonitor(MXS_MONITOR *mon)
|
||||
* @param dcb DCB to print diagnostics
|
||||
* @param arg The monitor handle
|
||||
*/
|
||||
static void diagnostics(DCB *dcb, const MXS_MONITOR *mon)
|
||||
static void diagnostics(const MXS_SPECIFIC_MONITOR *mon, DCB *dcb)
|
||||
{
|
||||
const MariaDBMonitor* handle = static_cast<const MariaDBMonitor*>(mon->handle);
|
||||
const MariaDBMonitor* handle = static_cast<const MariaDBMonitor*>(mon);
|
||||
handle->diagnostics(dcb);
|
||||
}
|
||||
|
||||
@ -946,9 +946,9 @@ static void diagnostics(DCB *dcb, const MXS_MONITOR *mon)
|
||||
*
|
||||
* @param arg The monitor handle
|
||||
*/
|
||||
static json_t* diagnostics_json(const MXS_MONITOR *mon)
|
||||
static json_t* diagnostics_json(const MXS_SPECIFIC_MONITOR *mon)
|
||||
{
|
||||
const MariaDBMonitor *handle = (const MariaDBMonitor *)mon->handle;
|
||||
const MariaDBMonitor *handle = static_cast<const MariaDBMonitor*>(mon);
|
||||
return handle->diagnostics_json();
|
||||
}
|
||||
|
||||
|
@ -39,9 +39,9 @@ MXS_MODULE info =
|
||||
/*lint +e14 */
|
||||
|
||||
static MXS_SPECIFIC_MONITOR *startMonitor(MXS_MONITOR *, const MXS_CONFIG_PARAMETER *);
|
||||
static void stopMonitor(MXS_MONITOR *);
|
||||
static void diagnostics(DCB *, const MXS_MONITOR *);
|
||||
static json_t* diagnostics_json(const MXS_MONITOR *);
|
||||
static void stopMonitor(MXS_SPECIFIC_MONITOR *);
|
||||
static void diagnostics(const MXS_SPECIFIC_MONITOR *, DCB *);
|
||||
static json_t* diagnostics_json(const MXS_SPECIFIC_MONITOR *);
|
||||
static void detectStaleMaster(void *, int);
|
||||
static MXS_MONITORED_SERVER *get_current_master(MXS_MONITOR *);
|
||||
static bool isMySQLEvent(mxs_monitor_event_t event);
|
||||
@ -165,9 +165,9 @@ startMonitor(MXS_MONITOR *mon, const MXS_CONFIG_PARAMETER *params)
|
||||
* @param arg Handle on thr running monior
|
||||
*/
|
||||
static void
|
||||
stopMonitor(MXS_MONITOR *mon)
|
||||
stopMonitor(MXS_SPECIFIC_MONITOR *mon)
|
||||
{
|
||||
MM_MONITOR *handle = (MM_MONITOR *) mon->handle;
|
||||
MM_MONITOR *handle = static_cast<MM_MONITOR*>(mon);
|
||||
|
||||
handle->shutdown = 1;
|
||||
thread_wait(handle->thread);
|
||||
@ -179,9 +179,9 @@ stopMonitor(MXS_MONITOR *mon)
|
||||
* @param dcb DCB to print diagnostics
|
||||
* @param arg The monitor handle
|
||||
*/
|
||||
static void diagnostics(DCB *dcb, const MXS_MONITOR *mon)
|
||||
static void diagnostics(const MXS_SPECIFIC_MONITOR *mon, DCB *dcb)
|
||||
{
|
||||
const MM_MONITOR *handle = (const MM_MONITOR *) mon->handle;
|
||||
const MM_MONITOR *handle = static_cast<const MM_MONITOR*>(mon);
|
||||
|
||||
dcb_printf(dcb, "Detect Stale Master:\t%s\n", (handle->detectStaleMaster == 1) ? "enabled" : "disabled");
|
||||
}
|
||||
@ -191,9 +191,9 @@ static void diagnostics(DCB *dcb, const MXS_MONITOR *mon)
|
||||
*
|
||||
* @param arg The monitor handle
|
||||
*/
|
||||
static json_t* diagnostics_json(const MXS_MONITOR *mon)
|
||||
static json_t* diagnostics_json(const MXS_SPECIFIC_MONITOR *mon)
|
||||
{
|
||||
const MM_MONITOR *handle = (const MM_MONITOR *)mon->handle;
|
||||
const MM_MONITOR *handle = static_cast<const MM_MONITOR*>(mon);
|
||||
|
||||
json_t* rval = json_object();
|
||||
json_object_set_new(rval, "detect_stale_master", json_boolean(handle->detectStaleMaster));
|
||||
|
@ -32,9 +32,9 @@ static void monitorMain(void *);
|
||||
|
||||
static MXS_SPECIFIC_MONITOR *startMonitor(MXS_MONITOR *,
|
||||
const MXS_CONFIG_PARAMETER *params);
|
||||
static void stopMonitor(MXS_MONITOR *);
|
||||
static void diagnostics(DCB *, const MXS_MONITOR *);
|
||||
static json_t* diagnostics_json(const MXS_MONITOR *);
|
||||
static void stopMonitor(MXS_SPECIFIC_MONITOR *);
|
||||
static void diagnostics(const MXS_SPECIFIC_MONITOR *, DCB *);
|
||||
static json_t* diagnostics_json(const MXS_SPECIFIC_MONITOR *);
|
||||
bool isNdbEvent(mxs_monitor_event_t event);
|
||||
|
||||
|
||||
@ -158,9 +158,9 @@ startMonitor(MXS_MONITOR *mon, const MXS_CONFIG_PARAMETER *params)
|
||||
* @param arg Handle on thr running monior
|
||||
*/
|
||||
static void
|
||||
stopMonitor(MXS_MONITOR *mon)
|
||||
stopMonitor(MXS_SPECIFIC_MONITOR *mon)
|
||||
{
|
||||
NDBC_MONITOR *handle = (NDBC_MONITOR *) mon->handle;
|
||||
NDBC_MONITOR *handle = static_cast<NDBC_MONITOR*>(mon);
|
||||
|
||||
handle->shutdown = 1;
|
||||
thread_wait(handle->thread);
|
||||
@ -173,7 +173,7 @@ stopMonitor(MXS_MONITOR *mon)
|
||||
* @param arg The monitor handle
|
||||
*/
|
||||
static void
|
||||
diagnostics(DCB *dcb, const MXS_MONITOR *mon)
|
||||
diagnostics(const MXS_SPECIFIC_MONITOR *mon, DCB *dcb)
|
||||
{
|
||||
}
|
||||
|
||||
@ -183,7 +183,7 @@ diagnostics(DCB *dcb, const MXS_MONITOR *mon)
|
||||
* @param dcb DCB to send output
|
||||
* @param arg The monitor handle
|
||||
*/
|
||||
static json_t* diagnostics_json(const MXS_MONITOR *mon)
|
||||
static json_t* diagnostics_json(const MXS_SPECIFIC_MONITOR *mon)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
Reference in New Issue
Block a user