MySQL 8.3.0
Source Code Documentation
gcs_xcom_statistics_manager.h
Go to the documentation of this file.
1/* Copyright (c) 2023, 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 also distributed 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 included with MySQL.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License, version 2.0, for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22
23#ifndef GCS_XCOM_STATISTICS_MANAGER_INCLUDED
24#define GCS_XCOM_STATISTICS_MANAGER_INCLUDED
25
27
28#include <map>
29#include <vector>
30
31/**
32 * @brief Enumerate that identifies all counter statistics.
33 */
35 kSucessfulProposalRounds = 0, // get_all_sucessful_proposal_rounds
36 kEmptyProposalRounds, // get_all_empty_proposal_rounds
37 kFullProposalCount, // get_all_full_proposal_count
38 kMessagesSent, // get_all_messages_sent
40};
41
42/**
43 * @brief Enumerate that identifies all cumulative statistics.
44 */
46 kBytesSent = 0, // get_all_bytes_sent
47 kMessageBytesReceived, // get_all_message_bytes_received
49};
50
51/**
52 * @brief Enumerate that identifies all time statistics.
53 */
55 kCumulativeProposalTime = 0, // cumulative_proposal_time
56 kLastProposalRoundTime, // last_proposal_round_time
58};
59
60/**
61 * @brief This class is the storage and provider of all statistics coming
62 * from either XCom and GCS.
63 */
65 public:
68
69 // SUM VARS
70 /**
71 * @brief Get the value of a provided statistic which is of a cumulative
72 * nature.
73 *
74 * @param to_get The statistic to get.
75 *
76 * @return uint64_t the value of the statistic
77 */
78 virtual uint64_t get_sum_var_value(
79 Gcs_cumulative_statistics_enum to_get) const = 0;
80
81 /**
82 * @brief Sets the value of a provided statistic which is of a cumulative
83 * nature.
84 *
85 * @param to_set The statistic to add.
86 * @param to_add The value to add to the provided statistic.
87 */
89 uint64_t to_add) = 0;
90
91 // COUNT VARS
92 /**
93 * @brief Get the value of a provided statistic which is of a discrete growth
94 * nature.
95 *
96 * @param to_get The statistic to get.
97 *
98 * @return uint64_t the value of the statistic
99 */
100 virtual uint64_t get_count_var_value(
101 Gcs_counter_statistics_enum to_get) const = 0;
102
103 /**
104 * @brief Sets the value of a provided statistic which is of a discrete growth
105 * nature. It always adds "+1" to the current value.
106 *
107 * @param to_set The statistic to add.
108 */
110
111 // TIMESTAMP VALUES
112 /**
113 * @brief Get the value of a provided statistic which is a timestamp.
114 *
115 * @param to_get The statistic to set.
116 *
117 * @return unsigned long long The timestamp value of that statistic.
118 */
119 virtual unsigned long long get_timestamp_var_value(
120 Gcs_time_statistics_enum to_get) const = 0;
121
122 /**
123 * @brief Sets the value of a provided timestamp statistic which is of a
124 * certain specific value.
125 *
126 * @param to_set The statistic to set.
127 * @param new_value The new value of that statistic.
128 */
130 unsigned long long new_value) = 0;
131
132 /**
133 * @brief Sets the value of a provided timestamp statistic which is of a
134 * cumulative nature.
135 *
136 * @param to_set The statistic to add.
137 * @param to_add The value to add to the provided statistic.
138 */
140 unsigned long long to_add) = 0;
141
142 // ALL OTHER VARS
143 /**
144 * @brief Get all suspicious seen by this node.
145 *
146 * @return std::vector<Gcs_node_suspicious> a vector containing all suspicious
147 * seen by this local node
148 */
149 virtual std::vector<Gcs_node_suspicious> get_all_suspicious() const = 0;
150
151 /**
152 * @brief Adds a suspicious count for a provided node.
153 *
154 * @param node_id The node identifier to add a suspicious. It must be in
155 * address:port format as provided by
156 * @see Gcs_member_identifier
157 */
158 virtual void add_suspicious_for_a_node(std::string node_id) = 0;
159};
160
163 public:
168
170
171 // SUM VARS
172 /**
173 * @see Gcs_xcom_statistics_manager_interface::get_sum_var_value
174 */
175 uint64_t get_sum_var_value(
176 Gcs_cumulative_statistics_enum to_get) const override;
177
178 /**
179 * @see Gcs_xcom_statistics_manager_interface::set_sum_var_value
180 */
182 uint64_t to_add) override;
183
184 // COUNT VARS
185 /**
186 * @see Gcs_xcom_statistics_manager_interface::get_count_var_value
187 */
188 uint64_t get_count_var_value(
189 Gcs_counter_statistics_enum to_get) const override;
190
191 /**
192 * @see Gcs_xcom_statistics_manager_interface::set_count_var_value
193 */
195
196 // TIMESTAMP VALUES
197 /**
198 * @see Gcs_xcom_statistics_manager_interface::get_timestamp_var_value
199 */
200 unsigned long long get_timestamp_var_value(
201 Gcs_time_statistics_enum to_get) const override;
202
203 /**
204 * @see Gcs_xcom_statistics_manager_interface::set_timestamp_var_value
205 */
207 unsigned long long new_value) override;
208
209 /**
210 * @see Gcs_xcom_statistics_manager_interface::set_sum_timestamp_var_value
211 */
213 unsigned long long to_add) override;
214
215 // ALL OTHER VARS
216 /**
217 * @see Gcs_xcom_statistics_manager_interface::get_all_suspicious
218 */
219 std::vector<Gcs_node_suspicious> get_all_suspicious() const override;
220
221 /**
222 * @see Gcs_xcom_statistics_manager_interface::add_suspicious_for_a_node
223 */
224 void add_suspicious_for_a_node(std::string node_id) override;
225
226 private:
227 std::vector<uint64_t> m_sum_statistics;
228 std::vector<uint64_t> m_count_statistics;
229 std::vector<unsigned long long> m_time_statistics;
230 std::map<std::string, uint64_t> m_suspicious_statistics;
231};
232
233#endif /* GCS_XCOM_STATISTICS_MANAGER_INCLUDED*/
Definition: gcs_xcom_statistics_manager.h:162
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:36
unsigned long long get_timestamp_var_value(Gcs_time_statistics_enum to_get) const override
Definition: gcs_xcom_statistics_manager.cc:48
std::vector< uint64_t > m_count_statistics
Definition: gcs_xcom_statistics_manager.h:228
void set_sum_timestamp_var_value(Gcs_time_statistics_enum to_set, unsigned long long to_add) override
Definition: gcs_xcom_statistics_manager.cc:58
void set_timestamp_var_value(Gcs_time_statistics_enum to_set, unsigned long long new_value) override
Definition: gcs_xcom_statistics_manager.cc:53
std::vector< unsigned long long > m_time_statistics
Definition: gcs_xcom_statistics_manager.h:229
std::vector< uint64_t > m_sum_statistics
Definition: gcs_xcom_statistics_manager.h:227
uint64_t get_sum_var_value(Gcs_cumulative_statistics_enum to_get) const override
Definition: gcs_xcom_statistics_manager.cc:26
std::map< std::string, uint64_t > m_suspicious_statistics
Definition: gcs_xcom_statistics_manager.h:230
std::vector< Gcs_node_suspicious > get_all_suspicious() const override
Definition: gcs_xcom_statistics_manager.cc:65
void set_count_var_value(Gcs_counter_statistics_enum to_set) override
Definition: gcs_xcom_statistics_manager.cc:41
void set_sum_var_value(Gcs_cumulative_statistics_enum to_set, uint64_t to_add) override
Definition: gcs_xcom_statistics_manager.cc:30
Gcs_xcom_statistics_manager_interface_impl()
Definition: gcs_xcom_statistics_manager.h:164
void add_suspicious_for_a_node(std::string node_id) override
Definition: gcs_xcom_statistics_manager.cc:74
This class is the storage and provider of all statistics coming from either XCom and GCS.
Definition: gcs_xcom_statistics_manager.h:64
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:34
@ kMessagesSent
Definition: gcs_xcom_statistics_manager.h:38
@ kFullProposalCount
Definition: gcs_xcom_statistics_manager.h:37
@ kEmptyProposalRounds
Definition: gcs_xcom_statistics_manager.h:36
@ kSucessfulProposalRounds
Definition: gcs_xcom_statistics_manager.h:35
@ kGcsCounterStatisticsEnumEnd
Definition: gcs_xcom_statistics_manager.h:39
Gcs_cumulative_statistics_enum
Enumerate that identifies all cumulative statistics.
Definition: gcs_xcom_statistics_manager.h:45
@ kBytesSent
Definition: gcs_xcom_statistics_manager.h:46
@ kMessageBytesReceived
Definition: gcs_xcom_statistics_manager.h:47
@ kGcsCumulativeStatisticsEnumEnd
Definition: gcs_xcom_statistics_manager.h:48
Gcs_time_statistics_enum
Enumerate that identifies all time statistics.
Definition: gcs_xcom_statistics_manager.h:54
@ kLastProposalRoundTime
Definition: gcs_xcom_statistics_manager.h:56
@ kGcsTimeStatisticsEnumEnd
Definition: gcs_xcom_statistics_manager.h:57
@ kCumulativeProposalTime
Definition: gcs_xcom_statistics_manager.h:55