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:
Johan Wikman
2018-05-16 11:35:24 +03:00
parent bcb7d09a15
commit 3606a5ed1c
12 changed files with 93 additions and 25 deletions

View File

@ -177,21 +177,13 @@ bool GaleraMonitor::start(const MXS_CONFIG_PARAMETER *params)
if (m_checked)
{
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();
configure(params);
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_FREE(m_script);
m_script = NULL;
}
else
{
@ -202,6 +194,21 @@ bool GaleraMonitor::start(const MXS_CONFIG_PARAMETER *params)
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
*

View File

@ -81,6 +81,8 @@ private:
GaleraMonitor(MXS_MONITOR* monitor);
~GaleraMonitor();
void configure(const MXS_CONFIG_PARAMETER* param);
bool detect_cluster_size(const int n_nodes,
const char *candidate_uuid,
const int candidate_size);