~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/replication_services.h

  • Committer: Jay Pipes
  • Date: 2010-04-08 16:27:25 UTC
  • mfrom: (1405.6.10 replication-pairs)
  • mto: This revision was merged to the branch mainline in revision 1457.
  • Revision ID: jpipes@serialcoder-20100408162725-sugbgn38oxjqclq2
Merge trunk and replication-pairs with conflict resolution

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
#include "drizzled/atomics.h"
29
29
#include "drizzled/plugin/replication.h"
30
30
 
 
31
#include <string>
31
32
#include <vector>
 
33
#include <utility>
32
34
 
33
35
namespace drizzled
34
36
{
67
69
    TRANSACTION= 1, /* A GPB Transaction Message */
68
70
    BLOB= 2 /* A BLOB value */
69
71
  };
70
 
  typedef std::vector<plugin::TransactionReplicator *> Replicators;
71
 
  typedef std::vector<plugin::TransactionApplier *> Appliers;
72
 
private:
73
 
  /** 
74
 
   * Atomic boolean set to true if any *active* replicators
75
 
   * or appliers are actually registered.
76
 
   */
77
 
  atomic<bool> is_active;
78
 
  /**
79
 
   * The timestamp of the last time a Transaction message was successfully
80
 
   * applied (sent to an Applier)
81
 
   */
82
 
  atomic<uint64_t> last_applied_timestamp;
83
 
  /** Our collection of replicator plugins */
84
 
  Replicators replicators;
85
 
  /** Our collection of applier plugins */
86
 
  Appliers appliers;
87
 
  /**
88
 
   * Helper method which is called after any change in the
89
 
   * registered appliers or replicators to evaluate whether
90
 
   * any remaining plugins are actually active.
91
 
   * 
92
 
   * This method properly sets the is_active member variable.
93
 
   */
94
 
  void evaluateActivePlugins();
95
 
public:
 
72
  typedef std::pair<plugin::TransactionReplicator *, plugin::TransactionApplier *> ReplicationPair;
 
73
  typedef std::vector<ReplicationPair> ReplicationStreams;
 
74
  /**
 
75
   * Method which is called after plugins have been loaded but
 
76
   * before the first client connects.  It determines if the registration
 
77
   * of applier and replicator plugins is proper and pairs
 
78
   * the applier and requested replicator plugins into the replication
 
79
   * streams.
 
80
   *
 
81
   * @todo
 
82
   *
 
83
   * This is only necessary because we don't yet have plugin dependency
 
84
   * tracking...
 
85
   */
 
86
  bool evaluateRegisteredPlugins();
96
87
  /** 
97
88
   * Helper method which pushes a constructed message out to the registered
98
89
   * replicator and applier plugins.
123
114
   * a replicator and an applier that are *active*?
124
115
   */
125
116
  bool isActive() const;
 
117
 
 
118
  /**
 
119
   * Returns the list of replication streams
 
120
   */
 
121
  ReplicationStreams &getReplicationStreams();
 
122
 
126
123
  /**
127
124
   * Attaches a replicator to our internal collection of
128
125
   * replicators.
130
127
   * @param Pointer to a replicator to attach/register
131
128
   */
132
129
  void attachReplicator(plugin::TransactionReplicator *in_replicator);
 
130
  
133
131
  /**
134
132
   * Detaches/unregisters a replicator with our internal
135
133
   * collection of replicators.
137
135
   * @param Pointer to the replicator to detach
138
136
   */
139
137
  void detachReplicator(plugin::TransactionReplicator *in_replicator);
 
138
  
140
139
  /**
141
140
   * Attaches a applier to our internal collection of
142
141
   * appliers.
143
142
   *
144
143
   * @param Pointer to a applier to attach/register
 
144
   * @param The name of the replicator to pair with
145
145
   */
146
 
  void attachApplier(plugin::TransactionApplier *in_applier);
 
146
  void attachApplier(plugin::TransactionApplier *in_applier, const std::string &requested_replicator);
 
147
  
147
148
  /**
148
149
   * Detaches/unregisters a applier with our internal
149
150
   * collection of appliers.
151
152
   * @param Pointer to the applier to detach
152
153
   */
153
154
  void detachApplier(plugin::TransactionApplier *in_applier);
154
 
  /** Returns the timestamp of the last Transaction which was sent to an
 
155
 
 
156
  /** 
 
157
   * Returns the timestamp of the last Transaction which was sent to an
155
158
   * applier.
156
159
   */
157
160
  uint64_t getLastAppliedTimestamp() const;
 
161
private:
 
162
  typedef std::vector<plugin::TransactionReplicator *> Replicators;
 
163
  typedef std::vector<std::pair<std::string, plugin::TransactionApplier *> > Appliers;
 
164
  /** 
 
165
   * Atomic boolean set to true if any *active* replicators
 
166
   * or appliers are actually registered.
 
167
   */
 
168
  bool is_active;
 
169
  /**
 
170
   * The timestamp of the last time a Transaction message was successfully
 
171
   * applied (sent to an Applier)
 
172
   */
 
173
  atomic<uint64_t> last_applied_timestamp;
 
174
  /** Our collection of registered replicator plugins */
 
175
  Replicators replicators;
 
176
  /** Our collection of registered applier plugins and their requested replicator plugin names */
 
177
  Appliers appliers;
 
178
  /** Our replication streams */
 
179
  ReplicationStreams replication_streams;
 
180
  /**
 
181
   * Strips underscores and lowercases supplied replicator name
 
182
   * or requested name, and appends the suffix "replicator" if missing...
 
183
   */
 
184
  void normalizeReplicatorName(std::string &name);
158
185
};
159
186
 
160
187
} /* namespace drizzled */