1320.4.1
by Joe Daly
scoreboard implementation for statistics |
1 |
/*
|
1999.6.1
by kalebral at gmail
update Copyright strings to a more common format to help with creating the master debian copyright file |
2 |
* Copyright (C) 2010 Joseph Daly <skinny.moey@gmail.com>
|
1320.4.1
by Joe Daly
scoreboard implementation for statistics |
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 |
||
1561.3.8
by Joe Daly
try and create some logic with header files, and implement flush status properly |
36 |
#include "user_commands.h" |
37 |
#include "global_stats.h" |
|
1320.4.1
by Joe Daly
scoreboard implementation for statistics |
38 |
#include "logging_stats.h" |
39 |
||
1320.5.6
by Joe Daly
first pass at using a module vector approach of scoreboard |
40 |
#include <vector> |
41 |
||
1491.4.6
by Joe Daly
rework stats_schema use static char * for command strings |
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 |
||
1616.2.1
by Joe Daly
update GLOBAL_STATEMENTS logic it was not including a sum of the current scoreboard only sessions that had terminated |
52 |
~Generator(); |
53 |
||
1491.4.6
by Joe Daly
rework stats_schema use static char * for command strings |
54 |
bool populate(); |
55 |
||
56 |
private: |
|
1616.2.1
by Joe Daly
update GLOBAL_STATEMENTS logic it was not including a sum of the current scoreboard only sessions that had terminated |
57 |
GlobalStats *global_stats_to_display; |
1491.4.6
by Joe Daly
rework stats_schema use static char * for command strings |
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; |
|
1491.4.2
by Joe Daly
rework atomics on cumulative user tables |
94 |
};
|
95 |
||
1320.5.1
by Joe Daly
add cumulative stats |
96 |
class CurrentCommandsTool : public drizzled::plugin::TableFunction |
1320.4.1
by Joe Daly
scoreboard implementation for statistics |
97 |
{
|
98 |
public: |
|
99 |
||
1320.5.1
by Joe Daly
add cumulative stats |
100 |
CurrentCommandsTool(LoggingStats *logging_stats); |
1320.4.1
by Joe Daly
scoreboard implementation for statistics |
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: |
|
1491.4.4
by Joe Daly
rework UserCommands class to have a simplier interface and remove get/increment functions |
109 |
LoggingStats *inner_logging_stats; |
1320.5.6
by Joe Daly
first pass at using a module vector approach of scoreboard |
110 |
Scoreboard *current_scoreboard; |
111 |
uint32_t current_bucket; |
|
1320.5.7
by Joe Daly
get tests to work, need to fix read lock on stats_schema current commands |
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; |
|
1683.1.1
by Joe Daly
use boost for locking instead of pthread |
117 |
boost::shared_mutex* current_lock; |
1491.4.4
by Joe Daly
rework UserCommands class to have a simplier interface and remove get/increment functions |
118 |
|
119 |
void setVectorIteratorsAndLock(uint32_t bucket_number); |
|
1320.4.1
by Joe Daly
scoreboard implementation for statistics |
120 |
};
|
121 |
||
122 |
Generator *generator(drizzled::Field **arg) |
|
123 |
{
|
|
1491.4.4
by Joe Daly
rework UserCommands class to have a simplier interface and remove get/increment functions |
124 |
return new Generator(arg, outer_logging_stats); |
1320.4.1
by Joe Daly
scoreboard implementation for statistics |
125 |
}
|
1491.4.4
by Joe Daly
rework UserCommands class to have a simplier interface and remove get/increment functions |
126 |
private: |
127 |
LoggingStats *outer_logging_stats; |
|
1320.4.1
by Joe Daly
scoreboard implementation for statistics |
128 |
};
|
129 |
||
1320.5.1
by Joe Daly
add cumulative stats |
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: |
|
1491.4.4
by Joe Daly
rework UserCommands class to have a simplier interface and remove get/increment functions |
143 |
LoggingStats *inner_logging_stats; |
1491.4.2
by Joe Daly
rework atomics on cumulative user tables |
144 |
int32_t record_number; |
145 |
int32_t last_valid_index; |
|
1320.5.1
by Joe Daly
add cumulative stats |
146 |
};
|
147 |
||
148 |
Generator *generator(drizzled::Field **arg) |
|
149 |
{
|
|
150 |
return new Generator(arg, outer_logging_stats); |
|
151 |
}
|
|
1491.4.4
by Joe Daly
rework UserCommands class to have a simplier interface and remove get/increment functions |
152 |
private: |
153 |
LoggingStats *outer_logging_stats; |
|
1320.5.1
by Joe Daly
add cumulative stats |
154 |
};
|
155 |
||
1625.2.1
by Joe Daly
initial user stats impl |
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 |
||
1711.7.2
by Joseph Daly
add memory usage |
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 |
||
1320.4.1
by Joe Daly
scoreboard implementation for statistics |
207 |
#endif /* PLUGIN_LOGGING_STATS_STATS_SCHEMA_H */ |