~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/transaction_services.h

  • Committer: Jay Pipes
  • Date: 2009-04-10 17:06:58 UTC
  • mto: (971.1.47 mordred)
  • mto: This revision was merged to the branch mainline in revision 990.
  • Revision ID: jpipes@serialcoder-20090410170658-d3azdnas1fn8v68l
Removal of log.cc (binlog), added Applier plugin and fixed up Replicator
plugin.  New transaction_services.cc class implementation of the API for
converting between internal formats and GPB Command Messages.

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>
 
23
#include <vector>
24
24
 
25
25
int replicator_initializer (st_plugin_int *plugin);
26
26
int replicator_finalizer (st_plugin_int *plugin);
27
27
 
 
28
/* some forward declarations needed */
 
29
class Session;
 
30
class Table;
 
31
 
 
32
namespace drizzled
 
33
{
 
34
  namespace plugin
 
35
  {
 
36
    class Replicator;
 
37
    class Applier;
 
38
  }
 
39
  namespace message
 
40
  {
 
41
    class Command;
 
42
  }
 
43
}
 
44
 
 
45
/**
 
46
 * This is a class which manages transforming internal 
 
47
 * transactional events into GPB messages and sending those
 
48
 * events out through registered replicators and appliers.
 
49
 */
 
50
namespace drizzled
 
51
{
 
52
class TransactionServices
 
53
{
 
54
private:
 
55
  /** Our collection of replicator plugins */
 
56
  std::vector<drizzled::plugin::Replicator *> replicators;
 
57
  /** Our collection of applier plugins */
 
58
  std::vector<drizzled::plugin::Applier *> appliers;
 
59
  /** 
 
60
   * Helper method which attaches a transaction context
 
61
   * the supplied command based on the supplied Session's
 
62
   * transaction information.
 
63
   */
 
64
  void setCommandTransactionContext(drizzled::message::Command *in_command, Session *in_session) const;
 
65
  /**
 
66
   * Helper method which pushes a constructed message out
 
67
   * to the registered replicator and applier plugins.
 
68
   *
 
69
   * @param Message to push out
 
70
   */
 
71
  void push(drizzled::message::Command *to_push);
 
72
public:
 
73
  /**
 
74
   * Attaches a replicator to our internal collection of
 
75
   * replicators.
 
76
   *
 
77
   * @param Pointer to a replicator to attach/register
 
78
   */
 
79
  void attachReplicator(drizzled::plugin::Replicator *in_replicator);
 
80
  /**
 
81
   * Detaches/unregisters a replicator with our internal
 
82
   * collection of replicators.
 
83
   *
 
84
   * @param Pointer to the replicator to detach
 
85
   */
 
86
  void detachReplicator(drizzled::plugin::Replicator *in_replicator);
 
87
  /**
 
88
   * Attaches a applier to our internal collection of
 
89
   * appliers.
 
90
   *
 
91
   * @param Pointer to a applier to attach/register
 
92
   */
 
93
  void attachApplier(drizzled::plugin::Applier *in_applier);
 
94
  /**
 
95
   * Detaches/unregisters a applier with our internal
 
96
   * collection of appliers.
 
97
   *
 
98
   * @param Pointer to the applier to detach
 
99
   */
 
100
  void detachApplier(drizzled::plugin::Applier *in_applier);
 
101
  /**
 
102
   * Creates a new StartTransaction GPB message and pushes
 
103
   * it to replicators.
 
104
   *
 
105
   * @param Pointer to the Session starting the transaction
 
106
   */
 
107
  void startTransaction(Session *in_session);
 
108
  /**
 
109
   * Creates a new CommitTransaction GPB message and pushes
 
110
   * it to replicators.
 
111
   *
 
112
   * @param Pointer to the Session committing the transaction
 
113
   */
 
114
  void commitTransaction(Session *in_session);
 
115
  /**
 
116
   * Creates a new RollbackTransaction GPB message and pushes
 
117
   * it to replicators.
 
118
   *
 
119
   * @param Pointer to the Session committing the transaction
 
120
   */
 
121
  void rollbackTransaction(Session *in_session);
 
122
  /**
 
123
   * Creates a new InsertRecord GPB message and pushes it to
 
124
   * replicators.
 
125
   *
 
126
   * @param Pointer to the Session which has inserted a record
 
127
   * @param Pointer to the Table containing insert information
 
128
   */
 
129
  void insertRecord(Session *in_session, Table *in_table);
 
130
  /**
 
131
   * Creates a new UpdateRecord GPB message and pushes it to
 
132
   * replicators.
 
133
   *
 
134
   * @param Pointer to the Session which has updated a record
 
135
   * @param Pointer to the Table containing update information
 
136
   */
 
137
  void updateRecord(Session *in_session, Table *in_table, const unsigned char *, const unsigned char *);
 
138
  /**
 
139
   * Creates a new DeleteRecord GPB message and pushes it to
 
140
   * replicators.
 
141
   *
 
142
   * @param Pointer to the Session which has deleted a record
 
143
   * @param Pointer to the Table containing delete information
 
144
   */
 
145
  void deleteRecord(Session *in_session, Table *in_table);
 
146
  /**
 
147
   * Creates a new RawSql GPB message and pushes it to 
 
148
   * replicators.
 
149
   *
 
150
   * @TODO With a real data dictionary, this really shouldn't
 
151
   * be needed.  CREATE TABLE would map to insertRecord call
 
152
   * on the I_S, etc.  Not sure what to do with administrative
 
153
   * commands like CHECK TABLE, though..
 
154
   *
 
155
   * @param Pointer to the Session which issued the statement
 
156
   * @param Query string
 
157
   * @param Length of the query string
 
158
   */
 
159
  void rawStatement(Session *in_session, const char *in_query, size_t in_query_len);
 
160
};
 
161
 
 
162
} /* end namespace drizzled */
 
163
 
 
164
#ifdef oldcode
28
165
/* todo, fill in this API */
29
166
/* these are the functions called by the rest of the drizzle server
30
167
   to do whatever this plugin does. */
39
176
bool replicator_end_transaction(Session *session, bool autocommit, bool commit);
40
177
bool replicator_prepare(Session *session);
41
178
bool replicator_statement(Session *session, const char *query, size_t query_length);
42
 
 
 
179
#endif /* oldcode */
43
180
#endif /* DRIZZLED_REPLICATOR_H */