MySQL 26.10.0
Source Code Documentation
hm::Health_Monitor Class Reference

Own the objects used by one Health Monitor component instance. More...

#include <health_monitor.h>

Public Member Functions

const char * name () const
 
const char * sysvar_prefix () const
 
void set_server_shutting_down (bool shutdown)
 Notify all Collectors that the server is shutting down and to stop work immediately. More...
 
bool initialized () const
 

Static Public Member Functions

static mysql_service_status_t component_init ()
 Create the component owner before publishing any of its objects to callbacks. More...
 
static mysql_service_status_t component_deinit ()
 Stop workers and unregister callbacks before destroying the component owner. More...
 
static Health_Monitor * instance () noexcept
 
static Disk_Collector * disk_collector () noexcept
 
static Disk_Forecaster * disk_forecaster () noexcept
 
static Memory_Collector * memory_collector () noexcept
 
static System_Collector * system_collector () noexcept
 
static Log * log () noexcept
 
static Periodic_Reporter * periodic_reporter () noexcept
 
static Status_vars * status_vars () noexcept
 
static Supervisor * supervisor () noexcept
 
static Tables * tables () noexcept
 
static Triggered_Reporter * memory_reporter () noexcept
 
static int system_vars_update ()
 Notify collectors of pending system variable updates. More...
 
static bool available () noexcept
 The Health Monitor is available if it is initialized and the server is not shutting down. More...
 

Private Member Functions

 Health_Monitor ()
 
 ~Health_Monitor ()
 
 Health_Monitor (const Health_Monitor &)=delete
 
Health_Monitor & operator= (const Health_Monitor &)=delete
 
 Health_Monitor (Health_Monitor &&)=delete
 
Health_Monitor & operator= (Health_Monitor &&)=delete
 
mysql_service_status_t initialize ()
 Health monitor initialization: More...
 
mysql_service_status_t deinitialize ()
 Health monitor deinitialization. More...
 
int collectors_init ()
 Initialize the Health Monitor collectors. More...
 
int collectors_deinit ()
 Deinitialize the Health Monitor collectors. More...
 
int collectors_start ()
 Start the Health Monitor collectors. More...
 
int collectors_stop ()
 Shut down the collectors. More...
 
int log_init ()
 Initialize the log manager. More...
 
int log_deinit ()
 Deinitialize the log manager. More...
 
int reporters_init ()
 Initialize the report manager. More...
 
int reporters_deinit ()
 Deinitialize the reporters. More...
 
int status_vars_init ()
 Initialize the status variable manager and initialize (but do not register) all status variables. More...
 
int status_vars_deinit ()
 Deinitialize the status variable manager after all status variables have been deregistered. More...
 
int status_vars_register ()
 Register all status variables. More...
 
int status_vars_unregister ()
 Deregister all status variables. More...
 
int supervisor_init ()
 Initialize the task supervisor. More...
 
int supervisor_deinit ()
 Deinitialize the task supervisor. More...
 
int system_vars_init ()
 Initialize but do not register all system variables. More...
 
int system_vars_register ()
 Register all system variables. More...
 
int system_vars_unregister ()
 Deregister all system variables. More...
 
int tables_init ()
 Initialize the table manager. More...
 
int tables_deinit ()
 Deinitialize the table manager after all tables have been deregistered. More...
 
int tables_register ()
 Register all Health Monitor tables in the Performance Schema. More...
 
int tables_unregister ()
 Deregister all Health Monitor tables. More...
 
int metrics_register ()
 Register metric sources exposed by the component. More...
 
int metrics_unregister ()
 Deregister metric sources exposed by the component. More...
 
void server_utils_init ()
 Initialize the server utility functions. More...
 
void server_utils_deinit ()
 Deinitialize the server utility functions. More...
 
int option_usage_tracker_init ()
 Register option usage tracker. More...
 
int option_usage_tracker_deinit ()
 Deregister option usage tracker. More...
 

Private Attributes

std::unique_ptr< Disk_Collector > m_disk_collector
 
std::unique_ptr< Disk_Forecaster > m_disk_forecaster
 
std::unique_ptr< Memory_Collector > m_memory_collector
 
std::unique_ptr< System_Collector > m_system_collector
 
std::unique_ptr< Log > m_log
 
std::unique_ptr< Periodic_Reporter > m_periodic_reporter
 
std::unique_ptr< Status_vars > m_status_vars
 
std::unique_ptr< Supervisor > m_supervisor
 
std::unique_ptr< Tables > m_tables
 
std::unique_ptr< Triggered_Reporter > m_memory_reporter
 
const std::string m_name {"Health Monitor"}
 
const std::string m_sysvar_prefix {"health_monitor"}
 
bool m_status_vars_registered {false}
 
bool m_system_vars_registered {false}
 
bool m_collectors_initialized {false}
 
bool m_collectors_started {false}
 
bool m_tables_initialized {false}
 
bool m_tables_registered {false}
 
bool m_metrics_registered {false}
 

Static Private Attributes

static Health_Monitor * m_instance {nullptr}
 
static std::atomic< bool > m_hm_initialized {false}
 
static std::atomic< bool > m_server_shutting_down {false}
 

Detailed Description

Own the objects used by one Health Monitor component instance.

Component initialization and deinitialization control their lifetime. Accessors return borrowed pointers, which can be null during initialization and teardown. Callers must not retain them beyond the component lifetime. Accessors do not synchronize access with component deinitialization.

Constructor & Destructor Documentation

◆ Health_Monitor() [1/3]

hm::Health_Monitor::Health_Monitor ( )
privatedefault

◆ ~Health_Monitor()

hm::Health_Monitor::~Health_Monitor ( )
privatedefault

◆ Health_Monitor() [2/3]

hm::Health_Monitor::Health_Monitor ( const Health_Monitor &  )
privatedelete

◆ Health_Monitor() [3/3]

hm::Health_Monitor::Health_Monitor ( Health_Monitor &&  )
privatedelete

Member Function Documentation

◆ available()

bool hm::Health_Monitor::available ( )
staticnoexcept

The Health Monitor is available if it is initialized and the server is not shutting down.

◆ collectors_deinit()

int hm::Health_Monitor::collectors_deinit ( )
private

Deinitialize the Health Monitor collectors.

◆ collectors_init()

int hm::Health_Monitor::collectors_init ( )
private

Initialize the Health Monitor collectors.

◆ collectors_start()

int hm::Health_Monitor::collectors_start ( )
private

Start the Health Monitor collectors.

Returns
0 - Supervisor and one or more collectors started successfully 0 - Supervisor started and no collectors are enabled 1 - Supervisor or all enabled collectors failed to start

◆ collectors_stop()

int hm::Health_Monitor::collectors_stop ( )
private

Shut down the collectors.

◆ component_deinit()

mysql_service_status_t hm::Health_Monitor::component_deinit ( )
static

Stop workers and unregister callbacks before destroying the component owner.

◆ component_init()

mysql_service_status_t hm::Health_Monitor::component_init ( )
static

Create the component owner before publishing any of its objects to callbacks.

On failure, release partially initialized objects while services are available.

◆ deinitialize()

mysql_service_status_t hm::Health_Monitor::deinitialize ( )
private

Health monitor deinitialization.

◆ disk_collector()

static Disk_Collector * hm::Health_Monitor::disk_collector ( )
inlinestaticnoexcept

◆ disk_forecaster()

static Disk_Forecaster * hm::Health_Monitor::disk_forecaster ( )
inlinestaticnoexcept

◆ initialize()

mysql_service_status_t hm::Health_Monitor::initialize ( )
private

Health monitor initialization:

  • Initialize the logging service
  • Initialize the report manager
  • Register system and status variables
  • Start enabled collectors
  • Initialize Health Monitor tables in the Performance Schema
  • Register metric sources for telemetry

◆ initialized()

bool hm::Health_Monitor::initialized ( ) const
inline

◆ instance()

static Health_Monitor * hm::Health_Monitor::instance ( )
inlinestaticnoexcept

◆ log()

static Log * hm::Health_Monitor::log ( )
inlinestaticnoexcept

◆ log_deinit()

int hm::Health_Monitor::log_deinit ( )
private

Deinitialize the log manager.

◆ log_init()

int hm::Health_Monitor::log_init ( )
private

Initialize the log manager.

◆ memory_collector()

static Memory_Collector * hm::Health_Monitor::memory_collector ( )
inlinestaticnoexcept

◆ memory_reporter()

static Triggered_Reporter * hm::Health_Monitor::memory_reporter ( )
inlinestaticnoexcept

◆ metrics_register()

int hm::Health_Monitor::metrics_register ( )
private

Register metric sources exposed by the component.

◆ metrics_unregister()

int hm::Health_Monitor::metrics_unregister ( )
private

Deregister metric sources exposed by the component.

◆ name()

const char * hm::Health_Monitor::name ( ) const
inline

◆ operator=() [1/2]

Health_Monitor & hm::Health_Monitor::operator= ( const Health_Monitor &  )
privatedelete

◆ operator=() [2/2]

Health_Monitor & hm::Health_Monitor::operator= ( Health_Monitor &&  )
privatedelete

◆ option_usage_tracker_deinit()

int hm::Health_Monitor::option_usage_tracker_deinit ( )
private

Deregister option usage tracker.

◆ option_usage_tracker_init()

int hm::Health_Monitor::option_usage_tracker_init ( )
private

Register option usage tracker.

◆ periodic_reporter()

static Periodic_Reporter * hm::Health_Monitor::periodic_reporter ( )
inlinestaticnoexcept

◆ reporters_deinit()

int hm::Health_Monitor::reporters_deinit ( )
private

Deinitialize the reporters.

◆ reporters_init()

int hm::Health_Monitor::reporters_init ( )
private

Initialize the report manager.

◆ server_utils_deinit()

void hm::Health_Monitor::server_utils_deinit ( )
private

Deinitialize the server utility functions.

◆ server_utils_init()

void hm::Health_Monitor::server_utils_init ( )
private

Initialize the server utility functions.

◆ set_server_shutting_down()

void hm::Health_Monitor::set_server_shutting_down ( bool  shutdown)

Notify all Collectors that the server is shutting down and to stop work immediately.

Although the Collector threads will eventually be terminated by component_deinit(), this ensures that Health Monitor will not issue queries or make system variable updates during shutdown.

Parameters
[in]shutdownNew value of the shutdown flag

◆ status_vars()

static Status_vars * hm::Health_Monitor::status_vars ( )
inlinestaticnoexcept

◆ status_vars_deinit()

int hm::Health_Monitor::status_vars_deinit ( )
private

Deinitialize the status variable manager after all status variables have been deregistered.

◆ status_vars_init()

int hm::Health_Monitor::status_vars_init ( )
private

Initialize the status variable manager and initialize (but do not register) all status variables.

◆ status_vars_register()

int hm::Health_Monitor::status_vars_register ( )
private

Register all status variables.

◆ status_vars_unregister()

int hm::Health_Monitor::status_vars_unregister ( )
private

Deregister all status variables.

◆ supervisor()

static Supervisor * hm::Health_Monitor::supervisor ( )
inlinestaticnoexcept

◆ supervisor_deinit()

int hm::Health_Monitor::supervisor_deinit ( )
private

Deinitialize the task supervisor.

◆ supervisor_init()

int hm::Health_Monitor::supervisor_init ( )
private

Initialize the task supervisor.

◆ system_collector()

static System_Collector * hm::Health_Monitor::system_collector ( )
inlinestaticnoexcept

◆ system_vars_init()

int hm::Health_Monitor::system_vars_init ( )
private

Initialize but do not register all system variables.

◆ system_vars_register()

int hm::Health_Monitor::system_vars_register ( )
private

Register all system variables.

◆ system_vars_unregister()

int hm::Health_Monitor::system_vars_unregister ( )
private

Deregister all system variables.

◆ system_vars_update()

int hm::Health_Monitor::system_vars_update ( )
static

Notify collectors of pending system variable updates.

This thread currently holds the LOCK_global_system_variables. The update process will signal the thread to stop, apply the new settings, and then restart it.

To avoid deadlocks, the update will be deferred for threads executing SQL queries or accessing global system variables until they complete their processing and release the LOCK_global_system_variables lock.

◆ sysvar_prefix()

const char * hm::Health_Monitor::sysvar_prefix ( ) const
inline

◆ tables()

static Tables * hm::Health_Monitor::tables ( )
inlinestaticnoexcept

◆ tables_deinit()

int hm::Health_Monitor::tables_deinit ( )
private

Deinitialize the table manager after all tables have been deregistered.

◆ tables_init()

int hm::Health_Monitor::tables_init ( )
private

Initialize the table manager.

◆ tables_register()

int hm::Health_Monitor::tables_register ( )
private

Register all Health Monitor tables in the Performance Schema.

◆ tables_unregister()

int hm::Health_Monitor::tables_unregister ( )
private

Deregister all Health Monitor tables.

Member Data Documentation

◆ m_collectors_initialized

bool hm::Health_Monitor::m_collectors_initialized {false}
private

◆ m_collectors_started

bool hm::Health_Monitor::m_collectors_started {false}
private

◆ m_disk_collector

std::unique_ptr<Disk_Collector> hm::Health_Monitor::m_disk_collector
private

◆ m_disk_forecaster

std::unique_ptr<Disk_Forecaster> hm::Health_Monitor::m_disk_forecaster
private

◆ m_hm_initialized

std::atomic< bool > hm::Health_Monitor::m_hm_initialized {false}
staticprivate

◆ m_instance

Health_Monitor * hm::Health_Monitor::m_instance {nullptr}
staticprivate

◆ m_log

std::unique_ptr<Log> hm::Health_Monitor::m_log
private

◆ m_memory_collector

std::unique_ptr<Memory_Collector> hm::Health_Monitor::m_memory_collector
private

◆ m_memory_reporter

std::unique_ptr<Triggered_Reporter> hm::Health_Monitor::m_memory_reporter
private

◆ m_metrics_registered

bool hm::Health_Monitor::m_metrics_registered {false}
private

◆ m_name

const std::string hm::Health_Monitor::m_name {"Health Monitor"}
private

◆ m_periodic_reporter

std::unique_ptr<Periodic_Reporter> hm::Health_Monitor::m_periodic_reporter
private

◆ m_server_shutting_down

std::atomic< bool > hm::Health_Monitor::m_server_shutting_down {false}
staticprivate

◆ m_status_vars

std::unique_ptr<Status_vars> hm::Health_Monitor::m_status_vars
private

◆ m_status_vars_registered

bool hm::Health_Monitor::m_status_vars_registered {false}
private

◆ m_supervisor

std::unique_ptr<Supervisor> hm::Health_Monitor::m_supervisor
private

◆ m_system_collector

std::unique_ptr<System_Collector> hm::Health_Monitor::m_system_collector
private

◆ m_system_vars_registered

bool hm::Health_Monitor::m_system_vars_registered {false}
private

◆ m_sysvar_prefix

const std::string hm::Health_Monitor::m_sysvar_prefix {"health_monitor"}
private

◆ m_tables

std::unique_ptr<Tables> hm::Health_Monitor::m_tables
private

◆ m_tables_initialized

bool hm::Health_Monitor::m_tables_initialized {false}
private

◆ m_tables_registered

bool hm::Health_Monitor::m_tables_registered {false}
private

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