Merge lp:~vjsamuel/drizzle/refactor-5-plugins into lp:~drizzle-trunk/drizzle/development

Proposed by Vijay Samuel
Status: Merged
Merged at revision: 1663
Proposed branch: lp:~vjsamuel/drizzle/refactor-5-plugins
Merge into: lp:~drizzle-trunk/drizzle/development
Diff against target: 387 lines (+184/-20)
6 files modified
plugin/auth_http/auth_http.cc (+12/-5)
plugin/filtered_replicator/filtered_replicator.cc (+36/-3)
plugin/hello_events/hello_events.cc (+73/-3)
plugin/logging_gearman/logging_gearman.cc (+13/-5)
plugin/logging_query/logging_query.cc (+49/-3)
plugin/transaction_log/tests/t/filtered_replicator-master.opt (+1/-1)
To merge this branch: bzr merge lp:~vjsamuel/drizzle/refactor-5-plugins
Reviewer Review Type Date Requested Status
Brian Aker Pending
Monty Taylor Pending
Drizzle Developers Pending
Review via email: mp+30176@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugin/auth_http/auth_http.cc'
2--- plugin/auth_http/auth_http.cc 2010-05-18 18:20:56 +0000
3+++ plugin/auth_http/auth_http.cc 2010-07-17 14:34:41 +0000
4@@ -23,15 +23,16 @@
5
6 #include <string>
7 #include <cassert>
8-
9+#include <boost/program_options.hpp>
10+#include <drizzled/module/option_map.h>
11 #include "drizzled/security_context.h"
12 #include "drizzled/plugin/authentication.h"
13 #include "drizzled/gettext.h"
14-
15+namespace po= boost::program_options;
16 using namespace drizzled;
17 using namespace std;
18
19-static bool sysvar_auth_http_enable= false;
20+static bool sysvar_auth_http_enable;
21 static char* sysvar_auth_http_url= NULL;
22
23 static size_t curl_cb_read(void *ptr, size_t size, size_t nmemb, void *stream)
24@@ -136,6 +137,12 @@
25 return 0;
26 }
27
28+static void init_options(drizzled::module::option_context &context)
29+{
30+ context("enable", po::value<bool>(&sysvar_auth_http_enable)->default_value(false)->zero_tokens(),
31+ N_("Enable HTTP Auth check"));
32+}
33+
34 static DRIZZLE_SYSVAR_BOOL(
35 enable,
36 sysvar_auth_http_enable,
37@@ -165,13 +172,13 @@
38 DRIZZLE_DECLARE_PLUGIN
39 {
40 DRIZZLE_VERSION_ID,
41- "auth_http",
42+ "auth-http",
43 "0.1",
44 "Mark Atwood",
45 "HTTP based authenication.",
46 PLUGIN_LICENSE_GPL,
47 initialize, /* Plugin Init */
48 auth_http_system_variables,
49- NULL /* config options */
50+ init_options /* config options */
51 }
52 DRIZZLE_DECLARE_PLUGIN_END;
53
54=== modified file 'plugin/filtered_replicator/filtered_replicator.cc'
55--- plugin/filtered_replicator/filtered_replicator.cc 2010-06-23 20:51:16 +0000
56+++ plugin/filtered_replicator/filtered_replicator.cc 2010-07-17 14:34:41 +0000
57@@ -43,10 +43,11 @@
58 #include <drizzled/plugin.h>
59
60 #include "filtered_replicator.h"
61-
62+#include <boost/program_options.hpp>
63+#include <drizzled/module/option_map.h>
64 #include <vector>
65 #include <string>
66-
67+namespace po= boost::program_options;
68 using namespace std;
69 using namespace drizzled;
70
71@@ -496,6 +497,28 @@
72
73 static int init(module::Context &context)
74 {
75+ const module::option_map &vm= context.getOptions();
76+
77+ if (vm.count("filteredschemas"))
78+ {
79+ sysvar_filtered_replicator_sch_filters= strdup(vm["filteredschemas"].as<string>().c_str());
80+ }
81+
82+ else
83+ {
84+ sysvar_filtered_replicator_sch_filters= (char *)"";
85+ }
86+
87+ if (vm.count("filteredtables"))
88+ {
89+ sysvar_filtered_replicator_tab_filters= strdup(vm["filteredtables"].as<string>().c_str());
90+ }
91+
92+ else
93+ {
94+ sysvar_filtered_replicator_tab_filters= (char *)"";
95+ }
96+
97 filtered_replicator= new(std::nothrow)
98 FilteredReplicator("filtered_replicator",
99 sysvar_filtered_replicator_sch_filters,
100@@ -574,6 +597,16 @@
101 }
102 }
103
104+static void init_options(drizzled::module::option_context &context)
105+{
106+ context("filteredschemas",
107+ po::value<string>(),
108+ N_("List of schemas to filter"));
109+ context("filteredtables",
110+ po::value<string>(),
111+ N_("List of tables to filter"));
112+}
113+
114 static DRIZZLE_SYSVAR_STR(filteredschemas,
115 sysvar_filtered_replicator_sch_filters,
116 PLUGIN_VAR_OPCMDARG,
117@@ -611,4 +644,4 @@
118 NULL
119 };
120
121-DRIZZLE_PLUGIN(init, filtered_replicator_system_variables, NULL);
122+DRIZZLE_PLUGIN(init, filtered_replicator_system_variables, init_options);
123
124=== modified file 'plugin/hello_events/hello_events.cc'
125--- plugin/hello_events/hello_events.cc 2010-05-21 16:22:35 +0000
126+++ plugin/hello_events/hello_events.cc 2010-07-17 14:34:41 +0000
127@@ -34,10 +34,11 @@
128 #include "config.h"
129 #include <string>
130 #include <cstdio>
131-
132+#include <boost/program_options.hpp>
133+#include <drizzled/module/option_map.h>
134 #include "drizzled/session.h"
135 #include "hello_events.h"
136-
137+namespace po= boost::program_options;
138 using namespace drizzled;
139 using namespace plugin;
140 using namespace std;
141@@ -285,6 +286,53 @@
142
143 static int init(module::Context &context)
144 {
145+ const module::option_map &vm= context.getOptions();
146+ if (vm.count("before-write-position"))
147+ {
148+ if (sysvar_before_write_position < 1 || sysvar_before_write_position > INT32_MAX -1)
149+ {
150+ errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of before-write-position\n"));
151+ exit(-1);
152+ }
153+ }
154+
155+ if (vm.count("before-update-position"))
156+ {
157+ if (sysvar_before_update_position < 1 || sysvar_before_update_position > INT32_MAX -1)
158+ {
159+ errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of before-update-position\n"));
160+ exit(-1);
161+ }
162+ }
163+
164+ if (vm.count("post-drop-db-position"))
165+ {
166+ if (sysvar_post_drop_db_position > -1 || sysvar_post_drop_db_position < INT32_MIN+1)
167+ {
168+ errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of before-update-position\n"));
169+ exit(-1);
170+ }
171+ }
172+
173+ if (vm.count("watch-databases"))
174+ {
175+ sysvar_db_list= strdup(vm["watch-databases"].as<string>().c_str());
176+ }
177+
178+ else
179+ {
180+ sysvar_db_list= (char *)"";
181+ }
182+
183+ if (vm.count("watch-tables"))
184+ {
185+ sysvar_table_list= strdup(vm["watch-tables"].as<string>().c_str());
186+ }
187+
188+ else
189+ {
190+ sysvar_table_list= (char *)"";
191+ }
192 hello_events= new HelloEvents(PLUGIN_NAME);
193
194 context.add(hello_events);
195@@ -297,6 +345,28 @@
196 return 0;
197 }
198
199+static void init_options(drizzled::module::option_context &context)
200+{
201+ context("watch-databases",
202+ po::value<string>(),
203+ N_("A comma delimited list of databases to watch"));
204+ context("watch-tables",
205+ po::value<string>(),
206+ N_("A comma delimited list of databases to watch"));
207+ context("enable",
208+ po::value<bool>(&sysvar_hello_events_enabled)->default_value(false)->zero_tokens(),
209+ N_("Enable Example Events Plugin"));
210+ context("before-write-position",
211+ po::value<int32_t>(&sysvar_before_write_position)->default_value(1),
212+ N_("Before write row event observer call position"));
213+ context("before-update-position",
214+ po::value<int32_t>(&sysvar_before_update_position)->default_value(1),
215+ N_("Before update row event observer call position"));
216+ context("post-drop-db-position",
217+ po::value<int32_t>(&sysvar_post_drop_db_position)->default_value(-1),
218+ N_("After drop database event observer call position"));
219+}
220+
221 static DRIZZLE_SYSVAR_STR(watch_databases,
222 sysvar_db_list,
223 PLUGIN_VAR_OPCMDARG,
224@@ -374,6 +444,6 @@
225 PLUGIN_LICENSE_BSD,
226 init, /* Plugin Init */
227 system_var, /* system variables */
228- NULL /* config options */
229+ init_options /* config options */
230 }
231 DRIZZLE_DECLARE_PLUGIN_END;
232
233=== modified file 'plugin/logging_gearman/logging_gearman.cc'
234--- plugin/logging_gearman/logging_gearman.cc 2010-05-18 18:20:56 +0000
235+++ plugin/logging_gearman/logging_gearman.cc 2010-07-17 14:34:41 +0000
236@@ -21,7 +21,8 @@
237 #include <drizzled/plugin/logging.h>
238 #include <drizzled/gettext.h>
239 #include <drizzled/session.h>
240-
241+#include <boost/program_options.hpp>
242+#include <drizzled/module/option_map.h>
243 #include <libgearman/gearman.h>
244 #include <limits.h>
245 #include <sys/time.h>
246@@ -31,12 +32,12 @@
247 #include <cstdio>
248
249 using namespace drizzled;
250-
251+namespace po= boost::program_options;
252
253 /* TODO make this dynamic as needed */
254 static const int MAX_MSG_LEN= 32*1024;
255
256-static bool sysvar_logging_gearman_enable= false;
257+static bool sysvar_logging_gearman_enable;
258 static char* sysvar_logging_gearman_host= NULL;
259 static char* sysvar_logging_gearman_function= NULL;
260
261@@ -298,6 +299,13 @@
262 return 0;
263 }
264
265+static void init_options(drizzled::module::option_context &context)
266+{
267+ context("enable",
268+ po::value<bool>(&sysvar_logging_gearman_enable)->default_value(false)->zero_tokens(),
269+ N_("Enable logging to a gearman server"));
270+}
271+
272 static DRIZZLE_SYSVAR_BOOL(
273 enable,
274 sysvar_logging_gearman_enable,
275@@ -335,13 +343,13 @@
276 DRIZZLE_DECLARE_PLUGIN
277 {
278 DRIZZLE_VERSION_ID,
279- "logging_gearman",
280+ "logging-gearman",
281 "0.1",
282 "Mark Atwood <mark@fallenpegasus.com>",
283 N_("Log queries to a Gearman server"),
284 PLUGIN_LICENSE_GPL,
285 logging_gearman_plugin_init,
286 logging_gearman_system_variables,
287- NULL
288+ init_options
289 }
290 DRIZZLE_DECLARE_PLUGIN_END;
291
292=== modified file 'plugin/logging_query/logging_query.cc'
293--- plugin/logging_query/logging_query.cc 2010-06-08 22:05:40 +0000
294+++ plugin/logging_query/logging_query.cc 2010-07-17 14:34:41 +0000
295@@ -29,9 +29,11 @@
296 #include <fcntl.h>
297 #include <string>
298 #include <boost/format.hpp>
299-
300+#include <boost/program_options.hpp>
301+#include <drizzled/module/option_map.h>
302 #include <cstdio>
303
304+namespace po= boost::program_options;
305 using namespace drizzled;
306 using namespace std;
307
308@@ -302,12 +304,56 @@
309
310 static int logging_query_plugin_init(drizzled::module::Context &context)
311 {
312+
313+ const module::option_map &vm= context.getOptions();
314+ if (vm.count("threshold-slow"))
315+ {
316+ if (sysvar_logging_query_threshold_slow > UINT32_MAX)
317+ {
318+ errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for threshold-slow"));
319+ exit(-1);
320+ }
321+ }
322+
323+ if (vm.count("threshold-big-resultset"))
324+ {
325+ if (sysvar_logging_query_threshold_big_resultset > UINT32_MAX)
326+ {
327+ errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for threshold-big-resultset"));
328+ exit(-1);
329+ }
330+ }
331+
332+ if (vm.count("threshold-big-examined"))
333+ {
334+ if (sysvar_logging_query_threshold_big_examined > UINT32_MAX)
335+ {
336+ errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for threshold-big-examined"));
337+ exit(-1);
338+ }
339+ }
340 handler= new Logging_query();
341 context.add(handler);
342
343 return 0;
344 }
345
346+static void init_options(drizzled::module::option_context &context)
347+{
348+ context("enable",
349+ po::value<bool>(&sysvar_logging_query_enable)->default_value(false)->zero_tokens(),
350+ N_("Enable logging to CSV file"));
351+ context("threshold-slow",
352+ po::value<unsigned long>(&sysvar_logging_query_threshold_slow)->default_value(0),
353+ N_("Threshold for logging slow queries, in microseconds"));
354+ context("threshold-big-resultset",
355+ po::value<unsigned long>(&sysvar_logging_query_threshold_big_resultset)->default_value(0),
356+ N_("Threshold for logging big queries, for rows returned"));
357+ context("threshold-big-examined",
358+ po::value<unsigned long>(&sysvar_logging_query_threshold_big_examined)->default_value(0),
359+ N_("Threshold for logging big queries, for rows examined"));
360+}
361+
362 static DRIZZLE_SYSVAR_BOOL(
363 enable,
364 sysvar_logging_query_enable,
365@@ -384,13 +430,13 @@
366 DRIZZLE_DECLARE_PLUGIN
367 {
368 DRIZZLE_VERSION_ID,
369- "logging_query",
370+ "logging-query",
371 "0.2",
372 "Mark Atwood <mark@fallenpegasus.com>",
373 N_("Log queries to a CSV file"),
374 PLUGIN_LICENSE_GPL,
375 logging_query_plugin_init,
376 logging_query_system_variables,
377- NULL
378+ init_options
379 }
380 DRIZZLE_DECLARE_PLUGIN_END;
381
382=== modified file 'plugin/transaction_log/tests/t/filtered_replicator-master.opt'
383--- plugin/transaction_log/tests/t/filtered_replicator-master.opt 2010-04-05 16:06:01 +0000
384+++ plugin/transaction_log/tests/t/filtered_replicator-master.opt 2010-07-17 14:34:41 +0000
385@@ -1,1 +1,1 @@
386---transaction-log-enable --transaction-log-use-replicator=filtered --scheduler=multi_thread --filtered-replicator-filteredschemas=notest
387+--transaction-log-enable --transaction-log-use-replicator=filtered --scheduler=multi_thread --filtered-replicator.filteredschemas=notest