~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/logging_stats/logging_stats.cc

  • Committer: Olaf van der Spek
  • Date: 2011-04-05 12:26:58 UTC
  • mto: (2278.1.2 build)
  • mto: This revision was merged to the branch mainline in revision 2272.
  • Revision ID: olafvdspek@gmail.com-20110405122658-xxrvmobwwwwf3oct
Refactor Open_tables_state

Show diffs side-by-side

added added

removed removed

Lines of Context:
94
94
#include <boost/program_options.hpp>
95
95
#include <drizzled/module/option_map.h>
96
96
#include <drizzled/session.h>
 
97
#include <drizzled/sql_lex.h>
 
98
#include <drizzled/statistics_variables.h>
97
99
 
98
100
namespace po= boost::program_options;
99
101
using namespace drizzled;
128
130
void LoggingStats::updateCurrentScoreboard(ScoreboardSlot *scoreboard_slot,
129
131
                                           Session *session)
130
132
{
131
 
  enum_sql_command sql_command= session->getLex()->sql_command;
 
133
  enum_sql_command sql_command= session->lex().sql_command;
132
134
 
133
135
  scoreboard_slot->getUserCommands()->logCommand(sql_command);
134
136
 
268
270
  }
269
271
}
270
272
 
271
 
static bool initTable()
272
 
{
273
 
  current_commands_tool= new(nothrow)CurrentCommandsTool(logging_stats);
274
 
 
275
 
  if (! current_commands_tool)
276
 
  {
277
 
    return true;
278
 
  }
279
 
 
280
 
  cumulative_commands_tool= new(nothrow)CumulativeCommandsTool(logging_stats);
281
 
 
282
 
  if (! cumulative_commands_tool)
283
 
  {
284
 
    return true;
285
 
  }
286
 
 
287
 
  global_statements_tool= new(nothrow)GlobalStatementsTool(logging_stats);
288
 
 
289
 
  if (! global_statements_tool)
290
 
  {
291
 
    return true;
292
 
  }
293
 
 
294
 
  session_statements_tool= new(nothrow)SessionStatementsTool(logging_stats);
295
 
 
296
 
  if (! session_statements_tool)
297
 
  {
298
 
    return true;
299
 
  }
300
 
 
301
 
  session_status_tool= new(nothrow)StatusTool(logging_stats, true);
302
 
 
303
 
  if (! session_status_tool)
304
 
  {
305
 
    return true;
306
 
  }
307
 
 
308
 
  global_status_tool= new(nothrow)StatusTool(logging_stats, false);
309
 
 
310
 
  if (! global_status_tool)
311
 
  {
312
 
    return true;
313
 
  }
314
 
 
315
 
  cumulative_user_stats_tool= new(nothrow)CumulativeUserStatsTool(logging_stats);
316
 
 
317
 
  if (! cumulative_user_stats_tool)
318
 
  {
319
 
    return true;
320
 
  }
321
 
 
322
 
  scoreboard_stats_tool= new(nothrow)ScoreboardStatsTool(logging_stats);
323
 
  
324
 
  if (! scoreboard_stats_tool)
325
 
  {
326
 
    return true;
327
 
  }
328
 
 
329
 
  return false;
330
 
}
331
 
 
332
273
static int init(drizzled::module::Context &context)
333
274
{
334
275
  const module::option_map &vm= context.getOptions();
335
 
 
336
 
  sysvar_logging_stats_enabled= (vm.count("disable")) ? false : true;
 
276
  sysvar_logging_stats_enabled= not vm.count("disable");
337
277
 
338
278
  logging_stats= new LoggingStats("logging_stats");
339
 
 
340
 
  if (initTable())
341
 
  {
342
 
    return 1;
343
 
  }
 
279
  current_commands_tool= new CurrentCommandsTool(logging_stats);
 
280
  cumulative_commands_tool= new CumulativeCommandsTool(logging_stats);
 
281
  global_statements_tool= new GlobalStatementsTool(logging_stats);
 
282
  session_statements_tool= new SessionStatementsTool(logging_stats);
 
283
  session_status_tool= new StatusTool(logging_stats, true);
 
284
  global_status_tool= new StatusTool(logging_stats, false);
 
285
  cumulative_user_stats_tool= new CumulativeUserStatsTool(logging_stats);
 
286
  scoreboard_stats_tool= new ScoreboardStatsTool(logging_stats);
344
287
 
345
288
  context.add(logging_stats);
346
289
  context.add(current_commands_tool);
353
296
  context.add(scoreboard_stats_tool);
354
297
 
355
298
  if (sysvar_logging_stats_enabled)
356
 
  {
357
299
    logging_stats->enable();
358
 
  }
359
300
 
360
301
  context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("max_user_count", sysvar_logging_stats_max_user_count));
361
302
  context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("bucket_count", sysvar_logging_stats_bucket_count));