MySQL  8.0.20
Source Code Documentation
group_action_message.h
Go to the documentation of this file.
1 /* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
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 GROUP_ACTION_MESSAGE_INCLUDED
24 #define GROUP_ACTION_MESSAGE_INCLUDED
25 
26 #include <string>
27 
28 #include "my_inttypes.h"
31 
33  public:
35  // This type should not be used anywhere.
37  // Length of the payload item: 2 bytes
39  // Length of the payload item: 2 bytes
41  // Length of the payload item: 4 bytes
43  // The uuid field
45  // The GCS protocol field: 2 bytes
47  // No valid type codes can appear after this one.
48  PIT_MAX = 5
49  };
50 
51  /** Enum for the types of message / actions */
53  // This type should not be used
55  // Change to multi primary
57  // Elect/Change mode to primary member
59  // Change GCS protocol version
61  // The end of the enum
63  };
64 
65  /** Enum for the phase of the action in the message */
67  ACTION_UNKNOWN_PHASE = 0, // This type should not be used
68  ACTION_START_PHASE = 1, // Start a new action
69  ACTION_END_PHASE = 2, // The action was ended
70  ACTION_ABORT_PHASE = 3, // The action was aborted
71  ACTION_PHASE_END = 4, // The enum end
72  };
73 
74  /**
75  Message constructor
76  */
78 
79  /**
80  Message constructor
81 
82  @param[in] type the action message type
83  */
85 
86  /**
87  Message constructor for ACTION_PRIMARY_ELECTION_MESSAGE action type
88 
89  @param[in] primary_uuid the primary uuid to elect
90  */
91  Group_action_message(std::string &primary_uuid);
92 
93  /**
94  Message constructor for ACTION_SET_COMMUNICATION_PROTOCOL_MESSAGE action
95  type
96 
97  @param[in] gcs_protocol the GCS protocol to change to
98  */
100 
101  /**
102  Message destructor
103  */
104  virtual ~Group_action_message();
105 
106  /**
107  Message constructor for raw data
108 
109  @param[in] buf raw data
110  @param[in] len raw length
111  */
112  Group_action_message(const uchar *buf, size_t len);
113 
114  /** Returns this group action message type */
116  return group_action_type;
117  }
118 
119  /** Returns this group action message phase */
121  return group_action_phase;
122  }
123 
125  group_action_phase = phase;
126  }
127 
128  /**
129  Set the return value for this message
130  @param return_value_arg the value to set
131  */
132  void set_return_value(int return_value_arg) {
133  return_value = return_value_arg;
134  }
135 
136  /**
137  @return The return value associated to this message.
138  */
140 
141  /**
142  Check what is the action that this message encodes from a buffer
143  @param buf the raw data buffer
144  @return If the message is a primary election action or other
145  */
147 
148  /**
149  Returns this group action primary to be elected uuid.
150 
151  @return the primary to be elected uuid, which can be empty
152  */
153  const std::string &get_primary_to_elect_uuid();
154 
155  /**
156  Returns the GCS protocol this group action wants the group to change to.
157 
158  @return the GCS protocol version
159  */
161 
162  protected:
163  /**
164  Encodes the message contents for transmission.
165 
166  @param[out] buffer the message buffer to be written
167  */
168  void encode_payload(std::vector<unsigned char> *buffer) const;
169 
170  /**
171  Message decoding method
172 
173  @param[in] buffer the received data
174  @param[in] end the end of the buffer.
175  */
176  void decode_payload(const unsigned char *buffer, const unsigned char *end);
177 
178  private:
179  /** The action type for this message */
181 
182  /** If it is a start, stop or other message */
184 
185  /** Is there any return value associated to this action */
187 
188  /* Option Values */
189 
190  /** The uuid for election, can be empty if not defined */
192 
193  /** The GCS protocol version to change to */
195 };
196 
197 #endif /* GROUP_ACTION_MESSAGE_INCLUDED */
Definition: group_action_message.h:40
Definition: group_action_message.h:44
unsigned char uchar
Definition: my_inttypes.h:51
int32 get_return_value()
Definition: group_action_message.h:139
Definition: group_action_message.h:68
Definition: group_action_message.h:71
char buffer[STRING_BUFFER]
Definition: test_sql_9_sessions.cc:57
Some integer typedefs for easier portability.
Definition: group_action_message.h:67
Definition: group_action_message.h:62
This is the base GCS plugin message.
Definition: gcs_plugin_messages.h:63
void set_group_action_message_phase(enum_action_message_phase phase)
Definition: group_action_message.h:124
enum_payload_item_type
Definition: group_action_message.h:34
void set_return_value(int return_value_arg)
Set the return value for this message.
Definition: group_action_message.h:132
Definition: group_action_message.h:32
Gcs_protocol_version
The GCS protocol versions.
Definition: gcs_types.h:127
Definition: group_action_message.h:58
Group_action_message()
Message constructor.
Definition: group_action_message.cc:27
void encode_payload(std::vector< unsigned char > *buffer) const
Encodes the message contents for transmission.
Definition: group_action_message.cc:113
Gcs_protocol_version const & get_gcs_protocol()
Returns the GCS protocol this group action wants the group to change to.
Definition: group_action_message.cc:160
Definition: group_action_message.h:56
Definition: group_action_message.h:42
Cursor end()
A past-the-end Cursor.
Definition: rules_table_service.cc:188
virtual ~Group_action_message()
Message destructor.
Definition: group_action_message.cc:59
Definition: group_action_message.h:69
Definition: group_action_message.h:70
Definition: group_action_message.h:38
static enum_action_message_type get_action_type(const uchar *buf)
Check what is the action that this message encodes from a buffer.
Definition: group_action_message.cc:142
Gcs_protocol_version gcs_protocol
The GCS protocol version to change to.
Definition: group_action_message.h:194
const std::string & get_primary_to_elect_uuid()
Returns this group action primary to be elected uuid.
Definition: group_action_message.cc:155
enum_action_message_type group_action_type
The action type for this message.
Definition: group_action_message.h:180
enum_action_message_phase get_group_action_message_phase()
Returns this group action message phase.
Definition: group_action_message.h:120
int32 return_value
Is there any return value associated to this action.
Definition: group_action_message.h:186
Definition: group_action_message.h:54
Definition: group_action_message.h:48
enum_action_message_phase
Enum for the phase of the action in the message.
Definition: group_action_message.h:66
int32_t int32
Definition: my_inttypes.h:65
enum_action_message_type get_group_action_message_type()
Returns this group action message type.
Definition: group_action_message.h:115
Definition: group_action_message.h:36
void decode_payload(const unsigned char *buffer, const unsigned char *end)
Message decoding method.
Definition: group_action_message.cc:66
std::string primary_election_uuid
The uuid for election, can be empty if not defined.
Definition: group_action_message.h:191
enum_action_message_phase group_action_phase
If it is a start, stop or other message.
Definition: group_action_message.h:183
enum_action_message_type
Enum for the types of message / actions.
Definition: group_action_message.h:52