Commit d97e8686 authored by unknown's avatar unknown

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)
parent 234ca309
......@@ -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()
......
......@@ -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))
......
......@@ -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);
......
......@@ -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())
......
......@@ -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;
}
......@@ -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 */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment