1 /* Copyright (c) 2015, 2021, 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 #include "gcs_xcom_statistics_interface.h"
24 /* purecov: begin deadcode */
25 using std::max;
26 using std::min;
27
Gcs_xcom_statistics()28 Gcs_xcom_statistics::Gcs_xcom_statistics()
29 :total_messages_sent(0),
30 total_bytes_sent(0),
31 total_messages_received(0),
32 total_bytes_received(0),
33 min_message_length(0),
34 max_message_length(0),
35 last_message_timestamp(0)
36 {}
37
38
~Gcs_xcom_statistics()39 Gcs_xcom_statistics::~Gcs_xcom_statistics() {}
40
41
get_total_messages_sent()42 long Gcs_xcom_statistics::get_total_messages_sent()
43 {
44 return total_messages_sent;
45 }
46
47
get_total_bytes_sent()48 long Gcs_xcom_statistics::get_total_bytes_sent()
49 {
50 return total_bytes_sent;
51 }
52
53
get_total_messages_received()54 long Gcs_xcom_statistics::get_total_messages_received()
55 {
56 return total_messages_received;
57 }
58
59
get_total_bytes_received()60 long Gcs_xcom_statistics::get_total_bytes_received()
61 {
62 return total_bytes_received;
63 }
64
65
get_min_message_length()66 long Gcs_xcom_statistics::get_min_message_length()
67 {
68 return min_message_length;
69 }
70
71
get_max_message_length()72 long Gcs_xcom_statistics::get_max_message_length()
73 {
74 return max_message_length;
75 }
76
77
get_last_message_timestamp()78 long Gcs_xcom_statistics::get_last_message_timestamp()
79 {
80 return last_message_timestamp;
81 }
82 /* purecov: end*/
83
update_message_sent(unsigned long long message_length)84 void Gcs_xcom_statistics::update_message_sent(unsigned long long message_length)
85 {
86 total_messages_sent++;
87 total_bytes_sent+= message_length;
88 }
89
90
update_message_received(long message_length)91 void Gcs_xcom_statistics::update_message_received(long message_length)
92 {
93 max_message_length= max(max_message_length, message_length);
94
95 // Make the first initialization of min_message_length here
96 if (min_message_length == 0)
97 min_message_length= message_length;
98
99 min_message_length= min(min_message_length, message_length);
100
101 total_messages_received++;
102 total_bytes_received+= message_length;
103 }
104