MySQL 8.3.0
Source Code Documentation
transaction_message.h
Go to the documentation of this file.
1/* Copyright (c) 2013, 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 TRANSACTION_MESSAGE_INCLUDED
24#define TRANSACTION_MESSAGE_INCLUDED
25
27
28/*
29 @class Transaction_message
30 Class to convey the serialized contents of the TCLE
31 */
33 public:
35 // This type should not be used anywhere.
37
38 // Length of the payload item: variable
40
41 // Length of the payload item: 8 bytes
43
44 // No valid type codes can appear after this one.
45 PIT_MAX = 3
46 };
47
48 /**
49 Constructor
50
51 @param[in] payload_capacity The transaction data size
52 */
53 Transaction_message(uint64_t payload_capacity);
54 ~Transaction_message() override;
55
56 /**
57 Overrides Basic_ostream::write().
58 Transaction_message is a Basic_ostream, which appends
59 data into the a Gcs_message_data.
60
61 @param[in] buffer where the data will be read
62 @param[in] length the length of the data to write
63
64 @return returns false if succeeds, otherwise true is returned.
65 */
66 bool write(const unsigned char *buffer, my_off_t length) override;
67
68 /**
69 Length of the message.
70
71 @return message length
72 */
73 uint64_t length() override;
74
75 /**
76 Get the Gcs_message_data object, which contains the serialized
77 transaction data.
78 The internal Gcs_message_data is nullified, to avoid further usage
79 of this Transaction object and the caller receives a pointer to the
80 previously internal Gcs_message_data, which whom it is now responsible.
81
82 @return the serialized transaction data in a Gcs_message_data object
83 */
85
86 /**
87 Return the time at which the message contained in the buffer was sent.
88 @see Metrics_handler::get_current_time()
89
90 @param[in] buffer the buffer to decode from.
91 @param[in] length the buffer length
92
93 @return the time on which the message was sent.
94 */
95 static uint64_t get_sent_timestamp(const unsigned char *buffer,
96 size_t length);
97
98 protected:
99 /*
100 Implementation of the template methods
101 */
102 void encode_payload(std::vector<unsigned char> *buffer) const override;
103 void decode_payload(const unsigned char *buffer,
104 const unsigned char *) override;
105
106 private:
108 static const uint64_t s_sent_timestamp_pit_size;
109};
110
111#endif /* TRANSACTION_MESSAGE_INCLUDED */
This class serves as data container for information flowing in the GCS ecosystem.
Definition: gcs_message.h:47
Definition: transaction_message_interface.h:40
Definition: transaction_message.h:32
Gcs_message_data * m_gcs_message_data
Definition: transaction_message.h:107
static uint64_t get_sent_timestamp(const unsigned char *buffer, size_t length)
Return the time at which the message contained in the buffer was sent.
Definition: transaction_message.cc:104
uint64_t length() override
Length of the message.
Definition: transaction_message.cc:67
void encode_payload(std::vector< unsigned char > *buffer) const override
Encodes the contents of this instance payload into the buffer.
Definition: transaction_message.cc:93
bool write(const unsigned char *buffer, my_off_t length) override
Overrides Basic_ostream::write().
Definition: transaction_message.cc:58
Gcs_message_data * get_message_data_and_reset() override
Get the Gcs_message_data object, which contains the serialized transaction data.
Definition: transaction_message.cc:76
enum_payload_item_type
Definition: transaction_message.h:34
@ PIT_MAX
Definition: transaction_message.h:45
@ PIT_UNKNOWN
Definition: transaction_message.h:36
@ PIT_SENT_TIMESTAMP
Definition: transaction_message.h:42
@ PIT_TRANSACTION_DATA
Definition: transaction_message.h:39
static const uint64_t s_sent_timestamp_pit_size
Definition: transaction_message.h:108
void decode_payload(const unsigned char *buffer, const unsigned char *) override
Decodes the contents of the buffer and sets the payload field values according to the values decoded.
Definition: transaction_message.cc:98
Transaction_message(uint64_t payload_capacity)
Constructor.
Definition: transaction_message.cc:31
~Transaction_message() override
Definition: transaction_message.cc:53
ulonglong my_off_t
Definition: my_inttypes.h:71
mutable_buffer buffer(void *p, size_t n) noexcept
Definition: buffer.h:417