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 |
|
1241.9.12
by Monty Taylor
Trims more out of server_includes.h. |
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> |
468
by Monty Taylor
Repaced sql_state stuff with template function and c++ algorithm. |
26 |
#include <drizzled/sql_state.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. |
27 |
#include <drizzled/session.h> |
1241.9.64
by Monty Taylor
Moved remaining non-public portions of mysys and mystrings to drizzled/internal. |
28 |
#include "drizzled/internal/my_sys.h" |
29 |
#include "drizzled/internal/m_string.h" |
|
971.7.1
by Eric Day
Client/Listen cleanup, moved globals, console plugin cleanup. |
30 |
#include <algorithm> |
1633.6.2
by Vijay Samuel
Reverted changes. |
31 |
#include <iostream> |
32 |
#include <boost/program_options.hpp> |
|
33 |
#include <drizzled/module/option_map.h> |
|
1960.2.6
by Andrew Hutchings
Add ip address limitation for admin connections |
34 |
#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 |
35 |
#include "drizzle_protocol.h" |
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. |
36 |
#include "plugin/drizzle_protocol/status_table.h" |
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
37 |
|
1633.6.2
by Vijay Samuel
Reverted changes. |
38 |
namespace po= boost::program_options; |
1320.2.1
by Monty Taylor
Merged in drizzle_protocol namespace change. |
39 |
using namespace drizzled; |
1067.4.8
by Nathan Williams
Converted all usages of cmin/cmax in plugin directory to std::min/max. |
40 |
using namespace std; |
1300.5.1
by Monty Taylor
Put drizzle_protocol plugin in to its own namespace so that symbols won't |
41 |
|
1964.2.9
by Monty Taylor
All protocol stuff except for the buffer_length. WTF? |
42 |
namespace drizzle_plugin |
43 |
{
|
|
1300.5.1
by Monty Taylor
Put drizzle_protocol plugin in to its own namespace so that symbols won't |
44 |
namespace drizzle_protocol |
45 |
{
|
|
46 |
||
1960.2.6
by Andrew Hutchings
Add ip address limitation for admin connections |
47 |
std::vector<std::string> ClientDrizzleProtocol::drizzle_admin_ip_addresses; |
1964.2.9
by Monty Taylor
All protocol stuff except for the buffer_length. WTF? |
48 |
static port_constraint port; |
49 |
static timeout_constraint connect_timeout; |
|
50 |
static timeout_constraint read_timeout; |
|
51 |
static timeout_constraint write_timeout; |
|
52 |
static retry_constraint retry_count; |
|
53 |
static buffer_constraint buffer_length; |
|
1666.4.19
by Monty Taylor
Free strdup'd option strings. |
54 |
|
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. |
55 |
static const uint32_t DRIZZLE_TCP_PORT= 4427; |
1726.3.6
by LinuxJedi
Add data_dictionary table for drizzle protocol status |
56 |
|
1953.2.6
by Andrew Hutchings
Completely redo max-connections so it is independant per-protocol. Also make counters independant |
57 |
ProtocolCounters *ListenDrizzleProtocol::drizzle_counters= new ProtocolCounters(); |
1953.2.5
by Andrew Hutchings
Make max-connections unique per-protocol |
58 |
|
1666.4.19
by Monty Taylor
Free strdup'd option strings. |
59 |
ListenDrizzleProtocol::~ListenDrizzleProtocol() |
60 |
{
|
|
971.7.1
by Eric Day
Client/Listen cleanup, moved globals, console plugin cleanup. |
61 |
}
|
971.3.48
by Eric Day
New Listen interface about done, not quite compiling yet, but need a backup. |
62 |
|
971.7.10
by Eric Day
Duplicated oldlibdrizzle module, one for Drizzle protocol and one for MySQL, per Brian's request from merge proposal. Port options are now --drizzle-protocol-port and --mysql-protocol-port. |
63 |
in_port_t ListenDrizzleProtocol::getPort(void) const |
971.3.48
by Eric Day
New Listen interface about done, not quite compiling yet, but need a backup. |
64 |
{
|
1964.2.9
by Monty Taylor
All protocol stuff except for the buffer_length. WTF? |
65 |
return port; |
971.3.48
by Eric Day
New Listen interface about done, not quite compiling yet, but need a backup. |
66 |
}
|
67 |
||
1960.2.6
by Andrew Hutchings
Add ip address limitation for admin connections |
68 |
void ClientDrizzleProtocol::drizzle_compose_ip_addresses(vector<string> options) |
69 |
{
|
|
70 |
for (vector<string>::iterator it= options.begin(); |
|
71 |
it != options.end(); |
|
72 |
++it) |
|
73 |
{
|
|
74 |
tokenize(*it, drizzle_admin_ip_addresses, ",", true); |
|
75 |
}
|
|
76 |
}
|
|
77 |
||
78 |
bool ClientDrizzleProtocol::isAdminAllowed(void) |
|
79 |
{
|
|
2008.1.1
by Brian Aker
Adding user identifier that makes use of a shared ptr to handle concurrency |
80 |
if (std::find(drizzle_admin_ip_addresses.begin(), drizzle_admin_ip_addresses.end(), session->user()->address()) != drizzle_admin_ip_addresses.end()) |
1960.2.6
by Andrew Hutchings
Add ip address limitation for admin connections |
81 |
return true; |
2008.1.1
by Brian Aker
Adding user identifier that makes use of a shared ptr to handle concurrency |
82 |
|
83 |
return false; |
|
1960.2.6
by Andrew Hutchings
Add ip address limitation for admin connections |
84 |
}
|
85 |
||
86 |
plugin::Client *ListenDrizzleProtocol::getClient(int fd) |
|
87 |
{
|
|
88 |
int new_fd; |
|
89 |
new_fd= acceptTcp(fd); |
|
90 |
if (new_fd == -1) |
|
91 |
return NULL; |
|
92 |
||
93 |
return new ClientDrizzleProtocol(new_fd, getCounters()); |
|
94 |
}
|
|
95 |
||
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. |
96 |
static int init(drizzled::module::Context &context) |
97 |
{
|
|
1633.6.2
by Vijay Samuel
Reverted changes. |
98 |
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. |
99 |
|
100 |
context.add(new StatusTable); |
|
1964.2.9
by Monty Taylor
All protocol stuff except for the buffer_length. WTF? |
101 |
context.add(new ListenDrizzleProtocol("drizzle_protocol", vm["bind-address"].as<std::string>(), true)); |
102 |
context.registerVariable(new sys_var_constrained_value_readonly<in_port_t>("port", port)); |
|
103 |
context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("connect_timeout", connect_timeout)); |
|
104 |
context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("read_timeout", read_timeout)); |
|
105 |
context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("write_timeout", write_timeout)); |
|
106 |
context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("retry_count", retry_count)); |
|
107 |
context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("buffer_length", buffer_length)); |
|
108 |
context.registerVariable(new sys_var_const_string_val("bind_address", |
|
109 |
vm["bind-address"].as<std::string>())); |
|
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. |
110 |
|
1953.2.6
by Andrew Hutchings
Completely redo max-connections so it is independant per-protocol. Also make counters independant |
111 |
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) |
112 |
|
971.3.16
by Eric Day
Cleaned up Protocol plugin interface (now a class factory) and moved libdrizzlclient to oldlibdrizzle to be clear. |
113 |
return 0; |
114 |
}
|
|
115 |
||
971.3.60
by Eric Day
Moved connect_timeout, net_*_timeout, and retry_count to plugin. |
116 |
|
1633.6.2
by Vijay Samuel
Reverted changes. |
117 |
static void init_options(drizzled::module::option_context &context) |
118 |
{
|
|
119 |
context("port", |
|
1964.2.9
by Monty Taylor
All protocol stuff except for the buffer_length. WTF? |
120 |
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. |
121 |
N_("Port number to use for connection or 0 for default to with Drizzle/MySQL protocol.")); |
1633.6.2
by Vijay Samuel
Reverted changes. |
122 |
context("connect-timeout", |
1964.2.9
by Monty Taylor
All protocol stuff except for the buffer_length. WTF? |
123 |
po::value<timeout_constraint>(&connect_timeout)->default_value(10), |
1633.6.2
by Vijay Samuel
Reverted changes. |
124 |
N_("Connect Timeout.")); |
125 |
context("read-timeout", |
|
1964.2.9
by Monty Taylor
All protocol stuff except for the buffer_length. WTF? |
126 |
po::value<timeout_constraint>(&read_timeout)->default_value(30), |
1633.6.2
by Vijay Samuel
Reverted changes. |
127 |
N_("Read Timeout.")); |
128 |
context("write-timeout", |
|
1964.2.9
by Monty Taylor
All protocol stuff except for the buffer_length. WTF? |
129 |
po::value<timeout_constraint>(&write_timeout)->default_value(60), |
1633.6.2
by Vijay Samuel
Reverted changes. |
130 |
N_("Write Timeout.")); |
131 |
context("retry-count", |
|
1964.2.9
by Monty Taylor
All protocol stuff except for the buffer_length. WTF? |
132 |
po::value<retry_constraint>(&retry_count)->default_value(10), |
1633.6.2
by Vijay Samuel
Reverted changes. |
133 |
N_("Retry Count.")); |
134 |
context("buffer-length", |
|
1964.2.9
by Monty Taylor
All protocol stuff except for the buffer_length. WTF? |
135 |
po::value<buffer_constraint>(&buffer_length)->default_value(16384), |
1633.6.2
by Vijay Samuel
Reverted changes. |
136 |
N_("Buffer length.")); |
137 |
context("bind-address", |
|
1976.5.2
by Brian Aker
This resolves the issue where one thread may be looking at schema while |
138 |
po::value<std::string>()->default_value(""), |
1633.6.2
by Vijay Samuel
Reverted changes. |
139 |
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) |
140 |
context("max-connections", |
1953.2.6
by Andrew Hutchings
Completely redo max-connections so it is independant per-protocol. Also make counters independant |
141 |
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) |
142 |
N_("Maximum simultaneous connections.")); |
1960.2.6
by Andrew Hutchings
Add ip address limitation for admin connections |
143 |
context("admin-ip-addresses", |
144 |
po::value<vector<string> >()->composing()->notifier(&ClientDrizzleProtocol::drizzle_compose_ip_addresses), |
|
145 |
N_("A restrictive IP address list for incoming admin connections.")); |
|
1633.6.2
by Vijay Samuel
Reverted changes. |
146 |
}
|
147 |
||
1320.2.1
by Monty Taylor
Merged in drizzle_protocol namespace change. |
148 |
} /* namespace drizzle_protocol */ |
1964.2.9
by Monty Taylor
All protocol stuff except for the buffer_length. WTF? |
149 |
} /* namespace drizzle_plugin */ |
1300.5.1
by Monty Taylor
Put drizzle_protocol plugin in to its own namespace so that symbols won't |
150 |
|
1964.2.9
by Monty Taylor
All protocol stuff except for the buffer_length. WTF? |
151 |
DRIZZLE_PLUGIN(drizzle_plugin::drizzle_protocol::init, NULL, drizzle_plugin::drizzle_protocol::init_options); |