~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/memcached_stats/memcached_stats.cc

  • Committer: Jay Pipes
  • Date: 2009-09-15 21:01:42 UTC
  • mto: (1126.2.5 merge)
  • mto: This revision was merged to the branch mainline in revision 1128.
  • Revision ID: jpipes@serialcoder-20090915210142-x8mwiqn1q0vzjspp
Moves Alter_info out into its own header and source file, cleans up some related include mess in sql_lex.h, and renames Alter_info to AlterInfo.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* 
2
 
 * Copyright (C) 2009, Padraig O'Sullivan
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 Padraig O'Sullivan 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
 
#include "config.h"
31
 
#include "drizzled/show.h"
32
 
#include "drizzled/gettext.h"
33
 
#include <boost/program_options.hpp>
34
 
#include <drizzled/module/option_map.h>
35
 
#include "stats_table.h"
36
 
#include "analysis_table.h"
37
 
#include "sysvar_holder.h"
38
 
 
39
 
#include <string>
40
 
#include <map>
41
 
 
42
 
namespace po=boost::program_options;
43
 
 
44
 
namespace drizzle_plugin
45
 
{
46
 
 
47
 
 
48
 
/*
49
 
 * DATA_DICTIONARY tables.
50
 
 */
51
 
static AnalysisTableTool *analysis_table_tool; 
52
 
 
53
 
static StatsTableTool *stats_table_tool;
54
 
 
55
 
/*
56
 
 * System variable related variables.
57
 
 */
58
 
static std::string sysvar_memcached_servers;
59
 
 
60
 
/**
61
 
 * Initialize the memcached stats plugin.
62
 
 *
63
 
 * @param[in] registry the drizzled::plugin::Registry singleton
64
 
 * @return false on success; true on failure.
65
 
 */
66
 
static int init(drizzled::module::Context &context)
67
 
{
68
 
  const drizzled::module::option_map &vm= context.getOptions();
69
 
 
70
 
  /* we are good to go */
71
 
  stats_table_tool= new StatsTableTool; 
72
 
  context.add(stats_table_tool);
73
 
 
74
 
  analysis_table_tool= new AnalysisTableTool;
75
 
  context.add(analysis_table_tool);
76
 
 
77
 
  context.registerVariable(new sys_var_std_string("servers",
78
 
                                                  sysvar_memcached_servers));
79
 
                          
80
 
  return 0;
81
 
}
82
 
 
83
 
static void init_options(drizzled::module::option_context &context)
84
 
{
85
 
  context("servers",
86
 
          po::value<std::string>()->default_value(""),
87
 
          _("List of memcached servers."));
88
 
}
89
 
 
90
 
} /* namespace drizzle_plugin */
91
 
 
92
 
DRIZZLE_DECLARE_PLUGIN
93
 
{
94
 
  DRIZZLE_VERSION_ID,
95
 
  "memcached_stats",
96
 
  "1.0",
97
 
  "Padraig O'Sullivan",
98
 
  N_("Memcached Stats as I_S tables"),
99
 
  PLUGIN_LICENSE_BSD,
100
 
  drizzle_plugin::init,   /* Plugin Init      */
101
 
  NULL, /* depends */
102
 
  drizzle_plugin::init_options    /* config options   */
103
 
}
104
 
DRIZZLE_DECLARE_PLUGIN_END;