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 |
||
1491.4.11
by Joe Daly
move comments to .cc file |
30 |
/**
|
31 |
* @details
|
|
32 |
*
|
|
33 |
* This class defines the following DATA_DICTIONARY tables:
|
|
34 |
*
|
|
1561.3.24
by Joe Daly
update comments in various files |
35 |
* drizzle> describe GLOBAL_STATEMENTS;
|
1491.4.11
by Joe Daly
move comments to .cc file |
36 |
* +----------------+---------+-------+---------+-----------------+-----------+
|
37 |
* | Field | Type | Null | Default | Default_is_NULL | On_Update |
|
|
38 |
* +----------------+---------+-------+---------+-----------------+-----------+
|
|
39 |
* | VARIABLE_NAME | VARCHAR | FALSE | | FALSE | |
|
|
40 |
* | VARIABLE_VALUE | BIGINT | FALSE | | FALSE | |
|
|
41 |
* +----------------+---------+-------+---------+-----------------+-----------+
|
|
42 |
*
|
|
1561.3.24
by Joe Daly
update comments in various files |
43 |
* drizzle> describe SESSION_STATEMENTS;
|
1491.4.11
by Joe Daly
move comments to .cc file |
44 |
* +----------------+---------+-------+---------+-----------------+-----------+
|
45 |
* | Field | Type | Null | Default | Default_is_NULL | On_Update |
|
|
46 |
* +----------------+---------+-------+---------+-----------------+-----------+
|
|
47 |
* | VARIABLE_NAME | VARCHAR | FALSE | | FALSE | |
|
|
48 |
* | VARIABLE_VALUE | BIGINT | FALSE | | FALSE | |
|
|
49 |
* +----------------+---------+-------+---------+-----------------+-----------+
|
|
50 |
*
|
|
51 |
* drizzle> describe CURRENT_SQL_COMMANDS;
|
|
52 |
* +----------------+---------+-------+---------+-----------------+-----------+
|
|
53 |
* | Field | Type | Null | Default | Default_is_NULL | On_Update |
|
|
54 |
* +----------------+---------+-------+---------+-----------------+-----------+
|
|
2029.1.26
by Brian Aker
Merge in work for reserved words in SQL standard. |
55 |
* | USERNAME | VARCHAR | FALSE | | FALSE | |
|
1491.4.11
by Joe Daly
move comments to .cc file |
56 |
* | IP | VARCHAR | FALSE | | FALSE | |
|
57 |
* | COUNT_SELECT | BIGINT | FALSE | | FALSE | |
|
|
58 |
* | COUNT_DELETE | BIGINT | FALSE | | FALSE | |
|
|
59 |
* | COUNT_UPDATE | BIGINT | FALSE | | FALSE | |
|
|
60 |
* | COUNT_INSERT | BIGINT | FALSE | | FALSE | |
|
|
61 |
* | COUNT_ROLLBACK | BIGINT | FALSE | | FALSE | |
|
|
62 |
* | COUNT_COMMIT | BIGINT | FALSE | | FALSE | |
|
|
63 |
* | COUNT_CREATE | BIGINT | FALSE | | FALSE | |
|
|
64 |
* | COUNT_ALTER | BIGINT | FALSE | | FALSE | |
|
|
65 |
* | COUNT_DROP | BIGINT | FALSE | | FALSE | |
|
|
66 |
* | COUNT_ADMIN | BIGINT | FALSE | | FALSE | |
|
|
67 |
* +----------------+---------+-------+---------+-----------------+-----------+
|
|
68 |
*
|
|
69 |
* drizzle> describe CUMULATIVE_SQL_COMMANDS;
|
|
70 |
* +----------------+---------+-------+---------+-----------------+-----------+
|
|
71 |
* | Field | Type | Null | Default | Default_is_NULL | On_Update |
|
|
72 |
* +----------------+---------+-------+---------+-----------------+-----------+
|
|
2029.1.26
by Brian Aker
Merge in work for reserved words in SQL standard. |
73 |
* | USERNAME | VARCHAR | FALSE | | FALSE | |
|
1491.4.11
by Joe Daly
move comments to .cc file |
74 |
* | COUNT_SELECT | BIGINT | FALSE | | FALSE | |
|
75 |
* | COUNT_DELETE | BIGINT | FALSE | | FALSE | |
|
|
76 |
* | COUNT_UPDATE | BIGINT | FALSE | | FALSE | |
|
|
77 |
* | COUNT_INSERT | BIGINT | FALSE | | FALSE | |
|
|
78 |
* | COUNT_ROLLBACK | BIGINT | FALSE | | FALSE | |
|
|
79 |
* | COUNT_COMMIT | BIGINT | FALSE | | FALSE | |
|
|
80 |
* | COUNT_CREATE | BIGINT | FALSE | | FALSE | |
|
|
81 |
* | COUNT_ALTER | BIGINT | FALSE | | FALSE | |
|
|
82 |
* | COUNT_DROP | BIGINT | FALSE | | FALSE | |
|
|
83 |
* | COUNT_ADMIN | BIGINT | FALSE | | FALSE | |
|
|
84 |
* +----------------+---------+-------+---------+-----------------+-----------+
|
|
1625.2.5
by Joe Daly
add comment describing table, and fix up schema_dictionary test |
85 |
*
|
86 |
* drizzle> describe CUMULATIVE_USER_STATS;
|
|
87 |
* +---------------------+---------+-------+---------+-----------------+-----------+
|
|
88 |
* | Field | Type | Null | Default | Default_is_NULL | On_Update |
|
|
89 |
* +---------------------+---------+-------+---------+-----------------+-----------+
|
|
2029.1.26
by Brian Aker
Merge in work for reserved words in SQL standard. |
90 |
* | USERNAME | VARCHAR | FALSE | | FALSE | |
|
1625.2.5
by Joe Daly
add comment describing table, and fix up schema_dictionary test |
91 |
* | BYTES_RECEIVED | VARCHAR | FALSE | | FALSE | |
|
92 |
* | BYTES_SENT | VARCHAR | FALSE | | FALSE | |
|
|
93 |
* | DENIED_CONNECTIONS | VARCHAR | FALSE | | FALSE | |
|
|
94 |
* | LOST_CONNECTIONS | VARCHAR | FALSE | | FALSE | |
|
|
95 |
* | ACCESS_DENIED | VARCHAR | FALSE | | FALSE | |
|
|
96 |
* | CONNECTED_TIME_SEC | VARCHAR | FALSE | | FALSE | |
|
|
97 |
* | EXECUTION_TIME_NSEC | VARCHAR | FALSE | | FALSE | |
|
|
98 |
* | ROWS_FETCHED | VARCHAR | FALSE | | FALSE | |
|
|
99 |
* | ROWS_UPDATED | VARCHAR | FALSE | | FALSE | |
|
|
100 |
* | ROWS_DELETED | VARCHAR | FALSE | | FALSE | |
|
|
101 |
* | ROWS_INSERTED | VARCHAR | FALSE | | FALSE | |
|
|
102 |
* +---------------------+---------+-------+---------+-----------------+-----------+
|
|
103 |
*
|
|
1491.4.11
by Joe Daly
move comments to .cc file |
104 |
*/
|
105 |
||
2173.2.1
by Monty Taylor
Fixes incorrect usage of include |
106 |
#include <config.h> |
2241.3.1
by Olaf van der Spek
Refactor Session::status_var |
107 |
#include <drizzled/statistics_variables.h> |
1320.4.1
by Joe Daly
scoreboard implementation for statistics |
108 |
#include "stats_schema.h" |
1491.4.15
by Joe Daly
remove com_stat_vars and rework lock in scoreboard to not lock on Sessions locating a slot they previously owned |
109 |
#include <sstream> |
110 |
||
1320.4.7
by Joe Daly
fix up some variable names, and namespaces paths in *.cc files, and add constant for UNINITIALIZED |
111 |
using namespace drizzled; |
112 |
using namespace plugin; |
|
1320.4.1
by Joe Daly
scoreboard implementation for statistics |
113 |
using namespace std; |
114 |
||
1491.4.6
by Joe Daly
rework stats_schema use static char * for command strings |
115 |
SessionStatementsTool::SessionStatementsTool(LoggingStats *in_logging_stats) : |
1491.4.25
by Joe Daly
disable logging_stats plugin and rename GLOBAL_STATEMENTS and SESSION_STATEMENTS tables to remove NEW tag |
116 |
plugin::TableFunction("DATA_DICTIONARY", "SESSION_STATEMENTS") |
1491.4.6
by Joe Daly
rework stats_schema use static char * for command strings |
117 |
{
|
118 |
logging_stats= in_logging_stats; |
|
119 |
add_field("VARIABLE_NAME"); |
|
1491.4.15
by Joe Daly
remove com_stat_vars and rework lock in scoreboard to not lock on Sessions locating a slot they previously owned |
120 |
add_field("VARIABLE_VALUE", 1024); |
1491.4.6
by Joe Daly
rework stats_schema use static char * for command strings |
121 |
}
|
122 |
||
1891.2.1
by Monty Taylor
Fixed things to make things compile with clang |
123 |
SessionStatementsTool::Generator::Generator(Field **arg, LoggingStats *in_logging_stats) : |
1491.4.6
by Joe Daly
rework stats_schema use static char * for command strings |
124 |
plugin::TableFunction::Generator(arg) |
125 |
{
|
|
126 |
count= 0; |
|
127 |
||
128 |
/* Set user_commands */
|
|
1891.2.1
by Monty Taylor
Fixed things to make things compile with clang |
129 |
Scoreboard *current_scoreboard= in_logging_stats->getCurrentScoreboard(); |
1491.4.6
by Joe Daly
rework stats_schema use static char * for command strings |
130 |
|
1603
by Brian Aker
Remove current_session from usage in table stats logging. |
131 |
uint32_t bucket_number= current_scoreboard->getBucketNumber(&getSession()); |
1491.4.6
by Joe Daly
rework stats_schema use static char * for command strings |
132 |
|
1966.2.6
by Brian Aker
This is from the catalog patch (I'm pushing it up as its own little thing |
133 |
std::vector<ScoreboardSlot* > *scoreboard_vector= |
1491.4.6
by Joe Daly
rework stats_schema use static char * for command strings |
134 |
current_scoreboard->getVectorOfScoreboardVectors()->at(bucket_number); |
135 |
||
136 |
ScoreboardSlot *scoreboard_slot= NULL; |
|
1966.2.6
by Brian Aker
This is from the catalog patch (I'm pushing it up as its own little thing |
137 |
for (std::vector<ScoreboardSlot *>::iterator it= scoreboard_vector->begin(); |
1491.4.6
by Joe Daly
rework stats_schema use static char * for command strings |
138 |
it != scoreboard_vector->end(); ++it) |
139 |
{
|
|
140 |
scoreboard_slot= *it; |
|
1603
by Brian Aker
Remove current_session from usage in table stats logging. |
141 |
if (scoreboard_slot->getSessionId() == getSession().getSessionId()) |
1491.4.6
by Joe Daly
rework stats_schema use static char * for command strings |
142 |
{
|
143 |
break; |
|
144 |
}
|
|
145 |
}
|
|
146 |
||
147 |
user_commands= NULL; |
|
148 |
||
149 |
if (scoreboard_slot != NULL) |
|
150 |
{
|
|
151 |
user_commands= scoreboard_slot->getUserCommands(); |
|
152 |
}
|
|
153 |
}
|
|
154 |
||
155 |
bool SessionStatementsTool::Generator::populate() |
|
156 |
{
|
|
157 |
if (user_commands == NULL) |
|
158 |
{
|
|
159 |
return false; |
|
160 |
}
|
|
161 |
||
1491.4.12
by Joe Daly
add all the com_stats vars |
162 |
uint32_t number_identifiers= UserCommands::getStatusVarsCount(); |
1491.4.6
by Joe Daly
rework stats_schema use static char * for command strings |
163 |
|
164 |
if (count == number_identifiers) |
|
165 |
{
|
|
166 |
return false; |
|
167 |
}
|
|
168 |
||
1491.4.15
by Joe Daly
remove com_stat_vars and rework lock in scoreboard to not lock on Sessions locating a slot they previously owned |
169 |
push(UserCommands::COM_STATUS_VARS[count]); |
170 |
ostringstream oss; |
|
171 |
oss << user_commands->getCount(count); |
|
172 |
push(oss.str()); |
|
1491.4.6
by Joe Daly
rework stats_schema use static char * for command strings |
173 |
|
174 |
++count; |
|
175 |
return true; |
|
176 |
}
|
|
177 |
||
178 |
GlobalStatementsTool::GlobalStatementsTool(LoggingStats *in_logging_stats) : |
|
1491.4.25
by Joe Daly
disable logging_stats plugin and rename GLOBAL_STATEMENTS and SESSION_STATEMENTS tables to remove NEW tag |
179 |
plugin::TableFunction("DATA_DICTIONARY", "GLOBAL_STATEMENTS") |
1491.4.2
by Joe Daly
rework atomics on cumulative user tables |
180 |
{
|
1491.4.6
by Joe Daly
rework stats_schema use static char * for command strings |
181 |
logging_stats= in_logging_stats; |
1491.4.2
by Joe Daly
rework atomics on cumulative user tables |
182 |
add_field("VARIABLE_NAME"); |
1491.4.15
by Joe Daly
remove com_stat_vars and rework lock in scoreboard to not lock on Sessions locating a slot they previously owned |
183 |
add_field("VARIABLE_VALUE", 1024); |
1491.4.2
by Joe Daly
rework atomics on cumulative user tables |
184 |
}
|
185 |
||
1891.2.1
by Monty Taylor
Fixed things to make things compile with clang |
186 |
GlobalStatementsTool::Generator::Generator(Field **arg, LoggingStats *in_logging_stats) : |
1491.4.2
by Joe Daly
rework atomics on cumulative user tables |
187 |
plugin::TableFunction::Generator(arg) |
188 |
{
|
|
189 |
count= 0; |
|
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 |
190 |
/* add the current scoreboard and the saved global statements */
|
191 |
global_stats_to_display= new GlobalStats(); |
|
1891.2.1
by Monty Taylor
Fixed things to make things compile with clang |
192 |
CumulativeStats *cumulativeStats= in_logging_stats->getCumulativeStats(); |
193 |
cumulativeStats->sumCurrentScoreboard(in_logging_stats->getCurrentScoreboard(), |
|
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 |
194 |
NULL, global_stats_to_display->getUserCommands()); |
1891.2.1
by Monty Taylor
Fixed things to make things compile with clang |
195 |
global_stats_to_display->merge(in_logging_stats->getCumulativeStats()->getGlobalStats()); |
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 |
196 |
}
|
197 |
||
198 |
GlobalStatementsTool::Generator::~Generator() |
|
199 |
{
|
|
200 |
delete global_stats_to_display; |
|
1491.4.2
by Joe Daly
rework atomics on cumulative user tables |
201 |
}
|
202 |
||
1491.4.6
by Joe Daly
rework stats_schema use static char * for command strings |
203 |
bool GlobalStatementsTool::Generator::populate() |
1491.4.2
by Joe Daly
rework atomics on cumulative user tables |
204 |
{
|
1491.4.12
by Joe Daly
add all the com_stats vars |
205 |
uint32_t number_identifiers= UserCommands::getStatusVarsCount(); |
1491.4.6
by Joe Daly
rework stats_schema use static char * for command strings |
206 |
if (count == number_identifiers) |
1491.4.2
by Joe Daly
rework atomics on cumulative user tables |
207 |
{
|
208 |
return false; |
|
209 |
}
|
|
210 |
||
1491.4.15
by Joe Daly
remove com_stat_vars and rework lock in scoreboard to not lock on Sessions locating a slot they previously owned |
211 |
push(UserCommands::COM_STATUS_VARS[count]); |
212 |
ostringstream oss; |
|
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 |
213 |
oss << global_stats_to_display->getUserCommands()->getCount(count); |
1491.4.15
by Joe Daly
remove com_stat_vars and rework lock in scoreboard to not lock on Sessions locating a slot they previously owned |
214 |
push(oss.str()); |
1491.4.2
by Joe Daly
rework atomics on cumulative user tables |
215 |
|
216 |
++count; |
|
217 |
return true; |
|
218 |
}
|
|
219 |
||
1491.4.4
by Joe Daly
rework UserCommands class to have a simplier interface and remove get/increment functions |
220 |
CurrentCommandsTool::CurrentCommandsTool(LoggingStats *logging_stats) : |
1320.5.1
by Joe Daly
add cumulative stats |
221 |
plugin::TableFunction("DATA_DICTIONARY", "CURRENT_SQL_COMMANDS") |
1320.4.1
by Joe Daly
scoreboard implementation for statistics |
222 |
{
|
1491.4.4
by Joe Daly
rework UserCommands class to have a simplier interface and remove get/increment functions |
223 |
outer_logging_stats= logging_stats; |
1320.4.1
by Joe Daly
scoreboard implementation for statistics |
224 |
|
2029.1.26
by Brian Aker
Merge in work for reserved words in SQL standard. |
225 |
add_field("USERNAME"); |
1320.4.1
by Joe Daly
scoreboard implementation for statistics |
226 |
add_field("IP"); |
1491.4.4
by Joe Daly
rework UserCommands class to have a simplier interface and remove get/increment functions |
227 |
|
1491.4.12
by Joe Daly
add all the com_stats vars |
228 |
uint32_t number_commands= UserCommands::getUserCounts(); |
1491.4.9
by Joe Daly
remove Identifiers class and fix guard in header |
229 |
|
230 |
for (uint32_t j= 0; j < number_commands; ++j) |
|
1491.4.4
by Joe Daly
rework UserCommands class to have a simplier interface and remove get/increment functions |
231 |
{
|
1491.4.12
by Joe Daly
add all the com_stats vars |
232 |
add_field(UserCommands::USER_COUNTS[j], TableFunction::NUMBER); |
1491.4.9
by Joe Daly
remove Identifiers class and fix guard in header |
233 |
}
|
1320.4.1
by Joe Daly
scoreboard implementation for statistics |
234 |
}
|
235 |
||
1320.5.6
by Joe Daly
first pass at using a module vector approach of scoreboard |
236 |
CurrentCommandsTool::Generator::Generator(Field **arg, LoggingStats *logging_stats) : |
1320.4.1
by Joe Daly
scoreboard implementation for statistics |
237 |
plugin::TableFunction::Generator(arg) |
238 |
{
|
|
1491.4.4
by Joe Daly
rework UserCommands class to have a simplier interface and remove get/increment functions |
239 |
inner_logging_stats= logging_stats; |
240 |
||
241 |
isEnabled= inner_logging_stats->isEnabled(); |
|
1320.5.17
by Joe Daly
clean up some unneeded destructors and add update comments |
242 |
|
243 |
if (isEnabled == false) |
|
244 |
{
|
|
245 |
return; |
|
246 |
}
|
|
247 |
||
1320.5.6
by Joe Daly
first pass at using a module vector approach of scoreboard |
248 |
current_scoreboard= logging_stats->getCurrentScoreboard(); |
249 |
current_bucket= 0; |
|
1320.5.7
by Joe Daly
get tests to work, need to fix read lock on stats_schema current commands |
250 |
|
251 |
vector_of_scoreboard_vectors_it= current_scoreboard->getVectorOfScoreboardVectors()->begin(); |
|
252 |
vector_of_scoreboard_vectors_end= current_scoreboard->getVectorOfScoreboardVectors()->end(); |
|
253 |
||
1320.5.6
by Joe Daly
first pass at using a module vector approach of scoreboard |
254 |
setVectorIteratorsAndLock(current_bucket); |
1320.4.1
by Joe Daly
scoreboard implementation for statistics |
255 |
}
|
256 |
||
1320.5.6
by Joe Daly
first pass at using a module vector approach of scoreboard |
257 |
void CurrentCommandsTool::Generator::setVectorIteratorsAndLock(uint32_t bucket_number) |
258 |
{
|
|
1966.2.6
by Brian Aker
This is from the catalog patch (I'm pushing it up as its own little thing |
259 |
std::vector<ScoreboardSlot* > *scoreboard_vector= |
1320.5.6
by Joe Daly
first pass at using a module vector approach of scoreboard |
260 |
current_scoreboard->getVectorOfScoreboardVectors()->at(bucket_number); |
261 |
||
262 |
current_lock= current_scoreboard->getVectorOfScoreboardLocks()->at(bucket_number); |
|
263 |
||
1320.5.7
by Joe Daly
get tests to work, need to fix read lock on stats_schema current commands |
264 |
scoreboard_vector_it= scoreboard_vector->begin(); |
265 |
scoreboard_vector_end= scoreboard_vector->end(); |
|
1683.1.1
by Joe Daly
use boost for locking instead of pthread |
266 |
current_lock->lock_shared(); |
1320.4.1
by Joe Daly
scoreboard implementation for statistics |
267 |
}
|
268 |
||
1320.5.1
by Joe Daly
add cumulative stats |
269 |
bool CurrentCommandsTool::Generator::populate() |
1320.4.1
by Joe Daly
scoreboard implementation for statistics |
270 |
{
|
1320.5.7
by Joe Daly
get tests to work, need to fix read lock on stats_schema current commands |
271 |
if (isEnabled == false) |
1320.4.1
by Joe Daly
scoreboard implementation for statistics |
272 |
{
|
273 |
return false; |
|
274 |
}
|
|
1320.5.6
by Joe Daly
first pass at using a module vector approach of scoreboard |
275 |
|
1320.5.7
by Joe Daly
get tests to work, need to fix read lock on stats_schema current commands |
276 |
while (vector_of_scoreboard_vectors_it != vector_of_scoreboard_vectors_end) |
1320.5.6
by Joe Daly
first pass at using a module vector approach of scoreboard |
277 |
{
|
1320.5.7
by Joe Daly
get tests to work, need to fix read lock on stats_schema current commands |
278 |
while (scoreboard_vector_it != scoreboard_vector_end) |
279 |
{
|
|
280 |
ScoreboardSlot *scoreboard_slot= *scoreboard_vector_it; |
|
281 |
if (scoreboard_slot->isInUse()) |
|
282 |
{
|
|
283 |
UserCommands *user_commands= scoreboard_slot->getUserCommands(); |
|
284 |
push(scoreboard_slot->getUser()); |
|
285 |
push(scoreboard_slot->getIp()); |
|
1491.4.4
by Joe Daly
rework UserCommands class to have a simplier interface and remove get/increment functions |
286 |
|
1491.4.12
by Joe Daly
add all the com_stats vars |
287 |
uint32_t number_commands= UserCommands::getUserCounts(); |
1491.4.4
by Joe Daly
rework UserCommands class to have a simplier interface and remove get/increment functions |
288 |
|
1491.4.9
by Joe Daly
remove Identifiers class and fix guard in header |
289 |
for (uint32_t j= 0; j < number_commands; ++j) |
1491.4.4
by Joe Daly
rework UserCommands class to have a simplier interface and remove get/increment functions |
290 |
{
|
1491.4.12
by Joe Daly
add all the com_stats vars |
291 |
push(user_commands->getUserCount(j)); |
1491.4.4
by Joe Daly
rework UserCommands class to have a simplier interface and remove get/increment functions |
292 |
}
|
293 |
||
1320.5.20
by Joe Daly
fix incrementors |
294 |
++scoreboard_vector_it; |
1320.5.7
by Joe Daly
get tests to work, need to fix read lock on stats_schema current commands |
295 |
return true; |
296 |
}
|
|
1320.5.20
by Joe Daly
fix incrementors |
297 |
++scoreboard_vector_it; |
1320.5.7
by Joe Daly
get tests to work, need to fix read lock on stats_schema current commands |
298 |
}
|
299 |
||
1320.5.20
by Joe Daly
fix incrementors |
300 |
++vector_of_scoreboard_vectors_it; |
1683.1.1
by Joe Daly
use boost for locking instead of pthread |
301 |
current_lock->unlock_shared(); |
1320.5.21
by Joe Daly
fix incrementors to be prefix |
302 |
++current_bucket; |
1320.5.7
by Joe Daly
get tests to work, need to fix read lock on stats_schema current commands |
303 |
if (vector_of_scoreboard_vectors_it != vector_of_scoreboard_vectors_end) |
304 |
{
|
|
305 |
setVectorIteratorsAndLock(current_bucket); |
|
306 |
}
|
|
307 |
}
|
|
308 |
||
309 |
return false; |
|
1320.4.1
by Joe Daly
scoreboard implementation for statistics |
310 |
}
|
1320.5.1
by Joe Daly
add cumulative stats |
311 |
|
312 |
CumulativeCommandsTool::CumulativeCommandsTool(LoggingStats *logging_stats) : |
|
313 |
plugin::TableFunction("DATA_DICTIONARY", "CUMULATIVE_SQL_COMMANDS") |
|
314 |
{
|
|
315 |
outer_logging_stats= logging_stats; |
|
316 |
||
2029.1.26
by Brian Aker
Merge in work for reserved words in SQL standard. |
317 |
add_field("USERNAME"); |
1491.4.4
by Joe Daly
rework UserCommands class to have a simplier interface and remove get/increment functions |
318 |
|
1491.4.12
by Joe Daly
add all the com_stats vars |
319 |
uint32_t number_commands= UserCommands::getUserCounts(); |
1491.4.9
by Joe Daly
remove Identifiers class and fix guard in header |
320 |
|
321 |
for (uint32_t j= 0; j < number_commands; ++j) |
|
1491.4.4
by Joe Daly
rework UserCommands class to have a simplier interface and remove get/increment functions |
322 |
{
|
1491.4.12
by Joe Daly
add all the com_stats vars |
323 |
add_field(UserCommands::USER_COUNTS[j], TableFunction::NUMBER); |
1491.4.4
by Joe Daly
rework UserCommands class to have a simplier interface and remove get/increment functions |
324 |
}
|
1320.5.1
by Joe Daly
add cumulative stats |
325 |
}
|
326 |
||
1491.4.4
by Joe Daly
rework UserCommands class to have a simplier interface and remove get/increment functions |
327 |
CumulativeCommandsTool::Generator::Generator(Field **arg, LoggingStats *logging_stats) : |
1320.5.1
by Joe Daly
add cumulative stats |
328 |
plugin::TableFunction::Generator(arg) |
329 |
{
|
|
1491.4.4
by Joe Daly
rework UserCommands class to have a simplier interface and remove get/increment functions |
330 |
inner_logging_stats= logging_stats; |
1320.5.1
by Joe Daly
add cumulative stats |
331 |
record_number= 0; |
332 |
||
1491.4.4
by Joe Daly
rework UserCommands class to have a simplier interface and remove get/increment functions |
333 |
if (inner_logging_stats->isEnabled()) |
1320.5.1
by Joe Daly
add cumulative stats |
334 |
{
|
1491.4.4
by Joe Daly
rework UserCommands class to have a simplier interface and remove get/increment functions |
335 |
last_valid_index= inner_logging_stats->getCumulativeStats()->getCumulativeStatsLastValidIndex(); |
1320.5.1
by Joe Daly
add cumulative stats |
336 |
}
|
337 |
else
|
|
338 |
{
|
|
1491.4.2
by Joe Daly
rework atomics on cumulative user tables |
339 |
last_valid_index= INVALID_INDEX; |
1320.5.1
by Joe Daly
add cumulative stats |
340 |
}
|
341 |
}
|
|
342 |
||
343 |
bool CumulativeCommandsTool::Generator::populate() |
|
344 |
{
|
|
1491.4.2
by Joe Daly
rework atomics on cumulative user tables |
345 |
if ((record_number > last_valid_index) || (last_valid_index == INVALID_INDEX)) |
1320.5.1
by Joe Daly
add cumulative stats |
346 |
{
|
347 |
return false; |
|
348 |
}
|
|
349 |
||
1491.4.2
by Joe Daly
rework atomics on cumulative user tables |
350 |
while (record_number <= last_valid_index) |
351 |
{
|
|
352 |
ScoreboardSlot *cumulative_scoreboard_slot= |
|
1491.4.4
by Joe Daly
rework UserCommands class to have a simplier interface and remove get/increment functions |
353 |
inner_logging_stats->getCumulativeStats()->getCumulativeStatsByUserVector()->at(record_number); |
1491.4.2
by Joe Daly
rework atomics on cumulative user tables |
354 |
|
355 |
if (cumulative_scoreboard_slot->isInUse()) |
|
356 |
{
|
|
1491.4.4
by Joe Daly
rework UserCommands class to have a simplier interface and remove get/increment functions |
357 |
UserCommands *user_commands= cumulative_scoreboard_slot->getUserCommands(); |
1491.4.2
by Joe Daly
rework atomics on cumulative user tables |
358 |
push(cumulative_scoreboard_slot->getUser()); |
1491.4.4
by Joe Daly
rework UserCommands class to have a simplier interface and remove get/increment functions |
359 |
|
1491.4.12
by Joe Daly
add all the com_stats vars |
360 |
uint32_t number_commands= UserCommands::getUserCounts(); |
1491.4.4
by Joe Daly
rework UserCommands class to have a simplier interface and remove get/increment functions |
361 |
|
1491.4.9
by Joe Daly
remove Identifiers class and fix guard in header |
362 |
for (uint32_t j= 0; j < number_commands; ++j) |
1491.4.4
by Joe Daly
rework UserCommands class to have a simplier interface and remove get/increment functions |
363 |
{
|
1491.4.12
by Joe Daly
add all the com_stats vars |
364 |
push(user_commands->getUserCount(j)); |
1491.4.4
by Joe Daly
rework UserCommands class to have a simplier interface and remove get/increment functions |
365 |
}
|
1491.4.2
by Joe Daly
rework atomics on cumulative user tables |
366 |
++record_number; |
367 |
return true; |
|
368 |
}
|
|
369 |
else
|
|
370 |
{
|
|
371 |
++record_number; |
|
372 |
}
|
|
373 |
}
|
|
374 |
||
375 |
return false; |
|
1320.5.1
by Joe Daly
add cumulative stats |
376 |
}
|
1625.2.1
by Joe Daly
initial user stats impl |
377 |
|
378 |
CumulativeUserStatsTool::CumulativeUserStatsTool(LoggingStats *logging_stats) : |
|
379 |
plugin::TableFunction("DATA_DICTIONARY", "CUMULATIVE_USER_STATS") |
|
380 |
{
|
|
381 |
outer_logging_stats= logging_stats; |
|
382 |
||
2029.1.26
by Brian Aker
Merge in work for reserved words in SQL standard. |
383 |
add_field("USERNAME"); |
1625.2.1
by Joe Daly
initial user stats impl |
384 |
add_field("BYTES_RECEIVED"); |
385 |
add_field("BYTES_SENT"); |
|
386 |
add_field("DENIED_CONNECTIONS"); |
|
387 |
add_field("LOST_CONNECTIONS"); |
|
388 |
add_field("ACCESS_DENIED"); |
|
389 |
add_field("CONNECTED_TIME_SEC"); |
|
390 |
add_field("EXECUTION_TIME_NSEC"); |
|
1625.2.2
by Joe Daly
add counter logic for rows sent/received/inserted/updated |
391 |
add_field("ROWS_FETCHED"); |
392 |
add_field("ROWS_UPDATED"); |
|
393 |
add_field("ROWS_DELETED"); |
|
394 |
add_field("ROWS_INSERTED"); |
|
1625.2.1
by Joe Daly
initial user stats impl |
395 |
}
|
396 |
||
397 |
CumulativeUserStatsTool::Generator::Generator(Field **arg, LoggingStats *logging_stats) : |
|
398 |
plugin::TableFunction::Generator(arg) |
|
399 |
{
|
|
400 |
inner_logging_stats= logging_stats; |
|
401 |
record_number= 0; |
|
402 |
||
403 |
if (inner_logging_stats->isEnabled()) |
|
404 |
{
|
|
405 |
last_valid_index= inner_logging_stats->getCumulativeStats()->getCumulativeStatsLastValidIndex(); |
|
406 |
}
|
|
407 |
else
|
|
408 |
{
|
|
409 |
last_valid_index= INVALID_INDEX; |
|
410 |
}
|
|
411 |
}
|
|
412 |
||
413 |
bool CumulativeUserStatsTool::Generator::populate() |
|
414 |
{
|
|
415 |
if ((record_number > last_valid_index) || (last_valid_index == INVALID_INDEX)) |
|
416 |
{
|
|
417 |
return false; |
|
418 |
}
|
|
419 |
||
420 |
while (record_number <= last_valid_index) |
|
421 |
{
|
|
422 |
ScoreboardSlot *cumulative_scoreboard_slot= |
|
423 |
inner_logging_stats->getCumulativeStats()->getCumulativeStatsByUserVector()->at(record_number); |
|
424 |
||
425 |
if (cumulative_scoreboard_slot->isInUse()) |
|
426 |
{
|
|
427 |
StatusVars *status_vars= cumulative_scoreboard_slot->getStatusVars(); |
|
428 |
push(cumulative_scoreboard_slot->getUser()); |
|
429 |
||
430 |
push(status_vars->getStatusVarCounters()->bytes_received); |
|
431 |
push(status_vars->getStatusVarCounters()->bytes_sent); |
|
432 |
push(status_vars->getStatusVarCounters()->aborted_connects); |
|
433 |
push(status_vars->getStatusVarCounters()->aborted_threads); |
|
434 |
push(status_vars->getStatusVarCounters()->access_denied); |
|
435 |
push(status_vars->getStatusVarCounters()->connection_time); |
|
436 |
push(status_vars->getStatusVarCounters()->execution_time_nsec); |
|
1625.2.2
by Joe Daly
add counter logic for rows sent/received/inserted/updated |
437 |
push(status_vars->sent_row_count); |
438 |
push(status_vars->getStatusVarCounters()->updated_row_count); |
|
439 |
push(status_vars->getStatusVarCounters()->deleted_row_count); |
|
440 |
push(status_vars->getStatusVarCounters()->inserted_row_count); |
|
441 |
||
1625.2.1
by Joe Daly
initial user stats impl |
442 |
++record_number; |
443 |
return true; |
|
444 |
}
|
|
445 |
else
|
|
446 |
{
|
|
447 |
++record_number; |
|
448 |
}
|
|
449 |
}
|
|
450 |
||
451 |
return false; |
|
452 |
}
|
|
1711.7.2
by Joseph Daly
add memory usage |
453 |
|
454 |
ScoreboardStatsTool::ScoreboardStatsTool(LoggingStats *logging_stats) : |
|
455 |
plugin::TableFunction("DATA_DICTIONARY", "SCOREBOARD_STATISTICS") |
|
456 |
{
|
|
457 |
outer_logging_stats= logging_stats; |
|
458 |
||
459 |
add_field("SCOREBOARD_SIZE", TableFunction::NUMBER); |
|
460 |
add_field("NUMBER_OF_RANGE_LOCKS", TableFunction::NUMBER); |
|
461 |
add_field("MAX_USERS_LOGGED", TableFunction::NUMBER); |
|
462 |
add_field("MEMORY_USAGE_BYTES", TableFunction::NUMBER); |
|
463 |
}
|
|
464 |
||
465 |
ScoreboardStatsTool::Generator::Generator(Field **arg, LoggingStats *logging_stats) : |
|
466 |
plugin::TableFunction::Generator(arg) |
|
467 |
{
|
|
468 |
inner_logging_stats= logging_stats; |
|
469 |
is_last_record= false; |
|
470 |
}
|
|
471 |
||
472 |
bool ScoreboardStatsTool::Generator::populate() |
|
473 |
{
|
|
474 |
if (is_last_record) |
|
475 |
{
|
|
476 |
return false; |
|
477 |
}
|
|
478 |
||
479 |
Scoreboard *scoreboard= inner_logging_stats->getCurrentScoreboard(); |
|
480 |
CumulativeStats *cumulativeStats= inner_logging_stats->getCumulativeStats(); |
|
481 |
||
482 |
push(static_cast<uint64_t>(scoreboard->getNumberPerBucket() * scoreboard->getNumberBuckets())); |
|
483 |
push(static_cast<uint64_t>(scoreboard->getNumberBuckets())); |
|
484 |
push(static_cast<uint64_t>(cumulativeStats->getCumulativeStatsByUserMax())); |
|
485 |
push(cumulativeStats->getCumulativeSizeBytes() + scoreboard->getScoreboardSizeBytes()); |
|
486 |
||
487 |
is_last_record= true; |
|
488 |
||
489 |
return true; |
|
490 |
}
|