mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Replace the approach using Foo_thread_args + Foo_thread and manually
spawned threads with a reusable class Thread. This is the second idea implemented in the Alik's patch for BUG#22306: STOP INSTANCE can not be applied for instances in Crashed, Failed and Abandoned. Commiting separately to ease review process. server-tools/instance-manager/commands.cc: Remove an unused header. server-tools/instance-manager/guardian.cc: Use Thread framework instead of manually spawning the Guardian thread. Tidy up. server-tools/instance-manager/guardian.h: Use Thread framework instead of manually spawning the Guardian thread. server-tools/instance-manager/instance.cc: Use Thread framework instead of manually spawning the instance monitoring thread. server-tools/instance-manager/listener.cc: Use Thread framework instead of manually spawning the mysql connection thread. server-tools/instance-manager/listener.h: Use Thread framework instead of manually spawning the mysql connection thread. Rename Listener_thread to Listener for brevity. server-tools/instance-manager/manager.cc: Change references to pointers, as per the coding style. Use Thread framework instead of manually spawning threads. server-tools/instance-manager/mysql_connection.cc: Get rid of Mysql_connection_thread_args. Use class Thread framework instead. Rename Mysql_connection_thread to Mysql_connection for brevity. server-tools/instance-manager/mysql_connection.h: Get rid of Mysql_connection_thread_args. Use class Thread framework instead. Rename Mysql_connection_thread to Mysql_connection for brevity. server-tools/instance-manager/priv.cc: Move set_stacksize_and_create_thread to thread_registry.cc and make it static: it is not used anywhere else now. server-tools/instance-manager/priv.h: No public set_stacksize_n_create_thread server-tools/instance-manager/thread_registry.cc: Implement a base Thread class to be used for all Instance Manager threads. server-tools/instance-manager/thread_registry.h: Implement a base Thread class to be used for all Instance Manager threads.
This commit is contained in:
@ -16,11 +16,10 @@
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
#include <my_global.h>
|
||||
#include <my_sys.h>
|
||||
#include <my_list.h>
|
||||
|
||||
#include "thread_registry.h"
|
||||
#include <my_sys.h>
|
||||
#include <my_list.h>
|
||||
|
||||
#if defined(__GNUC__) && defined(USE_PRAGMA_INTERFACE)
|
||||
#pragma interface
|
||||
@ -31,30 +30,12 @@ class Instance_map;
|
||||
class Thread_registry;
|
||||
struct GUARD_NODE;
|
||||
|
||||
pthread_handler_t guardian_thread_func(void *arg);
|
||||
|
||||
struct Guardian_args
|
||||
{
|
||||
Thread_registry &thread_registry;
|
||||
Instance_map *instance_map;
|
||||
int monitoring_interval;
|
||||
|
||||
Guardian_args(Thread_registry &thread_registry_arg,
|
||||
Instance_map *instance_map_arg,
|
||||
uint monitoring_interval_arg) :
|
||||
thread_registry(thread_registry_arg),
|
||||
instance_map(instance_map_arg),
|
||||
monitoring_interval(monitoring_interval_arg)
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
/**
|
||||
The guardian thread is responsible for monitoring and restarting of guarded
|
||||
instances.
|
||||
*/
|
||||
|
||||
class Guardian: public Guardian_args
|
||||
class Guardian: public Thread
|
||||
{
|
||||
public:
|
||||
/* states of an instance */
|
||||
@ -82,12 +63,10 @@ public:
|
||||
/* Return client state name. */
|
||||
static const char *get_instance_state_name(enum_instance_state state);
|
||||
|
||||
Guardian(Thread_registry &thread_registry_arg,
|
||||
Instance_map *instance_map_arg,
|
||||
uint monitoring_interval_arg);
|
||||
~Guardian();
|
||||
/* Main funtion of the thread */
|
||||
void run();
|
||||
Guardian(Thread_registry *thread_registry_arg,
|
||||
Instance_map *instance_map_arg,
|
||||
uint monitoring_interval_arg);
|
||||
virtual ~Guardian();
|
||||
/* Initialize or refresh the list of guarded instances */
|
||||
int init();
|
||||
/* Request guardian shutdown. Stop instances if needed */
|
||||
@ -117,6 +96,9 @@ public:
|
||||
a valid list node.
|
||||
*/
|
||||
inline enum_instance_state get_instance_state(LIST *instance_node);
|
||||
protected:
|
||||
/* Main funtion of the thread */
|
||||
virtual void run();
|
||||
|
||||
public:
|
||||
pthread_cond_t COND_guardian;
|
||||
@ -133,6 +115,9 @@ private:
|
||||
private:
|
||||
pthread_mutex_t LOCK_guardian;
|
||||
Thread_info thread_info;
|
||||
int monitoring_interval;
|
||||
Thread_registry *thread_registry;
|
||||
Instance_map *instance_map;
|
||||
LIST *guarded_instances;
|
||||
MEM_ROOT alloc;
|
||||
/* this variable is set to TRUE when we want to stop Guardian thread */
|
||||
|
Reference in New Issue
Block a user