MySQL 9.1.0
Source Code Documentation
Applier_handler Class Reference

#include <applier_handler.h>

Inheritance diagram for Applier_handler:
[legend]

Public Member Functions

 Applier_handler ()
 
int handle_event (Pipeline_event *ev, Continuation *cont) override
 Handling of an event as defined in the handler implementation. More...
 
int handle_action (Pipeline_action *action) override
 Handling of an action as defined in the handler implementation. More...
 
int initialize () override
 Initialization as defined in the handler implementation. More...
 
int terminate () override
 Terminate the execution as defined in the handler implementation. More...
 
bool is_unique () override
 This method identifies the handler as being unique. More...
 
int get_role () override
 This method returns the handler role. More...
 
int handle_binary_log_event (Pipeline_event *pevent, Continuation *cont)
 This method handles binary log events by storing them so they can be used on next handler. More...
 
int handle_applier_event (Pipeline_event *pevent, Continuation *cont)
 This method handles applier context events by storing them so they can be used on next handler. More...
 
int initialize_repositories (bool reset_logs, ulong plugin_shutdown_timeout)
 Initializes the SQL thread when receiving a configuration package. More...
 
int start_applier_thread ()
 Starts the SQL thread when receiving a action package. More...
 
int stop_applier_thread ()
 Stops the SQL thread when receiving a action package. More...
 
bool is_applier_thread_waiting ()
 Checks if the applier, and its workers when parallel applier is enabled, has already consumed all relay log, that is, applier is waiting for transactions to be queued. More...
 
int wait_for_gtid_execution (double timeout)
 Checks if all the queued transactions were executed. More...
 
int wait_for_gtid_execution (std::string &retrieved_set, double timeout, bool update_THD_status=true)
 Checks if all the given transactions were executed. More...
 
int is_partial_transaction_on_relay_log ()
 Checks if the channel's relay log contains partial transaction. More...
 
- Public Member Functions inherited from Event_handler
 Event_handler ()
 
virtual ~Event_handler ()=default
 
void plug_next_handler (Event_handler *next_handler)
 Plug an handler to be the next in line for execution. More...
 
void append (Event_handler *last_handler)
 Append an handler to be the last in line for execution. More...
 
int terminate_pipeline ()
 Shutdown and delete all handlers in the pipeline. More...
 

Private Attributes

Replication_thread_api channel_interface
 

Additional Inherited Members

- Static Public Member Functions inherited from Event_handler
static void append_handler (Event_handler **pipeline, Event_handler *event_handler)
 Append an handler to a given pipeline. More...
 
static void get_handler_by_role (Event_handler *pipeline, int role, Event_handler **event_handler)
 Returns an handler that plays the given role. More...
 
- Protected Member Functions inherited from Event_handler
int next (Pipeline_event *event, Continuation *continuation)
 Pass the event to the next handler in line. More...
 
int next (Pipeline_action *action)
 Pass the action to the next handler in line. More...
 

Constructor & Destructor Documentation

◆ Applier_handler()

Applier_handler::Applier_handler ( )
default

Member Function Documentation

◆ get_role()

int Applier_handler::get_role ( )
overridevirtual

This method returns the handler role.

Handlers can have different roles according to the tasks they represent. Is based on this role that certain components can extract and interact with pipeline handlers. This means that if a role is given to a singleton handler, no one else can have that role.

Returns
the handler role

Implements Event_handler.

◆ handle_action()

int Applier_handler::handle_action ( Pipeline_action action)
overridevirtual

Handling of an action as defined in the handler implementation.

As the handler can be included in a pipeline, somewhere in the method, the handler.next(action) method shall be invoked to allow the passing of the action to the next handler.

Note
Actions should not be treated asynchronously and as so, Continuations are not used here. Errors are returned directly or passed by in the action if it includes support for such
Parameters
[in]actionthe pipeline event to be handled

Implements Event_handler.

◆ handle_applier_event()

int Applier_handler::handle_applier_event ( Pipeline_event pevent,
Continuation cont 
)

This method handles applier context events by storing them so they can be used on next handler.

Parameters
[in]peventthe event to be injected
[in]contthe object used to wait
Returns
the operation status
Return values
0OK
!=0Error

◆ handle_binary_log_event()

int Applier_handler::handle_binary_log_event ( Pipeline_event pevent,
Continuation cont 
)

This method handles binary log events by storing them so they can be used on next handler.

Parameters
[in]peventthe event to be injected
[in]contthe object used to wait
Returns
the operation status
Return values
0OK
!=0Error

◆ handle_event()

int Applier_handler::handle_event ( Pipeline_event event,
Continuation continuation 
)
overridevirtual

Handling of an event as defined in the handler implementation.

As the handler can be included in a pipeline, somewhere in the method, the handler.next(event,continuation) method shall be invoked to allow the passing of the event to the next handler.

Also, if an error occurs, the continuation object shall be used to propagate such error. This class can also be used to know/report when the transaction to whom the event belongs was discarded.

Parameters
[in]eventthe pipeline event to be handled
[in,out]continuationtermination notification object.

Implements Event_handler.

◆ initialize()

int Applier_handler::initialize ( )
overridevirtual

Initialization as defined in the handler implementation.

Note
It's up to the developer to decide its own initialization strategy, but the suggested approach is to initialize basic structures here and then depend on Action packets to configure and start existing handler routines.

Implements Event_handler.

◆ initialize_repositories()

int Applier_handler::initialize_repositories ( bool  reset_logs,
ulong  plugin_shutdown_timeout 
)

Initializes the SQL thread when receiving a configuration package.

Parameters
reset_logsif a reset was executed in the server
plugin_shutdown_timeoutthe plugin's timeout for component shutdown
Returns
the operation status
Return values
0OK
!=0Error

◆ is_applier_thread_waiting()

bool Applier_handler::is_applier_thread_waiting ( )

Checks if the applier, and its workers when parallel applier is enabled, has already consumed all relay log, that is, applier is waiting for transactions to be queued.

Returns
the applier status
Return values
truethe applier is waiting
falseotherwise

◆ is_partial_transaction_on_relay_log()

int Applier_handler::is_partial_transaction_on_relay_log ( )

Checks if the channel's relay log contains partial transaction.

Return values
trueIf relaylog contains partial transaction.
falseIf relaylog does not contain partial transaction.

◆ is_unique()

bool Applier_handler::is_unique ( )
overridevirtual

This method identifies the handler as being unique.

An handler that is defined as unique is an handler that cannot be used more than once in a pipeline. Such tasks as certification and event application can only be done once. Unique handlers are also the only that, by being one of a kind, can be extracted during the pipeline life allowing dynamic changes to them.

Returns
if the handler is the a unique handler
Return values
trueis a unique handler
falseis a repeatable handler

Implements Event_handler.

◆ start_applier_thread()

int Applier_handler::start_applier_thread ( )

Starts the SQL thread when receiving a action package.

Returns
the operation status
Return values
0OK
!=0Error

◆ stop_applier_thread()

int Applier_handler::stop_applier_thread ( )

Stops the SQL thread when receiving a action package.

Returns
the operation status
Return values
0OK
!=0Error

◆ terminate()

int Applier_handler::terminate ( )
overridevirtual

Terminate the execution as defined in the handler implementation.

Implements Event_handler.

◆ wait_for_gtid_execution() [1/2]

int Applier_handler::wait_for_gtid_execution ( double  timeout)

Checks if all the queued transactions were executed.

Parameters
timeoutthe time (seconds) after which the method returns if the above condition was not satisfied
Returns
the operation status
Return values
0All transactions were executed
-1A timeout occurred
-2An error occurred

◆ wait_for_gtid_execution() [2/2]

int Applier_handler::wait_for_gtid_execution ( std::string &  retrieved_set,
double  timeout,
bool  update_THD_status = true 
)

Checks if all the given transactions were executed.

Parameters
retrieved_setthe set in string format of transaction to wait for
timeoutthe time (seconds) after which the method returns if the above condition was not satisfied
update_THD_statusShall the method update the THD stage
Returns
the operation status
Return values
0All transactions were executed
-1A timeout occurred
-2An error occurred

Member Data Documentation

◆ channel_interface

Replication_thread_api Applier_handler::channel_interface
private

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