MySQL 9.0.0
Source Code Documentation
Network_provider_manager Class Reference

Manages all running instances of a network provider. More...

#include <network_provider_manager.h>

Inheritance diagram for Network_provider_manager:
[legend]

Public Member Functions

 Network_provider_manager (Network_provider_manager const &)=delete
 
 Network_provider_manager (Network_provider_manager &&)=delete
 
Network_provider_manageroperator= (Network_provider_manager const &)=delete
 
Network_provider_manageroperator= (Network_provider_manager &&)=delete
 
bool initialize () override
 Initialize the network manager. More...
 
bool finalize () override
 Finalize the network manager. More...
 
void add_network_provider (std::shared_ptr< Network_provider > provider) override
 Add a new Gcs_network_provider instance. More...
 
void add_and_start_network_provider (std::shared_ptr< Network_provider > provider)
 Add a new Gcs_network_provider instance and start it. More...
 
void remove_network_provider (enum_transport_protocol provider_key) override
 Remove an active network provider. More...
 
void remove_all_network_provider () override
 Removes all configured network providers. More...
 
bool start_network_provider (enum_transport_protocol provider_key)
 Starts an already added network provider. More...
 
bool stop_all_network_providers () override
 Stops all network providers. More...
 
bool stop_network_provider (enum_transport_protocol provider_key)
 Stops a running network provider. More...
 
void set_running_protocol (enum_transport_protocol new_value) override
 Sets the running Communication Stack, thus defining the active provider. More...
 
enum_transport_protocol get_running_protocol () const override
 Gets the configured running protocol. More...
 
enum_transport_protocol get_incoming_connections_protocol () const override
 Get the incoming connections Communication Stack. More...
 
const std::shared_ptr< Network_providerget_provider (enum_transport_protocol provider)
 Gets a configured provider. More...
 
const std::shared_ptr< Network_providerget_active_provider ()
 Retrieves the active provider. More...
 
const std::shared_ptr< Network_providerget_incoming_connections_provider ()
 Retrieves the active provider for incoming connections. More...
 
bool start_active_network_provider () override
 Start the active provider. More...
 
bool stop_active_network_provider () override
 Stops the active provider. More...
 
bool configure_active_provider (Network_configuration_parameters &params) override
 Configures the active provider. More...
 
bool configure_active_provider_secure_connections (Network_configuration_parameters &params) override
 Configures the active provider with all things needed to establish SSL connections. More...
 
connection_descriptorincoming_connection ()
 Method to call to get Server Connections that are waiting to be accepted. More...
 
int close_xcom_connection (connection_descriptor *connection_handle)
 Closes an open connection to another XCom endpoint served by the a Network provider. More...
 
connection_descriptoropen_xcom_connection (const char *server, xcom_port port, bool use_ssl, int connection_timeout=Network_provider::default_connection_timeout(), network_provider_dynamic_log_level log_level=network_provider_dynamic_log_level::PROVIDED)
 Opens a new connection to another XCom endpoint served by the same Network provider. More...
 
int is_xcom_using_ssl () const override
 Return whether the SSL will be used to encrypt data or not. More...
 
int xcom_set_ssl_mode (int mode) override
 Set the operation mode which might be the following: More...
 
int xcom_get_ssl_mode (const char *mode) override
 Return the operation mode as an integer from an operation mode provided as a string. More...
 
int xcom_get_ssl_mode () override
 Return the configured value into SSL mode. More...
 
int xcom_set_ssl_fips_mode (int mode) override
 Set the operation fips mode which might be the following: More...
 
int xcom_get_ssl_fips_mode (const char *mode) override
 Return the operation fips mode as an integer from an operation fips mode provided as a string. More...
 
int xcom_get_ssl_fips_mode () override
 Returns the configured FIPS mode. More...
 
void cleanup_secure_connections_context () override
 Cleans up SSL context. More...
 
void delayed_cleanup_secure_connections_context () override
 Cleans up SSL context indirectly from the last active network provider. More...
 
void finalize_secure_connections_context () override
 Destroys all things SSL related. More...
 
- Public Member Functions inherited from Network_provider_management_interface
 Network_provider_management_interface ()
 
virtual ~Network_provider_management_interface ()
 
 Network_provider_management_interface (Network_provider_management_interface const &)=delete
 
Network_provider_management_interfaceoperator= (Network_provider_management_interface const &)=delete
 
 Network_provider_management_interface (Network_provider_management_interface &&)=default
 
Network_provider_management_interfaceoperator= (Network_provider_management_interface &&)=default
 
- Public Member Functions inherited from Network_provider_operations_interface
 Network_provider_operations_interface ()
 
virtual ~Network_provider_operations_interface ()
 
 Network_provider_operations_interface (Network_provider_operations_interface const &)=delete
 
Network_provider_operations_interfaceoperator= (Network_provider_operations_interface const &)=delete
 

Static Public Member Functions

static Network_provider_managergetInstance ()
 

Private Member Functions

 Network_provider_manager ()
 
virtual ~Network_provider_manager () override
 
void set_incoming_connections_protocol (enum_transport_protocol value)
 
void cleanup_incoming_connection (Network_provider &provider_ref)
 

Private Attributes

std::unordered_map< enum_transport_protocol, std::shared_ptr< Network_provider >, std::hash< int > > m_network_providers
 
enum_transport_protocol m_running_protocol
 
enum_transport_protocol m_incoming_connections_protocol
 
int m_ssl_mode
 
int m_ssl_fips_mode
 
Network_configuration_parameters m_active_provider_configuration
 
Network_configuration_parameters m_active_provider_secure_connections_configuration
 
std::shared_ptr< Xcom_network_providerm_xcom_network_provider
 
std::function< void()> m_ssl_data_context_cleaner {nullptr}
 

Detailed Description

Manages all running instances of a network provider.

Constructor & Destructor Documentation

◆ Network_provider_manager() [1/3]

Network_provider_manager::Network_provider_manager ( Network_provider_manager const &  )
delete

◆ Network_provider_manager() [2/3]

Network_provider_manager::Network_provider_manager ( Network_provider_manager &&  )
delete

◆ Network_provider_manager() [3/3]

Network_provider_manager::Network_provider_manager ( )
inlineprivate

◆ ~Network_provider_manager()

virtual Network_provider_manager::~Network_provider_manager ( )
inlineoverrideprivatevirtual

Member Function Documentation

◆ add_and_start_network_provider()

void Network_provider_manager::add_and_start_network_provider ( std::shared_ptr< Network_provider provider)

Add a new Gcs_network_provider instance and start it.

Parameters
provideran already instantiated shared_ptr object of a Gcs_network_provider

◆ add_network_provider()

void Network_provider_manager::add_network_provider ( std::shared_ptr< Network_provider provider)
overridevirtual

Add a new Gcs_network_provider instance.

Parameters
provideran already instantiated shared_ptr object of a Gcs_network_provider

Implements Network_provider_management_interface.

◆ cleanup_incoming_connection()

void Network_provider_manager::cleanup_incoming_connection ( Network_provider provider_ref)
private

◆ cleanup_secure_connections_context()

void Network_provider_manager::cleanup_secure_connections_context ( )
overridevirtual

Cleans up SSL context.

Implements Network_provider_management_interface.

◆ close_xcom_connection()

int Network_provider_manager::close_xcom_connection ( connection_descriptor connection_handle)

Closes an open connection to another XCom endpoint served by the a Network provider.

Parameters
connection_handlean open and valid connection
Returns
int an error code in case of error. 0, otherwise.

◆ configure_active_provider()

bool Network_provider_manager::configure_active_provider ( Network_configuration_parameters params)
overridevirtual

Configures the active provider.

Parameters
paramsconfiguration parameters.
Returns
true In case of success.
false In case of failure.

Implements Network_provider_operations_interface.

◆ configure_active_provider_secure_connections()

bool Network_provider_manager::configure_active_provider_secure_connections ( Network_configuration_parameters params)
overridevirtual

Configures the active provider with all things needed to establish SSL connections.

Parameters
paramsconfiguration parameters for SSL.
Returns
true In case of success.
false In case of failure.

Implements Network_provider_operations_interface.

◆ delayed_cleanup_secure_connections_context()

void Network_provider_manager::delayed_cleanup_secure_connections_context ( )
overridevirtual

Cleans up SSL context indirectly from the last active network provider.

Implements Network_provider_management_interface.

◆ finalize()

bool Network_provider_manager::finalize ( )
overridevirtual

Finalize the network manager.

It removes the default XCom provider,

Returns
true in case of error. false otherwise.

Implements Network_provider_management_interface.

◆ finalize_secure_connections_context()

void Network_provider_manager::finalize_secure_connections_context ( )
overridevirtual

Destroys all things SSL related.

Implements Network_provider_management_interface.

◆ get_active_provider()

const std::shared_ptr< Network_provider > Network_provider_manager::get_active_provider ( )

Retrieves the active provider.

This is determined by the value set in set_running_protocol.

Returns
const std::shared_ptr<Gcs_network_provider> a shared_ptr to the active provider.

◆ get_incoming_connections_protocol()

enum_transport_protocol Network_provider_manager::get_incoming_connections_protocol ( ) const
inlineoverridevirtual

Get the incoming connections Communication Stack.

This is the value that is used to report upwards the protocol in * which we are currently accepting connections.

Returns
CommunicationStack

Implements Network_provider_management_interface.

◆ get_incoming_connections_provider()

const std::shared_ptr< Network_provider > Network_provider_manager::get_incoming_connections_provider ( )

Retrieves the active provider for incoming connections.

This is determined by the value set in set_running_protocol when the active provider is started.

Returns
const std::shared_ptr<Gcs_network_provider> a shared_ptr to the active provider for incoming connections.

◆ get_provider()

const std::shared_ptr< Network_provider > Network_provider_manager::get_provider ( enum_transport_protocol  provider)

Gets a configured provider.

Parameters
providerconst std::shared_ptr<Gcs_network_provider> a shared_ptr to the active provider.
Returns
const std::shared_ptr<Network_provider>

◆ get_running_protocol()

enum_transport_protocol Network_provider_manager::get_running_protocol ( ) const
inlineoverridevirtual

Gets the configured running protocol.

It returns the value that is currently configured in the Running Communication Stack

Since this value is dynamic, it can cause a mismatch from the provider that we are actively receiving connections and the provider that we use to establish new connections

Returns
CommunicationStack value.

Implements Network_provider_management_interface.

◆ getInstance()

static Network_provider_manager & Network_provider_manager::getInstance ( )
inlinestatic

◆ incoming_connection()

connection_descriptor * Network_provider_manager::incoming_connection ( )

Method to call to get Server Connections that are waiting to be accepted.

Loop over this method to accept connections. They will be accepted from the provider that is configured in the Incoming Connection protocol.

Returns
connection_descriptor* a pointer to a connection_descriptor. If the pointer is nullptr, no new connections are available.

◆ initialize()

bool Network_provider_manager::initialize ( )
overridevirtual

Initialize the network manager.

It also creates the default XCom provider and adds it to the manager.

Returns
true in case of error. false otherwise.

Implements Network_provider_management_interface.

◆ is_xcom_using_ssl()

int Network_provider_manager::is_xcom_using_ssl ( ) const
overridevirtual

Return whether the SSL will be used to encrypt data or not.

Return 1 if it is enabled 0 otherwise.

Implements Network_provider_management_interface.

◆ open_xcom_connection()

connection_descriptor * Network_provider_manager::open_xcom_connection ( const char *  server,
xcom_port  port,
bool  use_ssl,
int  connection_timeout = Network_provider::default_connection_timeout(),
network_provider_dynamic_log_level  log_level = network_provider_dynamic_log_level::PROVIDED 
)

Opens a new connection to another XCom endpoint served by the same Network provider.

Parameters
serveraddress of the remote endpoint
portport of the remote endpoint
use_sslif this connection should use SSL
connection_timeoutoptional connection timeout.
log_levelruntime log level
Returns
connection_descriptor an established connection. nullptr in case of failure.

◆ operator=() [1/2]

Network_provider_manager & Network_provider_manager::operator= ( Network_provider_manager &&  )
delete

◆ operator=() [2/2]

Network_provider_manager & Network_provider_manager::operator= ( Network_provider_manager const &  )
delete

◆ remove_all_network_provider()

void Network_provider_manager::remove_all_network_provider ( )
overridevirtual

Removes all configured network providers.

Implements Network_provider_management_interface.

◆ remove_network_provider()

void Network_provider_manager::remove_network_provider ( enum_transport_protocol  provider_key)
overridevirtual

Remove an active network provider.

Parameters
provider_keya valid value of CommunicationStack of the provider that you want to remove.

Implements Network_provider_management_interface.

◆ set_incoming_connections_protocol()

void Network_provider_manager::set_incoming_connections_protocol ( enum_transport_protocol  value)
inlineprivate

◆ set_running_protocol()

void Network_provider_manager::set_running_protocol ( enum_transport_protocol  new_value)
inlineoverridevirtual

Sets the running Communication Stack, thus defining the active provider.

In runtime, this is will change the way we establish connections.

Parameters
new_valuevalue of the Communication Stack

Implements Network_provider_management_interface.

◆ start_active_network_provider()

bool Network_provider_manager::start_active_network_provider ( )
overridevirtual

Start the active provider.

Returns
true In case of success.
false In case of failure.

Implements Network_provider_operations_interface.

◆ start_network_provider()

bool Network_provider_manager::start_network_provider ( enum_transport_protocol  provider_key)

Starts an already added network provider.

Parameters
provider_keya valid value of CommunicationStack of the provider that you want to start.
Returns
true In case of success.
false In case of failure.

◆ stop_active_network_provider()

bool Network_provider_manager::stop_active_network_provider ( )
overridevirtual

Stops the active provider.

Returns
true In case of success.
false In case of failure.

Implements Network_provider_operations_interface.

◆ stop_all_network_providers()

bool Network_provider_manager::stop_all_network_providers ( )
overridevirtual

Stops all network providers.

Returns
true In case of success stopping ALL network providers
false In case of failure in stopping AT LEAST ONE network provider

Implements Network_provider_operations_interface.

◆ stop_network_provider()

bool Network_provider_manager::stop_network_provider ( enum_transport_protocol  provider_key)

Stops a running network provider.

Parameters
provider_keya valid value of CommunicationStack of the provider that you want to stop.
Returns
true In case of success.
false In case of failure.

◆ xcom_get_ssl_fips_mode() [1/2]

int Network_provider_manager::xcom_get_ssl_fips_mode ( )
overridevirtual

Returns the configured FIPS mode.

Implements Network_provider_management_interface.

◆ xcom_get_ssl_fips_mode() [2/2]

int Network_provider_manager::xcom_get_ssl_fips_mode ( const char *  mode)
overridevirtual

Return the operation fips mode as an integer from an operation fips mode provided as a string.

Note that the string must be provided in upper case letters and the possible values are: "OFF", "ON", "STRICT",

If a different value is provide, INVALID_SSL_MODE (-1) is returned.

Implements Network_provider_management_interface.

◆ xcom_get_ssl_mode() [1/2]

int Network_provider_manager::xcom_get_ssl_mode ( )
overridevirtual

Return the configured value into SSL mode.

Implements Network_provider_management_interface.

◆ xcom_get_ssl_mode() [2/2]

int Network_provider_manager::xcom_get_ssl_mode ( const char *  mode)
overridevirtual

Return the operation mode as an integer from an operation mode provided as a string.

Note that the string must be provided in upper case letters and the possible values are: "DISABLED", "PREFERRED", "REQUIRED", "VERIFY_CA" or "VERIFY_IDENTITY".

If a different value is provide, INVALID_SSL_MODE (-1) is returned.

Implements Network_provider_management_interface.

◆ xcom_set_ssl_fips_mode()

int Network_provider_manager::xcom_set_ssl_fips_mode ( int  mode)
overridevirtual

Set the operation fips mode which might be the following:

. SSL_FIPS_MODE_OFF (0): This will set openssl fips mode value to 0

. SSL_FIPS_MODE_ON (1): This will set openssl fips mode value to 1

. SSL_FIPS_MODE_STRICT (2): This will set openssl fips mode value to 2

If a different value is provide, INVALID_SSL_FIPS_MODE (-1) is returned.

Implements Network_provider_management_interface.

◆ xcom_set_ssl_mode()

int Network_provider_manager::xcom_set_ssl_mode ( int  mode)
overridevirtual

Set the operation mode which might be the following:

. SSL_DISABLED (1): The SSL mode will be disabled and this is the default value.

. SSL_PREFERRED (2): The SSL mode will be always disabled if this value is provided and is only allowed to keep the solution compatibility with MySQL server.

. SSL_REQUIRED (4): The SSL mode will be enabled but the verifications described in the next modes are not performed.

. SSL_VERIFY_CA (4) - Verify the server TLS certificate against the configured Certificate Authority (CA) certificates. The connection attempt fails if no valid matching CA certificates are found.

. SSL_VERIFY_IDENTITY (5): Like VERIFY_CA, but additionally verify that the server certificate matches the host to which the connection is attempted.

If a different value is provide, INVALID_SSL_MODE (-1) is returned.

Implements Network_provider_management_interface.

Member Data Documentation

◆ m_active_provider_configuration

Network_configuration_parameters Network_provider_manager::m_active_provider_configuration
private

◆ m_active_provider_secure_connections_configuration

Network_configuration_parameters Network_provider_manager::m_active_provider_secure_connections_configuration
private

◆ m_incoming_connections_protocol

enum_transport_protocol Network_provider_manager::m_incoming_connections_protocol
private

◆ m_network_providers

std::unordered_map<enum_transport_protocol, std::shared_ptr<Network_provider>, std::hash<int> > Network_provider_manager::m_network_providers
private

◆ m_running_protocol

enum_transport_protocol Network_provider_manager::m_running_protocol
private

◆ m_ssl_data_context_cleaner

std::function<void()> Network_provider_manager::m_ssl_data_context_cleaner {nullptr}
private

◆ m_ssl_fips_mode

int Network_provider_manager::m_ssl_fips_mode
private

◆ m_ssl_mode

int Network_provider_manager::m_ssl_mode
private

◆ m_xcom_network_provider

std::shared_ptr<Xcom_network_provider> Network_provider_manager::m_xcom_network_provider
private

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