1812.3.1
by Brian Aker
This patch encapsulates the MySQL protocol around the Drizzle port so that we have access even in the event of MySQL being installed and running. |
1 |
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
|
971.3.12
by Eric Day
Started abstracting Protocol, removed init_connect, init_file. |
2 |
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
|
3 |
*
|
|
1812.3.1
by Brian Aker
This patch encapsulates the MySQL protocol around the Drizzle port so that we have access even in the event of MySQL being installed and running. |
4 |
* Copyright (C) 2010 Brian Aker
|
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
|
|
971.3.12
by Eric Day
Started abstracting Protocol, removed init_connect, init_file. |
19 |
*/
|
1
by brian
clean slate |
20 |
|
1812.3.1
by Brian Aker
This patch encapsulates the MySQL protocol around the Drizzle port so that we have access even in the event of MySQL being installed and running. |
21 |
|
2173.2.1
by Monty Taylor
Fixes incorrect usage of include |
22 |
#include <config.h> |
971.3.60
by Eric Day
Moved connect_timeout, net_*_timeout, and retry_count to plugin. |
23 |
#include <drizzled/gettext.h> |
549
by Monty Taylor
Took gettext.h out of header files. |
24 |
#include <drizzled/error.h> |
971.3.61
by Eric Day
Removed setRandom from Protocol class. |
25 |
#include <drizzled/query_id.h> |
584.1.15
by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes. |
26 |
#include <drizzled/session.h> |
2173.2.1
by Monty Taylor
Fixes incorrect usage of include |
27 |
#include <drizzled/internal/my_sys.h> |
28 |
#include <drizzled/internal/m_string.h> |
|
971.7.1
by Eric Day
Client/Listen cleanup, moved globals, console plugin cleanup. |
29 |
#include <algorithm> |
1633.6.2
by Vijay Samuel
Reverted changes. |
30 |
#include <iostream> |
31 |
#include <boost/program_options.hpp> |
|
32 |
#include <drizzled/module/option_map.h> |
|
2173.2.1
by Monty Taylor
Fixes incorrect usage of include |
33 |
#include <drizzled/util/tokenize.h> |
1300.5.1
by Monty Taylor
Put drizzle_protocol plugin in to its own namespace so that symbols won't |
34 |
#include "drizzle_protocol.h" |
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
35 |
|
1633.6.2
by Vijay Samuel
Reverted changes. |
36 |
namespace po= boost::program_options; |
1320.2.1
by Monty Taylor
Merged in drizzle_protocol namespace change. |
37 |
using namespace drizzled; |
1067.4.8
by Nathan Williams
Converted all usages of cmin/cmax in plugin directory to std::min/max. |
38 |
using namespace std; |
1300.5.1
by Monty Taylor
Put drizzle_protocol plugin in to its own namespace so that symbols won't |
39 |
|
2318.3.1
by Olaf van der Spek
Refactor |
40 |
namespace drizzle_plugin { |
41 |
namespace drizzle_protocol { |
|
1300.5.1
by Monty Taylor
Put drizzle_protocol plugin in to its own namespace so that symbols won't |
42 |
|
1964.2.9
by Monty Taylor
All protocol stuff except for the buffer_length. WTF? |
43 |
static port_constraint port; |
44 |
static timeout_constraint connect_timeout; |
|
45 |
static timeout_constraint read_timeout; |
|
46 |
static timeout_constraint write_timeout; |
|
47 |
static retry_constraint retry_count; |
|
48 |
static buffer_constraint buffer_length; |
|
1666.4.19
by Monty Taylor
Free strdup'd option strings. |
49 |
|
1812.3.1
by Brian Aker
This patch encapsulates the MySQL protocol around the Drizzle port so that we have access even in the event of MySQL being installed and running. |
50 |
static const uint32_t DRIZZLE_TCP_PORT= 4427; |
1726.3.6
by LinuxJedi
Add data_dictionary table for drizzle protocol status |
51 |
|
2318.3.2
by Olaf van der Spek
Refactor |
52 |
ProtocolCounters ListenDrizzleProtocol::drizzle_counters; |
1953.2.5
by Andrew Hutchings
Make max-connections unique per-protocol |
53 |
|
2313.3.5
by Olaf van der Spek
Return void |
54 |
in_port_t ListenDrizzleProtocol::getPort() const |
971.3.48
by Eric Day
New Listen interface about done, not quite compiling yet, but need a backup. |
55 |
{
|
1964.2.9
by Monty Taylor
All protocol stuff except for the buffer_length. WTF? |
56 |
return port; |
971.3.48
by Eric Day
New Listen interface about done, not quite compiling yet, but need a backup. |
57 |
}
|
58 |
||
1960.2.6
by Andrew Hutchings
Add ip address limitation for admin connections |
59 |
plugin::Client *ListenDrizzleProtocol::getClient(int fd) |
60 |
{
|
|
2318.3.1
by Olaf van der Spek
Refactor |
61 |
int new_fd= acceptTcp(fd); |
2318.2.40
by Olaf van der Spek
Refactor |
62 |
return new_fd == -1 ? NULL : new ClientMySQLProtocol(new_fd, getCounters()); |
1960.2.6
by Andrew Hutchings
Add ip address limitation for admin connections |
63 |
}
|
64 |
||
1812.3.1
by Brian Aker
This patch encapsulates the MySQL protocol around the Drizzle port so that we have access even in the event of MySQL being installed and running. |
65 |
static int init(drizzled::module::Context &context) |
66 |
{
|
|
1633.6.2
by Vijay Samuel
Reverted changes. |
67 |
const module::option_map &vm= context.getOptions(); |
1812.3.1
by Brian Aker
This patch encapsulates the MySQL protocol around the Drizzle port so that we have access even in the event of MySQL being installed and running. |
68 |
|
2318.2.40
by Olaf van der Spek
Refactor |
69 |
ListenDrizzleProtocol *protocol=new ListenDrizzleProtocol("drizzle_protocol", vm["bind-address"].as<std::string>()); |
2131.7.1
by Andrew Hutchings
Add protocol counters table |
70 |
protocol->addCountersToTable(); |
71 |
context.add(protocol); |
|
1964.2.9
by Monty Taylor
All protocol stuff except for the buffer_length. WTF? |
72 |
context.registerVariable(new sys_var_constrained_value_readonly<in_port_t>("port", port)); |
73 |
context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("connect_timeout", connect_timeout)); |
|
74 |
context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("read_timeout", read_timeout)); |
|
75 |
context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("write_timeout", write_timeout)); |
|
76 |
context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("retry_count", retry_count)); |
|
77 |
context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("buffer_length", buffer_length)); |
|
2318.3.1
by Olaf van der Spek
Refactor |
78 |
context.registerVariable(new sys_var_const_string_val("bind_address", vm["bind-address"].as<std::string>())); |
2318.3.2
by Olaf van der Spek
Refactor |
79 |
context.registerVariable(new sys_var_uint32_t_ptr("max-connections", &ListenDrizzleProtocol::drizzle_counters.max_connections)); |
1953.2.2
by Andrew Hutchings
Add Drizzle protocol support for max-connections (shared with MySQL protocol for now as other stats are shared) |
80 |
|
971.3.16
by Eric Day
Cleaned up Protocol plugin interface (now a class factory) and moved libdrizzlclient to oldlibdrizzle to be clear. |
81 |
return 0; |
82 |
}
|
|
83 |
||
971.3.60
by Eric Day
Moved connect_timeout, net_*_timeout, and retry_count to plugin. |
84 |
|
1633.6.2
by Vijay Samuel
Reverted changes. |
85 |
static void init_options(drizzled::module::option_context &context) |
86 |
{
|
|
87 |
context("port", |
|
1964.2.9
by Monty Taylor
All protocol stuff except for the buffer_length. WTF? |
88 |
po::value<port_constraint>(&port)->default_value(DRIZZLE_TCP_PORT), |
1812.3.1
by Brian Aker
This patch encapsulates the MySQL protocol around the Drizzle port so that we have access even in the event of MySQL being installed and running. |
89 |
N_("Port number to use for connection or 0 for default to with Drizzle/MySQL protocol.")); |
1633.6.2
by Vijay Samuel
Reverted changes. |
90 |
context("connect-timeout", |
1964.2.9
by Monty Taylor
All protocol stuff except for the buffer_length. WTF? |
91 |
po::value<timeout_constraint>(&connect_timeout)->default_value(10), |
1633.6.2
by Vijay Samuel
Reverted changes. |
92 |
N_("Connect Timeout.")); |
93 |
context("read-timeout", |
|
1964.2.9
by Monty Taylor
All protocol stuff except for the buffer_length. WTF? |
94 |
po::value<timeout_constraint>(&read_timeout)->default_value(30), |
1633.6.2
by Vijay Samuel
Reverted changes. |
95 |
N_("Read Timeout.")); |
96 |
context("write-timeout", |
|
1964.2.9
by Monty Taylor
All protocol stuff except for the buffer_length. WTF? |
97 |
po::value<timeout_constraint>(&write_timeout)->default_value(60), |
1633.6.2
by Vijay Samuel
Reverted changes. |
98 |
N_("Write Timeout.")); |
99 |
context("retry-count", |
|
1964.2.9
by Monty Taylor
All protocol stuff except for the buffer_length. WTF? |
100 |
po::value<retry_constraint>(&retry_count)->default_value(10), |
1633.6.2
by Vijay Samuel
Reverted changes. |
101 |
N_("Retry Count.")); |
102 |
context("buffer-length", |
|
1964.2.9
by Monty Taylor
All protocol stuff except for the buffer_length. WTF? |
103 |
po::value<buffer_constraint>(&buffer_length)->default_value(16384), |
1633.6.2
by Vijay Samuel
Reverted changes. |
104 |
N_("Buffer length.")); |
105 |
context("bind-address", |
|
2215.6.1
by Brian Aker
This modifies basic auth such that: |
106 |
po::value<std::string>()->default_value("localhost"), |
1633.6.2
by Vijay Samuel
Reverted changes. |
107 |
N_("Address to bind to.")); |
1953.2.2
by Andrew Hutchings
Add Drizzle protocol support for max-connections (shared with MySQL protocol for now as other stats are shared) |
108 |
context("max-connections", |
2318.3.2
by Olaf van der Spek
Refactor |
109 |
po::value<uint32_t>(&ListenDrizzleProtocol::drizzle_counters.max_connections)->default_value(1000), |
1953.2.2
by Andrew Hutchings
Add Drizzle protocol support for max-connections (shared with MySQL protocol for now as other stats are shared) |
110 |
N_("Maximum simultaneous connections.")); |
1633.6.2
by Vijay Samuel
Reverted changes. |
111 |
}
|
112 |
||
1320.2.1
by Monty Taylor
Merged in drizzle_protocol namespace change. |
113 |
} /* namespace drizzle_protocol */ |
1964.2.9
by Monty Taylor
All protocol stuff except for the buffer_length. WTF? |
114 |
} /* namespace drizzle_plugin */ |
1300.5.1
by Monty Taylor
Put drizzle_protocol plugin in to its own namespace so that symbols won't |
115 |
|
1964.2.9
by Monty Taylor
All protocol stuff except for the buffer_length. WTF? |
116 |
DRIZZLE_PLUGIN(drizzle_plugin::drizzle_protocol::init, NULL, drizzle_plugin::drizzle_protocol::init_options); |