27
27
* THE POSSIBILITY OF SUCH DAMAGE.
31
#include <drizzled/show.h>
32
#include <drizzled/gettext.h>
33
#include <boost/program_options.hpp>
34
#include <drizzled/module/option_map.h>
31
#include "drizzled/show.h"
32
#include "drizzled/gettext.h"
33
#include "drizzled/plugin/info_schema_table.h"
35
35
#include "stats_table.h"
36
36
#include "analysis_table.h"
37
37
#include "sysvar_holder.h"
63
60
* @param[in] registry the drizzled::plugin::Registry singleton
64
61
* @return false on success; true on failure.
66
static int init(drizzled::module::Context &context)
63
static int init(plugin::Registry ®istry)
68
const drizzled::module::option_map &vm= context.getOptions();
66
SysvarHolder &sysvar_holder= SysvarHolder::singleton();
67
sysvar_holder.setServersString(sysvar_memcached_servers);
70
69
/* we are good to go */
71
stats_table_tool= new StatsTableTool;
72
context.add(stats_table_tool);
74
analysis_table_tool= new AnalysisTableTool;
75
context.add(analysis_table_tool);
77
context.registerVariable(new sys_var_std_string("servers",
78
sysvar_memcached_servers));
83
static void init_options(drizzled::module::option_context &context)
86
po::value<std::string>()->default_value(""),
87
_("List of memcached servers."));
90
} /* namespace drizzle_plugin */
70
stats_table_tool= new(std::nothrow)StatsTableTool;
71
registry.add(stats_table_tool);
73
analysis_table_tool= new(std::nothrow)AnalysisTableTool;
74
registry.add(analysis_table_tool);
80
* Clean up the memcached stats plugin.
82
* @param[in] registry the drizzled::plugin::Registry singleton
83
* @return false on success; true on failure
85
static int deinit(plugin::Registry ®istry)
87
registry.remove(stats_table_tool);
88
delete stats_table_tool;
89
registry.remove(analysis_table_tool);
90
delete analysis_table_tool;
94
static int check_memc_servers(Session *,
99
char buff[STRING_BUFFER_USUAL_SIZE];
100
int len= sizeof(buff);
101
const char *input= value->val_str(value, buff, &len);
105
SysvarHolder &sysvar_holder= SysvarHolder::singleton();
106
sysvar_holder.setServersStringVar(input);
107
*(bool *) save= (bool) true;
111
*(bool *) save= (bool) false;
115
static void set_memc_servers(Session *,
120
if (*(bool *) save != false)
122
SysvarHolder &sysvar_holder= SysvarHolder::singleton();
123
sysvar_holder.updateServersSysvar((const char **) var_ptr);
127
static DRIZZLE_SYSVAR_STR(servers,
128
sysvar_memcached_servers,
130
N_("List of memcached servers."),
131
check_memc_servers, /* check func */
132
set_memc_servers, /* update func */
133
""); /* default value */
135
static drizzle_sys_var *system_variables[]=
137
DRIZZLE_SYSVAR(servers),
92
141
DRIZZLE_DECLARE_PLUGIN
97
146
"Padraig O'Sullivan",
98
147
N_("Memcached Stats as I_S tables"),
99
148
PLUGIN_LICENSE_BSD,
100
drizzle_plugin::init, /* Plugin Init */
102
drizzle_plugin::init_options /* config options */
149
init, /* Plugin Init */
150
deinit, /* Plugin Deinit */
151
system_variables, /* system variables */
152
NULL /* config options */
104
154
DRIZZLE_DECLARE_PLUGIN_END;