MySQL 9.1.0
Source Code Documentation
|
This is a singleton class that provides various connection management related functionalities, most importantly dispatching new connections to the currently active Connection_handler. More...
#include <connection_handler_manager.h>
Public Types | |
enum | scheduler_types { SCHEDULER_ONE_THREAD_PER_CONNECTION = 0 , SCHEDULER_NO_THREADS , SCHEDULER_TYPES_COUNT } |
thread_handling enumeration. More... | |
Public Member Functions | |
bool | valid_connection_count () |
Check if the current number of connections are below or equal the value given by the max_connections server system variable. More... | |
bool | check_and_incr_conn_count (bool ignore_max_connection_count, bool internal_session) |
Increment connection count if max_connections is not exceeded. More... | |
void | inc_aborted_connects () |
ulong | aborted_connects () const |
ulong | connection_errors_max_connection () const |
void | load_connection_handler (Connection_handler *conn_handler) |
Dynamically load a connection handler implemented as a plugin. More... | |
bool | unload_connection_handler () |
Unload the connection handler previously loaded by load_connection_handler(). More... | |
void | process_new_connection (Channel_info *channel_info) |
Process a new incoming connection. More... | |
Static Public Member Functions | |
static Connection_handler_manager * | get_instance () |
Singleton method to return an instance of this class. More... | |
static bool | init () |
Initialize the connection handler manager. More... | |
static void | destroy_instance () |
Destroy the singleton instance. More... | |
static void | reset_max_used_connections () |
Reset the max_used_connections counter to the number of current connections. More... | |
static void | dec_connection_count () |
Decrease the number of current connections. More... | |
static ulong | get_incoming_connects () |
static void | wait_till_no_connection () |
Waits until all connections are done with their job. More... | |
static uint | get_connection_count () |
Return number of connections in thread-safe way. More... | |
Static Public Attributes | |
static uint | connection_count = 0 |
static ulong | max_used_connections = 0 |
static ulong | max_used_connections_time = 0 |
static std::atomic_ulong | incoming_connection_count = 0 |
static ulong | thread_handling |
static THD_event_functions * | event_functions = nullptr |
static THD_event_functions * | saved_event_functions |
static uint | max_threads = 0 |
Maximum number of threads that can be created by the current connection handler. More... | |
Private Member Functions | |
Connection_handler_manager (Connection_handler *connection_handler) | |
Constructor to instantiate an instance of this class. More... | |
~Connection_handler_manager () | |
Connection_handler_manager (const Connection_handler_manager &) | |
Connection_handler_manager & | operator= (const Connection_handler_manager &) |
Private Attributes | |
Connection_handler * | m_connection_handler |
Connection_handler * | m_saved_connection_handler |
ulong | m_saved_thread_handling |
ulong | m_aborted_connects |
ulong | m_connection_errors_max_connection |
Static Private Attributes | |
static Connection_handler_manager * | m_instance = nullptr |
static mysql_mutex_t | LOCK_connection_count |
static mysql_cond_t | COND_connection_count |
This is a singleton class that provides various connection management related functionalities, most importantly dispatching new connections to the currently active Connection_handler.
thread_handling enumeration.
The default of –thread-handling is the first one in the thread_handling_names array, this array has to be consistent with the order in this array, so to change default one has to change the first entry in this enum and the first entry in the thread_handling_names array.
Enumerator | |
---|---|
SCHEDULER_ONE_THREAD_PER_CONNECTION | |
SCHEDULER_NO_THREADS | |
SCHEDULER_TYPES_COUNT |
|
inlineprivate |
Constructor to instantiate an instance of this class.
|
inlineprivate |
|
private |
|
inline |
bool Connection_handler_manager::check_and_incr_conn_count | ( | bool | ignore_max_connection_count, |
bool | internal_session | ||
) |
Increment connection count if max_connections is not exceeded.
ignore_max_connection_count | true if checking for a limit specified by the max-connections server option should be skipped. |
internal_session | true if this is an internal session created by the session service. If this is the case, we will not count this as an incoming connection. |
true | max_connections NOT exceeded false max_connections reached |
|
inline |
|
inlinestatic |
Decrease the number of current connections.
|
static |
Destroy the singleton instance.
|
inlinestatic |
Return number of connections in thread-safe way.
|
inlinestatic |
|
inlinestatic |
Singleton method to return an instance of this class.
|
inline |
|
static |
Initialize the connection handler manager.
Must be called before get_instance() can be used.
void Connection_handler_manager::load_connection_handler | ( | Connection_handler * | conn_handler | ) |
Dynamically load a connection handler implemented as a plugin.
The current connection handler will be saved so that it can later be restored by unload_connection_handler().
|
private |
void Connection_handler_manager::process_new_connection | ( | Channel_info * | channel_info | ) |
Process a new incoming connection.
channel_info | Pointer to Channel_info object containing connection channel information. |
|
static |
Reset the max_used_connections counter to the number of current connections.
bool Connection_handler_manager::unload_connection_handler | ( | ) |
Unload the connection handler previously loaded by load_connection_handler().
The previous connection handler will be restored.
bool Connection_handler_manager::valid_connection_count | ( | ) |
Check if the current number of connections are below or equal the value given by the max_connections server system variable.
|
static |
Waits until all connections are done with their job.
In other words, wat till connection_count to become zero.
|
staticprivate |
|
static |
|
static |
|
static |
|
staticprivate |
|
private |
|
private |
|
private |
|
staticprivate |
|
private |
|
private |
|
static |
Maximum number of threads that can be created by the current connection handler.
Must be static as it is used by the signal handler.
|
static |
|
static |
|
static |
|
static |