38#include <drizzled/replication_services.h>
39#include <drizzled/plugin/transaction_replicator.h>
40#include <drizzled/plugin/transaction_applier.h>
41#include <drizzled/message/transaction.pb.h>
42#include <drizzled/gettext.h>
43#include <drizzled/session.h>
44#include <drizzled/error.h>
45#include <drizzled/errmsg_print.h>
55typedef std::vector<plugin::TransactionReplicator*> Replicators;
56typedef std::vector<std::pair<std::string, plugin::TransactionApplier*> > Appliers;
81 boost::to_lower(name);
82 if (name.find(
"replicator") == string::npos)
83 name.append(
"replicator");
85 size_t found_underscore= name.find(
'_');
86 while (found_underscore != string::npos)
88 name.erase(found_underscore, 1);
89 found_underscore= name.find(
'_');
109 errmsg_printf(error::ERROR,
110 N_(
"You registered a TransactionApplier plugin but no "
111 "TransactionReplicator plugins were registered.\n"));
115 for (Appliers::reference appl_iter :
appliers)
118 string requested_replicator_name= appl_iter.first;
122 Replicators::iterator repl_iter;
125 string replicator_name= (*repl_iter)->getName();
128 if (requested_replicator_name.compare(replicator_name) == 0)
136 errmsg_printf(error::ERROR,
137 N_(
"You registered a TransactionApplier plugin but no "
138 "TransactionReplicator plugins were registered that match the "
139 "requested replicator name of '%s'.\n"
140 "We have deactivated the TransactionApplier '%s'.\n"),
141 requested_replicator_name.c_str(),
142 applier->getName().c_str());
143 applier->deactivate();
167 appliers.push_back(make_pair(requested_replicator_name, in_applier));
180 message::Transaction &to_push)
182 plugin::ReplicationReturnCode result= plugin::SUCCESS;
189 result= cur_repl->
replicate(cur_appl, in_session, to_push);
191 if (result == plugin::SUCCESS)
static bool evaluateRegisteredPlugins()
static ReplicationStreams & getReplicationStreams()
static plugin::ReplicationReturnCode pushTransactionMessage(Session &in_session, message::Transaction &to_push)
static void attachApplier(plugin::TransactionApplier *in_applier, const std::string &requested_replicator)
static void attachReplicator(plugin::TransactionReplicator *in_replicator)
static void detachApplier(plugin::TransactionApplier *in_applier)
static void detachReplicator(plugin::TransactionReplicator *in_replicator)
virtual ReplicationReturnCode replicate(TransactionApplier *in_applier, Session &session, message::Transaction &to_replicate)=0
TODO: Rename this file - func.h is stupid.
static atomic< uint64_t > last_applied_timestamp
static Replicators replicators
static ReplicationServices::ReplicationStreams replication_streams
static void normalizeReplicatorName(string &name)