2116.1.1
by David Shrewsbury
Initial version of slave replication plugin. |
1 |
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
|
2 |
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
|
|
3 |
*
|
|
4 |
* Copyright (C) 2011 David Shrewsbury
|
|
5 |
*
|
|
6 |
* This program is free software; you can redistribute it and/or modify
|
|
7 |
* it under the terms of the GNU General Public License as published by
|
|
8 |
* the Free Software Foundation; either version 2 of the License, or
|
|
9 |
* (at your option) any later version.
|
|
10 |
*
|
|
11 |
* This program is distributed in the hope that it will be useful,
|
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14 |
* GNU General Public License for more details.
|
|
15 |
*
|
|
16 |
* You should have received a copy of the GNU General Public License
|
|
17 |
* along with this program; if not, write to the Free Software
|
|
18 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
19 |
*/
|
|
20 |
||
2116.1.38
by David Shrewsbury
Change include style |
21 |
#include <config.h> |
22 |
#include <plugin/slave/replication_slave.h> |
|
2116.1.31
by David Shrewsbury
Major refactor of common functionality into new classes. |
23 |
#include <drizzled/plugin.h> |
24 |
#include <drizzled/configmake.h> // for SYSCONFDIR |
|
25 |
#include <drizzled/module/option_map.h> |
|
2116.1.26
by David Shrewsbury
Add framework for loading config file |
26 |
#include <boost/program_options.hpp> |
27 |
#include <boost/filesystem.hpp> |
|
28 |
#include <string> |
|
2116.1.1
by David Shrewsbury
Initial version of slave replication plugin. |
29 |
|
30 |
using namespace drizzled; |
|
2116.1.26
by David Shrewsbury
Add framework for loading config file |
31 |
using namespace std; |
32 |
||
33 |
namespace po= boost::program_options; |
|
34 |
namespace fs= boost::filesystem; |
|
35 |
||
36 |
namespace slave |
|
37 |
{
|
|
38 |
||
39 |
static const fs::path DEFAULT_SLAVE_CFG_FILE= SYSCONFDIR "/slave.cfg"; |
|
40 |
||
41 |
static string slave_config; |
|
2116.1.1
by David Shrewsbury
Initial version of slave replication plugin. |
42 |
|
43 |
static int init(module::Context &context) |
|
44 |
{
|
|
2116.1.26
by David Shrewsbury
Add framework for loading config file |
45 |
const module::option_map &vm= context.getOptions(); |
46 |
||
2116.1.31
by David Shrewsbury
Major refactor of common functionality into new classes. |
47 |
ReplicationSlave *slave= new ReplicationSlave(vm["config-file"].as<string>()); |
2221.8.1
by David Shrewsbury
Add new --slave.max-commit-id option to control where we begin reading the master transaction log. |
48 |
if (vm.count("max-commit-id")) |
49 |
slave->setMaxCommitId(vm["max-commit-id"].as<uint64_t>()); |
|
2116.1.26
by David Shrewsbury
Add framework for loading config file |
50 |
context.add(slave); |
2116.1.1
by David Shrewsbury
Initial version of slave replication plugin. |
51 |
return 0; |
52 |
}
|
|
53 |
||
2116.1.26
by David Shrewsbury
Add framework for loading config file |
54 |
static void init_options(drizzled::module::option_context &context) |
55 |
{
|
|
2116.1.28
by David Shrewsbury
More config file work |
56 |
context("config-file", |
2116.1.26
by David Shrewsbury
Add framework for loading config file |
57 |
po::value<string>()->default_value(DEFAULT_SLAVE_CFG_FILE.string()), |
58 |
N_("Path to the slave configuration file")); |
|
2221.8.1
by David Shrewsbury
Add new --slave.max-commit-id option to control where we begin reading the master transaction log. |
59 |
context("max-commit-id", |
60 |
po::value<uint64_t>(), |
|
61 |
N_("Value to use as the maximum commit ID stored on the slave")); |
|
2116.1.26
by David Shrewsbury
Add framework for loading config file |
62 |
}
|
63 |
||
64 |
} /* namespace slave */ |
|
65 |
||
2116.1.11
by David Shrewsbury
Make slave plugin dependent on scheduler being loaded. |
66 |
DRIZZLE_DECLARE_PLUGIN
|
67 |
{
|
|
68 |
DRIZZLE_VERSION_ID, |
|
2116.1.28
by David Shrewsbury
More config file work |
69 |
"slave", |
2116.1.11
by David Shrewsbury
Make slave plugin dependent on scheduler being loaded. |
70 |
"1.0", |
71 |
"David Shrewsbury", |
|
72 |
"Implements Drizzle replication slave.", |
|
73 |
PLUGIN_LICENSE_GPL, |
|
2116.1.26
by David Shrewsbury
Add framework for loading config file |
74 |
slave::init, |
2116.1.36
by David Shrewsbury
Remove multi_thread plugin dependency |
75 |
NULL, /* depends */ |
2116.1.26
by David Shrewsbury
Add framework for loading config file |
76 |
slave::init_options /* config options */ |
2116.1.11
by David Shrewsbury
Make slave plugin dependent on scheduler being loaded. |
77 |
}
|
78 |
DRIZZLE_DECLARE_PLUGIN_END; |