61
63
* @param[in] registry the drizzled::plugin::Registry singleton
62
64
* @return false on success; true on failure.
64
static int init(module::Context &context)
66
static int init(drizzled::module::Context &context)
66
const module::option_map &vm= context.getOptions();
68
if(vm.count("servers"))
70
sysvar_memcached_servers= strdup(vm["servers"].as<string>().c_str());
75
sysvar_memcached_servers= strdup("");
78
SysvarHolder &sysvar_holder= SysvarHolder::singleton();
79
sysvar_holder.setServersString(sysvar_memcached_servers);
80
sysvar_holder.setMemoryPtr(sysvar_memcached_servers);
68
const drizzled::module::option_map &vm= context.getOptions();
82
70
/* we are good to go */
83
stats_table_tool= new(std::nothrow)StatsTableTool;
71
stats_table_tool= new StatsTableTool;
84
72
context.add(stats_table_tool);
86
analysis_table_tool= new(std::nothrow)AnalysisTableTool;
74
analysis_table_tool= new AnalysisTableTool;
87
75
context.add(analysis_table_tool);
77
context.registerVariable(new sys_var_std_string("servers",
78
sysvar_memcached_servers));
92
static int check_memc_servers(Session *,
97
char buff[STRING_BUFFER_USUAL_SIZE];
98
int len= sizeof(buff);
99
const char *input= value->val_str(value, buff, &len);
103
SysvarHolder &sysvar_holder= SysvarHolder::singleton();
104
sysvar_holder.setServersStringVar(input);
105
*(bool *) save= (bool) true;
109
*(bool *) save= (bool) false;
113
static void set_memc_servers(Session *,
118
if (*(bool *) save != false)
120
SysvarHolder &sysvar_holder= SysvarHolder::singleton();
121
sysvar_holder.updateServersSysvar((const char **) var_ptr);
125
static DRIZZLE_SYSVAR_STR(servers,
126
sysvar_memcached_servers,
128
N_("List of memcached servers."),
129
check_memc_servers, /* check func */
130
set_memc_servers, /* update func */
131
""); /* default value */
133
83
static void init_options(drizzled::module::option_context &context)
135
85
context("servers",
86
po::value<std::string>()->default_value(""),
137
87
N_("List of memcached servers."));
140
static drizzle_sys_var *system_variables[]=
142
DRIZZLE_SYSVAR(servers),
90
} /* namespace drizzle_plugin */
146
92
DRIZZLE_DECLARE_PLUGIN
151
97
"Padraig O'Sullivan",
152
98
N_("Memcached Stats as I_S tables"),
153
99
PLUGIN_LICENSE_BSD,
154
init, /* Plugin Init */
155
system_variables, /* system variables */
156
init_options /* config options */
100
drizzle_plugin::init, /* Plugin Init */
101
NULL, /* system variables */
102
drizzle_plugin::init_options /* config options */
158
104
DRIZZLE_DECLARE_PLUGIN_END;