summaryrefslogtreecommitdiff
path: root/server-tools/instance-manager/guardian.h
diff options
context:
space:
mode:
authorunknown <kostja@bodhi.local>2006-11-17 16:11:04 +0300
committerunknown <kostja@bodhi.local>2006-11-17 16:11:04 +0300
commita163ae30f23239e1f7a9efafc620e1bc74e009ba (patch)
tree5ecdad467c796454f72a94e294ff4958563441fb /server-tools/instance-manager/guardian.h
parent211b2bc92a25609e0c7323b5fee6f646abb3c748 (diff)
downloadmariadb-git-a163ae30f23239e1f7a9efafc620e1bc74e009ba.tar.gz
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.
Diffstat (limited to 'server-tools/instance-manager/guardian.h')
-rw-r--r--server-tools/instance-manager/guardian.h43
1 files changed, 14 insertions, 29 deletions
diff --git a/server-tools/instance-manager/guardian.h b/server-tools/instance-manager/guardian.h
index 4c518dddf23..0eee1dc631d 100644
--- a/server-tools/instance-manager/guardian.h
+++ b/server-tools/instance-manager/guardian.h
@@ -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 */