Drizzled Public API Documentation

stats_schema.h
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 #pragma once
31 
32 #include <drizzled/plugin/table_function.h>
33 #include <drizzled/field.h>
34 
35 #include "user_commands.h"
36 #include "global_stats.h"
37 #include "logging_stats.h"
38 
39 #include <vector>
40 
42 {
43 public:
44  GlobalStatementsTool(LoggingStats *logging_stats);
45 
47  {
48  public:
49  Generator(drizzled::Field **arg, LoggingStats *logging_stats);
50 
51  ~Generator();
52 
53  bool populate();
54 
55  private:
56  GlobalStats *global_stats_to_display;
57  uint32_t count;
58  };
59 
60  Generator *generator(drizzled::Field **arg)
61  {
62  return new Generator(arg, logging_stats);
63  }
64 
65 private:
66  LoggingStats *logging_stats;
67 };
68 
70 {
71 public:
72  SessionStatementsTool(LoggingStats *logging_stats);
73 
75  {
76  public:
77  Generator(drizzled::Field **arg, LoggingStats *logging_stats);
78 
79  bool populate();
80 
81  private:
82  UserCommands *user_commands;
83  uint32_t count;
84  };
85 
86  Generator *generator(drizzled::Field **arg)
87  {
88  return new Generator(arg, logging_stats);
89  }
90 
91 private:
92  LoggingStats *logging_stats;
93 };
94 
96 {
97 public:
98 
99  CurrentCommandsTool(LoggingStats *logging_stats);
100 
102  {
103  public:
104  Generator(drizzled::Field **arg, LoggingStats *logging_stats);
105 
106  bool populate();
107  private:
108  LoggingStats *inner_logging_stats;
109  Scoreboard *current_scoreboard;
110  uint32_t current_bucket;
111  bool isEnabled;
112  std::vector<ScoreboardSlot *>::iterator scoreboard_vector_it;
113  std::vector<ScoreboardSlot *>::iterator scoreboard_vector_end;
114  std::vector<std::vector<ScoreboardSlot* >* >::iterator vector_of_scoreboard_vectors_it;
115  std::vector<std::vector<ScoreboardSlot* >* >::iterator vector_of_scoreboard_vectors_end;
116  boost::shared_mutex* current_lock;
117 
118  void setVectorIteratorsAndLock(uint32_t bucket_number);
119  };
120 
121  Generator *generator(drizzled::Field **arg)
122  {
123  return new Generator(arg, outer_logging_stats);
124  }
125 private:
126  LoggingStats *outer_logging_stats;
127 };
128 
130 {
131 public:
132 
133  CumulativeCommandsTool(LoggingStats *logging_stats);
134 
136  {
137  public:
138  Generator(drizzled::Field **arg, LoggingStats *logging_stats);
139 
140  bool populate();
141  private:
142  LoggingStats *inner_logging_stats;
143  int32_t record_number;
144  int32_t last_valid_index;
145  };
146 
147  Generator *generator(drizzled::Field **arg)
148  {
149  return new Generator(arg, outer_logging_stats);
150  }
151 private:
152  LoggingStats *outer_logging_stats;
153 };
154 
156 {
157 public:
158 
159  CumulativeUserStatsTool(LoggingStats *logging_stats);
160 
162  {
163  public:
164  Generator(drizzled::Field **arg, LoggingStats *logging_stats);
165 
166  bool populate();
167  private:
168  LoggingStats *inner_logging_stats;
169  int32_t record_number;
170  int32_t last_valid_index;
171  };
172 
173  Generator *generator(drizzled::Field **arg)
174  {
175  return new Generator(arg, outer_logging_stats);
176  }
177 private:
178  LoggingStats *outer_logging_stats;
179 };
180 
182 {
183 public:
184 
185  ScoreboardStatsTool(LoggingStats *logging_stats);
186 
188  {
189  public:
190  Generator(drizzled::Field **arg, LoggingStats *logging_stats);
191 
192  bool populate();
193  private:
194  LoggingStats *inner_logging_stats;
195  bool is_last_record;
196  };
197 
198  Generator *generator(drizzled::Field **arg)
199  {
200  return new Generator(arg, outer_logging_stats);
201  }
202 private:
203  LoggingStats *outer_logging_stats;
204 };
205