~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/replicator.h

  • Committer: Padraig O'Sullivan
  • Date: 2009-09-13 01:03:01 UTC
  • mto: (1126.9.2 captain-20090915-01)
  • mto: This revision was merged to the branch mainline in revision 1133.
  • Revision ID: osullivan.padraig@gmail.com-20090913010301-tcvvezipx1124acy
Added calls to the dtrace delete begin/end probes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
22
22
 */
23
23
 
24
 
#ifndef DRIZZLED_PLUGIN_TRANSACTION_REPLICATOR_H
25
 
#define DRIZZLED_PLUGIN_TRANSACTION_REPLICATOR_H
26
 
 
27
 
#include "drizzled/atomics.h"
28
 
#include "drizzled/plugin/plugin.h"
 
24
#ifndef DRIZZLED_PLUGIN_REPLICATOR_H
 
25
#define DRIZZLED_PLUGIN_REPLICATOR_H
29
26
 
30
27
/**
31
 
 * @file Defines the API for a TransactionReplicator.  
 
28
 * @file Defines the API for a Replicator.  
32
29
 *
33
30
 * All a replicator does is replicate/reproduce
34
 
 * events, optionally transforming them before sending them off to a TransactionApplier.
 
31
 * events, optionally transforming them before sending them off to an applier.
35
32
 *
36
33
 * An applier is responsible for applying events, not a replicator...
37
34
 */
38
35
 
39
 
 
 
36
/* some forward declarations needed */
40
37
namespace drizzled
41
38
{
42
 
namespace message
43
 
44
 
  class Transaction;
45
 
  class Statement;
 
39
  namespace message
 
40
  {
 
41
    class Command;
 
42
  }
 
43
  class Applier;
46
44
}
47
45
 
 
46
namespace drizzled
 
47
{
48
48
namespace plugin
49
49
{
50
50
 
51
 
class TransactionApplier;
52
 
 
53
51
/**
54
 
 * Class which replicates Transaction messages
 
52
 * Class which replicates Command messages
55
53
 */
56
 
class TransactionReplicator : public Plugin
 
54
class Replicator
57
55
{
58
 
  TransactionReplicator();
59
 
  TransactionReplicator(const TransactionReplicator &);
60
 
  TransactionReplicator& operator=(const TransactionReplicator &);
61
 
  atomic<bool> is_enabled;
62
56
public:
63
 
  explicit TransactionReplicator(std::string name_arg)
64
 
    : Plugin(name_arg, "TransactionReplicator")
65
 
  {
66
 
    is_enabled= true;
67
 
  }
68
 
  virtual ~TransactionReplicator() {}
69
 
 
 
57
  Replicator() {}
 
58
  virtual ~Replicator() {}
70
59
  /**
71
 
   * Replicate a Transaction message to a TransactionApplier.
 
60
   * Replicate a Command message to an Applier.
72
61
   *
73
62
   * @note
74
63
   *
80
69
   * the supplied message to their own controlled memory storage
81
70
   * area.
82
71
   *
83
 
   * @param Pointer to the applier of the command message
84
 
   * @param Transaction message to be replicated
85
 
   */
86
 
  virtual void replicate(TransactionApplier *in_applier, 
87
 
                         message::Transaction &to_replicate)= 0;
88
 
  static bool addPlugin(TransactionReplicator *replicator);
89
 
  static void removePlugin(TransactionReplicator *replicator);
90
 
 
91
 
  virtual bool isEnabled() const
92
 
  {
93
 
    return is_enabled;
94
 
  }
95
 
 
96
 
  virtual void enable()
97
 
  {
98
 
    is_enabled= true;
99
 
  }
100
 
 
101
 
  virtual void disable()
102
 
  {
103
 
    is_enabled= false;
104
 
  }
 
72
   * @param Command message to be replicated
 
73
   */
 
74
  virtual void replicate(Applier *in_applier, drizzled::message::Command *to_replicate)= 0;
 
75
  /** 
 
76
   * A replicator plugin should override this with its
 
77
   * internal method for determining if it is active or not.
 
78
   */
 
79
  virtual bool isActive() {return false;}
105
80
};
106
81
 
107
 
} /* namespace plugin */
108
 
} /* namespace drizzled */
 
82
} /* end namespace drizzled::plugin */
 
83
} /* end namespace drizzled */
109
84
 
110
 
#endif /* DRIZZLED_PLUGIN_TRANSACTION_REPLICATOR_H */
 
85
#endif /* DRIZZLED_PLUGIN_REPLICATOR_H */