MySQL 26.10.0
Source Code Documentation
mrs_component::Backend Class Reference

Owns and controls the embedded MRS backend lifecycle. More...

#include <mrs_component_backend.h>

Inheritance diagram for mrs_component::Backend:
[legend]

Public Member Functions

 Backend ()=default
 
 ~Backend () override=default
 
 Backend (const Backend &src)=delete
 
 Backend (Backend &&src)=delete
 
Backend & operator= (const Backend &src)=delete
 
Backend & operator= (Backend &&src)=delete
 
void enable_lifecycle_operations ()
 
int start (AccountProvisioning account_provisioning)
 
int restart ()
 
int stop ()
 
int shutdown ()
 
const char * lifecycle_state_name () const
 
CurrentSecurityCtx get_current_sec_ctx () const
 

Private Types

enum class  LifecycleState : std::uint8_t {
  kStopped , kStarting , kWaitingForMetadata , kReady ,
  kStopping , kError
}
 

Private Member Functions

int start_backend (AccountProvisioning account_provisioning)
 
int stop_backend ()
 
void log_disabled_lifecycle_operation_rejection (const char *operation) const
 
void report_waiting_for_metadata ()
 
void report_metadata_ready ()
 
void report_backend_error ()
 
mrs::MrsStartResult on_mrs_start () override
 
void fetch_current_sec_ctx ()
 
bool provision_accounts (bool ignore_missing_provider_role_error) const
 
void configure_accounts (bool retry_account_provisioning, bool validate_metadata_account)
 
uint64_t populate_mrs_metadata () const
 
void reset_process_state_component () const
 
void setup_logger (mysql_harness::DIM &dim) const
 
void configure_loader (mysql_harness::DIM &dim) const
 
void install_embedded_runtime_integration ()
 
void reset_embedded_runtime_integration ()
 
void breakable_sleep (std::chrono::seconds duration) const
 
bool wait_for_metadata_schema (const std::string &user, const std::string &host, bool validate_metadata_account)
 
void run (std::promise< int > p, bool has_bootstrap_context)
 
mysql_harness::DIM & init_DIM ()
 
void init_builtins ()
 
- Private Member Functions inherited from mrs::MrsStartObserver
virtual ~MrsStartObserver ()=default
 

Private Attributes

RouterConfig m_router_config
 
LogLevel m_log_level {LogLevel::ERROR}
 
mysql_harness::logging::DomainLogger m_logger
 
std::mutex m_lifecycle_operation_mtx
 
std::mutex m_lifecycle_state_mtx
 
LifecycleState m_lifecycle_state {LifecycleState::kStopped}
 
bool m_lifecycle_admission_open {false}
 
std::mutex m_loader_create_mtx
 
std::unique_ptr< mysql_harness::Loader > m_loader
 
std::unique_ptr< ComponentEmbeddedRuntimeServices > m_embedded_runtime_services
 
std::thread m_service_thread
 
std::thread m_backend_starter_thread
 
std::atomic< bool > m_backend_thd_stop_requested {false}
 
std::optional< CurrentSecurityCtx > m_deferred_account_provisioning_context
 
bool m_debug_pause_before_account_provisioning {false}
 
bool m_debug_pause_before_runtime_status_publication {false}
 
std::atomic< bool > m_debug_resume_runtime_status_publication {false}
 
CurrentSecurityCtx m_sec_ctx
 

Detailed Description

Owns and controls the embedded MRS backend lifecycle.

Member Enumeration Documentation

◆ LifecycleState

enum class mrs_component::Backend::LifecycleState : std::uint8_t
strongprivate
Enumerator
kStopped 
kStarting 
kWaitingForMetadata 
kReady 
kStopping 
kError 

Constructor & Destructor Documentation

◆ Backend() [1/3]

mrs_component::Backend::Backend ( )
default

◆ ~Backend()

mrs_component::Backend::~Backend ( )
overridedefault

◆ Backend() [2/3]

mrs_component::Backend::Backend ( const Backend &  src)
delete

◆ Backend() [3/3]

mrs_component::Backend::Backend ( Backend &&  src)
delete

Member Function Documentation

◆ breakable_sleep()

void mrs_component::Backend::breakable_sleep ( std::chrono::seconds  duration) const
private

◆ configure_accounts()

void mrs_component::Backend::configure_accounts ( bool  retry_account_provisioning,
bool  validate_metadata_account 
)
private

◆ configure_loader()

void mrs_component::Backend::configure_loader ( mysql_harness::DIM &  dim) const
private

Due to BUG#38080803 we need to validate the value of bind_address:

  • If @bind_address=[set_of_addresses] - Error out, unsupported
  • If @bind_address=* OR @bind_address=:: : Log that needs dual-stack
  • Any other value remains unchanged.

◆ enable_lifecycle_operations()

void mrs_component::Backend::enable_lifecycle_operations ( )

◆ fetch_current_sec_ctx()

void mrs_component::Backend::fetch_current_sec_ctx ( )
private

◆ get_current_sec_ctx()

CurrentSecurityCtx mrs_component::Backend::get_current_sec_ctx ( ) const
inline

◆ init_builtins()

void mrs_component::Backend::init_builtins ( )
private

◆ init_DIM()

mysql_harness::DIM & mrs_component::Backend::init_DIM ( )
private

◆ install_embedded_runtime_integration()

void mrs_component::Backend::install_embedded_runtime_integration ( )
private

◆ lifecycle_state_name()

const char * mrs_component::Backend::lifecycle_state_name ( ) const

◆ log_disabled_lifecycle_operation_rejection()

void mrs_component::Backend::log_disabled_lifecycle_operation_rejection ( const char *  operation) const
private

◆ on_mrs_start()

mrs::MrsStartResult mrs_component::Backend::on_mrs_start ( )
overrideprivatevirtual

Implements mrs::MrsStartObserver.

◆ operator=() [1/2]

Backend & mrs_component::Backend::operator= ( Backend &&  src)
delete

◆ operator=() [2/2]

Backend & mrs_component::Backend::operator= ( const Backend &  src)
delete

◆ populate_mrs_metadata()

uint64_t mrs_component::Backend::populate_mrs_metadata ( ) const
private

Check if the entry already exists in the Metadata first, because for example the component was restarted, and if so, obtain it's ID. If the router does not exist yet we need to "bootstrap" it and insert a new entry in the table.

Info:

router_name = "@@hostname":"http_port" address = "@@hostname" product_name = "MySQL Rest Service Component" version = current attributes = {"server_uuid": "@@server_uuid", "mrs_metadata_accounts": metadata_account, "mrs_data_accounts": data_account} options = {}

◆ provision_accounts()

bool mrs_component::Backend::provision_accounts ( bool  ignore_missing_provider_role_error) const
private

◆ report_backend_error()

void mrs_component::Backend::report_backend_error ( )
private

◆ report_metadata_ready()

void mrs_component::Backend::report_metadata_ready ( )
private

◆ report_waiting_for_metadata()

void mrs_component::Backend::report_waiting_for_metadata ( )
private

◆ reset_embedded_runtime_integration()

void mrs_component::Backend::reset_embedded_runtime_integration ( )
private

◆ reset_process_state_component()

void mrs_component::Backend::reset_process_state_component ( ) const
private

◆ restart()

int mrs_component::Backend::restart ( )

◆ run()

void mrs_component::Backend::run ( std::promise< int >  p,
bool  has_bootstrap_context 
)
private

◆ setup_logger()

void mrs_component::Backend::setup_logger ( mysql_harness::DIM &  dim) const
private

◆ shutdown()

int mrs_component::Backend::shutdown ( )

◆ start()

int mrs_component::Backend::start ( AccountProvisioning  account_provisioning)

◆ start_backend()

int mrs_component::Backend::start_backend ( AccountProvisioning  account_provisioning)
private

Set the local_address:

1) Prefer socket if available: fetch the socket full path 2) Fallback to 127.0.0.1 otherwise.

On Windows, support for named_pipes is not available we need to fallback to tcp/ip.

◆ stop()

int mrs_component::Backend::stop ( )

◆ stop_backend()

int mrs_component::Backend::stop_backend ( )
private

◆ wait_for_metadata_schema()

bool mrs_component::Backend::wait_for_metadata_schema ( const std::string &  user,
const std::string &  host,
bool  validate_metadata_account 
)
private

Member Data Documentation

◆ m_backend_starter_thread

std::thread mrs_component::Backend::m_backend_starter_thread
private

◆ m_backend_thd_stop_requested

std::atomic<bool> mrs_component::Backend::m_backend_thd_stop_requested {false}
private

◆ m_debug_pause_before_account_provisioning

bool mrs_component::Backend::m_debug_pause_before_account_provisioning {false}
private

◆ m_debug_pause_before_runtime_status_publication

bool mrs_component::Backend::m_debug_pause_before_runtime_status_publication {false}
private

◆ m_debug_resume_runtime_status_publication

std::atomic<bool> mrs_component::Backend::m_debug_resume_runtime_status_publication {false}
private

◆ m_deferred_account_provisioning_context

std::optional<CurrentSecurityCtx> mrs_component::Backend::m_deferred_account_provisioning_context
private

◆ m_embedded_runtime_services

std::unique_ptr<ComponentEmbeddedRuntimeServices> mrs_component::Backend::m_embedded_runtime_services
private

◆ m_lifecycle_admission_open

bool mrs_component::Backend::m_lifecycle_admission_open {false}
private

◆ m_lifecycle_operation_mtx

std::mutex mrs_component::Backend::m_lifecycle_operation_mtx
private

◆ m_lifecycle_state

LifecycleState mrs_component::Backend::m_lifecycle_state {LifecycleState::kStopped}
private

◆ m_lifecycle_state_mtx

std::mutex mrs_component::Backend::m_lifecycle_state_mtx
mutableprivate

◆ m_loader

std::unique_ptr<mysql_harness::Loader> mrs_component::Backend::m_loader
private

◆ m_loader_create_mtx

std::mutex mrs_component::Backend::m_loader_create_mtx
private

◆ m_log_level

LogLevel mrs_component::Backend::m_log_level {LogLevel::ERROR}
private

◆ m_logger

mysql_harness::logging::DomainLogger mrs_component::Backend::m_logger
private

◆ m_router_config

RouterConfig mrs_component::Backend::m_router_config
private

◆ m_sec_ctx

CurrentSecurityCtx mrs_component::Backend::m_sec_ctx
private

◆ m_service_thread

std::thread mrs_component::Backend::m_service_thread
private

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