diff options
author | unknown <petr@mysql.com> | 2005-02-27 18:41:34 +0300 |
---|---|---|
committer | unknown <petr@mysql.com> | 2005-02-27 18:41:34 +0300 |
commit | dc9059e008c172d53e157b9386d12893dc308dfa (patch) | |
tree | 982685490bba283c69256c4a5183eda88216d20f /server-tools/instance-manager/guardian.h | |
parent | 4ce6711a14667d4b6cdef18b1424944adce45ad8 (diff) | |
download | mariadb-git-dc9059e008c172d53e157b9386d12893dc308dfa.tar.gz |
post-review fixes + cleanup + some minor fixes
server-tools/instance-manager/buffer.cc:
coding style fixes
server-tools/instance-manager/buffer.h:
wrong constructor initialisation fixed
server-tools/instance-manager/commands.cc:
cleanup
server-tools/instance-manager/guardian.cc:
cleanup + added lock/unlock routines
server-tools/instance-manager/guardian.h:
GUARD_NODE moved to the header
server-tools/instance-manager/instance.cc:
Fix for the linuxthreads/POSIX signal handling problem (see comments in the code)
server-tools/instance-manager/instance.h:
condition variable renamed and commented
server-tools/instance-manager/instance_map.cc:
We need to refresh guardian during flush_instances
server-tools/instance-manager/instance_map.h:
removed obsolete function declaration
server-tools/instance-manager/instance_options.cc:
added caching of computed values
server-tools/instance-manager/instance_options.h:
added vars to cache some option values
server-tools/instance-manager/listener.cc:
check whether we are running on the linux threads
server-tools/instance-manager/manager.cc:
lock guardian before init()
server-tools/instance-manager/parse_output.cc:
cleanup
server-tools/instance-manager/priv.cc:
added global variables to detect whether we are running on the LinuxThreads
server-tools/instance-manager/priv.h:
added global variables to detect whether we are running on the LinuxThreads
Diffstat (limited to 'server-tools/instance-manager/guardian.h')
-rw-r--r-- | server-tools/instance-manager/guardian.h | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/server-tools/instance-manager/guardian.h b/server-tools/instance-manager/guardian.h index 0aec00099de..e43b5d565d7 100644 --- a/server-tools/instance-manager/guardian.h +++ b/server-tools/instance-manager/guardian.h @@ -60,22 +60,47 @@ struct Guardian_thread_args class Guardian_thread: public Guardian_thread_args { public: + /* states of an instance */ + enum INSTANCE_STATE { NOT_STARTED= 1, STARTING, STARTED, JUST_CRASHED, + CRASHED, CRASHED_AND_ABANDONED, STOPPING }; + + /* + The Guardian list node structure. Guardian utilizes it to store + guarded instances plus some additional info. + */ + + struct GUARD_NODE + { + Instance *instance; + /* state of an instance (i.e. STARTED, CRASHED, etc.) */ + INSTANCE_STATE state; + /* the amount of attemts to restart instance (cleaned up at success) */ + int restart_counter; + /* triggered at a crash */ + time_t crash_moment; + /* General time field. Used to provide timeouts (at shutdown and restart) */ + time_t last_checked; + }; + + Guardian_thread(Thread_registry &thread_registry_arg, Instance_map *instance_map_arg, uint monitoring_interval_arg); ~Guardian_thread(); /* Main funtion of the thread */ void run(); - /* Initialize list of guarded instances */ + /* Initialize or refresh the list of guarded instances */ int init(); /* Request guardian shutdown. Stop instances if needed */ void request_shutdown(bool stop_instances); /* Start instance protection */ - int guard(Instance *instance); + int guard(Instance *instance, bool nolock= FALSE); /* Stop instance protection */ int stop_guard(Instance *instance); /* Returns true if guardian thread is stopped */ int is_stopped(); + int lock(); + int unlock(); public: pthread_cond_t COND_guardian; @@ -89,9 +114,6 @@ private: int stopped; private: - /* states of an instance */ - enum { NOT_STARTED= 1, STARTING, STARTED, JUST_CRASHED, CRASHED, - CRASHED_AND_ABANDONED, STOPPING }; pthread_mutex_t LOCK_guardian; Thread_info thread_info; LIST *guarded_instances; |