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