~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/default_replicator/default_replicator.cc

  • Committer: Eric Day
  • Date: 2009-10-31 21:53:33 UTC
  • mfrom: (1200 staging)
  • mto: This revision was merged to the branch mainline in revision 1202.
  • Revision ID: eday@oddments.org-20091031215333-j94bjoanwmi68p6f
Merged trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 *
24
24
 * Defines the implementation of the default replicator.
25
25
 *
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
28
28
 *
29
29
 * @details
30
30
 *
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.
33
 
 *
34
 
 * @todo
35
 
 *
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...
39
33
 */
40
34
 
 
35
#include <drizzled/server_includes.h>
41
36
#include "default_replicator.h"
42
37
 
43
38
#include <drizzled/gettext.h>
44
 
#include <drizzled/message/replication.pb.h>
 
39
#include <drizzled/plugin/transaction_applier.h>
45
40
 
46
41
#include <vector>
47
42
#include <string>
51
46
 
52
47
static bool sysvar_default_replicator_enable= false;
53
48
 
54
 
bool DefaultReplicator::isActive() const
 
49
bool DefaultReplicator::isEnabled() const
55
50
{
56
51
  return sysvar_default_replicator_enable;
57
52
}
58
53
 
59
 
void DefaultReplicator::activate()
 
54
void DefaultReplicator::enable()
60
55
{
61
56
  sysvar_default_replicator_enable= true;
62
57
}
63
58
 
64
 
void DefaultReplicator::deactivate()
 
59
void DefaultReplicator::disable()
65
60
{
66
61
  sysvar_default_replicator_enable= false;
67
62
}
68
63
 
69
 
void DefaultReplicator::replicate(plugin::CommandApplier *in_applier, message::Command &to_replicate)
 
64
void DefaultReplicator::replicate(plugin::TransactionApplier *in_applier, message::Transaction &to_replicate)
70
65
{
71
66
  /* 
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...
74
 
   *
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...
80
69
   */
81
 
  in_applier->apply(const_cast<const message::Command&>(to_replicate));
 
70
  in_applier->apply(to_replicate);
82
71
}
83
72
 
84
73
static DefaultReplicator *default_replicator= NULL; /* The singleton replicator */