~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/transaction_services.h

  • Committer: Brian Aker
  • Date: 2009-04-13 16:22:40 UTC
  • mfrom: (971.1.78 mordred)
  • Revision ID: brian@gaz-20090413162240-ugi3gvhofmcuglzl
Merge Monty

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Mark Atwood
 
4
 *  Copyright (C) 2008-2009 Sun Microsystems
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
20
20
#ifndef DRIZZLED_REPLICATOR_H
21
21
#define DRIZZLED_REPLICATOR_H
22
22
 
23
 
#include <drizzled/plugin/replicator.h>
24
 
 
25
 
int replicator_initializer (st_plugin_int *plugin);
26
 
int replicator_finalizer (st_plugin_int *plugin);
27
 
 
 
23
#include <vector>
 
24
 
 
25
 
 
26
/* some forward declarations needed */
 
27
class Session;
 
28
class Table;
 
29
 
 
30
namespace drizzled
 
31
{
 
32
  namespace plugin
 
33
  {
 
34
    class Replicator;
 
35
    class Applier;
 
36
  }
 
37
  namespace message
 
38
  {
 
39
    class Command;
 
40
  }
 
41
}
 
42
 
 
43
void add_replicator(drizzled::plugin::Replicator *repl);
 
44
void remove_replicator(drizzled::plugin::Replicator *repl);
 
45
 
 
46
/**
 
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.
 
50
 */
 
51
namespace drizzled
 
52
{
 
53
class TransactionServices
 
54
{
 
55
private:
 
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;
 
60
  /** 
 
61
   * Helper method which attaches a transaction context
 
62
   * the supplied command based on the supplied Session's
 
63
   * transaction information.
 
64
   */
 
65
  void setCommandTransactionContext(drizzled::message::Command *in_command, Session *in_session) const;
 
66
  /**
 
67
   * Helper method which pushes a constructed message out
 
68
   * to the registered replicator and applier plugins.
 
69
   *
 
70
   * @param Message to push out
 
71
   */
 
72
  void push(drizzled::message::Command *to_push);
 
73
public:
 
74
  /**
 
75
   * Attaches a replicator to our internal collection of
 
76
   * replicators.
 
77
   *
 
78
   * @param Pointer to a replicator to attach/register
 
79
   */
 
80
  void attachReplicator(drizzled::plugin::Replicator *in_replicator);
 
81
  /**
 
82
   * Detaches/unregisters a replicator with our internal
 
83
   * collection of replicators.
 
84
   *
 
85
   * @param Pointer to the replicator to detach
 
86
   */
 
87
  void detachReplicator(drizzled::plugin::Replicator *in_replicator);
 
88
  /**
 
89
   * Attaches a applier to our internal collection of
 
90
   * appliers.
 
91
   *
 
92
   * @param Pointer to a applier to attach/register
 
93
   */
 
94
  void attachApplier(drizzled::plugin::Applier *in_applier);
 
95
  /**
 
96
   * Detaches/unregisters a applier with our internal
 
97
   * collection of appliers.
 
98
   *
 
99
   * @param Pointer to the applier to detach
 
100
   */
 
101
  void detachApplier(drizzled::plugin::Applier *in_applier);
 
102
  /**
 
103
   * Creates a new StartTransaction GPB message and pushes
 
104
   * it to replicators.
 
105
   *
 
106
   * @param Pointer to the Session starting the transaction
 
107
   */
 
108
  void startTransaction(Session *in_session);
 
109
  /**
 
110
   * Creates a new CommitTransaction GPB message and pushes
 
111
   * it to replicators.
 
112
   *
 
113
   * @param Pointer to the Session committing the transaction
 
114
   */
 
115
  void commitTransaction(Session *in_session);
 
116
  /**
 
117
   * Creates a new RollbackTransaction GPB message and pushes
 
118
   * it to replicators.
 
119
   *
 
120
   * @param Pointer to the Session committing the transaction
 
121
   */
 
122
  void rollbackTransaction(Session *in_session);
 
123
  /**
 
124
   * Creates a new InsertRecord GPB message and pushes it to
 
125
   * replicators.
 
126
   *
 
127
   * @param Pointer to the Session which has inserted a record
 
128
   * @param Pointer to the Table containing insert information
 
129
   */
 
130
  void insertRecord(Session *in_session, Table *in_table);
 
131
  /**
 
132
   * Creates a new UpdateRecord GPB message and pushes it to
 
133
   * replicators.
 
134
   *
 
135
   * @param Pointer to the Session which has updated a record
 
136
   * @param Pointer to the Table containing update information
 
137
   */
 
138
  void updateRecord(Session *in_session, Table *in_table, const unsigned char *, const unsigned char *);
 
139
  /**
 
140
   * Creates a new DeleteRecord GPB message and pushes it to
 
141
   * replicators.
 
142
   *
 
143
   * @param Pointer to the Session which has deleted a record
 
144
   * @param Pointer to the Table containing delete information
 
145
   */
 
146
  void deleteRecord(Session *in_session, Table *in_table);
 
147
  /**
 
148
   * Creates a new RawSql GPB message and pushes it to 
 
149
   * replicators.
 
150
   *
 
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..
 
155
   *
 
156
   * @param Pointer to the Session which issued the statement
 
157
   * @param Query string
 
158
   * @param Length of the query string
 
159
   */
 
160
  void rawStatement(Session *in_session, const char *in_query, size_t in_query_len);
 
161
};
 
162
 
 
163
} /* end namespace drizzled */
 
164
 
 
165
#ifdef oldcode
28
166
/* todo, fill in this API */
29
167
/* these are the functions called by the rest of the drizzle server
30
168
   to do whatever this plugin does. */
39
177
bool replicator_end_transaction(Session *session, bool autocommit, bool commit);
40
178
bool replicator_prepare(Session *session);
41
179
bool replicator_statement(Session *session, const char *query, size_t query_length);
42
 
 
 
180
#endif /* oldcode */
43
181
#endif /* DRIZZLED_REPLICATOR_H */