1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008-2009 Sun Microsystems
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; version 2 of the License.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
#ifndef DRIZZLED_REPLICATOR_H
21
#define DRIZZLED_REPLICATOR_H
26
/* some forward declarations needed */
43
void add_replicator(drizzled::plugin::Replicator *repl);
44
void remove_replicator(drizzled::plugin::Replicator *repl);
47
* This is a class which manages transforming internal
48
* transactional events into GPB messages and sending those
49
* events out through registered replicators and appliers.
53
class TransactionServices
56
/** Our collection of replicator plugins */
57
std::vector<drizzled::plugin::Replicator *> replicators;
58
/** Our collection of applier plugins */
59
std::vector<drizzled::plugin::Applier *> appliers;
61
* Helper method which attaches a transaction context
62
* the supplied command based on the supplied Session's
63
* transaction information.
65
void setCommandTransactionContext(drizzled::message::Command *in_command, Session *in_session) const;
67
* Helper method which pushes a constructed message out
68
* to the registered replicator and applier plugins.
70
* @param Message to push out
72
void push(drizzled::message::Command *to_push);
75
* Attaches a replicator to our internal collection of
78
* @param Pointer to a replicator to attach/register
80
void attachReplicator(drizzled::plugin::Replicator *in_replicator);
82
* Detaches/unregisters a replicator with our internal
83
* collection of replicators.
85
* @param Pointer to the replicator to detach
87
void detachReplicator(drizzled::plugin::Replicator *in_replicator);
89
* Attaches a applier to our internal collection of
92
* @param Pointer to a applier to attach/register
94
void attachApplier(drizzled::plugin::Applier *in_applier);
96
* Detaches/unregisters a applier with our internal
97
* collection of appliers.
99
* @param Pointer to the applier to detach
101
void detachApplier(drizzled::plugin::Applier *in_applier);
103
* Creates a new StartTransaction GPB message and pushes
106
* @param Pointer to the Session starting the transaction
108
void startTransaction(Session *in_session);
110
* Creates a new CommitTransaction GPB message and pushes
113
* @param Pointer to the Session committing the transaction
115
void commitTransaction(Session *in_session);
117
* Creates a new RollbackTransaction GPB message and pushes
120
* @param Pointer to the Session committing the transaction
122
void rollbackTransaction(Session *in_session);
124
* Creates a new InsertRecord GPB message and pushes it to
127
* @param Pointer to the Session which has inserted a record
128
* @param Pointer to the Table containing insert information
130
void insertRecord(Session *in_session, Table *in_table);
132
* Creates a new UpdateRecord GPB message and pushes it to
135
* @param Pointer to the Session which has updated a record
136
* @param Pointer to the Table containing update information
138
void updateRecord(Session *in_session, Table *in_table, const unsigned char *, const unsigned char *);
140
* Creates a new DeleteRecord GPB message and pushes it to
143
* @param Pointer to the Session which has deleted a record
144
* @param Pointer to the Table containing delete information
146
void deleteRecord(Session *in_session, Table *in_table);
148
* Creates a new RawSql GPB message and pushes it to
151
* @TODO With a real data dictionary, this really shouldn't
152
* be needed. CREATE TABLE would map to insertRecord call
153
* on the I_S, etc. Not sure what to do with administrative
154
* commands like CHECK TABLE, though..
156
* @param Pointer to the Session which issued the statement
157
* @param Query string
158
* @param Length of the query string
160
void rawStatement(Session *in_session, const char *in_query, size_t in_query_len);
163
} /* end namespace drizzled */
166
/* todo, fill in this API */
167
/* these are the functions called by the rest of the drizzle server
168
to do whatever this plugin does. */
169
bool replicator_session_init (Session *session);
170
bool replicator_write_row(Session *session, Table *table);
171
bool replicator_update_row(Session *session, Table *table,
172
const unsigned char *before,
173
const unsigned char *after);
174
bool replicator_delete_row(Session *session, Table *table);
176
/* The below control transactions */
177
bool replicator_end_transaction(Session *session, bool autocommit, bool commit);
178
bool replicator_prepare(Session *session);
179
bool replicator_statement(Session *session, const char *query, size_t query_length);
181
#endif /* DRIZZLED_REPLICATOR_H */