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