1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
|
/* Copyright (C) 2008-2017 Kentoku Shiba
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#define SPIDER_LOCK_MODE_NO_LOCK 0
#define SPIDER_LOCK_MODE_SHARED 1
#define SPIDER_LOCK_MODE_EXCLUSIVE 2
#define SPIDER_BG_SIMPLE_NO_ACTION 0
#define SPIDER_BG_SIMPLE_CONNECT 1
#define SPIDER_BG_SIMPLE_DISCONNECT 2
#define SPIDER_BG_SIMPLE_RECORDS 3
uchar *spider_conn_get_key(
SPIDER_CONN *conn,
size_t *length,
my_bool not_used __attribute__ ((unused))
);
uchar *spider_ipport_conn_get_key(
SPIDER_IP_PORT_CONN *ip_port,
size_t *length,
my_bool not_used __attribute__ ((unused))
);
int spider_reset_conn_setted_parameter(
SPIDER_CONN *conn,
THD *thd
);
int spider_free_conn_alloc(
SPIDER_CONN *conn
);
void spider_free_conn_from_trx(
SPIDER_TRX *trx,
SPIDER_CONN *conn,
bool another,
bool trx_free,
int *roop_count
);
SPIDER_CONN *spider_create_conn(
SPIDER_SHARE *share,
ha_spider *spider,
int link_id,
int base_link_id,
uint conn_kind,
int *error_num
);
SPIDER_CONN *spider_get_conn(
SPIDER_SHARE *share,
int link_idx,
char *conn_key,
SPIDER_TRX *trx,
ha_spider *spider,
bool another,
bool thd_chg,
uint conn_kind,
int *error_num
);
int spider_free_conn(
SPIDER_CONN *conn
);
int spider_check_and_get_casual_read_conn(
THD *thd,
ha_spider *spider,
int link_idx
);
int spider_check_and_init_casual_read(
THD *thd,
ha_spider *spider,
int link_idx
);
void spider_conn_queue_connect(
SPIDER_SHARE *share,
SPIDER_CONN *conn,
int link_idx
);
void spider_conn_queue_connect_rewrite(
SPIDER_SHARE *share,
SPIDER_CONN *conn,
int link_idx
);
void spider_conn_queue_ping(
ha_spider *spider,
SPIDER_CONN *conn,
int link_idx
);
void spider_conn_queue_ping_rewrite(
ha_spider *spider,
SPIDER_CONN *conn,
int link_idx
);
void spider_conn_queue_trx_isolation(
SPIDER_CONN *conn,
int trx_isolation
);
void spider_conn_queue_semi_trx_isolation(
SPIDER_CONN *conn,
int trx_isolation
);
void spider_conn_queue_autocommit(
SPIDER_CONN *conn,
bool autocommit
);
void spider_conn_queue_sql_log_off(
SPIDER_CONN *conn,
bool sql_log_off
);
void spider_conn_queue_time_zone(
SPIDER_CONN *conn,
Time_zone *time_zone
);
void spider_conn_queue_start_transaction(
SPIDER_CONN *conn
);
void spider_conn_queue_xa_start(
SPIDER_CONN *conn,
XID *xid
);
void spider_conn_clear_queue(
SPIDER_CONN *conn
);
void spider_conn_clear_queue_at_commit(
SPIDER_CONN *conn
);
void spider_conn_set_timeout(
SPIDER_CONN *conn,
uint net_read_timeout,
uint net_write_timeout
);
void spider_conn_set_timeout_from_share(
SPIDER_CONN *conn,
int link_idx,
THD *thd,
SPIDER_SHARE *share
);
void spider_conn_set_timeout_from_direct_sql(
SPIDER_CONN *conn,
THD *thd,
SPIDER_DIRECT_SQL *direct_sql
);
void spider_tree_insert(
SPIDER_CONN *top,
SPIDER_CONN *conn
);
SPIDER_CONN *spider_tree_first(
SPIDER_CONN *top
);
SPIDER_CONN *spider_tree_last(
SPIDER_CONN *top
);
SPIDER_CONN *spider_tree_next(
SPIDER_CONN *current
);
SPIDER_CONN *spider_tree_delete(
SPIDER_CONN *conn,
SPIDER_CONN *top
);
#ifndef WITHOUT_SPIDER_BG_SEARCH
int spider_set_conn_bg_param(
ha_spider *spider
);
int spider_create_conn_thread(
SPIDER_CONN *conn
);
void spider_free_conn_thread(
SPIDER_CONN *conn
);
void spider_bg_conn_wait(
SPIDER_CONN *conn
);
void spider_bg_all_conn_wait(
ha_spider *spider
);
int spider_bg_all_conn_pre_next(
ha_spider *spider,
int link_idx
);
void spider_bg_conn_break(
SPIDER_CONN *conn,
ha_spider *spider
);
void spider_bg_all_conn_break(
ha_spider *spider
);
bool spider_bg_conn_get_job(
SPIDER_CONN *conn
);
int spider_bg_conn_search(
ha_spider *spider,
int link_idx,
int first_link_idx,
bool first,
bool pre_next,
bool discard_result
);
void spider_bg_conn_simple_action(
SPIDER_CONN *conn,
uint simple_action,
bool caller_wait,
void *target,
uint link_idx,
int *error_num
);
void *spider_bg_conn_action(
void *arg
);
int spider_create_sts_thread(
SPIDER_SHARE *share
);
void spider_free_sts_thread(
SPIDER_SHARE *share
);
void *spider_bg_sts_action(
void *arg
);
int spider_create_crd_thread(
SPIDER_SHARE *share
);
void spider_free_crd_thread(
SPIDER_SHARE *share
);
void *spider_bg_crd_action(
void *arg
);
int spider_create_mon_threads(
SPIDER_TRX *trx,
SPIDER_SHARE *share
);
void spider_free_mon_threads(
SPIDER_SHARE *share
);
void *spider_bg_mon_action(
void *arg
);
#endif
int spider_conn_first_link_idx(
THD *thd,
long *link_statuses,
long *access_balances,
uint *conn_link_idx,
int link_count,
int link_status
);
int spider_conn_next_link_idx(
THD *thd,
long *link_statuses,
long *access_balances,
uint *conn_link_idx,
int link_idx,
int link_count,
int link_status
);
int spider_conn_link_idx_next(
long *link_statuses,
uint *conn_link_idx,
int link_idx,
int link_count,
int link_status
);
int spider_conn_get_link_status(
long *link_statuses,
uint *conn_link_idx,
int link_idx
);
int spider_conn_lock_mode(
ha_spider *spider
);
bool spider_conn_check_recovery_link(
SPIDER_SHARE *share
);
bool spider_conn_use_handler(
ha_spider *spider,
int lock_mode,
int link_idx
);
bool spider_conn_need_open_handler(
ha_spider *spider,
uint idx,
int link_idx
);
SPIDER_IP_PORT_CONN *spider_create_ipport_conn(SPIDER_CONN *conn);
SPIDER_CONN* spider_get_conn_from_idle_connection
(
SPIDER_SHARE *share,
int link_idx,
char *conn_key,
ha_spider *spider,
uint conn_kind,
int base_link_idx,
int *error_num
);
void spider_free_ipport_conn(void *info);
|