~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/memcached_stats/memcached_stats.cc

  • Committer: Brian Aker
  • Date: 2010-02-20 01:44:37 UTC
  • mfrom: (1273.13.94 build)
  • Revision ID: brian@gaz-20100220014437-0l1jlxf79lzeglwq
Merge JDaly, Lint fixes by brian.

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
using namespace drizzled;
44
44
 
45
45
/*
46
 
 * Vectors of columns for I_S tables.
47
 
 */
48
 
static vector<const plugin::ColumnInfo *> memcached_stats_columns;
49
 
static vector<const plugin::ColumnInfo *> memcached_analysis_columns;
50
 
 
51
 
/*
52
 
 * Methods for I_S tables.
53
 
 */
54
 
static plugin::InfoSchemaMethods *memcached_stats_methods= NULL;
55
 
static plugin::InfoSchemaMethods *memcached_analysis_methods= NULL;
56
 
 
57
 
/*
58
 
 * I_S tables.
59
 
 */
60
 
static plugin::InfoSchemaTable *memcached_stats_table= NULL;
61
 
static plugin::InfoSchemaTable *memcached_analysis_table= NULL;
 
46
 * DATA_DICTIONARY tables.
 
47
 */
 
48
static AnalysisTableTool *analysis_table_tool; 
 
49
 
 
50
static StatsTableTool *stats_table_tool;
62
51
 
63
52
/*
64
53
 * System variable related variables.
66
55
static char *sysvar_memcached_servers= NULL;
67
56
 
68
57
/**
69
 
 * Populate the vectors of columns for each I_S table.
70
 
 *
71
 
 * @return false on success; true on failure.
72
 
 */
73
 
static bool initColumns()
74
 
{
75
 
  if (createMemcachedStatsColumns(memcached_stats_columns))
76
 
  {
77
 
    return true;
78
 
  }
79
 
 
80
 
  if (createMemcachedAnalysisColumns(memcached_analysis_columns))
81
 
  {
82
 
    return true;
83
 
  }
84
 
 
85
 
  return false;
86
 
}
87
 
 
88
 
/**
89
 
 * Clear the vectors of columns for each I_S table.
90
 
 */
91
 
static void cleanupColumns()
92
 
{
93
 
  clearMemcachedColumns(memcached_stats_columns);
94
 
  clearMemcachedColumns(memcached_analysis_columns);
95
 
}
96
 
 
97
 
/**
98
 
 * Initialize the methods for each I_S table.
99
 
 *
100
 
 * @return false on success; true on failure
101
 
 */
102
 
static bool initMethods()
103
 
{
104
 
  memcached_stats_methods= new(std::nothrow) 
105
 
    MemcachedStatsISMethods();
106
 
  if (! memcached_stats_methods)
107
 
  {
108
 
    return true;
109
 
  }
110
 
 
111
 
  memcached_analysis_methods= new(std::nothrow) 
112
 
    MemcachedAnalysisISMethods();
113
 
  if (! memcached_analysis_methods)
114
 
  {
115
 
    return true;
116
 
  }
117
 
 
118
 
  return false;
119
 
}
120
 
 
121
 
/**
122
 
 * Delete memory allocated for the I_S table methods.
123
 
 */
124
 
static void cleanupMethods()
125
 
{
126
 
  delete memcached_stats_methods;
127
 
  delete memcached_analysis_methods;
128
 
}
129
 
 
130
 
/**
131
 
 * Initialize the I_S tables related to memcached.
132
 
 *
133
 
 * @return false on success; true on failure
134
 
 */
135
 
static bool initMemcachedTables()
136
 
{
137
 
  memcached_stats_table= new(std::nothrow) plugin::InfoSchemaTable("MEMCACHED_STATS",
138
 
                                                           memcached_stats_columns,
139
 
                                                           -1, -1, false, false, 0,
140
 
                                                           memcached_stats_methods,
141
 
                                                           "MEMCACHED_STATS");
142
 
  if (! memcached_stats_table)
143
 
  {
144
 
    return true;
145
 
  }
146
 
 
147
 
  memcached_analysis_table= 
148
 
    new(std::nothrow) plugin::InfoSchemaTable("MEMCACHED_ANALYSIS",
149
 
                                      memcached_analysis_columns,
150
 
                                      -1, -1, false, false, 0,
151
 
                                      memcached_analysis_methods,
152
 
                                      "MEMCACHED_STATS");
153
 
  if (! memcached_analysis_table)
154
 
  {
155
 
    return true;
156
 
  }
157
 
 
158
 
  return false;
159
 
}
160
 
 
161
 
/**
162
 
 * Delete memory allocated for the I_S tables.
163
 
 */
164
 
static void cleanupMemcachedTables()
165
 
{
166
 
  delete memcached_stats_table;
167
 
  delete memcached_analysis_table;
168
 
}
169
 
 
170
 
/**
171
58
 * Initialize the memcached stats plugin.
172
59
 *
173
60
 * @param[in] registry the drizzled::plugin::Registry singleton
175
62
 */
176
63
static int init(plugin::Registry &registry)
177
64
{
178
 
  if (initMethods())
179
 
  {
180
 
    return 1;
181
 
  }
182
 
 
183
 
  if (initColumns())
184
 
  {
185
 
    return 1;
186
 
  }
187
 
 
188
 
  if (initMemcachedTables())
189
 
  {
190
 
    return 1;
191
 
  }
192
65
 
193
66
  SysvarHolder &sysvar_holder= SysvarHolder::singleton();
194
67
  sysvar_holder.setServersString(sysvar_memcached_servers);
195
68
 
196
69
  /* we are good to go */
197
 
  registry.add(memcached_stats_table);
198
 
  registry.add(memcached_analysis_table);
 
70
  stats_table_tool= new(std::nothrow)StatsTableTool; 
 
71
  registry.add(stats_table_tool);
 
72
 
 
73
  analysis_table_tool= new(std::nothrow)AnalysisTableTool;
 
74
  registry.add(analysis_table_tool);
199
75
 
200
76
  return 0;
201
77
}
208
84
 */
209
85
static int deinit(plugin::Registry &registry)
210
86
{
211
 
  registry.remove(memcached_stats_table);
212
 
  registry.remove(memcached_analysis_table);
213
 
 
214
 
  cleanupMethods();
215
 
  cleanupColumns();
216
 
  cleanupMemcachedTables();
217
 
 
 
87
  registry.remove(stats_table_tool);
 
88
  delete stats_table_tool;
 
89
  registry.remove(analysis_table_tool);
 
90
  delete analysis_table_tool;
218
91
  return 0;
219
92
}
220
93