Drizzled Public API Documentation

stats_schema.h

00001 /*
00002  * Copyright (C) 2010 Joseph Daly <skinny.moey@gmail.com>
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions are met:
00007  *
00008  *   * Redistributions of source code must retain the above copyright notice,
00009  *     this list of conditions and the following disclaimer.
00010  *   * Redistributions in binary form must reproduce the above copyright notice,
00011  *     this list of conditions and the following disclaimer in the documentation
00012  *     and/or other materials provided with the distribution.
00013  *   * Neither the name of Joseph Daly nor the names of its contributors
00014  *     may be used to endorse or promote products derived from this software
00015  *     without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00018  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
00021  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00022  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00023  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00024  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00025  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00026  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
00027  * THE POSSIBILITY OF SUCH DAMAGE.
00028  */
00029 
00030 #pragma once
00031 
00032 #include <drizzled/plugin/table_function.h>
00033 #include <drizzled/field.h>
00034 
00035 #include "user_commands.h"
00036 #include "global_stats.h"
00037 #include "logging_stats.h"
00038 
00039 #include <vector>
00040 
00041 class GlobalStatementsTool : public drizzled::plugin::TableFunction
00042 {
00043 public:
00044   GlobalStatementsTool(LoggingStats *logging_stats);
00045 
00046   class Generator : public drizzled::plugin::TableFunction::Generator
00047   {
00048   public:
00049     Generator(drizzled::Field **arg, LoggingStats *logging_stats);
00050 
00051     ~Generator();
00052 
00053     bool populate();
00054 
00055   private:
00056     GlobalStats *global_stats_to_display; 
00057     uint32_t count;
00058   };
00059 
00060   Generator *generator(drizzled::Field **arg)
00061   {
00062     return new Generator(arg, logging_stats);
00063   }
00064 
00065 private:
00066   LoggingStats *logging_stats;
00067 };
00068 
00069 class SessionStatementsTool : public drizzled::plugin::TableFunction
00070 {
00071 public:
00072   SessionStatementsTool(LoggingStats *logging_stats);
00073 
00074   class Generator : public drizzled::plugin::TableFunction::Generator
00075   {
00076   public:
00077     Generator(drizzled::Field **arg, LoggingStats *logging_stats);
00078 
00079     bool populate();
00080 
00081   private:
00082     UserCommands *user_commands;
00083     uint32_t count;
00084   };
00085 
00086   Generator *generator(drizzled::Field **arg)
00087   {
00088     return new Generator(arg, logging_stats);
00089   }
00090 
00091 private:
00092   LoggingStats *logging_stats;
00093 };
00094 
00095 class CurrentCommandsTool : public drizzled::plugin::TableFunction
00096 {
00097 public:
00098 
00099   CurrentCommandsTool(LoggingStats *logging_stats);
00100 
00101   class Generator : public drizzled::plugin::TableFunction::Generator
00102   {
00103   public:
00104     Generator(drizzled::Field **arg, LoggingStats *logging_stats);
00105 
00106     bool populate();
00107   private:
00108     LoggingStats *inner_logging_stats; 
00109     Scoreboard *current_scoreboard; 
00110     uint32_t current_bucket;
00111     bool isEnabled;
00112     std::vector<ScoreboardSlot *>::iterator scoreboard_vector_it;
00113     std::vector<ScoreboardSlot *>::iterator scoreboard_vector_end;
00114     std::vector<std::vector<ScoreboardSlot* >* >::iterator vector_of_scoreboard_vectors_it;
00115     std::vector<std::vector<ScoreboardSlot* >* >::iterator vector_of_scoreboard_vectors_end; 
00116     boost::shared_mutex* current_lock;
00117 
00118     void setVectorIteratorsAndLock(uint32_t bucket_number);
00119   };
00120 
00121   Generator *generator(drizzled::Field **arg)
00122   {
00123     return new Generator(arg, outer_logging_stats);
00124   }
00125 private:
00126   LoggingStats *outer_logging_stats;
00127 };
00128 
00129 class CumulativeCommandsTool : public drizzled::plugin::TableFunction
00130 {
00131 public:
00132 
00133   CumulativeCommandsTool(LoggingStats *logging_stats);
00134 
00135   class Generator : public drizzled::plugin::TableFunction::Generator
00136   {
00137   public:
00138     Generator(drizzled::Field **arg, LoggingStats *logging_stats);
00139 
00140     bool populate();
00141   private:
00142     LoggingStats *inner_logging_stats;
00143     int32_t record_number;
00144     int32_t last_valid_index;
00145   };
00146 
00147   Generator *generator(drizzled::Field **arg)
00148   {
00149     return new Generator(arg, outer_logging_stats);
00150   }
00151 private:
00152   LoggingStats *outer_logging_stats;
00153 };
00154 
00155 class CumulativeUserStatsTool : public drizzled::plugin::TableFunction
00156 {
00157 public:
00158 
00159   CumulativeUserStatsTool(LoggingStats *logging_stats);
00160 
00161   class Generator : public drizzled::plugin::TableFunction::Generator
00162   {
00163   public:
00164     Generator(drizzled::Field **arg, LoggingStats *logging_stats);
00165 
00166     bool populate();
00167   private:
00168     LoggingStats *inner_logging_stats;
00169     int32_t record_number;
00170     int32_t last_valid_index;
00171   };
00172 
00173   Generator *generator(drizzled::Field **arg)
00174   {
00175     return new Generator(arg, outer_logging_stats);
00176   }
00177 private:
00178   LoggingStats *outer_logging_stats;
00179 };
00180 
00181 class ScoreboardStatsTool : public drizzled::plugin::TableFunction
00182 {
00183 public:
00184 
00185   ScoreboardStatsTool(LoggingStats *logging_stats);
00186 
00187   class Generator : public drizzled::plugin::TableFunction::Generator
00188   {
00189   public:
00190     Generator(drizzled::Field **arg, LoggingStats *logging_stats);
00191 
00192     bool populate();
00193   private:
00194     LoggingStats *inner_logging_stats;
00195     bool is_last_record;
00196   };
00197 
00198   Generator *generator(drizzled::Field **arg)
00199   {
00200     return new Generator(arg, outer_logging_stats);
00201   }
00202 private:
00203   LoggingStats *outer_logging_stats;
00204 };
00205