MySQL 9.1.0
Source Code Documentation
transaction_with_guarantee_message.h
Go to the documentation of this file.
1/* Copyright (c) 2018, 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 TRANSACTION_WITH_GUARANTEE_MESSAGE_INCLUDED
25#define TRANSACTION_WITH_GUARANTEE_MESSAGE_INCLUDED
26
28
30
31/*
32 @class Transaction_with_guarantee_message
33 Class to convey the serialized contents of the TCLE, plus guarantees.
34 */
37 public:
39 // This type should not be used anywhere.
41
42 // Length of the payload item: variable
44
45 // Length of the payload item: 1 byte
47
48 // Length of the payload item: 8 bytes
50
51 // No valid type codes can appear after this one.
52 PIT_MAX = 4
53 };
54
55 /**
56 Constructor
57
58 @param[in] payload_capacity The transaction data size
59 @param[in] consistency_level The transaction consistency level
60 */
62 uint64_t payload_capacity,
65
66 /**
67 Overrides Basic_ostream::write().
68 Transaction_with_guarantee_message is a Basic_ostream, which
69 appends data into the a Gcs_message_data.
70
71 @param[in] buffer where the data will be read
72 @param[in] length the length of the data to write
73
74 @return returns false if succeeds, otherwise true is returned.
75 */
76 bool write(const unsigned char *buffer, my_off_t length) override;
77
78 /**
79 Length of the message.
80
81 @return message length
82 */
83 uint64_t length() override;
84
85 /**
86 Get the Gcs_message_data object, which contains the serialized
87 transaction data.
88 The internal Gcs_message_data is nullified, to avoid further usage
89 of this Transaction object and the caller receives a pointer to the
90 previously internal Gcs_message_data, which whom it is now responsible.
91
92 @return the serialized transaction data in a Gcs_message_data object
93 */
95
96 /**
97 Decode transaction consistency without unmarshal transaction data.
98
99 @return the transaction consistency
100 */
102 decode_and_get_consistency_level(const unsigned char *buffer, size_t);
103
104 /**
105 Return the time at which the message contained in the buffer was sent.
106 @see Metrics_handler::get_current_time()
107
108 @param[in] buffer the buffer to decode from.
109 @param[in] length the buffer length
110
111 @return the time on which the message was sent.
112 */
113 static uint64_t get_sent_timestamp(const unsigned char *buffer,
114 size_t length);
115
116 protected:
117 /*
118 Implementation of the template methods
119 */
120 void encode_payload(std::vector<unsigned char> *buffer) const override;
121 void decode_payload(const unsigned char *buffer,
122 const unsigned char *) override;
123
124 private:
126 static const uint64_t s_consistency_level_pit_size;
128 static const uint64_t s_sent_timestamp_pit_size;
129};
130
131#endif /* TRANSACTION_WITH_GUARANTEE_MESSAGE_INCLUDED */
This class serves as data container for information flowing in the GCS ecosystem.
Definition: gcs_message.h:48
Definition: transaction_message_interface.h:41
Definition: transaction_with_guarantee_message.h:36
static const uint64_t s_sent_timestamp_pit_size
Definition: transaction_with_guarantee_message.h:128
uint64_t length() override
Length of the message.
Definition: transaction_with_guarantee_message.cc:78
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_with_guarantee_message.cc:153
Gcs_message_data * m_gcs_message_data
Definition: transaction_with_guarantee_message.h:125
~Transaction_with_guarantee_message() override
Definition: transaction_with_guarantee_message.cc:63
void encode_payload(std::vector< unsigned char > *buffer) const override
Encodes the contents of this instance payload into the buffer.
Definition: transaction_with_guarantee_message.cc:118
Gcs_message_data * get_message_data_and_reset() override
Get the Gcs_message_data object, which contains the serialized transaction data.
Definition: transaction_with_guarantee_message.cc:88
enum_payload_item_type
Definition: transaction_with_guarantee_message.h:38
@ PIT_MAX
Definition: transaction_with_guarantee_message.h:52
@ PIT_UNKNOWN
Definition: transaction_with_guarantee_message.h:40
@ PIT_TRANSACTION_DATA
Definition: transaction_with_guarantee_message.h:43
@ PIT_SENT_TIMESTAMP
Definition: transaction_with_guarantee_message.h:49
@ PIT_TRANSACTION_CONSISTENCY_LEVEL
Definition: transaction_with_guarantee_message.h:46
Transaction_with_guarantee_message(uint64_t payload_capacity, enum_group_replication_consistency_level consistency_level)
Constructor.
Definition: transaction_with_guarantee_message.cc:36
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_with_guarantee_message.cc:124
bool write(const unsigned char *buffer, my_off_t length) override
Overrides Basic_ostream::write().
Definition: transaction_with_guarantee_message.cc:68
enum_group_replication_consistency_level m_consistency_level
Definition: transaction_with_guarantee_message.h:127
static enum_group_replication_consistency_level decode_and_get_consistency_level(const unsigned char *buffer, size_t)
Decode transaction consistency without unmarshal transaction data.
Definition: transaction_with_guarantee_message.cc:131
static const uint64_t s_consistency_level_pit_size
Definition: transaction_with_guarantee_message.h:126
ulonglong my_off_t
Definition: my_inttypes.h:72
mutable_buffer buffer(void *p, size_t n) noexcept
Definition: buffer.h:418
API for Group Replication plugin.
enum_group_replication_consistency_level
Definition: plugin_group_replication.h:35