MySQL 8.4.0
Source Code Documentation
gms_listener_test.h
Go to the documentation of this file.
1/* Copyright (c) 2017, 2024, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is designed to work with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have either included with
13 the program or referenced in the documentation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef GMS_LISTENER_TEST_H
25#define GMS_LISTENER_TEST_H
26
29
30#define GMS_LISTENER_EXAMPLE_NAME "group_membership_listener.gr_example"
31#define GMST_LISTENER_EXAMPLE_NAME "group_member_status_listener.gr_example"
32
35
36/**
37 An example implementation of the group_membership_listener
38 service. It is actually used for testing purposes.
39*/
41 public:
42 /**
43 @c notify_view_change(const char*)
44 */
45 static DEFINE_BOOL_METHOD(notify_view_change, (const char *));
46
47 /**
48 @c notify_quorum_lost(const char*)
49 */
50 static DEFINE_BOOL_METHOD(notify_quorum_lost, (const char *));
51};
52
53/**
54 An example implementation of the group_member_status_listener
55 service. It is actually used for testing purposes.
56*/
58 public:
59 /**
60 @c notify_member_role_change(const char*)
61 */
62 static DEFINE_BOOL_METHOD(notify_member_role_change, (const char *));
63
64 /**
65 @c notify_member_state_change(const char*)
66 */
67 static DEFINE_BOOL_METHOD(notify_member_state_change, (const char *));
68};
69
71 public:
72 /**
73 Gms_listener_test_parameters constructor.
74
75 @param [in] message Message to add to the table
76 */
77 Gms_listener_test_parameters(const std::string &message)
78 : m_message(message), m_error(1){};
80
81 /**
82 Get value for class private member error.
83
84 @return the error value returned
85 @retval 0 OK
86 @retval !=0 Error
87 */
88 int get_error();
89
90 /**
91 Set value for class private member error.
92
93 @param [in] error Set value of error
94 */
95 void set_error(int error);
96
97 /**
98 Get message to add to the table.
99
100 @return the message
101 */
102 const std::string &get_message();
103
104 private:
105 const std::string m_message{""};
106 int m_error{1};
107};
108
110 public:
111 Gms_listener_test() = default;
112
113 virtual ~Gms_listener_test() override = default;
114
115 /**
116 Method that will be run on mysql_thread.
117
118 @param [in, out] parameters Values used by method to get service variable.
119
120 */
121 void run(Mysql_thread_body_parameters *parameters) override;
122
123 /**
124 Log the notification message to the test table.
125 This method will run on the MySQL session of the global
126 `mysql_thread_handler`, which is already prepared to be
127 directly use by the `Sql_service_interface`.
128
129 @param [in] message Message to add to the table
130
131 @return the error value returned
132 @retval false OK
133 @retval true Error
134 */
135 bool log_notification_to_test_table(const std::string &message);
136};
137
138#endif /* GMS_LISTENER_TEST_H */
Definition: gms_listener_test.h:70
int m_error
Definition: gms_listener_test.h:106
virtual ~Gms_listener_test_parameters()
Definition: gms_listener_test.h:79
Gms_listener_test_parameters(const std::string &message)
Gms_listener_test_parameters constructor.
Definition: gms_listener_test.h:77
const std::string & get_message()
Get message to add to the table.
Definition: gms_listener_test.cc:57
void set_error(int error)
Set value for class private member error.
Definition: gms_listener_test.cc:55
const std::string m_message
Definition: gms_listener_test.h:105
int get_error()
Get value for class private member error.
Definition: gms_listener_test.cc:53
Definition: gms_listener_test.h:109
void run(Mysql_thread_body_parameters *parameters) override
Method that will be run on mysql_thread.
Definition: gms_listener_test.cc:79
virtual ~Gms_listener_test() override=default
Gms_listener_test()=default
bool log_notification_to_test_table(const std::string &message)
Log the notification message to the test table.
Definition: gms_listener_test.cc:61
Interface for Mysql_thread_body parameters.
Definition: mysql_thread.h:39
Interface for Mysql_thread_body, the task of a Mysql_thread.
Definition: mysql_thread.h:108
An example implementation of the group_member_status_listener service.
Definition: gms_listener_test.h:57
static mysql_service_status_t notify_member_state_change(const char *) noexcept
notify_member_state_change(const char*)
Definition: gms_listener_test.cc:210
static mysql_service_status_t notify_member_role_change(const char *) noexcept
notify_member_role_change(const char*)
Definition: gms_listener_test.cc:199
An example implementation of the group_membership_listener service.
Definition: gms_listener_test.h:40
static mysql_service_status_t notify_view_change(const char *) noexcept
notify_view_change(const char*)
Definition: gms_listener_test.cc:178
static mysql_service_status_t notify_quorum_lost(const char *) noexcept
notify_quorum_lost(const char*)
Definition: gms_listener_test.cc:188
void unregister_listener_service_gr_example()
Definition: gms_listener_test.cc:261
void register_listener_service_gr_example()
Definition: gms_listener_test.cc:265
Specifies macros to define Service Implementations.
#define DEFINE_BOOL_METHOD(name, args)
A short macro to define method that returns bool, which is the most common case.
Definition: service_implementation.h:88