MySQL 8.0.39
Source Code Documentation
notification.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 NOTIFICATION_H
25#define NOTIFICATION_H
26
27#include <string>
28
29/**
30 A convenience context class used to share information between
31 the event handlers and the notifier. It contains flags stating
32 which notifications should be triggered and also the view
33 identifier.
34 */
36 private:
41 std::string m_view_id;
42
43 public:
45 : m_member_role_changed(false),
47 m_quorum_lost(false),
48 m_view_changed(false),
49 m_view_id("") {}
50
51 void reset() {
54 m_view_changed = false;
55 m_quorum_lost = false;
56 }
59 void set_quorum_lost() { m_quorum_lost = true; }
61 void set_view_id(const std::string &v) { m_view_id.assign(v); }
62
65 bool get_quorum_lost() const { return m_quorum_lost; }
66 bool get_view_changed() const { return m_view_changed; }
67 const std::string &get_view_id() const { return m_view_id; }
68};
69
70/**
71 This function SHALL trigger the notifications based on the
72 notification context provided as an argument. Different
73 notifications SHALL be emitted depending on what is flagged.
74
75 It calls out into those services that have registered
76 themselves in the server service registry as listeners for
77 the notifications such as view changes, or member state
78 changes.
79
80 If an error is returned it can be that part of the notifications
81 have succeeded and part have not.
82
83 @note The assumption is that this function is fast, i.e.,
84 consumers SHALL implement a notification handling system
85 that will release the caller thread immediately after they
86 receive the notification.
87
88 @param ctx The notification context.
89 */
91
92#endif /* LISTENER_SERVICES_NOTIFICATION_H */
A convenience context class used to share information between the event handlers and the notifier.
Definition: notification.h:35
void set_view_id(const std::string &v)
Definition: notification.h:61
bool get_member_role_changed() const
Definition: notification.h:63
const std::string & get_view_id() const
Definition: notification.h:67
std::string m_view_id
Definition: notification.h:41
bool m_member_state_changed
Definition: notification.h:38
bool get_view_changed() const
Definition: notification.h:66
void reset()
Definition: notification.h:51
bool m_quorum_lost
Definition: notification.h:39
void set_quorum_lost()
Definition: notification.h:59
bool m_member_role_changed
Definition: notification.h:37
void set_view_changed()
Definition: notification.h:60
bool m_view_changed
Definition: notification.h:40
bool get_quorum_lost() const
Definition: notification.h:65
bool get_member_state_changed() const
Definition: notification.h:64
void set_member_state_changed()
Definition: notification.h:58
Notification_context()
Definition: notification.h:44
void set_member_role_changed()
Definition: notification.h:57
bool notify_and_reset_ctx(Notification_context &ctx)
This function SHALL trigger the notifications based on the notification context provided as an argume...
Definition: notification.cc:205