MXS-1775 Change MonitorInstance::configure() prototype
Now return boolean, to allow derived class to signal a failure to configure.
This commit is contained in:
@ -80,9 +80,13 @@ protected:
|
||||
*
|
||||
* When the monitor is started, this function will be called in order
|
||||
* to allow the concrete implementation to configure itself from
|
||||
* configuration parameters. The default implementation does nothing.
|
||||
* configuration parameters. The default implementation returns true.
|
||||
*
|
||||
* @return True, if the monitor could be configured, false otherwise.
|
||||
*
|
||||
* @note If false is returned, then the monitor will not be started.
|
||||
*/
|
||||
virtual void configure(const MXS_CONFIG_PARAMETER* pParams);
|
||||
virtual bool configure(const MXS_CONFIG_PARAMETER* pParams);
|
||||
|
||||
/**
|
||||
* @brief Check whether the monitor has sufficient rights
|
||||
|
@ -2599,8 +2599,8 @@ bool MonitorInstance::start(const MXS_CONFIG_PARAMETER* pParams)
|
||||
m_events = config_get_enum(pParams, "events", mxs_monitor_event_enum_values);
|
||||
m_master = NULL;
|
||||
|
||||
configure(pParams);
|
||||
|
||||
if (configure(pParams))
|
||||
{
|
||||
if (thread_start(&m_thread, &maxscale::MonitorInstance::main, this, 0) == NULL)
|
||||
{
|
||||
MXS_ERROR("Failed to start monitor thread for monitor '%s'.", m_monitor->name);
|
||||
@ -2622,19 +2622,21 @@ bool MonitorInstance::start(const MXS_CONFIG_PARAMETER* pParams)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return started;
|
||||
}
|
||||
|
||||
bool MonitorInstance::configure(const MXS_CONFIG_PARAMETER* pParams)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MonitorInstance::has_sufficient_permissions() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void MonitorInstance::configure(const MXS_CONFIG_PARAMETER* pParams)
|
||||
{
|
||||
}
|
||||
|
||||
void MonitorInstance::flush_server_status()
|
||||
{
|
||||
for (MXS_MONITORED_SERVER *pMs = m_monitor->monitored_servers; pMs; pMs = pMs->next)
|
||||
|
@ -49,8 +49,9 @@ json_t* AuroraMonitor::diagnostics_json() const
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void AuroraMonitor::configure(const MXS_CONFIG_PARAMETER* params)
|
||||
bool AuroraMonitor::configure(const MXS_CONFIG_PARAMETER* params)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AuroraMonitor::has_sufficient_permissions() const
|
||||
|
@ -32,7 +32,7 @@ public:
|
||||
json_t* diagnostics_json() const;
|
||||
|
||||
protected:
|
||||
void configure(const MXS_CONFIG_PARAMETER* params);
|
||||
bool configure(const MXS_CONFIG_PARAMETER* params);
|
||||
bool has_sufficient_permissions() const;
|
||||
void update_server_status(MXS_MONITORED_SERVER* monitored_server);
|
||||
|
||||
|
@ -130,7 +130,7 @@ json_t* GaleraMonitor::diagnostics_json() const
|
||||
return rval;
|
||||
}
|
||||
|
||||
void GaleraMonitor::configure(const MXS_CONFIG_PARAMETER* params)
|
||||
bool 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");
|
||||
@ -142,6 +142,8 @@ void GaleraMonitor::configure(const MXS_CONFIG_PARAMETER* params)
|
||||
|
||||
/* Reset all data in the hashtable */
|
||||
reset_cluster_info();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GaleraMonitor::has_sufficient_permissions() const
|
||||
|
@ -64,7 +64,7 @@ public:
|
||||
json_t* diagnostics_json() const;
|
||||
|
||||
protected:
|
||||
void configure(const MXS_CONFIG_PARAMETER* param);
|
||||
bool configure(const MXS_CONFIG_PARAMETER* param);
|
||||
bool has_sufficient_permissions() const;
|
||||
void update_server_status(MXS_MONITORED_SERVER* monitored_server);
|
||||
void tick();
|
||||
|
@ -49,8 +49,9 @@ json_t* GRMon::diagnostics_json() const
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void GRMon::configure(const MXS_CONFIG_PARAMETER* params)
|
||||
bool GRMon::configure(const MXS_CONFIG_PARAMETER* params)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GRMon::has_sufficient_permissions() const
|
||||
|
@ -32,7 +32,7 @@ public:
|
||||
json_t* diagnostics_json() const;
|
||||
|
||||
protected:
|
||||
void configure(const MXS_CONFIG_PARAMETER* params);
|
||||
bool configure(const MXS_CONFIG_PARAMETER* params);
|
||||
bool has_sufficient_permissions() const;
|
||||
void update_server_status(MXS_MONITORED_SERVER* monitored_server);
|
||||
|
||||
|
@ -64,9 +64,11 @@ json_t* MMMonitor::diagnostics_json() const
|
||||
return rval;
|
||||
}
|
||||
|
||||
void MMMonitor::configure(const MXS_CONFIG_PARAMETER* params)
|
||||
bool MMMonitor::configure(const MXS_CONFIG_PARAMETER* params)
|
||||
{
|
||||
m_detectStaleMaster = config_get_bool(params, "detect_stale_master");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MMMonitor::has_sufficient_permissions() const
|
||||
|
@ -32,7 +32,7 @@ public:
|
||||
json_t* diagnostics_json() const;
|
||||
|
||||
protected:
|
||||
void configure(const MXS_CONFIG_PARAMETER* params);
|
||||
bool configure(const MXS_CONFIG_PARAMETER* params);
|
||||
bool has_sufficient_permissions() const;
|
||||
void update_server_status(MXS_MONITORED_SERVER* monitored_server);
|
||||
void tick();
|
||||
|
@ -47,8 +47,9 @@ json_t* NDBCMonitor::diagnostics_json() const
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void NDBCMonitor::configure(const MXS_CONFIG_PARAMETER* params)
|
||||
bool NDBCMonitor::configure(const MXS_CONFIG_PARAMETER* params)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NDBCMonitor::has_sufficient_permissions() const
|
||||
|
@ -32,7 +32,7 @@ public:
|
||||
json_t* diagnostics_json() const;
|
||||
|
||||
protected:
|
||||
void configure(const MXS_CONFIG_PARAMETER* params);
|
||||
bool configure(const MXS_CONFIG_PARAMETER* params);
|
||||
bool has_sufficient_permissions() const;
|
||||
void update_server_status(MXS_MONITORED_SERVER* monitored_server);
|
||||
|
||||
|
Reference in New Issue
Block a user