2
* Copyright (C) 2009 Sun Microsystems
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
#include "drizzled/server_includes.h"
20
#include "drizzled/show.h"
21
#include "drizzled/gettext.h"
22
#include "drizzled/info_schema.h"
24
#include "stats_table.h"
30
using namespace drizzled;
33
* Vectors of columns for I_S tables.
35
static vector<const ColumnInfo *> memcached_stats_columns;
38
* Methods for I_S tables.
40
static InfoSchemaMethods *memcached_stats_methods= NULL;
45
static InfoSchemaTable *memcached_stats_table= NULL;
48
* System variable related variables.
50
static char *sysvar_memcached_servers= NULL;
51
static const char DEFAULT_SERVERS_STRING[]= "localhost:11211";
54
* Populate the vectors of columns for each I_S table.
56
* @return false on success; true on failure.
58
static bool initColumns()
60
if (createMemcachedStatsColumns(memcached_stats_columns))
69
* Clear the vectors of columns for each I_S table.
71
static void cleanupColumns()
73
clearMemcachedColumns(memcached_stats_columns);
77
* Initialize the methods for each I_S table.
79
* @return false on success; true on failure
81
static bool initMethods()
83
memcached_stats_methods= new(std::nothrow)
84
MemcachedStatsISMethods(sysvar_memcached_servers);
85
if (! memcached_stats_methods)
94
* Delete memory allocated for the I_S table methods.
96
static void cleanupMethods()
98
delete memcached_stats_methods;
102
* Initialize the I_S tables related to memcached.
104
* @return false on success; true on failure
106
static bool initMemcachedTables()
108
memcached_stats_table= new(std::nothrow) InfoSchemaTable("MEMCACHED_STATS",
109
memcached_stats_columns,
110
-1, -1, false, false, 0,
111
memcached_stats_methods);
112
if (! memcached_stats_table)
121
* Delete memory allocated for the I_S tables.
123
static void cleanupMemcachedTables()
125
delete memcached_stats_table;
129
* Initialize the memcached stats plugin.
131
* @param[in] registry the drizzled::plugin::Registry singleton
132
* @return false on success; true on failure.
134
static int init(plugin::Registry ®istry)
146
if (initMemcachedTables())
151
/* we are good to go */
152
registry.add(memcached_stats_table);
158
* Clean up the memcached stats plugin.
160
* @param[in] registry the drizzled::plugin::Registry singleton
161
* @return false on success; true on failure
163
static int deinit(plugin::Registry ®istry)
165
registry.remove(memcached_stats_table);
169
cleanupMemcachedTables();
174
static DRIZZLE_SYSVAR_STR(servers,
175
sysvar_memcached_servers,
177
N_("List of memcached servers."),
178
NULL, /* check func */
179
NULL, /* update func */
180
DEFAULT_SERVERS_STRING);
182
static struct st_mysql_sys_var *system_variables[]=
184
DRIZZLE_SYSVAR(servers),
188
drizzle_declare_plugin(memcached_stats)
192
"Padraig O'Sullivan",
193
N_("Memcached Stats as I_S tables"),
195
init, /* Plugin Init */
196
deinit, /* Plugin Deinit */
197
NULL, /* status variables */
198
system_variables, /* system variables */
199
NULL /* config options */
201
drizzle_declare_plugin_end;