summaryrefslogtreecommitdiff
path: root/server-tools
diff options
context:
space:
mode:
authorunknown <petr@mysql.com>2004-10-27 10:21:48 +0400
committerunknown <petr@mysql.com>2004-10-27 10:21:48 +0400
commitd97e8686f1aa3c880eb5baa9319b1e821d6d2bab (patch)
treeb02502dafdd06567037ebe20ec97173a4268fc16 /server-tools
parent234ca309b9e1e49b6425fbf0dfd662e7d0f7b383 (diff)
downloadmariadb-git-d97e8686f1aa3c880eb5baa9319b1e821d6d2bab.tar.gz
more review fixes
server-tools/instance-manager/command.cc: member rename server-tools/instance-manager/commands.cc: rename server-tools/instance-manager/commands.h: member rename server-tools/instance-manager/guardian.cc: guardian fixed to use Instance_map::Iterator intead of Imap server-tools/instance-manager/instance_map.cc: removed get_instance method from Instance_map as it is needed only by Iterator which is made a friend class server-tools/instance-manager/instance_map.h: use Instance_map::Iterator instead if Imap_iterator (no need to add more names to the global namespace)
Diffstat (limited to 'server-tools')
-rw-r--r--server-tools/instance-manager/command.cc4
-rw-r--r--server-tools/instance-manager/commands.cc18
-rw-r--r--server-tools/instance-manager/commands.h12
-rw-r--r--server-tools/instance-manager/guardian.cc2
-rw-r--r--server-tools/instance-manager/instance_map.cc20
-rw-r--r--server-tools/instance-manager/instance_map.h35
6 files changed, 41 insertions, 50 deletions
diff --git a/server-tools/instance-manager/command.cc b/server-tools/instance-manager/command.cc
index 9f7d08d9fda..818c4b0cae2 100644
--- a/server-tools/instance-manager/command.cc
+++ b/server-tools/instance-manager/command.cc
@@ -21,8 +21,8 @@
#include "command.h"
-Command::Command(Instance_map *imap_arg)
- :instance_map(imap_arg)
+Command::Command(Instance_map *instance_map_arg)
+ :instance_map(instance_map_arg)
{}
Command::~Command()
diff --git a/server-tools/instance-manager/commands.cc b/server-tools/instance-manager/commands.cc
index 357b9a47d4d..102a3df00e5 100644
--- a/server-tools/instance-manager/commands.cc
+++ b/server-tools/instance-manager/commands.cc
@@ -60,7 +60,7 @@ int Show_instances::do_command(struct st_net *net)
{
Instance *instance;
- Imap_iterator iterator(instance_map);
+ Instance_map::Iterator iterator(instance_map);
instance_map->lock();
while (instance= iterator.next())
@@ -110,9 +110,9 @@ int Flush_instances::execute(struct st_net *net, ulong connection_id)
/* implementation for Show_instance_status: */
-Show_instance_status::Show_instance_status(Instance_map *imap_arg,
+Show_instance_status::Show_instance_status(Instance_map *instance_map_arg,
const char *name, uint len)
- :Command(imap_arg)
+ :Command(instance_map_arg)
{
Instance *instance;
@@ -212,9 +212,9 @@ int Show_instance_status::execute(struct st_net *net, ulong connection_id)
/* Implementation for Show_instance_options */
-Show_instance_options::Show_instance_options(Instance_map *imap_arg,
+Show_instance_options::Show_instance_options(Instance_map *instance_map_arg,
const char *name, uint len):
- Command(imap_arg)
+ Command(instance_map_arg)
{
Instance *instance;
@@ -333,9 +333,9 @@ int Show_instance_options::execute(struct st_net *net, ulong connection_id)
/* Implementation for Start_instance */
-Start_instance::Start_instance(Instance_map *imap_arg,
+Start_instance::Start_instance(Instance_map *instance_map_arg,
const char *name, uint len)
- :Command(imap_arg)
+ :Command(instance_map_arg)
{
/* we make a search here, since we don't want t store the name */
if (instance= instance_map->find(name, len))
@@ -366,9 +366,9 @@ int Start_instance::execute(struct st_net *net, ulong connection_id)
/* Implementation for Stop_instance: */
-Stop_instance::Stop_instance(Instance_map *imap_arg,
+Stop_instance::Stop_instance(Instance_map *instance_map_arg,
const char *name, uint len)
- :Command(imap_arg)
+ :Command(instance_map_arg)
{
/* we make a search here, since we don't want t store the name */
if (instance= instance_map->find(name, len))
diff --git a/server-tools/instance-manager/commands.h b/server-tools/instance-manager/commands.h
index 8b53b21bbac..cd13bf09549 100644
--- a/server-tools/instance-manager/commands.h
+++ b/server-tools/instance-manager/commands.h
@@ -27,7 +27,7 @@
class Show_instances : public Command
{
public:
- Show_instances(Instance_map *imap_arg): Command(imap_arg)
+ Show_instances(Instance_map *instance_map_arg): Command(instance_map_arg)
{}
int do_command(struct st_net *net);
@@ -43,7 +43,7 @@ public:
class Flush_instances : public Command
{
public:
- Flush_instances(Instance_map *imap_arg): Command(imap_arg)
+ Flush_instances(Instance_map *instance_map_arg): Command(instance_map_arg)
{}
int execute(struct st_net *net, ulong connection_id);
@@ -59,7 +59,7 @@ class Show_instance_status : public Command
{
public:
- Show_instance_status(Instance_map *imap_arg, const char *name, uint len);
+ Show_instance_status(Instance_map *instance_map_arg, const char *name, uint len);
int do_command(struct st_net *net, const char *instance_name);
int execute(struct st_net *net, ulong connection_id);
const char *instance_name;
@@ -75,7 +75,7 @@ class Show_instance_options : public Command
{
public:
- Show_instance_options(Instance_map *imap_arg, const char *name, uint len);
+ Show_instance_options(Instance_map *instance_map_arg, const char *name, uint len);
int execute(struct st_net *net, ulong connection_id);
int do_command(struct st_net *net, const char *instance_name);
@@ -91,7 +91,7 @@ public:
class Start_instance : public Command
{
public:
- Start_instance(Instance_map *imap_arg, const char *name, uint len);
+ Start_instance(Instance_map *instance_map_arg, const char *name, uint len);
int execute(struct st_net *net, ulong connection_id);
const char *instance_name;
@@ -107,7 +107,7 @@ public:
class Stop_instance : public Command
{
public:
- Stop_instance(Instance_map *imap_arg, const char *name, uint len);
+ Stop_instance(Instance_map *instance_map_arg, const char *name, uint len);
Instance *instance;
int execute(struct st_net *net, ulong connection_id);
diff --git a/server-tools/instance-manager/guardian.cc b/server-tools/instance-manager/guardian.cc
index 5a4d0bade74..c7c0f1b0a77 100644
--- a/server-tools/instance-manager/guardian.cc
+++ b/server-tools/instance-manager/guardian.cc
@@ -107,7 +107,7 @@ void Guardian_thread::run()
int Guardian_thread::start()
{
Instance *instance;
- Imap_iterator iterator(instance_map);
+ Instance_map::Iterator iterator(instance_map);
instance_map->lock();
while (instance= iterator.next())
diff --git a/server-tools/instance-manager/instance_map.cc b/server-tools/instance-manager/instance_map.cc
index aa81194b1d4..b70f622fa73 100644
--- a/server-tools/instance-manager/instance_map.cc
+++ b/server-tools/instance-manager/instance_map.cc
@@ -226,26 +226,20 @@ int Instance_map::load()
}
-Instance *Instance_map::get_instance(uint instance_number)
-{
- if (instance_number < hash.records)
- return (Instance *) hash_element(&hash, instance_number);
- else
- return NULL;
-}
+/*--- Implementaton of the Instance map iterator class ---*/
-/*--- Implementaton of the Instance map iterator class (Imap_iterator) ---*/
-
-
-void Imap_iterator::go_to_first()
+void Instance_map::Iterator::go_to_first()
{
current_instance=0;
}
-Instance *Imap_iterator::next()
+Instance *Instance_map::Iterator::next()
{
- return instance_map->get_instance(current_instance++);
+ if (current_instance < instance_map->hash.records)
+ return (Instance *) hash_element(&instance_map->hash, current_instance++);
+ else
+ return NULL;
}
diff --git a/server-tools/instance-manager/instance_map.h b/server-tools/instance-manager/instance_map.h
index 193376c6f23..21d8c5caa9f 100644
--- a/server-tools/instance-manager/instance_map.h
+++ b/server-tools/instance-manager/instance_map.h
@@ -38,6 +38,22 @@ extern void free_groups(char **groups);
class Instance_map
{
+ friend class Iterator;
+public:
+ /* Instance_map iterator */
+ class Iterator
+ {
+ private:
+ uint current_instance;
+ Instance_map *instance_map;
+ public:
+ Iterator(Instance_map *instance_map_arg) :
+ instance_map(instance_map_arg), current_instance(0)
+ {}
+
+ void go_to_first();
+ Instance *next();
+ };
public:
/* returns a pointer to the instance or NULL, if there is no such instance */
Instance *find(const char *name, uint name_len);
@@ -47,7 +63,6 @@ public:
int cleanup();
int lock();
int unlock();
- Instance *get_instance(uint instance_number);
Instance_map();
~Instance_map();
@@ -72,22 +87,4 @@ private:
HASH hash;
};
-
-/* Instance_map iterator */
-
-class Imap_iterator
-{
-private:
- uint current_instance;
- Instance_map *instance_map;
-public:
- Imap_iterator(Instance_map *instance_map_arg) :
- instance_map(instance_map_arg), current_instance(0)
- {}
-
- void go_to_first();
- Instance *next();
-};
-
-
#endif /* INCLUDES_MYSQL_INSTANCE_MANAGER_INSTANCE_MAP_H */