1
by brian
clean slate |
1 |
#ifndef RPL_REPORTING_H
|
2 |
#define RPL_REPORTING_H
|
|
3 |
||
4 |
/**
|
|
5 |
Maximum size of an error message from a slave thread.
|
|
6 |
*/
|
|
7 |
#define MAX_SLAVE_ERRMSG 1024
|
|
8 |
||
9 |
/**
|
|
10 |
Mix-in to handle the message logging and reporting for relay log
|
|
11 |
info and master log info structures.
|
|
12 |
||
13 |
By inheriting from this class, the class is imbued with
|
|
14 |
capabilities to do slave reporting.
|
|
15 |
*/
|
|
16 |
class Slave_reporting_capability |
|
17 |
{
|
|
18 |
public: |
|
19 |
/**
|
|
20 |
Constructor.
|
|
21 |
||
22 |
@param thread_name Printable name of the slave thread that is reporting.
|
|
23 |
*/
|
|
24 |
Slave_reporting_capability(char const *thread_name) |
|
25 |
: m_thread_name(thread_name) |
|
26 |
{
|
|
27 |
}
|
|
28 |
||
29 |
/**
|
|
30 |
Writes a message and, if it's an error message, to Last_Error
|
|
31 |
(which will be displayed by SHOW SLAVE STATUS).
|
|
32 |
||
33 |
@param level The severity level
|
|
34 |
@param err_code The error code
|
|
35 |
@param msg The message (usually related to the error
|
|
36 |
code, but can contain more information), in
|
|
37 |
printf() format.
|
|
38 |
*/
|
|
39 |
void report(loglevel level, int err_code, const char *msg, ...) const |
|
212.5.26
by Monty Taylor
Removed my_attribute. Renaming __attribute__((format(x,y,z))) to ATTRIBUTE_FORMAT(x,y,z) is retarded. So we don't do it anymore. |
40 |
__attribute__((format(printf, 4, 5))); |
1
by brian
clean slate |
41 |
|
42 |
/**
|
|
43 |
Clear errors. They will not show up under <code>SHOW SLAVE
|
|
44 |
STATUS</code>.
|
|
45 |
*/
|
|
46 |
void clear_error() { |
|
47 |
m_last_error.clear(); |
|
48 |
}
|
|
49 |
||
50 |
/**
|
|
51 |
Error information structure.
|
|
52 |
*/
|
|
53 |
class Error { |
|
54 |
friend class Slave_reporting_capability; |
|
55 |
public: |
|
56 |
Error() |
|
57 |
{
|
|
58 |
clear(); |
|
59 |
}
|
|
60 |
||
61 |
void clear() |
|
62 |
{
|
|
63 |
number= 0; |
|
64 |
message[0]= '\0'; |
|
65 |
}
|
|
66 |
||
67 |
/** Error code */
|
|
205
by Brian Aker
uint32 -> uin32_t |
68 |
uint32_t number; |
1
by brian
clean slate |
69 |
/** Error message */
|
70 |
char message[MAX_SLAVE_ERRMSG]; |
|
71 |
};
|
|
72 |
||
73 |
Error const& last_error() const { return m_last_error; } |
|
74 |
||
75 |
private: |
|
76 |
/**
|
|
77 |
Last error produced by the I/O or SQL thread respectively.
|
|
78 |
*/
|
|
79 |
mutable Error m_last_error; |
|
80 |
||
81 |
char const *const m_thread_name; |
|
82 |
};
|
|
83 |
||
84 |
#endif // RPL_REPORTING_H |
|
85 |