MySQL 8.0.39
Source Code Documentation
|
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_lock > | component_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) |
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 |
A class with an implementation of the Dynamic Loader Service.
typedef std::pair<my_component_registry::const_iterator, minimal_chassis::rwlock_scoped_lock> mysql_dynamic_loader_imp::component_iterator |
|
private |
|
static |
De-initializes loader.
De-initializes RW lock, all other structures doesn't require any action.
|
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.
urn | URN of Components to get scheme loader Service for. | |
[out] | out_scheme_service | Pointer to store result scheme loader Service. |
[in,out] | scheme_services | Map of scheme loader services already acquired. |
false | success |
true | failure |
|
static |
Initializes loader for usage.
Initializes RW lock, all other structures should be empty. Shouldn't be called multiple times.
|
staticnoexcept |
Creates iterator that iterates through all loaded Components.
If successful it leaves read lock on dynamic loader until iterator is released.
[out] | out_iterator | Pointer to Component iterator handle. |
false | success |
true | failure |
|
staticnoexcept |
Gets name and URN of Service pointed to by iterator.
iterator | Component iterator handle. | |
[out] | out_name | Pointer to string with Component name to set result pointer to. |
[out] | out_urn | Pointer to string with URN from which the Component was loaded from, to set result pointer to. |
false | success |
true | Failure, may be caused when called on iterator that went through all values already. |
|
staticnoexcept |
Checks if specified iterator is valid, i.e.
have not reached one-past-last element.
iterator | Component iterator handle. |
false | Valid |
true | Invalid or reached one-past-last element. |
|
staticnoexcept |
Advances specified iterator to next element.
Will succeed but return true if it reaches one-past-last element.
iterator | Component iterator handle. |
false | success |
true | Failure or called on iterator that was on last element. |
|
staticnoexcept |
Releases Component iterator.
Releases read lock on dynamic loader.
iterator | Component iterator handle. |
|
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.
urns | List of URNs of Components to load. |
component_count | Number of Components on list to load. |
false | success |
true | failure |
|
staticprivate |
Checks if all dependencies can be satisfied with existing or to be added Services.
loaded_components | List of Components to continue load of. |
services_provided | List of Services that are being provided by Components to be loaded. |
false | success |
true | failure |
|
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.
loaded_components | List of Components to continue load of. |
false | success |
true | failure |
|
staticprivate |
Adds all Components to main list of loaded Components.
Marks changes done by all previous steps as not to be rolled back.
loaded_components | List of Components to continue load of. |
false | success |
true | failure |
|
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.
loaded_components | List of Components to continue load of. |
false | success |
true | failure |
|
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.
urns | List of URNs of Components to load. |
component_count | Number of Components on list to load. |
false | success |
true | failure |
|
staticprivate |
Registers all Services that are provided by specified Components.
In case of failure rollbacks all changes, i.e. unregister registered Service Implementations.
loaded_components | List of Components to continue load of. |
false | success |
true | failure |
|
staticprivate |
Acquires Service Implementations for all dependencies of Components.
In case of failure rollbacks all changes, i.e. release Services that were acquired.
loaded_components | List of Components to continue load of. |
false | success |
true | failure |
|
static |
De-initializes RW lock.
|
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.
urns | List of URNs of Components to unload. |
component_count | Number of Components on list to unload. |
false | success |
true | failure |
|
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.
components_to_unload | List of Components to continue unload of. |
dependency_graph | A graph of dependencies between the Components to be unloaded. |
scheme_services | Map of scheme loading Services prefetched with Service Implementations required to unload all Components to unload. |
false | success |
true | failure |
|
staticprivate |
Finishes unloading process by marking changes to not be rolled back.
false | success |
true | failure |
|
staticprivate |
Deinitialize Components using their deinitialization method.
In case of failure rollbacks all changes, i.e. calls initialization method again on deinitialized Components.
components_to_unload | List of Components to continue unload of. |
scheme_services | Map of scheme loading Services prefetched with Service Implementations required to unload all Components to unload. |
false | success |
true | failure |
|
staticprivate |
Prefetch all scheme loading Services before we get a lock on a Registry.
components_to_unload | List of Components to continue unload of. |
dependency_graph | A graph of dependencies between the Components to be unloaded. |
false | success |
true | failure |
|
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.
urns | List of URNs of Components to unload. |
component_count | Number of Components on list to unload. |
false | success |
true | failure |
|
staticprivate |
Takes a lock on all services that are provided by the Components to be unloaded, to prevent reference count from being changed.
components_to_unload | List of Components to continue unload of. |
dependency_graph | A graph of dependencies between the Components to be unloaded. |
scheme_services | Map of scheme loading Services prefetched with Service Implementations required to unload all Components to unload. |
false | success |
true | failure |
|
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.
components_to_unload | List of Components to continue unload of. |
false | success |
true | failure |
|
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.
components_to_unload | List of Components to continue unload of. |
scheme_services | Map of scheme loading Services prefetched with Service Implementations required to unload all Components to unload. |
false | success |
true | failure |
|
staticprivate |
Releases Service Implementations acquired to satisfy dependencies.
In case of failure rollbacks all changes, i.e. acquires Services for released dependencies again.
components_to_unload | List of Components to continue unload of. |
scheme_services | Map of scheme loading Services prefetched with Service Implementations required to unload all Components to unload. |
false | success |
true | failure |
|
staticprivate |
Unregisters all Service Implementations of specified Components.
In case of failure rollbacks all changes, i.e. registers unregistered Service Implementations again.
components_to_unload | List of Components to continue unload of. |
scheme_services | Map of scheme loading Services prefetched with Service Implementations required to unload all Components to unload. |
false | success |
true | failure |
|
staticprivate |
|
staticprivate |
|
staticprivate |