MySQL 8.4.0
Source Code Documentation
group_action.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 GROUP_ACTION_INCLUDED
25#define GROUP_ACTION_INCLUDED
26
30
31/**
32 @class Group_action_diagnostics
33 The parent class for group wide operations
34*/
36 public:
38 GROUP_ACTION_LOG_INFO = 0, // Info message on termination
39 GROUP_ACTION_LOG_WARNING = 1, // Warning on termination
40 GROUP_ACTION_LOG_ERROR = 2, // Error message on error situations
41 GROUP_ACTION_LOG_END = 3 // Enum end
42 };
43
44 /**
45 Constructor
46 */
48
49 /**
50 Set the message for this operation
51 @param diagnostics another diagnostics object
52 */
54
55 /**
56 Set the result level for the message for this operation
57 @param level the level of the return message
58 */
60
61 /**
62 Set the message for this operation
63 @param level if it is an information, warning or error message
64 @param message the message to the user
65 */
67 std::string &message);
68
69 /**
70 Set the message for this operation
71 @param level if it is an information, warning or error message
72 @param message the message to the user
73 */
75 const char *message);
76
77 /**
78 Appends the given message to the execution message for this operation
79 @param message the message to append
80*/
81 void append_execution_message(const char *message);
82
83 /**
84 Appends the given message to the execution message for this operation
85 @param message the message to append
86 */
87 void append_execution_message(std::string &message);
88
89 /**
90 Set the warning message for this operation
91 @param warning_msg the message to the user
92 */
93 void set_warning_message(const char *warning_msg);
94
95 /**
96 Append to the warning message for this operation
97 @param warning_msg the message to the user
98 */
99 void append_warning_message(const char *warning_msg);
100
101 /**
102 @return the message to be shown to the user
103 */
104 std::string &get_execution_message();
105
106 /**
107 @return the warning to be shown to the user
108 */
109 std::string &get_warning_message();
110
111 /**
112 @return the message level be shown to the user
113 */
115
116 /**
117 return The test has logged warnings?
118 */
119 bool has_warning();
120
121 /**
122 Removes the old log messages and level information
123 */
124 void clear_info();
125
126 private:
127 /** Simply log, are there warnings, or should we report an error*/
129 /** The log execution message: success or failure*/
130 std::string log_message;
131 /** The warning message*/
132 std::string warning_message;
133};
134
135/**
136 @class Group_action
137 The parent class for group wide operations
138*/
140 public:
141 /** Enum for the end results of a action execution */
143 GROUP_ACTION_RESULT_TERMINATED = 0, // Terminated with success
144 GROUP_ACTION_RESULT_ERROR = 1, // Error on execution
145 GROUP_ACTION_RESULT_RESTART = 2, // Due to error the action shall restart
146 GROUP_ACTION_RESULT_ABORTED = 3, // Was aborted due to some internal check
147 GROUP_ACTION_RESULT_KILLED = 4, // Action was killed
148 GROUP_ACTION_RESULT_END = 5 // Enum end
149 };
150
151 virtual ~Group_action() = 0;
152
153 /**
154 Get the message with parameters to this action
155 @param[out] message the message to start the action
156 */
157 virtual void get_action_message(Group_action_message **message) = 0;
158
159 /*
160 Get the message with parameters to this action
161 @param message the message to start the action
162 @param message_origin the invoker address
163 */
165 const std::string &message_origin) = 0;
166
167 /**
168 Execute the action
169 @param invoking_member is the member that invoked it
170 @param stage_handler the stage handler to report progress
171
172 @returns the execution result
173 */
175 bool invoking_member, Plugin_stage_monitor_handler *stage_handler,
177
178 /*
179 Terminate the executing configuration operation
180 @param killed are we killing the action.
181
182 @return true if a problem was found when stopping the action.
183 */
184 virtual bool stop_action_execution(bool killed) = 0;
185
186 /**
187 Gets the info about execution, be it success or failure
188 @return the execution diagnostics object that was the message and its level
189 */
191
192 /**
193 For this action, what is the PSI key for the last stage when the action is
194 terminating.
195
196 @note if not implemented this method will return an invalid key that will
197 make the PFS stage mechanism to never start any stage.
198
199 @return The stage key, -1 if the method is not implemented by the class
200 */
202};
203
204#endif /* GROUP_ACTION_INCLUDED */
The parent class for group wide operations.
Definition: group_action.h:35
enum_action_result_level message_level
Simply log, are there warnings, or should we report an error.
Definition: group_action.h:128
std::string log_message
The log execution message: success or failure.
Definition: group_action.h:130
Group_action_diagnostics()
Constructor.
Definition: group_action.cc:26
void append_execution_message(const char *message)
Appends the given message to the execution message for this operation.
Definition: group_action.cc:57
bool has_warning()
return The test has logged warnings?
Definition: group_action.cc:86
enum_action_result_level
Definition: group_action.h:37
@ GROUP_ACTION_LOG_END
Definition: group_action.h:41
@ GROUP_ACTION_LOG_WARNING
Definition: group_action.h:39
@ GROUP_ACTION_LOG_ERROR
Definition: group_action.h:40
@ GROUP_ACTION_LOG_INFO
Definition: group_action.h:38
void set_warning_message(const char *warning_msg)
Set the warning message for this operation.
Definition: group_action.cc:65
void set_execution_message(enum_action_result_level level, std::string &message)
Set the message for this operation.
Definition: group_action.cc:43
std::string warning_message
The warning message.
Definition: group_action.h:132
std::string & get_warning_message()
Definition: group_action.cc:77
void set_execution_info(Group_action_diagnostics *diagnostics)
Set the message for this operation.
Definition: group_action.cc:31
void clear_info()
Removes the old log messages and level information.
Definition: group_action.cc:90
enum_action_result_level get_execution_message_level()
Definition: group_action.cc:82
void set_execution_message_level(enum_action_result_level level)
Set the result level for the message for this operation.
Definition: group_action.cc:38
std::string & get_execution_message()
Definition: group_action.cc:73
void append_warning_message(const char *warning_msg)
Append to the warning message for this operation.
Definition: group_action.cc:69
Definition: group_action_message.h:33
The parent class for group wide operations.
Definition: group_action.h:139
virtual void get_action_message(Group_action_message **message)=0
Get the message with parameters to this action.
virtual enum_action_execution_result execute_action(bool invoking_member, Plugin_stage_monitor_handler *stage_handler, Notification_context *)=0
Execute the action.
virtual PSI_stage_key get_action_stage_termination_key()
For this action, what is the PSI key for the last stage when the action is terminating.
Definition: group_action.cc:98
virtual Group_action_diagnostics * get_execution_info()=0
Gets the info about execution, be it success or failure.
enum_action_execution_result
Enum for the end results of a action execution.
Definition: group_action.h:142
@ GROUP_ACTION_RESULT_END
Definition: group_action.h:148
@ GROUP_ACTION_RESULT_TERMINATED
Definition: group_action.h:143
@ GROUP_ACTION_RESULT_RESTART
Definition: group_action.h:145
@ GROUP_ACTION_RESULT_ERROR
Definition: group_action.h:144
@ GROUP_ACTION_RESULT_KILLED
Definition: group_action.h:147
@ GROUP_ACTION_RESULT_ABORTED
Definition: group_action.h:146
virtual ~Group_action()=0
virtual int process_action_message(Group_action_message &message, const std::string &message_origin)=0
virtual bool stop_action_execution(bool killed)=0
A convenience context class used to share information between the event handlers and the notifier.
Definition: notification.h:35
Definition: stage_monitor_handler.h:30
unsigned int PSI_stage_key
Instrumented stage key.
Definition: psi_stage_bits.h:43