Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00030 #pragma once
00031
00032 #include <drizzled/atomics.h>
00033 #include <drizzled/plugin/transaction_replicator.h>
00034
00035 #include PCRE_HEADER
00036
00037 #include <vector>
00038 #include <string>
00039
00040 namespace drizzle_plugin
00041 {
00042
00043 class FilteredReplicator :
00044 public drizzled::plugin::TransactionReplicator
00045 {
00046 public:
00047 FilteredReplicator(std::string name_arg,
00048 const std::string &sch_filter,
00049 const std::string &tab_filter,
00050 const std::string &sch_regex,
00051 const std::string &tab_regex);
00052
00054 ~FilteredReplicator();
00055
00073 drizzled::plugin::ReplicationReturnCode
00074 replicate(drizzled::plugin::TransactionApplier *in_applier,
00075 drizzled::Session &in_session,
00076 drizzled::message::Transaction &to_replicate);
00077
00085 void setSchemaFilter(const std::string &input);
00086
00090 const std::string &getSchemaFilter() const
00091 {
00092 return _sch_filter;
00093 }
00094
00102 void setTableFilter(const std::string &input);
00103
00107 const std::string &getTableFilter() const
00108 {
00109 return _tab_filter;
00110 }
00111
00118 void updateTableSysvar(const char **var_ptr)
00119 {
00120 *var_ptr= _tab_filter.c_str();
00121 pthread_mutex_unlock(&sysvar_tab_lock);
00122 }
00123
00130 void updateSchemaSysvar(const char **var_ptr)
00131 {
00132 *var_ptr= _sch_filter.c_str();
00133 pthread_mutex_unlock(&sysvar_sch_lock);
00134 }
00135
00136 private:
00137
00146 void populateFilter(std::string input,
00147 std::vector<std::string> &filter);
00148
00157 bool isSchemaFiltered(const std::string &schema_name);
00158
00167 bool isTableFiltered(const std::string &table_name);
00168
00178 void parseStatementTableMetadata(const drizzled::message::Statement &in_statement,
00179 std::string &in_schema_name,
00180 std::string &in_table_name) const;
00181
00193 void parseQuery(const std::string &sql,
00194 std::string &schema_name,
00195 std::string &table_name);
00196
00197
00198
00199
00200 std::vector<std::string> schemas_to_filter;
00201 std::vector<std::string> tables_to_filter;
00202
00203
00204
00205
00206
00207 std::string _sch_filter;
00208 std::string _tab_filter;
00209
00210 const std::string _sch_regex;
00211 const std::string _tab_regex;
00212
00213
00214
00215
00216
00217
00218
00219
00220 pthread_mutex_t sch_vector_lock;
00221 pthread_mutex_t tab_vector_lock;
00222
00223
00224
00225
00226
00227
00228 pthread_mutex_t sysvar_sch_lock;
00229 pthread_mutex_t sysvar_tab_lock;
00230
00231 pcre *sch_re;
00232 pcre *tab_re;
00233 };
00234
00235 }
00236