MySQL 9.0.0
Source Code Documentation
mysql_dynamic_loader_imp Class Reference

A class with an implementation of the Dynamic Loader Service. More...

#include <dynamic_loader_imp.h>

Public Types

typedef std::pair< my_component_registry::const_iterator, minimal_chassis::rwlock_scoped_lockcomponent_iterator
 

Static Public Member Functions

static void init ()
 Initializes loader for usage. More...
 
static void deinit ()
 De-initializes loader. More...
 
static void rw_lock_deinit ()
 De-initializes RW lock. More...
 
static mysql_service_status_t load (const char *urns[], int component_count) noexcept
 Loads specified group of Components by URN, initializes them and registers all Service Implementations present in these Components. More...
 
static mysql_service_status_t unload (const char *urns[], int component_count) noexcept
 Unloads specified group of Components by URN, deinitializes them and unregisters all Service Implementations present in these Components. More...
 
static mysql_service_status_t iterator_create (my_h_component_iterator *out_iterator) noexcept
 Creates iterator that iterates through all loaded Components. More...
 
static void iterator_release (my_h_component_iterator iterator) noexcept
 Releases Component iterator. More...
 
static mysql_service_status_t iterator_get (my_h_component_iterator iterator, const char **out_name, const char **out_urn) noexcept
 Gets name and URN of Service pointed to by iterator. More...
 
static mysql_service_status_t iterator_next (my_h_component_iterator iterator) noexcept
 Advances specified iterator to next element. More...
 
static mysql_service_status_t iterator_is_valid (my_h_component_iterator iterator) noexcept
 Checks if specified iterator is valid, i.e. More...
 

Private Types

typedef std::unordered_map< my_string, my_service< const mysql_service_dynamic_loader_scheme_t > > scheme_service_map
 

Static Private Member Functions

static bool load_do_load_component_by_scheme (const char *urns[], int component_count)
 Loads specified group of Components by URN. More...
 
static bool load_do_collect_services_provided (std::vector< std::unique_ptr< mysql_component > > &loaded_components, std::vector< const char * > &services_loaded)
 Prepares a list of all Services that are provided by specified Components. More...
 
static bool load_do_check_dependencies (std::vector< std::unique_ptr< mysql_component > > &loaded_components, const std::set< my_string > &services_provided)
 Checks if all dependencies can be satisfied with existing or to be added Services. More...
 
static bool load_do_register_services (std::vector< std::unique_ptr< mysql_component > > &loaded_components)
 Registers all Services that are provided by specified Components. More...
 
static bool load_do_resolve_dependencies (std::vector< std::unique_ptr< mysql_component > > &loaded_components)
 Acquires Service Implementations for all dependencies of Components. More...
 
static bool load_do_initialize_components (std::vector< std::unique_ptr< mysql_component > > &loaded_components)
 Calls Components initialization method to make Components ready to function. More...
 
static bool load_do_commit (std::vector< std::unique_ptr< mysql_component > > &loaded_components)
 Adds all Components to main list of loaded Components. More...
 
static bool unload_do_list_components (const char *urns[], int component_count)
 Unloads all Components specified in list. More...
 
static bool unload_do_topological_order (const std::vector< mysql_component * > &components_to_unload)
 Orders components in a order that would allow allow deinitialization to be done always for components that have all their dependencies still not deinitialized. More...
 
static bool unload_do_get_scheme_services (const std::vector< mysql_component * > &components_to_unload, const std::map< const void *, std::vector< mysql_component * > > &dependency_graph)
 Prefetch all scheme loading Services before we get a lock on a Registry. More...
 
static bool unload_do_lock_provided_services (const std::vector< mysql_component * > &components_to_unload, const std::map< const void *, std::vector< mysql_component * > > &dependency_graph, scheme_service_map &scheme_services)
 Takes a lock on all services that are provided by the Components to be unloaded, to prevent reference count from being changed. More...
 
static bool unload_do_check_provided_services_reference_count (const std::vector< mysql_component * > &components_to_unload, const std::map< const void *, std::vector< mysql_component * > > &dependency_graph, scheme_service_map &scheme_services)
 Checks if all Service Implementations provided by the Components to be unloaded have no references outside the group of Components to be unloaded. More...
 
static bool unload_do_deinitialize_components (const std::vector< mysql_component * > &components_to_unload, scheme_service_map &scheme_services)
 Deinitialize Components using their deinitialization method. More...
 
static bool unload_do_unload_dependencies (const std::vector< mysql_component * > &components_to_unload, scheme_service_map &scheme_services)
 Releases Service Implementations acquired to satisfy dependencies. More...
 
static bool unload_do_unregister_services (const std::vector< mysql_component * > &components_to_unload, scheme_service_map &scheme_services)
 Unregisters all Service Implementations of specified Components. More...
 
static bool unload_do_unload_components (const std::vector< mysql_component * > &components_to_unload, scheme_service_map &scheme_services)
 Uses Component URN to extract the scheme part of URN (part before "://") and use it to acquire Service Implementation of scheme Component loader Service for specified scheme, used then to unload specified Components. More...
 
static bool unload_do_commit ()
 Finishes unloading process by marking changes to not be rolled back. More...
 
static bool get_scheme_service_from_urn (const my_string &urn, const mysql_service_dynamic_loader_scheme_t **out_scheme_service, scheme_service_map &scheme_services)
 Returns scheme loading Service based on given URN. More...
 

Static Private Attributes

static my_component_registry components_list
 
static mysql_rwlock_t LOCK_dynamic_loader
 
static generation_urns_list urns_with_gen_list
 

Detailed Description

A class with an implementation of the Dynamic Loader Service.

Member Typedef Documentation

◆ component_iterator

typedef std::pair<my_component_registry::const_iterator, minimal_chassis::rwlock_scoped_lock> mysql_dynamic_loader_imp::component_iterator

◆ scheme_service_map

Member Function Documentation

◆ deinit()

void mysql_dynamic_loader_imp::deinit ( )
static

De-initializes loader.

De-initializes RW lock, all other structures doesn't require any action.

◆ get_scheme_service_from_urn()

bool mysql_dynamic_loader_imp::get_scheme_service_from_urn ( const my_string urn,
const mysql_service_dynamic_loader_scheme_t **  out_scheme_service,
scheme_service_map scheme_services 
)
staticprivate

Returns scheme loading Service based on given URN.

It uses supplied cache to reuse Services. If Service is not present in cache, it will be acquired from registry.

Parameters
urnURN of Components to get scheme loader Service for.
[out]out_scheme_servicePointer to store result scheme loader Service.
[in,out]scheme_servicesMap of scheme loader services already acquired.
Returns
Status of performed operation
Return values
falsesuccess
truefailure

◆ init()

void mysql_dynamic_loader_imp::init ( )
static

Initializes loader for usage.

Initializes RW lock, all other structures should be empty. Shouldn't be called multiple times.

◆ iterator_create()

mysql_service_status_t mysql_dynamic_loader_imp::iterator_create ( my_h_component_iterator out_iterator)
staticnoexcept

Creates iterator that iterates through all loaded Components.

If successful it leaves read lock on dynamic loader until iterator is released.

Parameters
[out]out_iteratorPointer to Component iterator handle.
Returns
Status of performed operation
Return values
falsesuccess
truefailure

◆ iterator_get()

mysql_service_status_t mysql_dynamic_loader_imp::iterator_get ( my_h_component_iterator  iterator,
const char **  out_name,
const char **  out_urn 
)
staticnoexcept

Gets name and URN of Service pointed to by iterator.

Parameters
iteratorComponent iterator handle.
[out]out_namePointer to string with Component name to set result pointer to.
[out]out_urnPointer to string with URN from which the Component was loaded from, to set result pointer to.
Returns
Status of performed operation
Return values
falsesuccess
trueFailure, may be caused when called on iterator that went through all values already.

◆ iterator_is_valid()

mysql_service_status_t mysql_dynamic_loader_imp::iterator_is_valid ( my_h_component_iterator  iterator)
staticnoexcept

Checks if specified iterator is valid, i.e.

have not reached one-past-last element.

Parameters
iteratorComponent iterator handle.
Returns
Validity of iterator
Return values
falseValid
trueInvalid or reached one-past-last element.

◆ iterator_next()

mysql_service_status_t mysql_dynamic_loader_imp::iterator_next ( my_h_component_iterator  iterator)
staticnoexcept

Advances specified iterator to next element.

Will succeed but return true if it reaches one-past-last element.

Parameters
iteratorComponent iterator handle.
Returns
Status of performed operation and validity of iterator after operation.
Return values
falsesuccess
trueFailure or called on iterator that was on last element.

◆ iterator_release()

void mysql_dynamic_loader_imp::iterator_release ( my_h_component_iterator  iterator)
staticnoexcept

Releases Component iterator.

Releases read lock on dynamic loader.

Parameters
iteratorComponent iterator handle.

◆ load()

mysql_service_status_t mysql_dynamic_loader_imp::load ( const char *  urns[],
int  component_count 
)
staticnoexcept

Loads specified group of Components by URN, initializes them and registers all Service Implementations present in these Components.

Assures all dependencies will be met after loading specified Components. The dependencies may be circular, in such case it's necessary to specify all Components on cycle to load in one batch. From URNs specified the scheme part of URN (part before "://") is extracted and used to acquire Service Implementation of scheme Component loader Service for specified scheme.

Parameters
urnsList of URNs of Components to load.
component_countNumber of Components on list to load.
Returns
Status of performed operation
Return values
falsesuccess
truefailure

◆ load_do_check_dependencies()

bool mysql_dynamic_loader_imp::load_do_check_dependencies ( std::vector< std::unique_ptr< mysql_component > > &  loaded_components,
const std::set< my_string > &  services_provided 
)
staticprivate

Checks if all dependencies can be satisfied with existing or to be added Services.

Parameters
loaded_componentsList of Components to continue load of.
services_providedList of Services that are being provided by Components to be loaded.
Returns
Status of performed operation
Return values
falsesuccess
truefailure

◆ load_do_collect_services_provided()

bool mysql_dynamic_loader_imp::load_do_collect_services_provided ( std::vector< std::unique_ptr< mysql_component > > &  loaded_components,
std::vector< const char * > &  services_loaded 
)
staticprivate

Prepares a list of all Services that are provided by specified Components.

This will enable us in next step to check if these may be used to satisfy other Components dependencies.

Parameters
loaded_componentsList of Components to continue load of.
services_loadedList of services loaded
Returns
Status of performed operation
Return values
falsesuccess
truefailure

◆ load_do_commit()

bool mysql_dynamic_loader_imp::load_do_commit ( std::vector< std::unique_ptr< mysql_component > > &  loaded_components)
staticprivate

Adds all Components to main list of loaded Components.

Marks changes done by all previous steps as not to be rolled back.

Parameters
loaded_componentsList of Components to continue load of.
Returns
Status of performed operation
Return values
falsesuccess
truefailure

◆ load_do_initialize_components()

bool mysql_dynamic_loader_imp::load_do_initialize_components ( std::vector< std::unique_ptr< mysql_component > > &  loaded_components)
staticprivate

Calls Components initialization method to make Components ready to function.

In case of failure rollbacks all changes, i.e. calls deinitialization methods on initialized Components.

Parameters
loaded_componentsList of Components to continue load of.
Returns
Status of performed operation
Return values
falsesuccess
truefailure

◆ load_do_load_component_by_scheme()

bool mysql_dynamic_loader_imp::load_do_load_component_by_scheme ( const char *  urns[],
int  component_count 
)
staticprivate

Loads specified group of Components by URN.

From URNs specified the scheme part of URN (part before "://") is extracted and used to acquire Service Implementation of scheme Component loader Service for specified scheme. In case of failure rollbacks all changes, i.e. unloads loaded Components.

Parameters
urnsList of URNs of Components to load.
component_countNumber of Components on list to load.
Returns
Status of performed operation
Return values
falsesuccess
truefailure

◆ load_do_register_services()

bool mysql_dynamic_loader_imp::load_do_register_services ( std::vector< std::unique_ptr< mysql_component > > &  loaded_components)
staticprivate

Registers all Services that are provided by specified Components.

In case of failure rollbacks all changes, i.e. unregister registered Service Implementations.

Parameters
loaded_componentsList of Components to continue load of.
Returns
Status of performed operation
Return values
falsesuccess
truefailure

◆ load_do_resolve_dependencies()

bool mysql_dynamic_loader_imp::load_do_resolve_dependencies ( std::vector< std::unique_ptr< mysql_component > > &  loaded_components)
staticprivate

Acquires Service Implementations for all dependencies of Components.

In case of failure rollbacks all changes, i.e. release Services that were acquired.

Parameters
loaded_componentsList of Components to continue load of.
Returns
Status of performed operation
Return values
falsesuccess
truefailure

◆ rw_lock_deinit()

void mysql_dynamic_loader_imp::rw_lock_deinit ( )
static

De-initializes RW lock.

◆ unload()

mysql_service_status_t mysql_dynamic_loader_imp::unload ( const char *  urns[],
int  component_count 
)
staticnoexcept

Unloads specified group of Components by URN, deinitializes them and unregisters all Service Implementations present in these Components.

Assumes, thous does not check it, all dependencies of not unloaded Components will still be met after unloading specified Components. The dependencies may be circular, in such case it's necessary to specify all Components on cycle to unload in one batch. From URNs specified the scheme part of URN (part before "://") is extracted and used to acquire Service Implementation of scheme Component loader Service for specified scheme. URN specified should be identical to ones specified in load() method, i.e. all letters must have the same case.

Parameters
urnsList of URNs of Components to unload.
component_countNumber of Components on list to unload.
Returns
Status of performed operation
Return values
falsesuccess
truefailure

◆ unload_do_check_provided_services_reference_count()

bool mysql_dynamic_loader_imp::unload_do_check_provided_services_reference_count ( const std::vector< mysql_component * > &  components_to_unload,
const std::map< const void *, std::vector< mysql_component * > > &  dependency_graph,
scheme_service_map scheme_services 
)
staticprivate

Checks if all Service Implementations provided by the Components to be unloaded have no references outside the group of Components to be unloaded.

This assures that continuing deinitialization of these Components in topological order, and by this also unregistration of all provided Service Implementations will succeed.

Parameters
components_to_unloadList of Components to continue unload of.
dependency_graphA graph of dependencies between the Components to be unloaded.
scheme_servicesMap of scheme loading Services prefetched with Service Implementations required to unload all Components to unload.
Returns
Status of performed operation
Return values
falsesuccess
truefailure

◆ unload_do_commit()

bool mysql_dynamic_loader_imp::unload_do_commit ( )
staticprivate

Finishes unloading process by marking changes to not be rolled back.

Returns
Status of performed operation
Return values
falsesuccess
truefailure

◆ unload_do_deinitialize_components()

bool mysql_dynamic_loader_imp::unload_do_deinitialize_components ( const std::vector< mysql_component * > &  components_to_unload,
scheme_service_map scheme_services 
)
staticprivate

Deinitialize Components using their deinitialization method.

In case of failure rollbacks all changes, i.e. calls initialization method again on deinitialized Components.

Parameters
components_to_unloadList of Components to continue unload of.
scheme_servicesMap of scheme loading Services prefetched with Service Implementations required to unload all Components to unload.
Returns
Status of performed operation
Return values
falsesuccess
truefailure

◆ unload_do_get_scheme_services()

bool mysql_dynamic_loader_imp::unload_do_get_scheme_services ( const std::vector< mysql_component * > &  components_to_unload,
const std::map< const void *, std::vector< mysql_component * > > &  dependency_graph 
)
staticprivate

Prefetch all scheme loading Services before we get a lock on a Registry.

Parameters
components_to_unloadList of Components to continue unload of.
dependency_graphA graph of dependencies between the Components to be unloaded.
Returns
Status of performed operation
Return values
falsesuccess
truefailure

◆ unload_do_list_components()

bool mysql_dynamic_loader_imp::unload_do_list_components ( const char *  urns[],
int  component_count 
)
staticprivate

Unloads all Components specified in list.

It does not acquire a write lock on dynamic loader, but requires it to be acquired by caller.

Parameters
urnsList of URNs of Components to unload.
component_countNumber of Components on list to unload.
Returns
Status of performed operation
Return values
falsesuccess
truefailure

◆ unload_do_lock_provided_services()

bool mysql_dynamic_loader_imp::unload_do_lock_provided_services ( const std::vector< mysql_component * > &  components_to_unload,
const std::map< const void *, std::vector< mysql_component * > > &  dependency_graph,
scheme_service_map scheme_services 
)
staticprivate

Takes a lock on all services that are provided by the Components to be unloaded, to prevent reference count from being changed.

Parameters
components_to_unloadList of Components to continue unload of.
dependency_graphA graph of dependencies between the Components to be unloaded.
scheme_servicesMap of scheme loading Services prefetched with Service Implementations required to unload all Components to unload.
Returns
Status of performed operation
Return values
falsesuccess
truefailure

◆ unload_do_topological_order()

bool mysql_dynamic_loader_imp::unload_do_topological_order ( const std::vector< mysql_component * > &  components_to_unload)
staticprivate

Orders components in a order that would allow allow deinitialization to be done always for components that have all their dependencies still not deinitialized.

It also creates a graph of dependencies between the Service Implementations provided by the Components to be unloaded and Components that use this Service Implementation.

Parameters
components_to_unloadList of Components to continue unload of.
Returns
Status of performed operation
Return values
falsesuccess
truefailure

◆ unload_do_unload_components()

bool mysql_dynamic_loader_imp::unload_do_unload_components ( const std::vector< mysql_component * > &  components_to_unload,
scheme_service_map scheme_services 
)
staticprivate

Uses Component URN to extract the scheme part of URN (part before "://") and use it to acquire Service Implementation of scheme Component loader Service for specified scheme, used then to unload specified Components.

The unloaded Components are removed from the main list of all loaded Components. In case of failure rollbacks all changes, i.e. loads unloaded Components by their URN and add them to the main list of loaded Components again.

Parameters
components_to_unloadList of Components to continue unload of.
scheme_servicesMap of scheme loading Services prefetched with Service Implementations required to unload all Components to unload.
Returns
Status of performed operation
Return values
falsesuccess
truefailure

◆ unload_do_unload_dependencies()

bool mysql_dynamic_loader_imp::unload_do_unload_dependencies ( const std::vector< mysql_component * > &  components_to_unload,
scheme_service_map scheme_services 
)
staticprivate

Releases Service Implementations acquired to satisfy dependencies.

In case of failure rollbacks all changes, i.e. acquires Services for released dependencies again.

Parameters
components_to_unloadList of Components to continue unload of.
scheme_servicesMap of scheme loading Services prefetched with Service Implementations required to unload all Components to unload.
Returns
Status of performed operation
Return values
falsesuccess
truefailure

◆ unload_do_unregister_services()

bool mysql_dynamic_loader_imp::unload_do_unregister_services ( const std::vector< mysql_component * > &  components_to_unload,
scheme_service_map scheme_services 
)
staticprivate

Unregisters all Service Implementations of specified Components.

In case of failure rollbacks all changes, i.e. registers unregistered Service Implementations again.

Parameters
components_to_unloadList of Components to continue unload of.
scheme_servicesMap of scheme loading Services prefetched with Service Implementations required to unload all Components to unload.
Returns
Status of performed operation
Return values
falsesuccess
truefailure

Member Data Documentation

◆ components_list

my_component_registry mysql_dynamic_loader_imp::components_list
staticprivate

◆ LOCK_dynamic_loader

mysql_rwlock_t mysql_dynamic_loader_imp::LOCK_dynamic_loader
staticprivate

◆ urns_with_gen_list

generation_urns_list mysql_dynamic_loader_imp::urns_with_gen_list
staticprivate

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