summaryrefslogtreecommitdiff
path: root/storage/ndb/include/transporter/TransporterCallback.hpp
blob: 55bbe49fdf9053001fd81e3d7fdab1cab3b95c8f (plain)
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
/* Copyright (c) 2003, 2005 MySQL AB
   Use is subject to license terms

   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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA */

//**************************************************************************** 
// 
//  AUTHOR 
//      Åsa Fransson 
// 
//  NAME 
//      TransporterCallback 
// 
// 
//***************************************************************************/ 
#ifndef TRANSPORTER_CALLBACK_H 
#define TRANSPORTER_CALLBACK_H 
 
#include <kernel_types.h> 
#include "TransporterDefinitions.hpp" 
 
 
/** 
 * Call back functions 
 */ 
 
/** 
 * The execute function 
 */ 
void
execute(void * callbackObj, 
	SignalHeader * const header,  
	Uint8 prio,  
	Uint32 * const signalData,
	LinearSectionPtr ptr[3]);

/** 
 * A function to avoid job buffer overflow in NDB kernel, empty in API 
 * Non-zero return means we executed signals. This is necessary information 
 * to the transporter to ensure that it properly uses the transporter after 
 * coming back again. 
 */ 
int
checkJobBuffer(); 

/** 
 * Report send length 
 */ 
void 
reportSendLen(void * callbackObj,
	      NodeId nodeId, Uint32 count, Uint64 bytes); 
 
/** 
 * Report average receive length 
 */ 
void 
reportReceiveLen(void * callbackObj, 
		 NodeId nodeId, Uint32 count, Uint64 bytes); 
 
/** 
 * Report connection established 
 */ 
void 
reportConnect(void * callbackObj, NodeId nodeId); 
 
/** 
 * Report connection broken 
 */ 
 
void 
reportDisconnect(void * callbackObj,
		 NodeId nodeId, Uint32 errNo); 

#define TE_DO_DISCONNECT 0x8000

enum TransporterError { 
  TE_NO_ERROR = 0,
  /** 
   * TE_ERROR_CLOSING_SOCKET 
   * 
   *   Error found during closing of socket 
   * 
   * Recommended behavior: Ignore 
   */ 
  TE_ERROR_CLOSING_SOCKET = 0x1, 
 
  /** 
   * TE_ERROR_IN_SELECT_BEFORE_ACCEPT 
   * 
   *   Error found during accept (just before) 
   *     The transporter will retry. 
   * 
   * Recommended behavior: Ignore  
   *   (or possible do setPerformState(PerformDisconnect) 
   */ 
  TE_ERROR_IN_SELECT_BEFORE_ACCEPT = 0x2, 
 
  /** 
   * TE_INVALID_MESSAGE_LENGTH 
   * 
   *   Error found in message (message length) 
   * 
   * Recommended behavior: setPerformState(PerformDisconnect) 
   */ 
  TE_INVALID_MESSAGE_LENGTH = 0x3 | TE_DO_DISCONNECT, 
   
  /** 
   * TE_INVALID_CHECKSUM 
   * 
   *   Error found in message (checksum) 
   * 
   * Recommended behavior: setPerformState(PerformDisonnect) 
   */ 
  TE_INVALID_CHECKSUM = 0x4 | TE_DO_DISCONNECT, 
 
  /** 
   * TE_COULD_NOT_CREATE_SOCKET 
   * 
   *   Error found while creating socket 
   * 
   * Recommended behavior: setPerformState(PerformDisonnect) 
   */ 
  TE_COULD_NOT_CREATE_SOCKET = 0x5, 
 
  /** 
   * TE_COULD_NOT_BIND_SOCKET 
   * 
   *   Error found while binding server socket 
   * 
   * Recommended behavior: setPerformState(PerformDisonnect) 
   */ 
  TE_COULD_NOT_BIND_SOCKET = 0x6, 
 
  /** 
   * TE_LISTEN_FAILED 
   * 
   *   Error found while listening to server socket 
   * 
   * Recommended behavior: setPerformState(PerformDisonnect) 
   */ 
  TE_LISTEN_FAILED = 0x7, 
 
  /** 
   * TE_ACCEPT_RETURN_ERROR 
   * 
   *   Error found during accept 
   *     The transporter will retry. 
   * 
   * Recommended behavior: Ignore  
   *   (or possible do setPerformState(PerformDisconnect) 
   */ 
  TE_ACCEPT_RETURN_ERROR = 0x8 
 
  /** 
   * TE_SHM_DISCONNECT  
   * 
   *    The remote node has disconnected 
   * 
   * Recommended behavior: setPerformState(PerformDisonnect) 
   */ 
  ,TE_SHM_DISCONNECT = 0xb | TE_DO_DISCONNECT
 
  /** 
   * TE_SHM_IPC_STAT 
   * 
   *    Unable to check shm segment 
   *      probably because remote node 
   *      has disconnected and removed it 
   * 
   * Recommended behavior: setPerformState(PerformDisonnect) 
   */ 
  ,TE_SHM_IPC_STAT = 0xc | TE_DO_DISCONNECT

  /**
   * Permanent error
   */
  ,TE_SHM_IPC_PERMANENT = 0x21 
 
  /** 
   * TE_SHM_UNABLE_TO_CREATE_SEGMENT 
   * 
   *    Unable to create shm segment 
   *      probably os something error 
   * 
   * Recommended behavior: setPerformState(PerformDisonnect) 
   */ 
  ,TE_SHM_UNABLE_TO_CREATE_SEGMENT = 0xd 
 
  /** 
   * TE_SHM_UNABLE_TO_ATTACH_SEGMENT 
   * 
   *    Unable to attach shm segment 
   *      probably invalid group / user 
   * 
   * Recommended behavior: setPerformState(PerformDisonnect) 
   */ 
  ,TE_SHM_UNABLE_TO_ATTACH_SEGMENT = 0xe 
 
  /** 
   * TE_SHM_UNABLE_TO_REMOVE_SEGMENT 
   * 
   *    Unable to remove shm segment 
   * 
   * Recommended behavior: Ignore (not much to do) 
   *                       Print warning to logfile 
   */ 
  ,TE_SHM_UNABLE_TO_REMOVE_SEGMENT = 0xf 
 
  ,TE_TOO_SMALL_SIGID = 0x10 
  ,TE_TOO_LARGE_SIGID = 0x11 
  ,TE_WAIT_STACK_FULL = 0x12 | TE_DO_DISCONNECT
  ,TE_RECEIVE_BUFFER_FULL = 0x13 | TE_DO_DISCONNECT
 
  /** 
   * TE_SIGNAL_LOST_SEND_BUFFER_FULL 
   * 
   *   Send buffer is full, and trying to force send fails 
   *   a signal is dropped!! very bad very bad 
   * 
   */ 
  ,TE_SIGNAL_LOST_SEND_BUFFER_FULL = 0x14 | TE_DO_DISCONNECT
 
  /** 
   * TE_SIGNAL_LOST 
   * 
   *   Send failed for unknown reason 
   *   a signal is dropped!! very bad very bad 
   * 
   */ 
  ,TE_SIGNAL_LOST = 0x15 
 
  /** 
   * TE_SEND_BUFFER_FULL 
   *  
   *   The send buffer was full, but sleeping for a while solved it 
   */ 
  ,TE_SEND_BUFFER_FULL = 0x16 
 
  /** 
   * TE_SCI_UNABLE_TO_CLOSE_CHANNEL 
   *  
   *  Unable to close the sci channel and the resources allocated by  
   *  the sisci api. 
   */ 
  ,TE_SCI_UNABLE_TO_CLOSE_CHANNEL = 0x22 
 
  /** 
   * TE_SCI_LINK_ERROR 
   *  
   *  There is no link from this node to the switch.  
   *  No point in continuing. Must check the connections. 
   * Recommended behavior: setPerformState(PerformDisonnect) 
   */ 
  ,TE_SCI_LINK_ERROR = 0x0017 
 
  /** 
   * TE_SCI_UNABLE_TO_START_SEQUENCE 
   *  
   *  Could not start a sequence, because system resources  
   *  are exumed or no sequence has been created. 
   *  Recommended behavior: setPerformState(PerformDisonnect) 
   */ 
  ,TE_SCI_UNABLE_TO_START_SEQUENCE = 0x18 | TE_DO_DISCONNECT
   
  /** 
   * TE_SCI_UNABLE_TO_REMOVE_SEQUENCE 
   *  
   *  Could not remove a sequence 
   */ 
  ,TE_SCI_UNABLE_TO_REMOVE_SEQUENCE = 0x19 | TE_DO_DISCONNECT
 
  /** 
   * TE_SCI_UNABLE_TO_CREATE_SEQUENCE 
   *  
   *  Could not create a sequence, because system resources are 
   *  exempted. Must reboot. 
   *  Recommended behavior: setPerformState(PerformDisonnect) 
   */ 
  ,TE_SCI_UNABLE_TO_CREATE_SEQUENCE = 0x1a | TE_DO_DISCONNECT
 
  /** 
   * TE_SCI_UNRECOVERABLE_DATA_TFX_ERROR 
   *  
   *  Tried to send data on redundant link but failed. 
   *  Recommended behavior: setPerformState(PerformDisonnect) 
   */ 
  ,TE_SCI_UNRECOVERABLE_DATA_TFX_ERROR = 0x1b | TE_DO_DISCONNECT
 
  /** 
   * TE_SCI_CANNOT_INIT_LOCALSEGMENT 
   *  
   *  Cannot initialize local segment. A whole lot of things has 
   *  gone wrong (no system resources). Must reboot. 
   *  Recommended behavior: setPerformState(PerformDisonnect) 
   */ 
  ,TE_SCI_CANNOT_INIT_LOCALSEGMENT = 0x1c | TE_DO_DISCONNECT
 
  /** 
   * TE_SCI_CANNOT_MAP_REMOTESEGMENT 
   *  
   *  Cannot map remote segment. No system resources are left.  
   *  Must reboot system. 
   *  Recommended behavior: setPerformState(PerformDisonnect) 
   */ 
  ,TE_SCI_CANNOT_MAP_REMOTESEGMENT = 0x1d | TE_DO_DISCONNECT
 
   /** 
   * TE_SCI_UNABLE_TO_UNMAP_SEGMENT 
   *  
   *  Cannot free the resources used by this segment (step 1). 
   *  Recommended behavior: setPerformState(PerformDisonnect) 
   */ 
  ,TE_SCI_UNABLE_TO_UNMAP_SEGMENT = 0x1e | TE_DO_DISCONNECT
 
   /** 
   * TE_SCI_UNABLE_TO_REMOVE_SEGMENT 
   *  
   *  Cannot free the resources used by this segment (step 2). 
   *  Cannot guarantee that enough resources exist for NDB 
   *  to map more segment 
   *  Recommended behavior: setPerformState(PerformDisonnect) 
   */ 
  ,TE_SCI_UNABLE_TO_REMOVE_SEGMENT = 0x1f  | TE_DO_DISCONNECT
 
   /** 
   * TE_SCI_UNABLE_TO_DISCONNECT_SEGMENT 
   *  
   *  Cannot disconnect from a remote segment. 
   *  Recommended behavior: setPerformState(PerformDisonnect) 
   */ 
  ,TE_SCI_UNABLE_TO_DISCONNECT_SEGMENT = 0x20 | TE_DO_DISCONNECT
 
  /* Used 0x21 */
  /* Used 0x22 */
}; 
 
/** 
 * Report error 
 */ 
void 
reportError(void * callbackObj, NodeId nodeId, TransporterError errorCode,
	    const char *info = 0);

void
transporter_recv_from(void* callbackObj, NodeId node);
 
#endif