~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/logging_stats/stats_schema.h

This patch completes the first step in the splitting of
the XA resource manager API from the storage engine API,
as outlined in the specification here:

http://drizzle.org/wiki/XaStorageEngine

* Splits plugin::StorageEngine into a base StorageEngine
  class and two derived classes, TransactionalStorageEngine
  and XaStorageEngine.  XaStorageEngine derives from
  TransactionalStorageEngine and creates the XA Resource
  Manager API for storage engines.

  - The methods moved from StorageEngine to TransactionalStorageEngine
    include releaseTemporaryLatches(), startConsistentSnapshot(), 
    commit(), rollback(), setSavepoint(), releaseSavepoint(),
    rollbackToSavepoint() and hasTwoPhaseCommit()
  - The methods moved from StorageEngine to XaStorageEngine
    include recover(), commitXid(), rollbackXid(), and prepare()

* Places all static "EngineVector"s into their proper
  namespaces (typedefs belong in header files, not implementation files)
  and places all static methods corresponding
  to either only transactional engines or only XA engines
  into their respective files in /drizzled/plugin/

* Modifies the InnoDB "handler" files to extend plugin::XaStorageEngine
  and not plugin::StorageEngine

The next step, as outlined in the wiki spec page above, is to isolate
the XA Resource Manager API into its own plugin class and modify
plugin::XaStorageEngine to implement plugin::XaResourceManager via
composition.  This is necessary to enable building plugins which can
participate in an XA transaction *without having to have that plugin
implement the entire storage engine API*

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (C) 2010 Joseph Daly <skinny.moey@gmail.com>
3
 
 * All rights reserved.
4
 
 *
5
 
 * Redistribution and use in source and binary forms, with or without
6
 
 * modification, are permitted provided that the following conditions are met:
7
 
 *
8
 
 *   * Redistributions of source code must retain the above copyright notice,
9
 
 *     this list of conditions and the following disclaimer.
10
 
 *   * Redistributions in binary form must reproduce the above copyright notice,
11
 
 *     this list of conditions and the following disclaimer in the documentation
12
 
 *     and/or other materials provided with the distribution.
13
 
 *   * Neither the name of Joseph Daly nor the names of its contributors
14
 
 *     may be used to endorse or promote products derived from this software
15
 
 *     without specific prior written permission.
16
 
 *
17
 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18
 
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
 
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
 
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21
 
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22
 
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23
 
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24
 
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25
 
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26
 
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
27
 
 * THE POSSIBILITY OF SUCH DAMAGE.
28
 
 */
29
 
 
30
 
#ifndef PLUGIN_LOGGING_STATS_STATS_SCHEMA_H
31
 
#define PLUGIN_LOGGING_STATS_STATS_SCHEMA_H
32
 
 
33
 
#include <drizzled/plugin/table_function.h>
34
 
#include <drizzled/field.h>
35
 
 
36
 
#include "user_commands.h"
37
 
#include "global_stats.h"
38
 
#include "logging_stats.h"
39
 
 
40
 
#include <vector>
41
 
 
42
 
class GlobalStatementsTool : public drizzled::plugin::TableFunction
43
 
{
44
 
public:
45
 
  GlobalStatementsTool(LoggingStats *logging_stats);
46
 
 
47
 
  class Generator : public drizzled::plugin::TableFunction::Generator
48
 
  {
49
 
  public:
50
 
    Generator(drizzled::Field **arg, LoggingStats *logging_stats);
51
 
 
52
 
    ~Generator();
53
 
 
54
 
    bool populate();
55
 
 
56
 
  private:
57
 
    GlobalStats *global_stats_to_display; 
58
 
    uint32_t count;
59
 
  };
60
 
 
61
 
  Generator *generator(drizzled::Field **arg)
62
 
  {
63
 
    return new Generator(arg, logging_stats);
64
 
  }
65
 
 
66
 
private:
67
 
  LoggingStats *logging_stats;
68
 
};
69
 
 
70
 
class SessionStatementsTool : public drizzled::plugin::TableFunction
71
 
{
72
 
public:
73
 
  SessionStatementsTool(LoggingStats *logging_stats);
74
 
 
75
 
  class Generator : public drizzled::plugin::TableFunction::Generator
76
 
  {
77
 
  public:
78
 
    Generator(drizzled::Field **arg, LoggingStats *logging_stats);
79
 
 
80
 
    bool populate();
81
 
 
82
 
  private:
83
 
    UserCommands *user_commands;
84
 
    uint32_t count;
85
 
  };
86
 
 
87
 
  Generator *generator(drizzled::Field **arg)
88
 
  {
89
 
    return new Generator(arg, logging_stats);
90
 
  }
91
 
 
92
 
private:
93
 
  LoggingStats *logging_stats;
94
 
};
95
 
 
96
 
class CurrentCommandsTool : public drizzled::plugin::TableFunction
97
 
{
98
 
public:
99
 
 
100
 
  CurrentCommandsTool(LoggingStats *logging_stats);
101
 
 
102
 
  class Generator : public drizzled::plugin::TableFunction::Generator
103
 
  {
104
 
  public:
105
 
    Generator(drizzled::Field **arg, LoggingStats *logging_stats);
106
 
 
107
 
    bool populate();
108
 
  private:
109
 
    LoggingStats *inner_logging_stats; 
110
 
    Scoreboard *current_scoreboard; 
111
 
    uint32_t current_bucket;
112
 
    bool isEnabled;
113
 
    std::vector<ScoreboardSlot *>::iterator scoreboard_vector_it;
114
 
    std::vector<ScoreboardSlot *>::iterator scoreboard_vector_end;
115
 
    std::vector<std::vector<ScoreboardSlot* >* >::iterator vector_of_scoreboard_vectors_it;
116
 
    std::vector<std::vector<ScoreboardSlot* >* >::iterator vector_of_scoreboard_vectors_end; 
117
 
    boost::shared_mutex* current_lock;
118
 
 
119
 
    void setVectorIteratorsAndLock(uint32_t bucket_number);
120
 
  };
121
 
 
122
 
  Generator *generator(drizzled::Field **arg)
123
 
  {
124
 
    return new Generator(arg, outer_logging_stats);
125
 
  }
126
 
private:
127
 
  LoggingStats *outer_logging_stats;
128
 
};
129
 
 
130
 
class CumulativeCommandsTool : public drizzled::plugin::TableFunction
131
 
{
132
 
public:
133
 
 
134
 
  CumulativeCommandsTool(LoggingStats *logging_stats);
135
 
 
136
 
  class Generator : public drizzled::plugin::TableFunction::Generator
137
 
  {
138
 
  public:
139
 
    Generator(drizzled::Field **arg, LoggingStats *logging_stats);
140
 
 
141
 
    bool populate();
142
 
  private:
143
 
    LoggingStats *inner_logging_stats;
144
 
    int32_t record_number;
145
 
    int32_t last_valid_index;
146
 
  };
147
 
 
148
 
  Generator *generator(drizzled::Field **arg)
149
 
  {
150
 
    return new Generator(arg, outer_logging_stats);
151
 
  }
152
 
private:
153
 
  LoggingStats *outer_logging_stats;
154
 
};
155
 
 
156
 
class CumulativeUserStatsTool : public drizzled::plugin::TableFunction
157
 
{
158
 
public:
159
 
 
160
 
  CumulativeUserStatsTool(LoggingStats *logging_stats);
161
 
 
162
 
  class Generator : public drizzled::plugin::TableFunction::Generator
163
 
  {
164
 
  public:
165
 
    Generator(drizzled::Field **arg, LoggingStats *logging_stats);
166
 
 
167
 
    bool populate();
168
 
  private:
169
 
    LoggingStats *inner_logging_stats;
170
 
    int32_t record_number;
171
 
    int32_t last_valid_index;
172
 
  };
173
 
 
174
 
  Generator *generator(drizzled::Field **arg)
175
 
  {
176
 
    return new Generator(arg, outer_logging_stats);
177
 
  }
178
 
private:
179
 
  LoggingStats *outer_logging_stats;
180
 
};
181
 
 
182
 
class ScoreboardStatsTool : public drizzled::plugin::TableFunction
183
 
{
184
 
public:
185
 
 
186
 
  ScoreboardStatsTool(LoggingStats *logging_stats);
187
 
 
188
 
  class Generator : public drizzled::plugin::TableFunction::Generator
189
 
  {
190
 
  public:
191
 
    Generator(drizzled::Field **arg, LoggingStats *logging_stats);
192
 
 
193
 
    bool populate();
194
 
  private:
195
 
    LoggingStats *inner_logging_stats;
196
 
    bool is_last_record;
197
 
  };
198
 
 
199
 
  Generator *generator(drizzled::Field **arg)
200
 
  {
201
 
    return new Generator(arg, outer_logging_stats);
202
 
  }
203
 
private:
204
 
  LoggingStats *outer_logging_stats;
205
 
};
206
 
 
207
 
#endif /* PLUGIN_LOGGING_STATS_STATS_SCHEMA_H */