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>
55 typedef std::vector<plugin::TransactionReplicator*> Replicators;
56 typedef 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(
'_');
94 bool ReplicationServices::evaluateRegisteredPlugins()
109 errmsg_printf(error::ERROR,
110 N_(
"You registered a TransactionApplier plugin but no "
111 "TransactionReplicator plugins were registered.\n"));
115 BOOST_FOREACH(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));
174 bool ReplicationServices::isActive()
179 plugin::ReplicationReturnCode ReplicationServices::pushTransactionMessage(
Session &in_session,
182 plugin::ReplicationReturnCode result= plugin::SUCCESS;
189 result= cur_repl->
replicate(cur_appl, in_session, to_push);
191 if (result == plugin::SUCCESS)
207 ReplicationServices::ReplicationStreams &ReplicationServices::getReplicationStreams()