MySQL  8.0.18
Source Code Documentation
test_pfs_resource_group.cc File Reference

Test component for the Performance Schema Resource Group service. More...

#include <mysql/components/component_implementation.h>
#include <mysql/components/service_implementation.h>
#include <mysql/components/services/pfs_notification.h>
#include <mysql/components/services/pfs_resource_group.h>
#include <string.h>
#include <atomic>
#include <fstream>
#include <iostream>
#include <sstream>
#include <string>

Classes

struct  User_data
 
struct  Event_info
 

Enumerations

enum  event_type { SESSION_CONNECT, SESSION_DISCONNECT }
 

Functions

 REQUIRES_SERVICE_PLACEHOLDER (pfs_notification_v3)
 
 REQUIRES_SERVICE_PLACEHOLDER (pfs_resource_group_v3)
 
static std::string separator ("===========================")
 
void print_log (std::string msg)
 
void print_event (const Event_info &event, std::string &msg)
 
void session_event (const Event_info &event)
 Test the Resource Group service. More...
 
void session_connect_callback (const PSI_thread_attrs *thread_attrs)
 Callback for session connection. More...
 
void session_disconnect_callback (const PSI_thread_attrs *thread_attrs)
 Callback for session disconnect. More...
 
mysql_service_status_t test_pfs_resource_group_init ()
 Initialize the test component, open logfile, register callbacks. More...
 
mysql_service_status_t test_pfs_resource_group_deinit ()
 Unregister callbacks, close logfile. More...
 
 END_COMPONENT_PROVIDES ()
 
 REQUIRES_SERVICE (pfs_notification_v3)
 
 REQUIRES_SERVICE (pfs_resource_group_v3)
 
 END_COMPONENT_REQUIRES ()
 
 METADATA ("mysql.author", "Oracle Corporation")
 
 METADATA ("mysql.license", "GPL")
 
 METADATA ("test_pfs_resource_group", "1")
 
 END_COMPONENT_METADATA ()
 

Variables

static bool debug_mode = false
 
const char * event_name [] = {"SESSION_CONNECT", "SESSION_DISCONNECT"}
 
static int handle = 0
 
static std::ofstream log_outfile
 
mysql_component_t mysql_component_test_pfs_resource_group
 

Detailed Description

Test component for the Performance Schema Resource Group service.

Upon installation, this component registers callback functions for these session events: session_connect session_disconnect session_change_user

These events are triggered externally from an MTR script.

When a new session connects, the callback function invokes set_thread_resource_group() with test data that varies according to which of the predefined usernames is associated with the connection.

Results are logged to a logfile and to stderr.

See also
test_pfs_resource_group()

Enumeration Type Documentation

◆ event_type

enum event_type
Enumerator
SESSION_CONNECT 
SESSION_DISCONNECT 

Function Documentation

◆ END_COMPONENT_METADATA()

END_COMPONENT_METADATA ( )

◆ END_COMPONENT_PROVIDES()

END_COMPONENT_PROVIDES ( )

◆ END_COMPONENT_REQUIRES()

END_COMPONENT_REQUIRES ( )

◆ METADATA() [1/3]

METADATA ( "mysql.author"  ,
"Oracle Corporation"   
)

◆ METADATA() [2/3]

METADATA ( "mysql.license"  ,
"GPL"   
)

◆ METADATA() [3/3]

METADATA ( "test_pfs_resource_group"  ,
"1"   
)

◆ print_event()

void print_event ( const Event_info event,
std::string &  msg 
)

◆ print_log()

void print_log ( std::string  msg)

◆ REQUIRES_SERVICE() [1/2]

REQUIRES_SERVICE ( pfs_resource_group_v3  )

◆ REQUIRES_SERVICE() [2/2]

REQUIRES_SERVICE ( pfs_notification_v3  )

◆ REQUIRES_SERVICE_PLACEHOLDER() [1/2]

REQUIRES_SERVICE_PLACEHOLDER ( pfs_notification_v3  )

◆ REQUIRES_SERVICE_PLACEHOLDER() [2/2]

REQUIRES_SERVICE_PLACEHOLDER ( pfs_resource_group_v3  )

◆ separator()

static std::string separator ( )
static

◆ session_connect_callback()

void session_connect_callback ( const PSI_thread_attrs thread_attrs)

Callback for session connection.

◆ session_disconnect_callback()

void session_disconnect_callback ( const PSI_thread_attrs thread_attrs)

Callback for session disconnect.

◆ session_event()

void session_event ( const Event_info event)

Test the Resource Group service.

Log messages are written to the console and log file.

Returns
NULL for success

◆ test_pfs_resource_group_deinit()

mysql_service_status_t test_pfs_resource_group_deinit ( )

Unregister callbacks, close logfile.

Returns
0 for success

◆ test_pfs_resource_group_init()

mysql_service_status_t test_pfs_resource_group_init ( )

Initialize the test component, open logfile, register callbacks.

Launch a thread to process session event callbacks.

Returns
0 for success

Variable Documentation

◆ debug_mode

bool debug_mode = false
static

◆ event_name

const char* event_name[] = {"SESSION_CONNECT", "SESSION_DISCONNECT"}

◆ handle

int handle = 0
static

◆ log_outfile

std::ofstream log_outfile
static

◆ mysql_component_test_pfs_resource_group

mysql_component_t mysql_component_test_pfs_resource_group
Initial value:
= { "mysql:test_pfs_resource_group" , __test_pfs_resource_group_provides, __test_pfs_resource_group_requires, __test_pfs_resource_group_metadata,
mysql_service_status_t test_pfs_resource_group_init()
Initialize the test component, open logfile, register callbacks.
Definition: test_pfs_resource_group.cc:205
mysql_service_status_t test_pfs_resource_group_deinit()
Unregister callbacks, close logfile.
Definition: test_pfs_resource_group.cc:244