1.1.5
by Marc Deslauriers
Import upstream version 5.1.61 |
1 |
/* Copyright (c) 2007 MySQL AB, 2009 Sun Microsystems, Inc.
|
2 |
Use is subject to license terms.
|
|
3 |
||
4 |
This program is free software; you can redistribute it and/or modify
|
|
5 |
it under the terms of the GNU General Public License as published by
|
|
6 |
the Free Software Foundation; version 2 of the License.
|
|
7 |
||
8 |
This program is distributed in the hope that it will be useful,
|
|
9 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
GNU General Public License for more details.
|
|
12 |
||
13 |
You should have received a copy of the GNU General Public License
|
|
14 |
along with this program; if not, write to the Free Software
|
|
15 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
|
16 |
||
1
by Chuck Short
Import upstream version 5.1.30 |
17 |
#ifndef RPL_REPORTING_H
|
18 |
#define RPL_REPORTING_H
|
|
19 |
||
20 |
/**
|
|
21 |
Maximum size of an error message from a slave thread.
|
|
22 |
*/
|
|
23 |
#define MAX_SLAVE_ERRMSG 1024
|
|
24 |
||
25 |
/**
|
|
26 |
Mix-in to handle the message logging and reporting for relay log
|
|
27 |
info and master log info structures.
|
|
28 |
||
29 |
By inheriting from this class, the class is imbued with
|
|
30 |
capabilities to do slave reporting.
|
|
31 |
*/
|
|
32 |
class Slave_reporting_capability |
|
33 |
{
|
|
34 |
public: |
|
0.2.3
by Norbert Tretkowski
Import upstream version 5.1.37 |
35 |
/** lock used to synchronize m_last_error on 'SHOW SLAVE STATUS' **/
|
36 |
mutable pthread_mutex_t err_lock; |
|
1
by Chuck Short
Import upstream version 5.1.30 |
37 |
/**
|
38 |
Constructor.
|
|
39 |
||
40 |
@param thread_name Printable name of the slave thread that is reporting.
|
|
41 |
*/
|
|
42 |
Slave_reporting_capability(char const *thread_name) |
|
43 |
: m_thread_name(thread_name) |
|
44 |
{
|
|
0.2.3
by Norbert Tretkowski
Import upstream version 5.1.37 |
45 |
pthread_mutex_init(&err_lock, MY_MUTEX_INIT_FAST); |
1
by Chuck Short
Import upstream version 5.1.30 |
46 |
}
|
47 |
||
48 |
/**
|
|
49 |
Writes a message and, if it's an error message, to Last_Error
|
|
50 |
(which will be displayed by SHOW SLAVE STATUS).
|
|
51 |
||
52 |
@param level The severity level
|
|
53 |
@param err_code The error code
|
|
54 |
@param msg The message (usually related to the error
|
|
55 |
code, but can contain more information), in
|
|
56 |
printf() format.
|
|
57 |
*/
|
|
58 |
void report(loglevel level, int err_code, const char *msg, ...) const |
|
59 |
ATTRIBUTE_FORMAT(printf, 4, 5); |
|
60 |
||
61 |
/**
|
|
62 |
Clear errors. They will not show up under <code>SHOW SLAVE
|
|
63 |
STATUS</code>.
|
|
64 |
*/
|
|
65 |
void clear_error() { |
|
0.2.3
by Norbert Tretkowski
Import upstream version 5.1.37 |
66 |
pthread_mutex_lock(&err_lock); |
1
by Chuck Short
Import upstream version 5.1.30 |
67 |
m_last_error.clear(); |
0.2.3
by Norbert Tretkowski
Import upstream version 5.1.37 |
68 |
pthread_mutex_unlock(&err_lock); |
1
by Chuck Short
Import upstream version 5.1.30 |
69 |
}
|
70 |
||
71 |
/**
|
|
72 |
Error information structure.
|
|
73 |
*/
|
|
74 |
class Error { |
|
75 |
friend class Slave_reporting_capability; |
|
76 |
public: |
|
77 |
Error() |
|
78 |
{
|
|
79 |
clear(); |
|
80 |
}
|
|
81 |
||
82 |
void clear() |
|
83 |
{
|
|
84 |
number= 0; |
|
85 |
message[0]= '\0'; |
|
86 |
}
|
|
87 |
||
88 |
/** Error code */
|
|
89 |
uint32 number; |
|
90 |
/** Error message */
|
|
91 |
char message[MAX_SLAVE_ERRMSG]; |
|
92 |
};
|
|
93 |
||
94 |
Error const& last_error() const { return m_last_error; } |
|
95 |
||
0.2.3
by Norbert Tretkowski
Import upstream version 5.1.37 |
96 |
virtual ~Slave_reporting_capability()= 0; |
1
by Chuck Short
Import upstream version 5.1.30 |
97 |
private: |
98 |
/**
|
|
99 |
Last error produced by the I/O or SQL thread respectively.
|
|
100 |
*/
|
|
101 |
mutable Error m_last_error; |
|
102 |
||
103 |
char const *const m_thread_name; |
|
0.2.3
by Norbert Tretkowski
Import upstream version 5.1.37 |
104 |
|
105 |
// not implemented
|
|
106 |
Slave_reporting_capability(const Slave_reporting_capability& rhs); |
|
107 |
Slave_reporting_capability& operator=(const Slave_reporting_capability& rhs); |
|
1
by Chuck Short
Import upstream version 5.1.30 |
108 |
};
|
109 |
||
110 |
#endif // RPL_REPORTING_H |
|
111 |