MySQL 26.10.0
Source Code Documentation
hm::Server Class Reference

Server utility class. More...

#include <health_monitor_server.h>

Public Member Functions

Processlist_Ids get_fg_sessions_with_global_lock ()
 Get list of foreground sessions holding a global read lock. More...
 
int kill_query (const std::string &pid, std::string &errmsg)
 Terminate the query running on a connection. More...
 
int kill_query (const std::string &pid)
 Terminate the query running on a connection. More...
 
int kill_connection (const std::string &pid, std::string &errmsg)
 Terminate a server thread given a proceslist id. More...
 
int kill_connection (const std::string &pid)
 Terminate a server thread given a processlist id. More...
 

Static Public Member Functions

static int register_group_member_status_listeners ()
 Register the group member status listener. More...
 
static int unregister_group_member_status_listeners ()
 Unregister the group member status listener. More...
 
static GR_Status gr_status ()
 Get the group replication status. More...
 
static GR_Status get_group_replication_status ()
 Get the current group replication status. More...
 
static void set_group_replication_status (const char *view_id)
 Set the internal group replication status. More...
 
static bool is_group_replication_primary ()
 Determine if the server is a group replication primary. More...
 
static bool is_group_replication_secondary ()
 Determine if the server is a group replication secondary. More...
 
static bool is_member_online_with_group_majority ()
 Determine if the server is online and in a group majority. More...
 
static bool set_system_variable (const std::string &name, const std::string &value)
 Set server system variable. More...
 
static bool get_system_variable (const std::string &name, std::string &value)
 Get server system variable. More...
 
static bool get_status_variable (const std::string &name, std::string &value)
 Get server global status variable. More...
 
static bool get_offline_mode (bool &error)
 Get the value of OFFLINE_MODE. More...
 
static std::string get_offline_mode_str ()
 OFFLINE_MODE message string. More...
 
static bool set_offline_mode ()
 Set OFFLINE_MODE = ON. More...
 
static bool clear_offline_mode ()
 Clear OFFLINE_MODE, set to OFF. More...
 
static bool get_super_read_only (bool &error)
 Get the value of SUPER_READ_ONLY. More...
 
static std::string get_super_read_only_str ()
 SUPER_READ_ONLY message string. More...
 
static bool set_super_read_only ()
 Set SUPER_READ_ONLY = ON. More...
 
static bool clear_super_read_only ()
 Clear SUPER_READ_ONLY, set to OFF. More...
 
static bool get_read_only (bool &error)
 Get the value of READ_ONLY. More...
 
static bool clear_read_only ()
 Clear READ_ONLY, set to OFF. More...
 
static bool get_log_diagnostic_enable (bool &error)
 Get the value of LOG_DIAGNOSTIC_ENABLE. More...
 
static std::string & to_lower (std::string &str)
 Convert string to lower case. More...
 

Static Private Member Functions

static Processlist_Ids processlist_id_list (Result_Set &results)
 Build a list of processlist ids from a result set. More...
 

Static Private Attributes

static GR_Status m_gr_status
 Group replication status. More...
 
static std::shared_mutex m_gr_mutex
 Initialize static members. More...
 

Detailed Description

Server utility class.

Provides server information, status and utilities.

Member Function Documentation

◆ clear_offline_mode()

bool hm::Server::clear_offline_mode ( )
static

Clear OFFLINE_MODE, set to OFF.

Returns
false if successful, true otherwise

◆ clear_read_only()

bool hm::Server::clear_read_only ( )
static

Clear READ_ONLY, set to OFF.

Setting READ_ONLY = OFF also sets SUPER_READ_ONLY = OFF.

Returns
false if successful, true otherwise

◆ clear_super_read_only()

bool hm::Server::clear_super_read_only ( )
static

Clear SUPER_READ_ONLY, set to OFF.

Returns
false if successful, true otherwise

◆ get_fg_sessions_with_global_lock()

Processlist_Ids hm::Server::get_fg_sessions_with_global_lock ( )

Get list of foreground sessions holding a global read lock.

Only one session is expected, but this will accommodate multiple ids. Filter protected service accounts, allow root for MTR.

Returns
String vector with 0 or more processlist ids

◆ get_group_replication_status()

GR_Status hm::Server::get_group_replication_status ( )
static

Get the current group replication status.

Group replication status is dynamic and must be refreshed for each check.

Returns
GR_Status

◆ get_log_diagnostic_enable()

bool hm::Server::get_log_diagnostic_enable ( bool &  error)
static

Get the value of LOG_DIAGNOSTIC_ENABLE.

Returns
true if LOG_DIAGNOSTIC_ENABLE = ON, false otherwise

◆ get_offline_mode()

bool hm::Server::get_offline_mode ( bool &  error)
static

Get the value of OFFLINE_MODE.

Parameters
[in,out]errorError code, 0 if successful
Returns
true if OFFLINE_MODE = ON, false otherwise

◆ get_offline_mode_str()

std::string hm::Server::get_offline_mode_str ( )
static

OFFLINE_MODE message string.

Returns
"OFFLINE_MODE = ON/OFF" or "" if error

◆ get_read_only()

bool hm::Server::get_read_only ( bool &  error)
static

Get the value of READ_ONLY.

Returns
true if READ_ONLY = ON, false otherwise

◆ get_status_variable()

bool hm::Server::get_status_variable ( const std::string &  name,
std::string &  value 
)
static

Get server global status variable.

Parameters
[in]namevariable name
[out]valuevariable value
Returns
false if successful, true otherwise

◆ get_super_read_only()

bool hm::Server::get_super_read_only ( bool &  error)
static

Get the value of SUPER_READ_ONLY.

Parameters
[in,out]errorError code, 0 if successful
Returns
true if SUPER_READ_ONLY = ON, false otherwise

◆ get_super_read_only_str()

std::string hm::Server::get_super_read_only_str ( )
static

SUPER_READ_ONLY message string.

Returns
"SUPER_READ_ONLY = ON/OFF" or "" if error

◆ get_system_variable()

bool hm::Server::get_system_variable ( const std::string &  name,
std::string &  value 
)
static

Get server system variable.

Parameters
[in]namevariable name
[out]valuevariable value
Returns
false if successful, true otherwise

◆ gr_status()

GR_Status hm::Server::gr_status ( )
static

Get the group replication status.

Returns
GR_Status

◆ is_group_replication_primary()

bool hm::Server::is_group_replication_primary ( )
static

Determine if the server is a group replication primary.

Returns
true if server is a primary, false otherwise

◆ is_group_replication_secondary()

bool hm::Server::is_group_replication_secondary ( )
static

Determine if the server is a group replication secondary.

Returns
true if server is a secondary, false otherwise

◆ is_member_online_with_group_majority()

bool hm::Server::is_member_online_with_group_majority ( )
static

Determine if the server is online and in a group majority.

Returns
true if server is in a group majority, false otherwise

◆ kill_connection() [1/2]

int hm::Server::kill_connection ( const std::string &  pid)

Terminate a server thread given a processlist id.

Parameters
[in]pidProcesslist id string
Returns
0 Success, 1 query error

◆ kill_connection() [2/2]

int hm::Server::kill_connection ( const std::string &  pid,
std::string &  errmsg 
)

Terminate a server thread given a proceslist id.

Note that mysql client apps may attempt to reconnect. Issue warning if command fails.

Parameters
[in]pidProcesslist id string
[out]errmsgError message if any
Returns
0 Success, 1 query error

◆ kill_query() [1/2]

int hm::Server::kill_query ( const std::string &  pid)

Terminate the query running on a connection.

Parameters
[in]pidProcesslist id string
Returns
0 Success, 1 query error

◆ kill_query() [2/2]

int hm::Server::kill_query ( const std::string &  pid,
std::string &  errmsg 
)

Terminate the query running on a connection.

Return error message if command fails.

Parameters
[in]pidProcesslist id string
[out]errmsgError message if any
Returns
0 Success, 1 query error

◆ processlist_id_list()

Processlist_Ids hm::Server::processlist_id_list ( Result_Set &  results)
staticprivate

Build a list of processlist ids from a result set.

Parameters
resultsQuery results
Returns
String vector with 0 or more processlist ids

◆ register_group_member_status_listeners()

int hm::Server::register_group_member_status_listeners ( )
static

Register the group member status listener.

Returns
0 if successful, non-zero otherwise

◆ set_group_replication_status()

void hm::Server::set_group_replication_status ( const char *  view_id)
static

Set the internal group replication status.

Parameters
view_idGroup replication view id

◆ set_offline_mode()

bool hm::Server::set_offline_mode ( )
static

Set OFFLINE_MODE = ON.

Returns
false if successful, true otherwise

◆ set_super_read_only()

bool hm::Server::set_super_read_only ( )
static

Set SUPER_READ_ONLY = ON.

Setting SUPER_READ_ONLY = ON also sets READ_ONLY = ON.

Returns
false if successful, true otherwise

◆ set_system_variable()

bool hm::Server::set_system_variable ( const std::string &  name,
const std::string &  value 
)
static

Set server system variable.

Parameters
[in]namevariable name
[in]valuevariable value
Returns
false if successful, true otherwise

◆ to_lower()

std::string & hm::Server::to_lower ( std::string &  str)
static

Convert string to lower case.

Parameters
strString to convert
Returns
Converted string

◆ unregister_group_member_status_listeners()

int hm::Server::unregister_group_member_status_listeners ( )
static

Unregister the group member status listener.

Returns
0 if successful, non-zero otherwise

Member Data Documentation

◆ m_gr_mutex

std::shared_mutex hm::Server::m_gr_mutex
staticprivate

Initialize static members.

◆ m_gr_status

GR_Status hm::Server::m_gr_status
staticprivate

Group replication status.


The documentation for this class was generated from the following files: