MXS-1775 Introduce MonitorInstance::has_sufficient_permissions()
With this function in place, it is now possible to move the thread starting to MonitorInstance.
This commit is contained in:
parent
3606a5ed1c
commit
adb7f156d6
@ -32,6 +32,7 @@ public:
|
||||
protected:
|
||||
MonitorInstance(MXS_MONITOR* pMonitor);
|
||||
|
||||
virtual bool has_sufficient_permissions() const;
|
||||
virtual void configure(const MXS_CONFIG_PARAMETER* pParams);
|
||||
|
||||
virtual void main() = 0;
|
||||
|
@ -2535,6 +2535,11 @@ void MonitorInstance::stop()
|
||||
m_script = NULL;
|
||||
}
|
||||
|
||||
bool MonitorInstance::has_sufficient_permissions() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void MonitorInstance::configure(const MXS_CONFIG_PARAMETER* pParams)
|
||||
{
|
||||
}
|
||||
|
@ -191,9 +191,7 @@ bool AuroraMonitor::start(const MXS_CONFIG_PARAMETER *params)
|
||||
|
||||
if (!m_checked)
|
||||
{
|
||||
if (!check_monitor_permissions(m_monitor, "SELECT @@aurora_server_id, server_id FROM "
|
||||
"information_schema.replica_host_status "
|
||||
"WHERE session_id = 'MASTER_SESSION_ID'"))
|
||||
if (!has_sufficient_permissions())
|
||||
{
|
||||
MXS_ERROR("Failed to start monitor. See earlier errors for more information.");
|
||||
}
|
||||
@ -222,6 +220,13 @@ bool AuroraMonitor::start(const MXS_CONFIG_PARAMETER *params)
|
||||
return started;
|
||||
}
|
||||
|
||||
bool AuroraMonitor::has_sufficient_permissions() const
|
||||
{
|
||||
return check_monitor_permissions(m_monitor, "SELECT @@aurora_server_id, server_id FROM "
|
||||
"information_schema.replica_host_status "
|
||||
"WHERE session_id = 'MASTER_SESSION_ID'");
|
||||
}
|
||||
|
||||
void AuroraMonitor::configure(const MXS_CONFIG_PARAMETER* params)
|
||||
{
|
||||
m_script = config_copy_string(params, "script");
|
||||
|
@ -36,6 +36,7 @@ private:
|
||||
AuroraMonitor(MXS_MONITOR* monitor);
|
||||
~AuroraMonitor();
|
||||
|
||||
bool has_sufficient_permissions() const;
|
||||
void configure(const MXS_CONFIG_PARAMETER* params);
|
||||
|
||||
void main();
|
||||
|
@ -165,7 +165,7 @@ bool GaleraMonitor::start(const MXS_CONFIG_PARAMETER *params)
|
||||
|
||||
if (!m_checked)
|
||||
{
|
||||
if (!check_monitor_permissions(m_monitor, "SHOW STATUS LIKE 'wsrep_local_state'"))
|
||||
if (!has_sufficient_permissions())
|
||||
{
|
||||
MXS_ERROR("Failed to start monitor. See earlier errors for more information.");
|
||||
}
|
||||
@ -194,6 +194,11 @@ bool GaleraMonitor::start(const MXS_CONFIG_PARAMETER *params)
|
||||
return started;
|
||||
}
|
||||
|
||||
bool GaleraMonitor::has_sufficient_permissions() const
|
||||
{
|
||||
return check_monitor_permissions(m_monitor, "SHOW STATUS LIKE 'wsrep_local_state'");
|
||||
}
|
||||
|
||||
void GaleraMonitor::configure(const MXS_CONFIG_PARAMETER* params)
|
||||
{
|
||||
m_disableMasterFailback = config_get_bool(params, "disable_master_failback");
|
||||
|
@ -81,8 +81,6 @@ 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);
|
||||
@ -93,5 +91,8 @@ private:
|
||||
void set_galera_cluster();
|
||||
void update_sst_donor_nodes(int is_cluster);
|
||||
|
||||
bool has_sufficient_permissions() const;
|
||||
void configure(const MXS_CONFIG_PARAMETER* param);
|
||||
|
||||
void main();
|
||||
};
|
||||
|
@ -56,7 +56,14 @@ bool GRMon::start(const MXS_CONFIG_PARAMETER* params)
|
||||
|
||||
if (!m_checked)
|
||||
{
|
||||
m_checked = true;
|
||||
if (!has_sufficient_permissions())
|
||||
{
|
||||
MXS_ERROR("Failed to start monitor. See earlier errors for more information.");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_checked = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_checked)
|
||||
@ -76,6 +83,11 @@ bool GRMon::start(const MXS_CONFIG_PARAMETER* params)
|
||||
return started;
|
||||
}
|
||||
|
||||
bool GRMon::has_sufficient_permissions() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void GRMon::configure(const MXS_CONFIG_PARAMETER* params)
|
||||
{
|
||||
m_script = config_get_string(params, "script");
|
||||
|
@ -39,6 +39,7 @@ private:
|
||||
GRMon(MXS_MONITOR* monitor);
|
||||
~GRMon();
|
||||
|
||||
bool has_sufficient_permissions() const;
|
||||
void configure(const MXS_CONFIG_PARAMETER* params);
|
||||
|
||||
void main();
|
||||
|
@ -127,7 +127,7 @@ bool MMMonitor::start(const MXS_CONFIG_PARAMETER *params)
|
||||
|
||||
if (!m_checked)
|
||||
{
|
||||
if (!check_monitor_permissions(m_monitor, "SHOW SLAVE STATUS"))
|
||||
if (!has_sufficient_permissions())
|
||||
{
|
||||
MXS_ERROR("Failed to start monitor. See earlier errors for more information.");
|
||||
}
|
||||
@ -156,6 +156,11 @@ bool MMMonitor::start(const MXS_CONFIG_PARAMETER *params)
|
||||
return started;
|
||||
}
|
||||
|
||||
bool MMMonitor::has_sufficient_permissions() const
|
||||
{
|
||||
return check_monitor_permissions(m_monitor, "SHOW SLAVE STATUS");
|
||||
}
|
||||
|
||||
void MMMonitor::configure(const MXS_CONFIG_PARAMETER* params)
|
||||
{
|
||||
m_script = config_copy_string(params, "script");
|
||||
|
@ -42,6 +42,7 @@ private:
|
||||
|
||||
MXS_MONITORED_SERVER *get_current_master();
|
||||
|
||||
bool has_sufficient_permissions() const;
|
||||
void configure(const MXS_CONFIG_PARAMETER* params);
|
||||
|
||||
void main();
|
||||
|
@ -111,7 +111,7 @@ bool NDBCMonitor::start(const MXS_CONFIG_PARAMETER *params)
|
||||
|
||||
if (!m_checked)
|
||||
{
|
||||
if (!check_monitor_permissions(m_monitor, "SHOW STATUS LIKE 'Ndb_number_of_ready_data_nodes'"))
|
||||
if (!has_sufficient_permissions())
|
||||
{
|
||||
MXS_ERROR("Failed to start monitor. See earlier errors for more information.");
|
||||
}
|
||||
@ -140,6 +140,11 @@ bool NDBCMonitor::start(const MXS_CONFIG_PARAMETER *params)
|
||||
return started;
|
||||
}
|
||||
|
||||
bool NDBCMonitor::has_sufficient_permissions() const
|
||||
{
|
||||
return check_monitor_permissions(m_monitor, "SHOW STATUS LIKE 'Ndb_number_of_ready_data_nodes'");
|
||||
}
|
||||
|
||||
void NDBCMonitor::configure(const MXS_CONFIG_PARAMETER* params)
|
||||
{
|
||||
m_script = config_copy_string(params, "script");
|
||||
|
@ -39,6 +39,7 @@ private:
|
||||
NDBCMonitor(MXS_MONITOR* monitor);
|
||||
~NDBCMonitor();
|
||||
|
||||
bool has_sufficient_permissions() const;
|
||||
void configure(const MXS_CONFIG_PARAMETER* params);
|
||||
|
||||
void main();
|
||||
|
Loading…
x
Reference in New Issue
Block a user