drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
drizzle_plugin::FilteredReplicator Class Reference
Inheritance diagram for drizzle_plugin::FilteredReplicator:
[legend]
Collaboration diagram for drizzle_plugin::FilteredReplicator:
[legend]

Public Member Functions

 FilteredReplicator (std::string name_arg, const std::string &sch_filter, const std::string &tab_filter, const std::string &sch_regex, const std::string &tab_regex)
 ~FilteredReplicator ()
drizzled::plugin::ReplicationReturnCode replicate (drizzled::plugin::TransactionApplier *in_applier, drizzled::Session &in_session, drizzled::message::Transaction &to_replicate)
void setSchemaFilter (const std::string &input)
const std::string & getSchemaFilter () const
void setTableFilter (const std::string &input)
const std::string & getTableFilter () const
void updateTableSysvar (const char **var_ptr)
void updateSchemaSysvar (const char **var_ptr)
Public Member Functions inherited from drizzled::plugin::TransactionReplicator
 TransactionReplicator (std::string name_arg)
virtual ReplicationReturnCode replicate (TransactionApplier *in_applier, Session &session, message::Transaction &to_replicate)=0
Public Member Functions inherited from drizzled::plugin::Plugin
 Plugin (const std::string &name, const std::string &type_name)
virtual void shutdownPlugin ()
virtual void prime ()
virtual void startup (drizzled::Session &)
void activate ()
void deactivate ()
bool isActive () const
const std::string & getName () const
void setModule (module::Module *module)
const std::string & getTypeName () const
virtual bool removeLast () const
const std::string & getModuleName () const

Private Member Functions

void populateFilter (std::string input, std::vector< std::string > &filter)
bool isSchemaFiltered (const std::string &schema_name)
bool isTableFiltered (const std::string &table_name)
void parseStatementTableMetadata (const drizzled::message::Statement &in_statement, std::string &in_schema_name, std::string &in_table_name) const
void parseQuery (const std::string &sql, std::string &schema_name, std::string &table_name)

Private Attributes

std::vector< std::string > schemas_to_filter
std::vector< std::string > tables_to_filter
std::string _sch_filter
std::string _tab_filter
const std::string _sch_regex
const std::string _tab_regex
pthread_mutex_t sch_vector_lock
pthread_mutex_t tab_vector_lock
pthread_mutex_t sysvar_sch_lock
pthread_mutex_t sysvar_tab_lock
pcre2_code * sch_re
pcre2_code * tab_re

Additional Inherited Members

Public Types inherited from drizzled::plugin::Plugin
typedef std::pair< const std::string, const std::string > map_key
typedef std::unique_ptr< plugin::Plugin, deleter_fn > owned_ptr
typedef std::map< const map_key, owned_ptr > map
typedef std::vector< Plugin * > vector
Static Public Member Functions inherited from drizzled::plugin::TransactionReplicator
static bool addPlugin (TransactionReplicator &replicator)
static void removePlugin (TransactionReplicator &replicator)

Detailed Description

Definition at line 43 of file filtered_replicator.h.

Constructor & Destructor Documentation

◆ FilteredReplicator()

drizzle_plugin::FilteredReplicator::FilteredReplicator ( std::string name_arg,
const std::string & sch_filter,
const std::string & tab_filter,
const std::string & sch_regex,
const std::string & tab_regex )

Definition at line 61 of file filtered_replicator.cc.

◆ ~FilteredReplicator()

drizzle_plugin::FilteredReplicator::~FilteredReplicator ( )

Destructor

Definition at line 132 of file filtered_replicator.cc.

Member Function Documentation

◆ getSchemaFilter()

const std::string & drizzle_plugin::FilteredReplicator::getSchemaFilter ( ) const
inline
Returns
string of comma-separated list of schemas to filter

Definition at line 90 of file filtered_replicator.h.

◆ getTableFilter()

const std::string & drizzle_plugin::FilteredReplicator::getTableFilter ( ) const
inline
Returns
string of comma-separated list of tables to filter

Definition at line 107 of file filtered_replicator.h.

◆ isSchemaFiltered()

bool drizzle_plugin::FilteredReplicator::isSchemaFiltered ( const std::string & schema_name)
private

Search the vector of schemas to filter to determine whether the given schema should be filtered or not. The parameter is obtained from the Transaction message passed to the replicator.

Parameters
[in]schema_namename of schema to search for
Returns
true if the given schema should be filtered; false otherwise

Definition at line 319 of file filtered_replicator.cc.

◆ isTableFiltered()

bool drizzle_plugin::FilteredReplicator::isTableFiltered ( const std::string & table_name)
private

Search the vector of tables to filter to determine whether the given table should be filtered or not. The parameter is obtained from the Transaction message passed to the replicator.

Parameters
[in]table_namename of table to search for
Returns
true if the given table should be filtered; false otherwise

Definition at line 351 of file filtered_replicator.cc.

◆ parseQuery()

void drizzle_plugin::FilteredReplicator::parseQuery ( const std::string & sql,
std::string & schema_name,
std::string & table_name )
private

If the command message consists of raw SQL, this method parses a string representation of the raw SQL and extracts the schema name and table name from that raw SQL.

Parameters
[in]sqlstd::string representation of the raw SQL
[out]schema_nameparameter to be populated with the schema name from the parsed SQL
[out]table_nameparameter to be populated with the table name from the parsed SQL

Definition at line 383 of file filtered_replicator.cc.

◆ parseStatementTableMetadata()

void drizzle_plugin::FilteredReplicator::parseStatementTableMetadata ( const drizzled::message::Statement & in_statement,
std::string & in_schema_name,
std::string & in_table_name ) const
private

Given a supplied Statement message, parse out the table and schema name from the various metadata and header pieces for the different Statement types.

Parameters
[in]Statementto parse
[out]Schemaname to fill
[out]Tablename to fill

Definition at line 150 of file filtered_replicator.cc.

◆ populateFilter()

void drizzle_plugin::FilteredReplicator::populateFilter ( std::string input,
std::vector< std::string > & filter )
private

Given a comma-separated string, parse that string to obtain each entry and add each entry to the supplied vector.

Parameters
[in]inputa comma-separated string of entries
[out]filtera std::vector to be populated with the entries from the input string

Definition at line 300 of file filtered_replicator.cc.

◆ replicate()

plugin::ReplicationReturnCode drizzle_plugin::FilteredReplicator::replicate ( drizzled::plugin::TransactionApplier * in_applier,
drizzled::Session & in_session,
drizzled::message::Transaction & to_replicate )

Replicate a Transaction message to an Applier.

Note

It is important to note that memory allocation for the supplied pointer is not guaranteed after the completion of this function – meaning the caller can dispose of the supplied message. Therefore, replicators and appliers implementing an asynchronous replication system must copy the supplied message to their own controlled memory storage area.

Parameters
Applierto replicate to
Sessiondescriptor
Transactionmessage to be replicated

Definition at line 225 of file filtered_replicator.cc.

◆ setSchemaFilter()

void drizzle_plugin::FilteredReplicator::setSchemaFilter ( const std::string & input)

Populate the vector of schemas to filter from the comma-separated list of schemas given. This method clears the vector first.

Parameters
[in]inputcomma-separated filter to use

Definition at line 481 of file filtered_replicator.cc.

◆ setTableFilter()

void drizzle_plugin::FilteredReplicator::setTableFilter ( const std::string & input)

Populate the vector of tables to filter from the comma-separated list of tables given. This method clears the vector first.

Parameters
[in]inputcomma-separated filter to use

Definition at line 492 of file filtered_replicator.cc.

◆ updateSchemaSysvar()

void drizzle_plugin::FilteredReplicator::updateSchemaSysvar ( const char ** var_ptr)
inline

Update the given system variable and release the mutex associated with this system variable.

Parameters
[out]var_ptrthe system variable to update

Definition at line 130 of file filtered_replicator.h.

◆ updateTableSysvar()

void drizzle_plugin::FilteredReplicator::updateTableSysvar ( const char ** var_ptr)
inline

Update the given system variable and release the mutex associated with this system variable.

Parameters
[out]var_ptrthe system variable to update

Definition at line 118 of file filtered_replicator.h.

Member Data Documentation

◆ _sch_filter

std::string drizzle_plugin::FilteredReplicator::_sch_filter
private

Definition at line 207 of file filtered_replicator.h.

◆ _sch_regex

const std::string drizzle_plugin::FilteredReplicator::_sch_regex
private

Definition at line 210 of file filtered_replicator.h.

◆ _tab_filter

std::string drizzle_plugin::FilteredReplicator::_tab_filter
private

Definition at line 208 of file filtered_replicator.h.

◆ _tab_regex

const std::string drizzle_plugin::FilteredReplicator::_tab_regex
private

Definition at line 211 of file filtered_replicator.h.

◆ sch_re

pcre2_code* drizzle_plugin::FilteredReplicator::sch_re
private

Definition at line 231 of file filtered_replicator.h.

◆ sch_vector_lock

pthread_mutex_t drizzle_plugin::FilteredReplicator::sch_vector_lock
private

Definition at line 220 of file filtered_replicator.h.

◆ schemas_to_filter

std::vector<std::string> drizzle_plugin::FilteredReplicator::schemas_to_filter
private

Definition at line 200 of file filtered_replicator.h.

◆ sysvar_sch_lock

pthread_mutex_t drizzle_plugin::FilteredReplicator::sysvar_sch_lock
private

Definition at line 228 of file filtered_replicator.h.

◆ sysvar_tab_lock

pthread_mutex_t drizzle_plugin::FilteredReplicator::sysvar_tab_lock
private

Definition at line 229 of file filtered_replicator.h.

◆ tab_re

pcre2_code* drizzle_plugin::FilteredReplicator::tab_re
private

Definition at line 232 of file filtered_replicator.h.

◆ tab_vector_lock

pthread_mutex_t drizzle_plugin::FilteredReplicator::tab_vector_lock
private

Definition at line 221 of file filtered_replicator.h.

◆ tables_to_filter

std::vector<std::string> drizzle_plugin::FilteredReplicator::tables_to_filter
private

Definition at line 201 of file filtered_replicator.h.


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