MySQL 9.1.0
Source Code Documentation
gcs_xcom_statistics_manager.h
Go to the documentation of this file.
1/* Copyright (c) 2023, 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 GCS_XCOM_STATISTICS_MANAGER_INCLUDED
25#define GCS_XCOM_STATISTICS_MANAGER_INCLUDED
26
28
29#include <map>
30#include <vector>
31
32/**
33 * @brief Enumerate that identifies all counter statistics.
34 */
36 kSucessfulProposalRounds = 0, // get_all_sucessful_proposal_rounds
37 kEmptyProposalRounds, // get_all_empty_proposal_rounds
38 kFullProposalCount, // get_all_full_proposal_count
39 kMessagesSent, // get_all_messages_sent
41};
42
43/**
44 * @brief Enumerate that identifies all cumulative statistics.
45 */
47 kBytesSent = 0, // get_all_bytes_sent
48 kMessageBytesReceived, // get_all_message_bytes_received
50};
51
52/**
53 * @brief Enumerate that identifies all time statistics.
54 */
56 kCumulativeProposalTime = 0, // cumulative_proposal_time
57 kLastProposalRoundTime, // last_proposal_round_time
59};
60
61/**
62 * @brief This class is the storage and provider of all statistics coming
63 * from either XCom and GCS.
64 */
66 public:
69
70 // SUM VARS
71 /**
72 * @brief Get the value of a provided statistic which is of a cumulative
73 * nature.
74 *
75 * @param to_get The statistic to get.
76 *
77 * @return uint64_t the value of the statistic
78 */
79 virtual uint64_t get_sum_var_value(
80 Gcs_cumulative_statistics_enum to_get) const = 0;
81
82 /**
83 * @brief Sets the value of a provided statistic which is of a cumulative
84 * nature.
85 *
86 * @param to_set The statistic to add.
87 * @param to_add The value to add to the provided statistic.
88 */
90 uint64_t to_add) = 0;
91
92 // COUNT VARS
93 /**
94 * @brief Get the value of a provided statistic which is of a discrete growth
95 * nature.
96 *
97 * @param to_get The statistic to get.
98 *
99 * @return uint64_t the value of the statistic
100 */
101 virtual uint64_t get_count_var_value(
102 Gcs_counter_statistics_enum to_get) const = 0;
103
104 /**
105 * @brief Sets the value of a provided statistic which is of a discrete growth
106 * nature. It always adds "+1" to the current value.
107 *
108 * @param to_set The statistic to add.
109 */
111
112 // TIMESTAMP VALUES
113 /**
114 * @brief Get the value of a provided statistic which is a timestamp.
115 *
116 * @param to_get The statistic to set.
117 *
118 * @return unsigned long long The timestamp value of that statistic.
119 */
120 virtual unsigned long long get_timestamp_var_value(
121 Gcs_time_statistics_enum to_get) const = 0;
122
123 /**
124 * @brief Sets the value of a provided timestamp statistic which is of a
125 * certain specific value.
126 *
127 * @param to_set The statistic to set.
128 * @param new_value The new value of that statistic.
129 */
131 unsigned long long new_value) = 0;
132
133 /**
134 * @brief Sets the value of a provided timestamp statistic which is of a
135 * cumulative nature.
136 *
137 * @param to_set The statistic to add.
138 * @param to_add The value to add to the provided statistic.
139 */
141 unsigned long long to_add) = 0;
142
143 // ALL OTHER VARS
144 /**
145 * @brief Get all suspicious seen by this node.
146 *
147 * @return std::vector<Gcs_node_suspicious> a vector containing all suspicious
148 * seen by this local node
149 */
150 virtual std::vector<Gcs_node_suspicious> get_all_suspicious() const = 0;
151
152 /**
153 * @brief Adds a suspicious count for a provided node.
154 *
155 * @param node_id The node identifier to add a suspicious. It must be in
156 * address:port format as provided by
157 * @see Gcs_member_identifier
158 */
159 virtual void add_suspicious_for_a_node(std::string node_id) = 0;
160};
161
164 public:
169
171
172 // SUM VARS
173 /**
174 * @see Gcs_xcom_statistics_manager_interface::get_sum_var_value
175 */
176 uint64_t get_sum_var_value(
177 Gcs_cumulative_statistics_enum to_get) const override;
178
179 /**
180 * @see Gcs_xcom_statistics_manager_interface::set_sum_var_value
181 */
183 uint64_t to_add) override;
184
185 // COUNT VARS
186 /**
187 * @see Gcs_xcom_statistics_manager_interface::get_count_var_value
188 */
189 uint64_t get_count_var_value(
190 Gcs_counter_statistics_enum to_get) const override;
191
192 /**
193 * @see Gcs_xcom_statistics_manager_interface::set_count_var_value
194 */
196
197 // TIMESTAMP VALUES
198 /**
199 * @see Gcs_xcom_statistics_manager_interface::get_timestamp_var_value
200 */
201 unsigned long long get_timestamp_var_value(
202 Gcs_time_statistics_enum to_get) const override;
203
204 /**
205 * @see Gcs_xcom_statistics_manager_interface::set_timestamp_var_value
206 */
208 unsigned long long new_value) override;
209
210 /**
211 * @see Gcs_xcom_statistics_manager_interface::set_sum_timestamp_var_value
212 */
214 unsigned long long to_add) override;
215
216 // ALL OTHER VARS
217 /**
218 * @see Gcs_xcom_statistics_manager_interface::get_all_suspicious
219 */
220 std::vector<Gcs_node_suspicious> get_all_suspicious() const override;
221
222 /**
223 * @see Gcs_xcom_statistics_manager_interface::add_suspicious_for_a_node
224 */
225 void add_suspicious_for_a_node(std::string node_id) override;
226
227 private:
228 std::vector<uint64_t> m_sum_statistics;
229 std::vector<uint64_t> m_count_statistics;
230 std::vector<unsigned long long> m_time_statistics;
231 std::map<std::string, uint64_t> m_suspicious_statistics;
232};
233
234#endif /* GCS_XCOM_STATISTICS_MANAGER_INCLUDED*/
Definition: gcs_xcom_statistics_manager.h:163
virtual ~Gcs_xcom_statistics_manager_interface_impl() override=default
uint64_t get_count_var_value(Gcs_counter_statistics_enum to_get) const override
Definition: gcs_xcom_statistics_manager.cc:37
unsigned long long get_timestamp_var_value(Gcs_time_statistics_enum to_get) const override
Definition: gcs_xcom_statistics_manager.cc:49
std::vector< uint64_t > m_count_statistics
Definition: gcs_xcom_statistics_manager.h:229
void set_sum_timestamp_var_value(Gcs_time_statistics_enum to_set, unsigned long long to_add) override
Definition: gcs_xcom_statistics_manager.cc:59
void set_timestamp_var_value(Gcs_time_statistics_enum to_set, unsigned long long new_value) override
Definition: gcs_xcom_statistics_manager.cc:54
std::vector< unsigned long long > m_time_statistics
Definition: gcs_xcom_statistics_manager.h:230
std::vector< uint64_t > m_sum_statistics
Definition: gcs_xcom_statistics_manager.h:228
uint64_t get_sum_var_value(Gcs_cumulative_statistics_enum to_get) const override
Definition: gcs_xcom_statistics_manager.cc:27
std::map< std::string, uint64_t > m_suspicious_statistics
Definition: gcs_xcom_statistics_manager.h:231
std::vector< Gcs_node_suspicious > get_all_suspicious() const override
Definition: gcs_xcom_statistics_manager.cc:66
void set_count_var_value(Gcs_counter_statistics_enum to_set) override
Definition: gcs_xcom_statistics_manager.cc:42
void set_sum_var_value(Gcs_cumulative_statistics_enum to_set, uint64_t to_add) override
Definition: gcs_xcom_statistics_manager.cc:31
Gcs_xcom_statistics_manager_interface_impl()
Definition: gcs_xcom_statistics_manager.h:165
void add_suspicious_for_a_node(std::string node_id) override
Definition: gcs_xcom_statistics_manager.cc:75
This class is the storage and provider of all statistics coming from either XCom and GCS.
Definition: gcs_xcom_statistics_manager.h:65
virtual void set_sum_timestamp_var_value(Gcs_time_statistics_enum to_set, unsigned long long to_add)=0
Sets the value of a provided timestamp statistic which is of a cumulative nature.
virtual void set_timestamp_var_value(Gcs_time_statistics_enum to_set, unsigned long long new_value)=0
Sets the value of a provided timestamp statistic which is of a certain specific value.
virtual void add_suspicious_for_a_node(std::string node_id)=0
Adds a suspicious count for a provided node.
virtual void set_sum_var_value(Gcs_cumulative_statistics_enum to_set, uint64_t to_add)=0
Sets the value of a provided statistic which is of a cumulative nature.
virtual unsigned long long get_timestamp_var_value(Gcs_time_statistics_enum to_get) const =0
Get the value of a provided statistic which is a timestamp.
virtual uint64_t get_count_var_value(Gcs_counter_statistics_enum to_get) const =0
Get the value of a provided statistic which is of a discrete growth nature.
virtual std::vector< Gcs_node_suspicious > get_all_suspicious() const =0
Get all suspicious seen by this node.
virtual void set_count_var_value(Gcs_counter_statistics_enum to_set)=0
Sets the value of a provided statistic which is of a discrete growth nature.
virtual ~Gcs_xcom_statistics_manager_interface()=default
virtual uint64_t get_sum_var_value(Gcs_cumulative_statistics_enum to_get) const =0
Get the value of a provided statistic which is of a cumulative nature.
Gcs_counter_statistics_enum
Enumerate that identifies all counter statistics.
Definition: gcs_xcom_statistics_manager.h:35
@ kMessagesSent
Definition: gcs_xcom_statistics_manager.h:39
@ kFullProposalCount
Definition: gcs_xcom_statistics_manager.h:38
@ kEmptyProposalRounds
Definition: gcs_xcom_statistics_manager.h:37
@ kSucessfulProposalRounds
Definition: gcs_xcom_statistics_manager.h:36
@ kGcsCounterStatisticsEnumEnd
Definition: gcs_xcom_statistics_manager.h:40
Gcs_cumulative_statistics_enum
Enumerate that identifies all cumulative statistics.
Definition: gcs_xcom_statistics_manager.h:46
@ kBytesSent
Definition: gcs_xcom_statistics_manager.h:47
@ kMessageBytesReceived
Definition: gcs_xcom_statistics_manager.h:48
@ kGcsCumulativeStatisticsEnumEnd
Definition: gcs_xcom_statistics_manager.h:49
Gcs_time_statistics_enum
Enumerate that identifies all time statistics.
Definition: gcs_xcom_statistics_manager.h:55
@ kLastProposalRoundTime
Definition: gcs_xcom_statistics_manager.h:57
@ kGcsTimeStatisticsEnumEnd
Definition: gcs_xcom_statistics_manager.h:58
@ kCumulativeProposalTime
Definition: gcs_xcom_statistics_manager.h:56