MXS-1775 Introduce MonitorInstance::configure() function
The configuring of the monitor instance is now performed in a separate function. That is in preparation for the moving of the start function to maxscale::MonitorInstance.
This commit is contained in:
@ -32,6 +32,8 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
MonitorInstance(MXS_MONITOR* pMonitor);
|
MonitorInstance(MXS_MONITOR* pMonitor);
|
||||||
|
|
||||||
|
virtual void configure(const MXS_CONFIG_PARAMETER* pParams);
|
||||||
|
|
||||||
virtual void main() = 0;
|
virtual void main() = 0;
|
||||||
|
|
||||||
static void main(void* pArg);
|
static void main(void* pArg);
|
||||||
|
@ -2535,6 +2535,10 @@ void MonitorInstance::stop()
|
|||||||
m_script = NULL;
|
m_script = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MonitorInstance::configure(const MXS_CONFIG_PARAMETER* pParams)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
//static
|
//static
|
||||||
void MonitorInstance::main(void* pArg)
|
void MonitorInstance::main(void* pArg)
|
||||||
{
|
{
|
||||||
|
@ -185,6 +185,10 @@ bool AuroraMonitor::start(const MXS_CONFIG_PARAMETER *params)
|
|||||||
{
|
{
|
||||||
bool started = false;
|
bool started = false;
|
||||||
|
|
||||||
|
ss_dassert(!m_shutdown);
|
||||||
|
ss_dassert(!m_thread);
|
||||||
|
ss_dassert(!m_script);
|
||||||
|
|
||||||
if (!m_checked)
|
if (!m_checked)
|
||||||
{
|
{
|
||||||
if (!check_monitor_permissions(m_monitor, "SELECT @@aurora_server_id, server_id FROM "
|
if (!check_monitor_permissions(m_monitor, "SELECT @@aurora_server_id, server_id FROM "
|
||||||
@ -201,8 +205,7 @@ bool AuroraMonitor::start(const MXS_CONFIG_PARAMETER *params)
|
|||||||
|
|
||||||
if (m_checked)
|
if (m_checked)
|
||||||
{
|
{
|
||||||
m_script = config_copy_string(params, "script");
|
configure(params);
|
||||||
m_events = config_get_enum(params, "events", mxs_monitor_event_enum_values);
|
|
||||||
|
|
||||||
if (thread_start(&m_thread, &maxscale::MonitorInstance::main, this, 0) == NULL)
|
if (thread_start(&m_thread, &maxscale::MonitorInstance::main, this, 0) == NULL)
|
||||||
{
|
{
|
||||||
@ -219,6 +222,12 @@ bool AuroraMonitor::start(const MXS_CONFIG_PARAMETER *params)
|
|||||||
return started;
|
return started;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AuroraMonitor::configure(const MXS_CONFIG_PARAMETER* params)
|
||||||
|
{
|
||||||
|
m_script = config_copy_string(params, "script");
|
||||||
|
m_events = config_get_enum(params, "events", mxs_monitor_event_enum_values);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Diagnostic interface
|
* Diagnostic interface
|
||||||
*
|
*
|
||||||
|
@ -36,5 +36,7 @@ private:
|
|||||||
AuroraMonitor(MXS_MONITOR* monitor);
|
AuroraMonitor(MXS_MONITOR* monitor);
|
||||||
~AuroraMonitor();
|
~AuroraMonitor();
|
||||||
|
|
||||||
|
void configure(const MXS_CONFIG_PARAMETER* params);
|
||||||
|
|
||||||
void main();
|
void main();
|
||||||
};
|
};
|
||||||
|
@ -177,21 +177,13 @@ bool GaleraMonitor::start(const MXS_CONFIG_PARAMETER *params)
|
|||||||
|
|
||||||
if (m_checked)
|
if (m_checked)
|
||||||
{
|
{
|
||||||
m_disableMasterFailback = config_get_bool(params, "disable_master_failback");
|
configure(params);
|
||||||
m_availableWhenDonor = config_get_bool(params, "available_when_donor");
|
|
||||||
m_disableMasterRoleSetting = config_get_bool(params, "disable_master_role_setting");
|
|
||||||
m_root_node_as_master = config_get_bool(params, "root_node_as_master");
|
|
||||||
m_use_priority = config_get_bool(params, "use_priority");
|
|
||||||
m_script = config_copy_string(params, "script");
|
|
||||||
m_events = config_get_enum(params, "events", mxs_monitor_event_enum_values);
|
|
||||||
m_set_donor_nodes = config_get_bool(params, "set_donor_nodes");
|
|
||||||
|
|
||||||
/* Reset all data in the hashtable */
|
|
||||||
reset_cluster_info();
|
|
||||||
|
|
||||||
if (thread_start(&m_thread, &maxscale::MonitorInstance::main, this, 0) == NULL)
|
if (thread_start(&m_thread, &maxscale::MonitorInstance::main, this, 0) == NULL)
|
||||||
{
|
{
|
||||||
MXS_ERROR("Failed to start monitor thread for monitor '%s'.", m_monitor->name);
|
MXS_ERROR("Failed to start monitor thread for monitor '%s'.", m_monitor->name);
|
||||||
|
MXS_FREE(m_script);
|
||||||
|
m_script = NULL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -202,6 +194,21 @@ bool GaleraMonitor::start(const MXS_CONFIG_PARAMETER *params)
|
|||||||
return started;
|
return started;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GaleraMonitor::configure(const MXS_CONFIG_PARAMETER* params)
|
||||||
|
{
|
||||||
|
m_disableMasterFailback = config_get_bool(params, "disable_master_failback");
|
||||||
|
m_availableWhenDonor = config_get_bool(params, "available_when_donor");
|
||||||
|
m_disableMasterRoleSetting = config_get_bool(params, "disable_master_role_setting");
|
||||||
|
m_root_node_as_master = config_get_bool(params, "root_node_as_master");
|
||||||
|
m_use_priority = config_get_bool(params, "use_priority");
|
||||||
|
m_script = config_copy_string(params, "script");
|
||||||
|
m_events = config_get_enum(params, "events", mxs_monitor_event_enum_values);
|
||||||
|
m_set_donor_nodes = config_get_bool(params, "set_donor_nodes");
|
||||||
|
|
||||||
|
/* Reset all data in the hashtable */
|
||||||
|
reset_cluster_info();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Diagnostic interface
|
* Diagnostic interface
|
||||||
*
|
*
|
||||||
|
@ -81,6 +81,8 @@ private:
|
|||||||
GaleraMonitor(MXS_MONITOR* monitor);
|
GaleraMonitor(MXS_MONITOR* monitor);
|
||||||
~GaleraMonitor();
|
~GaleraMonitor();
|
||||||
|
|
||||||
|
void configure(const MXS_CONFIG_PARAMETER* param);
|
||||||
|
|
||||||
bool detect_cluster_size(const int n_nodes,
|
bool detect_cluster_size(const int n_nodes,
|
||||||
const char *candidate_uuid,
|
const char *candidate_uuid,
|
||||||
const int candidate_size);
|
const int candidate_size);
|
||||||
|
@ -51,20 +51,38 @@ bool GRMon::start(const MXS_CONFIG_PARAMETER* params)
|
|||||||
{
|
{
|
||||||
bool started = false;
|
bool started = false;
|
||||||
|
|
||||||
m_shutdown = 0;
|
ss_dassert(!m_shutdown);
|
||||||
m_master = NULL;
|
ss_dassert(!m_thread);
|
||||||
m_script = config_get_string(params, "script");
|
|
||||||
m_events = config_get_enum(params, "events", mxs_monitor_event_enum_values);
|
|
||||||
m_thread = 0;
|
|
||||||
|
|
||||||
if (thread_start(&m_thread, &maxscale::MonitorInstance::main, this, 0) != NULL)
|
if (!m_checked)
|
||||||
{
|
{
|
||||||
started = true;
|
m_checked = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_checked)
|
||||||
|
{
|
||||||
|
configure(params);
|
||||||
|
|
||||||
|
if (thread_start(&m_thread, &maxscale::MonitorInstance::main, this, 0) == NULL)
|
||||||
|
{
|
||||||
|
;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
started = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return started;
|
return started;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GRMon::configure(const MXS_CONFIG_PARAMETER* params)
|
||||||
|
{
|
||||||
|
m_script = config_get_string(params, "script");
|
||||||
|
m_events = config_get_enum(params, "events", mxs_monitor_event_enum_values);
|
||||||
|
m_master = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
void GRMon::diagnostics(DCB* dcb) const
|
void GRMon::diagnostics(DCB* dcb) const
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -39,5 +39,7 @@ private:
|
|||||||
GRMon(MXS_MONITOR* monitor);
|
GRMon(MXS_MONITOR* monitor);
|
||||||
~GRMon();
|
~GRMon();
|
||||||
|
|
||||||
|
void configure(const MXS_CONFIG_PARAMETER* params);
|
||||||
|
|
||||||
void main();
|
void main();
|
||||||
};
|
};
|
||||||
|
@ -121,6 +121,10 @@ bool MMMonitor::start(const MXS_CONFIG_PARAMETER *params)
|
|||||||
{
|
{
|
||||||
bool started = false;
|
bool started = false;
|
||||||
|
|
||||||
|
ss_dassert(!m_shutdown);
|
||||||
|
ss_dassert(!m_thread);
|
||||||
|
ss_dassert(!m_script);
|
||||||
|
|
||||||
if (!m_checked)
|
if (!m_checked)
|
||||||
{
|
{
|
||||||
if (!check_monitor_permissions(m_monitor, "SHOW SLAVE STATUS"))
|
if (!check_monitor_permissions(m_monitor, "SHOW SLAVE STATUS"))
|
||||||
@ -135,9 +139,7 @@ bool MMMonitor::start(const MXS_CONFIG_PARAMETER *params)
|
|||||||
|
|
||||||
if (m_checked)
|
if (m_checked)
|
||||||
{
|
{
|
||||||
m_detectStaleMaster = config_get_bool(params, "detect_stale_master");
|
configure(params);
|
||||||
m_script = config_copy_string(params, "script");
|
|
||||||
m_events = config_get_enum(params, "events", mxs_monitor_event_enum_values);
|
|
||||||
|
|
||||||
if (thread_start(&m_thread, &maxscale::MonitorInstance::main, this, 0) == NULL)
|
if (thread_start(&m_thread, &maxscale::MonitorInstance::main, this, 0) == NULL)
|
||||||
{
|
{
|
||||||
@ -154,6 +156,13 @@ bool MMMonitor::start(const MXS_CONFIG_PARAMETER *params)
|
|||||||
return started;
|
return started;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MMMonitor::configure(const MXS_CONFIG_PARAMETER* params)
|
||||||
|
{
|
||||||
|
m_script = config_copy_string(params, "script");
|
||||||
|
m_events = config_get_enum(params, "events", mxs_monitor_event_enum_values);
|
||||||
|
m_detectStaleMaster = config_get_bool(params, "detect_stale_master");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Diagnostic interface
|
* Diagnostic interface
|
||||||
*
|
*
|
||||||
|
@ -42,5 +42,7 @@ private:
|
|||||||
|
|
||||||
MXS_MONITORED_SERVER *get_current_master();
|
MXS_MONITORED_SERVER *get_current_master();
|
||||||
|
|
||||||
|
void configure(const MXS_CONFIG_PARAMETER* params);
|
||||||
|
|
||||||
void main();
|
void main();
|
||||||
};
|
};
|
||||||
|
@ -105,6 +105,10 @@ bool NDBCMonitor::start(const MXS_CONFIG_PARAMETER *params)
|
|||||||
{
|
{
|
||||||
bool started = false;
|
bool started = false;
|
||||||
|
|
||||||
|
ss_dassert(!m_shutdown);
|
||||||
|
ss_dassert(!m_thread);
|
||||||
|
ss_dassert(!m_script);
|
||||||
|
|
||||||
if (!m_checked)
|
if (!m_checked)
|
||||||
{
|
{
|
||||||
if (!check_monitor_permissions(m_monitor, "SHOW STATUS LIKE 'Ndb_number_of_ready_data_nodes'"))
|
if (!check_monitor_permissions(m_monitor, "SHOW STATUS LIKE 'Ndb_number_of_ready_data_nodes'"))
|
||||||
@ -119,8 +123,7 @@ bool NDBCMonitor::start(const MXS_CONFIG_PARAMETER *params)
|
|||||||
|
|
||||||
if (m_checked)
|
if (m_checked)
|
||||||
{
|
{
|
||||||
m_script = config_copy_string(params, "script");
|
configure(params);
|
||||||
m_events = config_get_enum(params, "events", mxs_monitor_event_enum_values);
|
|
||||||
|
|
||||||
if (thread_start(&m_thread, &maxscale::MonitorInstance::main, this, 0) == NULL)
|
if (thread_start(&m_thread, &maxscale::MonitorInstance::main, this, 0) == NULL)
|
||||||
{
|
{
|
||||||
@ -137,6 +140,12 @@ bool NDBCMonitor::start(const MXS_CONFIG_PARAMETER *params)
|
|||||||
return started;
|
return started;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NDBCMonitor::configure(const MXS_CONFIG_PARAMETER* params)
|
||||||
|
{
|
||||||
|
m_script = config_copy_string(params, "script");
|
||||||
|
m_events = config_get_enum(params, "events", mxs_monitor_event_enum_values);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Diagnostic interface
|
* Diagnostic interface
|
||||||
*
|
*
|
||||||
|
@ -39,5 +39,7 @@ private:
|
|||||||
NDBCMonitor(MXS_MONITOR* monitor);
|
NDBCMonitor(MXS_MONITOR* monitor);
|
||||||
~NDBCMonitor();
|
~NDBCMonitor();
|
||||||
|
|
||||||
|
void configure(const MXS_CONFIG_PARAMETER* params);
|
||||||
|
|
||||||
void main();
|
void main();
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user