1
#ifndef INCLUDES_MYSQL_INSTANCE_MANAGER_INSTANCE_H
2
#define INCLUDES_MYSQL_INSTANCE_MANAGER_INSTANCE_H
3
/* Copyright (C) 2004 MySQL AB
5
This program is free software; you can redistribute it and/or modify
6
it under the terms of the GNU General Public License as published by
7
the Free Software Foundation; version 2 of the License.
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
14
You should have received a copy of the GNU General Public License
15
along with this program; if not, write to the Free Software
16
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
18
#include <my_global.h>
21
#include "instance_options.h"
24
#if defined(__GNUC__) && defined(USE_PRAGMA_INTERFACE)
29
class Thread_registry;
33
Instance_name -- the class represents instance name -- a string of length
34
less than MAX_INSTANCE_NAME_SIZE.
36
Generally, this is just a string with self-memory-management and should be
37
eliminated in the future.
43
Instance_name(const LEX_STRING *name);
46
inline const LEX_STRING *get_str() const
51
inline const char *get_c_str() const
56
inline uint get_length() const
63
char str_buffer[MAX_INSTANCE_NAME_SIZE];
70
/* States of an instance. */
71
enum enum_instance_state
79
CRASHED_AND_ABANDONED,
85
The constant defines name of the default mysqld-instance ("mysqld").
87
static const LEX_STRING DFLT_INSTANCE_NAME;
90
static bool is_name_valid(const LEX_STRING *name);
91
static bool is_mysqld_compatible_name(const LEX_STRING *name);
97
bool init(const LEX_STRING *name_arg);
98
bool complete_initialization();
103
bool is_mysqld_running();
107
bool kill_mysqld(int signo);
112
const char *get_state_name();
118
The operation is intended to check if the instance is mysqld-compatible
121
inline bool is_mysqld_compatible() const;
124
The operation is intended to check if the instance is configured properly
125
or not. Misconfigured instances are not managed.
127
inline bool is_configured() const;
130
The operation returns TRUE if the instance is guarded and FALSE otherwise.
132
inline bool is_guarded() const;
135
The operation returns name of the instance.
137
inline const LEX_STRING *get_name() const;
140
The operation returns the current state of the instance.
142
NOTE: At the moment should be used only for guarded instances.
144
inline enum_instance_state get_state() const;
147
The operation changes the state of the instance.
149
NOTE: At the moment should be used only for guarded instances.
152
inline void set_state(enum_instance_state new_state);
155
The operation returns crashed flag.
157
inline bool is_crashed();
161
This attributes contains instance options.
165
Instance_options options;
169
monitoring_thread_active is TRUE if there is a thread that monitors the
170
corresponding mysqld-process.
172
bool monitoring_thread_active;
175
crashed is TRUE when corresponding mysqld-process has been died after
181
configured is TRUE when the instance is configured and FALSE otherwise.
182
Misconfigured instances are not managed.
187
mysqld_compatible specifies whether the instance is mysqld-compatible
188
or not. Mysqld-compatible instances can contain only mysqld-specific
189
options. At the moment an instance is mysqld-compatible if its name is
192
The idea is that [mysqld] section should contain only mysqld-specific
193
options (no Instance Manager-specific options) to be readable by mysqld
196
bool mysqld_compatible;
199
Mutex protecting the instance.
201
pthread_mutex_t LOCK_instance;
204
/* Guarded-instance attributes. */
206
/* state of an instance (i.e. STARTED, CRASHED, etc.) */
207
enum_instance_state state;
210
/* the amount of attemts to restart instance (cleaned up at success) */
213
/* triggered at a crash */
216
/* General time field. Used to provide timeouts (at shutdown and restart) */
220
static const char *get_instance_state_name(enum_instance_state state);
225
bool wait_for_stop();
228
friend class Instance_monitor;
232
inline bool Instance::is_mysqld_compatible() const
234
return mysqld_compatible;
238
inline bool Instance::is_configured() const
244
inline bool Instance::is_guarded() const
246
return !options.nonguarded;
250
inline const LEX_STRING *Instance::get_name() const
252
return &options.instance_name;
256
inline Instance::enum_instance_state Instance::get_state() const
262
inline void Instance::set_state(enum_instance_state new_state)
268
inline bool Instance::is_crashed()
273
#endif /* INCLUDES_MYSQL_INSTANCE_MANAGER_INSTANCE_H */