24
24
* Defines the implementation of the default replicator.
26
* @see drizzled/plugin/command_replicator.h
27
* @see drizzled/plugin/command_applier.h
26
* @see drizzled/plugin/transaction_replicator.h
27
* @see drizzled/plugin/transaction_applier.h
31
31
* This is a very simple implementation. All we do is pass along the
32
32
* event to the supplier. This is meant as a skeleton replicator only.
36
* Want a neat project? Take this skeleton replicator and make a
37
* simple filtered replicator which allows the user to filter out
38
* events based on a schema or table name...
35
#include <drizzled/server_includes.h>
41
36
#include "default_replicator.h"
43
38
#include <drizzled/gettext.h>
44
#include <drizzled/message/replication.pb.h>
39
#include <drizzled/plugin/transaction_applier.h>
52
47
static bool sysvar_default_replicator_enable= false;
54
bool DefaultReplicator::isActive() const
49
bool DefaultReplicator::isEnabled() const
56
51
return sysvar_default_replicator_enable;
59
void DefaultReplicator::activate()
54
void DefaultReplicator::enable()
61
56
sysvar_default_replicator_enable= true;
64
void DefaultReplicator::deactivate()
59
void DefaultReplicator::disable()
66
61
sysvar_default_replicator_enable= false;
69
void DefaultReplicator::replicate(plugin::CommandApplier *in_applier, message::Command &to_replicate)
64
void DefaultReplicator::replicate(plugin::TransactionApplier *in_applier, message::Transaction &to_replicate)
72
67
* We do absolutely nothing but call the applier's apply() method, passing
73
* along the supplied Command. Yep, told you it was simple...
75
* Perfectly fine to use const_cast<> below. All that does is allow the replicator
76
* to conform to the CommandApplier::apply() API call which dictates that the applier
77
* shall never modify the supplied Command message argument. Since the replicator
78
* itself *can* modify the supplied Command message, we use const_cast<> here to
79
* set the message to a readonly state that the compiler will like.
68
* along the supplied Transaction. Yep, told you it was simple...
81
in_applier->apply(const_cast<const message::Command&>(to_replicate));
70
in_applier->apply(to_replicate);
84
73
static DefaultReplicator *default_replicator= NULL; /* The singleton replicator */