MySQL 26.10.0
Source Code Documentation
hm::Periodic_Reporter Class Reference

The Periodic_Reporter has a framework for printing reports to some destination. More...

#include <health_monitor_periodic_reporter.h>

Inheritance diagram for hm::Periodic_Reporter:
[legend]

Public Member Functions

 Periodic_Reporter (const char *reporter_name, const char *status_name, const char *instr_name, const char *os_name, const char *description, sv_bool *sysvar_running, sv_char *sysvar_def)
 
 ~Periodic_Reporter () override=default
 
 Periodic_Reporter (const Periodic_Reporter &)=delete
 
Periodic_Reporter & operator= (const Periodic_Reporter &)=delete
 
 Periodic_Reporter (Periodic_Reporter &&)=delete
 
Periodic_Reporter & operator= (Periodic_Reporter &&)=delete
 
void pre_process () override
 Set the timer to 10 sec before starting to process. More...
 
void process () override
 Run report only if more than half of the level 3 limit is available. More...
 
virtual void issue_report ()
 Process all periodic report definitions, issue those that are due. More...
 
void log_resource_status () override
 Periodic Reporter status. More...
 
std::string format_settings () override
 Periodic_Reporter settings formatted string. More...
 
bool settings_changed () override
 Indicate if the Memory Periodic_Reporter settings have changed. More...
 
void set_params () override
 Set report parameters from the system variables. More...
 
bool running () const override
 Return health_monitor reporting variable. More...
 
int report_deprecated_usage ()
 Periodically report usage of the deprecated features. More...
 
- Public Member Functions inherited from hm::Collector
 Collector ()=default
 
 Collector (const char *name, const char *resource_name, const char *instr_name, const char *os_name, const char *description)
 
 ~Collector () override=default
 
 Collector (const Collector &)=delete
 
Collector & operator= (const Collector &)=delete
 
 Collector (Collector &&)=delete
 
Collector & operator= (Collector &&)=delete
 
const char * resource_name () const
 
void run_process () override
 Sample collection loop. More...
 
virtual void set_buffer_size ()
 
virtual bool dynamic_settings_changed ()
 
virtual bool static_settings_changed ()
 
void mark_settings_pending ()
 Mark a settings update for evaluation by the Supervisor. More...
 
bool settings_pending () const
 
void set_settings_pending (bool pending)
 
virtual bool update_settings ()
 Update system variable settings for the Collector. More...
 
int base_interval () const
 
int sample_interval () const
 
void set_sample_interval (int sample_interval)
 Set the sample interval, adjust to the nearest multiple of the base interval. More...
 
void set_collector_intervals (int base_interval, int sample_interval)
 Set the base and sample intervals together to ensure that the sample interval is a multiple of the base interval. More...
 
virtual void log_collector_status (bool settings)
 Collector status with optional settings. More...
 
virtual void log_collector_status (const std::string &state_msg, bool settings)
 Collector status with optional message and optional settings. More...
 
virtual void log_status ()
 Issue a log status message for the collector. More...
 
virtual void log_resource_levels ()
 Log general resource status with state, mode (Fallback, Recovery, ...) and levels. More...
 
virtual std::string build_collector_message (const std::string &status, const std::string &mode, const std::string &message, bool settings)
 Formatted collector message with optional settings. More...
 
virtual std::string build_resource_message (const std::string &status, const std::string &mode, const std::string &message, bool levels)
 Formatted resource message, no levels or settings. More...
 
virtual std::string format_status_info ()
 
virtual std::string tag_collector_state ()
 
virtual std::string tag_resource_state ()
 
virtual std::string tag_mode ()
 
- Public Member Functions inherited from hm::Thread
 Thread ()=default
 
 Thread (const char *name, const char *instr_name, const char *os_name, const char *desc)
 
virtual ~Thread ()=0
 
const char * name () const
 
virtual int start ()
 
virtual void stop ()
 
void signal ()
 Signal the processing loop to end the current cycle. More...
 

Static Public Attributes

static const char * default_periodic_report
 
- Static Public Attributes inherited from hm::Collector
static constexpr uint64_t no_warn_level {std::numeric_limits<uint64_t>::max()}
 
static constexpr int k_min_interval {1}
 
static constexpr int k_max_interval {86400}
 
static constexpr int k_default_base_interval {10}
 
static constexpr int k_default_sample_interval {k_default_base_interval * 6}
 

Protected Attributes

bool m_settings_changed = false
 
Report_Definition_Manager m_rep_mgr
 
sv_bool * m_sysvar_running = nullptr
 
sv_char * m_sysvar_def = nullptr
 
- Protected Attributes inherited from hm::Collector
const std::string m_resource_name
 
bool m_running {false}
 
- Protected Attributes inherited from hm::Thread
std::mutex m_command_lock
 
const std::string m_name
 
const std::string m_instr_name
 
const std::string m_os_name
 
const std::string m_description
 
std::atomic< bool > m_thread_running {false}
 
bool m_stop {false}
 
my_thread_handle m_thread
 
PSI_thread_key m_thread_key {0}
 
PSI_thread_info m_thread_info
 
mysql_mutex_t m_wait_lock
 
PSI_mutex_key m_mutex_key {0}
 
PSI_mutex_info m_mutex_info
 
mysql_cond_t m_wait
 
PSI_cond_key m_cond_key {0}
 
PSI_cond_info m_cond_info
 

Private Attributes

int deprecation_msg_next = 0
 

Static Private Attributes

static const uint DEPRECATION_REPORT_SAMPLE_INTERVAL = 3600
 

Additional Inherited Members

- Static Public Member Functions inherited from hm::Collector
static std::string format_level (uint64_t mbytes)
 Format storage amount in MiB, no units. More...
 
static std::string format_mb (uint64_t mbytes, int prec, bool show_units)
 Format storage amount. More...
 
- Static Public Member Functions inherited from hm::Thread
static void cleanup ()
 Cleanup thread instrumentation. More...
 
static int join (my_thread_handle *thread, void **value_ptr)
 
static bool joinable (const my_thread_handle &thread)
 
- Public Attributes inherited from hm::Collector
const std::string k_started {"Started"}
 
const std::string k_stopped {"Stopped"}
 
const std::string k_offline_mode {"OFFLINE_MODE"}
 
const std::string k_super_read_only {"SUPER_READ_ONLY"}
 
const std::string k_invalid_path {"Invalid Path"}
 
const std::string k_error {"ERROR"}
 
const std::string k_system_error {"SYSTEM ERROR"}
 
const std::string k_failed {"failed"}
 
const std::string k_remaining {"attempts remaining"}
 
int m_retention {0}
 
std::atomic< bool > m_settings_pending {false}
 
int m_status_interval {0}
 
int m_status_counter {0}
 
bool m_verbose_log {false}
 
bool m_force_status {false}
 
Cycle_Timer m_sample_timer
 
Cycle_Timer m_status_timer
 
- Protected Member Functions inherited from hm::Collector
void consume_settings_pending ()
 Consume one pending notification without clearing a concurrent update. More...
 
void apply_pending_settings ()
 Apply settings while the collector command lock is held. More...
 
Cycle_Timer & sample_timer ()
 
Cycle_Timer & status_message_timer ()
 
void initialize_sample_timers ()
 Initialize collection timers. More...
 
void advance_sample_timers ()
 Process collector sample and status timers. More...
 
- Protected Member Functions inherited from hm::Thread
int start_thread ()
 
void stop_thread ()
 
void request_thread_stop ()
 Request that the worker stop without waiting for it to exit. More...
 
void join_thread ()
 Wait for a stopped worker to exit. More...
 
bool stop_requested ()
 Return true when worker shutdown has been requested. More...
 
virtual void post_process ()
 

Detailed Description

The Periodic_Reporter has a framework for printing reports to some destination.

A Report_Definition_Manager will observe changes to a config variable that defines the report contents. On some event, the report is issued. Such an event can be the expiration of a timer, a signal, etc.

The Periodic_Reporter will issue reports at specified intervals, as indicated by the report definition. Other behavior can be defined in subclasses.

Constructor & Destructor Documentation

◆ Periodic_Reporter() [1/3]

hm::Periodic_Reporter::Periodic_Reporter ( const char *  reporter_name,
const char *  status_name,
const char *  instr_name,
const char *  os_name,
const char *  description,
sv_bool *  sysvar_running,
sv_char *  sysvar_def 
)

◆ ~Periodic_Reporter()

hm::Periodic_Reporter::~Periodic_Reporter ( )
overridedefault

◆ Periodic_Reporter() [2/3]

hm::Periodic_Reporter::Periodic_Reporter ( const Periodic_Reporter &  )
delete

◆ Periodic_Reporter() [3/3]

hm::Periodic_Reporter::Periodic_Reporter ( Periodic_Reporter &&  )
delete

Member Function Documentation

◆ format_settings()

std::string hm::Periodic_Reporter::format_settings ( )
overridevirtual

Periodic_Reporter settings formatted string.

Reimplemented from hm::Collector.

◆ issue_report()

void hm::Periodic_Reporter::issue_report ( )
virtual

Process all periodic report definitions, issue those that are due.

Adjust the time for next emission, and set the sample interval for the report manager to wake up again when the next report is to be issued.

Reimplemented in hm::Triggered_Reporter.

◆ log_resource_status()

void hm::Periodic_Reporter::log_resource_status ( )
overridevirtual

Periodic Reporter status.

Implements hm::Collector.

◆ operator=() [1/2]

Periodic_Reporter & hm::Periodic_Reporter::operator= ( const Periodic_Reporter &  )
delete

◆ operator=() [2/2]

Periodic_Reporter & hm::Periodic_Reporter::operator= ( Periodic_Reporter &&  )
delete

◆ pre_process()

void hm::Periodic_Reporter::pre_process ( )
overridevirtual

Set the timer to 10 sec before starting to process.

This means at the first round of processing, all reports will be issued after 10 sec, then they will be issued according to the defined interval. The initial sample interval is set to 10 sec to let the memory collector have enough time to collect its data.

Reimplemented from hm::Thread.

◆ process()

void hm::Periodic_Reporter::process ( )
overridevirtual

Run report only if more than half of the level 3 limit is available.

The actual report is issued in a virtual method that may be redefined in some subclass. This is because the behavior is different, e.g. a periodic report must keep track of which reports to issue at which intervals.

Reimplemented from hm::Collector.

◆ report_deprecated_usage()

int hm::Periodic_Reporter::report_deprecated_usage ( )

Periodically report usage of the deprecated features.

Returns
Time remaining to issue this report.

◆ running()

bool hm::Periodic_Reporter::running ( ) const
overridevirtual

Return health_monitor reporting variable.

Reimplemented from hm::Thread.

◆ set_params()

void hm::Periodic_Reporter::set_params ( )
overridevirtual

Set report parameters from the system variables.

Reimplemented from hm::Collector.

◆ settings_changed()

bool hm::Periodic_Reporter::settings_changed ( )
overridevirtual

Indicate if the Memory Periodic_Reporter settings have changed.

Returns
true if settings have changed

Reimplemented from hm::Collector.

Member Data Documentation

◆ default_periodic_report

const char * hm::Periodic_Reporter::default_periodic_report
static

◆ deprecation_msg_next

int hm::Periodic_Reporter::deprecation_msg_next = 0
private

◆ DEPRECATION_REPORT_SAMPLE_INTERVAL

const uint hm::Periodic_Reporter::DEPRECATION_REPORT_SAMPLE_INTERVAL = 3600
staticprivate

◆ m_rep_mgr

Report_Definition_Manager hm::Periodic_Reporter::m_rep_mgr
protected

◆ m_settings_changed

bool hm::Periodic_Reporter::m_settings_changed = false
protected

◆ m_sysvar_def

sv_char* hm::Periodic_Reporter::m_sysvar_def = nullptr
protected

◆ m_sysvar_running

sv_bool* hm::Periodic_Reporter::m_sysvar_running = nullptr
protected

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