summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/ImplRepo_Service/Repository.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'TAO/orbsvcs/ImplRepo_Service/Repository.cpp')
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/Repository.cpp316
1 files changed, 163 insertions, 153 deletions
diff --git a/TAO/orbsvcs/ImplRepo_Service/Repository.cpp b/TAO/orbsvcs/ImplRepo_Service/Repository.cpp
index 10da79c6d87..4f6d2303a82 100644
--- a/TAO/orbsvcs/ImplRepo_Service/Repository.cpp
+++ b/TAO/orbsvcs/ImplRepo_Service/Repository.cpp
@@ -6,239 +6,249 @@
ACE_RCSID(ImplRepo_Service, Repository, "$Id$")
-
-
-// Initialize the command_line and working_dir.
-
-Server_Info::Server_Info (const ACE_TString POA_name,
- const ACE_TString logical_server_name,
- const ACE_TString startup_command,
- const ACE_TString working_dir)
-: starting_up_ (0),
- logical_server_name_ (logical_server_name),
- POA_name_ (POA_name),
- startup_command_ (startup_command),
- working_dir_ (working_dir),
- host_ (""),
- port_ (0),
- server_object_ior_ ("")
+Repository_Record::Repository_Record ()
+: comm_line (ACE::strnew ("")),
+ env (ACE::strnew ("")),
+ wdir (ACE::strnew ("")),
+ host (ACE::strnew ("")),
+ port (0),
+ ping_ior (ACE::strnew (""))
{
// Nothing
}
-
-Server_Info::~Server_Info ()
+Repository_Record::Repository_Record (const Repository_Record &r)
+: comm_line (ACE::strnew (r.comm_line)),
+ env (ACE::strnew (r.env)),
+ wdir (ACE::strnew (r.wdir)),
+ host (ACE::strnew (r.host)),
+ port (r.port),
+ ping_ior (ACE::strnew (r.ping_ior))
{
// Nothing
}
-
-// Updates information that is relevant only when an instance
-// of the server is running.
-
-void
-Server_Info::update_running_info (const ACE_TString host,
- const unsigned short port,
- const ACE_TString server_object_ior)
+Repository_Record::Repository_Record (const ASYS_TCHAR *c,
+ const ASYS_TCHAR *e,
+ const ASYS_TCHAR *w,
+ const ASYS_TCHAR *h,
+ const unsigned short p,
+ const ASYS_TCHAR *pi)
+: comm_line (ACE::strnew (c)),
+ env (ACE::strnew (e)),
+ wdir (ACE::strnew (w)),
+ host (ACE::strnew (h)),
+ port (p),
+ ping_ior (ACE::strnew (pi))
{
- this->host_ = host;
- this->port_ = port;
- this->server_object_ior_ = server_object_ior;
}
-
-// Returns startup information.
-
-void
-Server_Info::get_startup_info (ACE_TString &logical_server_name,
- ACE_TString &startup_command,
- ACE_TString &working_dir)
+Repository_Record::~Repository_Record ()
{
- logical_server_name = this->logical_server_name_;
- startup_command = this->startup_command_;
- working_dir = this->working_dir_;
+ delete [] this->comm_line;
+ delete [] this->env;
+ delete [] this->wdir;
+ delete [] this->host;
+ delete [] this->ping_ior;
}
-
-// Returns information about a running instance.
-
-void
-Server_Info::get_running_info (ACE_TString &host,
- unsigned short &port,
- ACE_TString &server_object_ior)
+Repository_Record &
+Repository_Record::operator= (Repository_Record &r)
{
- host = this->host_;
- port = this->port_;
- server_object_ior = this->server_object_ior_;
+ if (this == &r)
+ return *this;
+
+ delete [] this->comm_line;
+ delete [] this->env;
+ delete [] this->wdir;
+ delete [] this->host;
+ delete [] this->ping_ior;
+
+ this->comm_line = ACE::strnew (r.comm_line);
+ this->env = ACE::strnew (r.env);
+ this->wdir = ACE::strnew (r.wdir);
+ this->host = ACE::strnew (r.host);
+ this->port = r.port;
+ this->ping_ior = ACE::strnew (r.ping_ior);
+
+ return *this;
}
// Default Constructor
-
-Server_Repository::Server_Repository ()
+Repository::Repository ()
{
// Nothing
}
-
// Add a new server to the Repository
-
int
-Server_Repository::add (const ACE_TString POA_name,
- const ACE_TString logical_server_name,
- const ACE_TString startup_command,
- const ACE_TString working_dir)
+Repository::add (ACE_TString key, const Repository_Record &rec)
{
- Server_Info *new_server;
- ACE_NEW_RETURN (new_server,
- Server_Info (POA_name, logical_server_name, startup_command, working_dir),
- -1);
-
- return this->repository_.bind (POA_name, new_server);
-}
+ if (OPTIONS::instance ()->debug () >= 2)
+ ACE_DEBUG ((LM_DEBUG, "Repository: Adding key %s\n", key.c_str ()));
+ Repository_Record *new_rec = new Repository_Record (rec);
-// Update the associated process information.
+ // Store the record in the repository.
+ return this->repository_.bind (key, new_rec);
+}
-int
-Server_Repository::update (const ACE_TString POA_name,
- const ACE_TString host,
- const unsigned short port,
- const ACE_TString server_object_ior)
+int
+Repository::update (ACE_TString key, const Repository_Record &rec)
{
- Server_Info *server;
- int retval = this->repository_.find (POA_name, server);
+ if (OPTIONS::instance ()->debug () >= 2)
+ ACE_DEBUG ((LM_DEBUG, "Repository: Updating key %s\n", key.c_str ()));
- // Only fill in data if it was found
- if (retval == 0)
- server->update_running_info (host, port, server_object_ior);
+ Repository_Record *new_rec = new Repository_Record (rec);
+ Repository_Record *old_rec;
- return retval;
+ // Store the record in the repository.
+ int retval = this->repository_.rebind (key, new_rec, old_rec);
+
+ if (retval == 1)
+ delete old_rec;
+
+ return retval >= 0 ? 0 : -1;
}
+// Removes the server from the Repository
+int
+Repository::remove (ACE_TString key)
+{
+ if (OPTIONS::instance ()->debug () >= 2)
+ ACE_DEBUG ((LM_DEBUG, "Repository: Removing key %s\n", key.c_str ()));
+ return this->repository_.unbind (key.c_str ());
+}
-// Returns information related to startup.
+// Find the key record in the Repository
int
-Server_Repository::get_startup_info (const ACE_TString POA_name,
- ACE_TString &logical_server_name,
- ACE_TString &startup_command,
- ACE_TString &working_dir)
+Repository::resolve (ACE_TString key, Repository_Record &rec)
{
- Server_Info *server;
- int retval = this->repository_.find (POA_name, server);
+ if (OPTIONS::instance ()->debug () >= 2)
+ ACE_DEBUG ((LM_DEBUG, "Repository: Resolving key %s\n", key.c_str ()));
+
+ Repository_Record *rep_rec;
+ int retval = this->repository_.find (key, rep_rec);
- // Only fill in data if it was found
if (retval == 0)
- server->get_startup_info (logical_server_name, startup_command, working_dir);
+ rec = *rep_rec;
return retval;
}
-
-
-// Returns information related to a running copy.
+// = Accessor methods
int
-Server_Repository::get_running_info (const ACE_TString POA_name,
- ACE_TString &host,
- unsigned short &port,
- ACE_TString &server_object_ior)
+Repository::get_comm_line (ACE_TString key, ASYS_TCHAR *&comm_line)
{
- Server_Info *server;
- int retval = this->repository_.find (POA_name, server);
+ Repository_Record *rec;
+ int retval = this->repository_.find (key, rec);
- // Only fill in data if it was found
if (retval == 0)
- server->get_running_info (host, port, server_object_ior);
+ {
+ ACE_NEW_RETURN (comm_line, ASYS_TCHAR [ACE_OS::strlen (rec->comm_line) + 1], -1);
+ ACE_OS::strcpy (comm_line, rec->comm_line);
+ }
return retval;
}
-// Checks the starting_up_ variable in the Server_Info and
-// returns the previous value or -1 if the POA_name wasn't found
-
int
-Server_Repository::starting_up (const ACE_TString POA_name, int new_value)
+Repository::get_env (ACE_TString key, ASYS_TCHAR *&env)
{
- Server_Info *server;
- int retval = this->repository_.find (POA_name, server);
+ Repository_Record *rec;
+ int retval = this->repository_.find (key, rec);
- // Only fill in data if it was found
if (retval == 0)
- {
- retval = server->starting_up_;
- server->starting_up_ = new_value;
- }
+ {
+ ACE_NEW_RETURN (env, ASYS_TCHAR [ACE_OS::strlen (rec->env) + 1], -1);
+ ACE_OS::strcpy (env, rec->env);
+ }
return retval;
}
-
-// Same as above but does not alter the value
-
int
-Server_Repository::starting_up (const ACE_TString POA_name)
+Repository::get_wdir (ACE_TString key, ASYS_TCHAR *&wdir)
{
- Server_Info *server;
- int retval = this->repository_.find (POA_name, server);
+ Repository_Record *rec;
+ int retval = this->repository_.find (key, rec);
- // Only fill in data if it was found
if (retval == 0)
- retval = server->starting_up_;
+ {
+ ACE_NEW_RETURN (wdir, ASYS_TCHAR [ACE_OS::strlen (rec->wdir) + 1], -1);
+ ACE_OS::strcpy (wdir, rec->wdir);
+ }
return retval;
}
-
-// Removes the server from the Repository.
-
int
-Server_Repository::remove (const ACE_TString POA_name)
+Repository::get_hostport (ACE_TString key, ASYS_TCHAR *&host, unsigned short &port)
{
- return this->repository_.unbind (POA_name);
-}
+ Repository_Record *rec;
+ int retval = this->repository_.find (key, rec);
+ if (retval == 0)
+ {
+ host = rec->host;
+ port = rec->port;
+ }
-// Returns a new iterator that travels over the repository.
+ return retval;
+}
-Server_Repository::HASH_IR_ITER *
-Server_Repository::new_iterator ()
+int
+Repository::get_ping_ior (ACE_TString key, ASYS_TCHAR *&ping_ior)
{
- HASH_IR_ITER *hash_iter;
- ACE_NEW_RETURN (hash_iter,
- Server_Repository::HASH_IR_ITER (this->repository_),
- 0);
- return hash_iter;
-}
+ Repository_Record *rec;
+ int retval = this->repository_.find (key, rec);
+ if (retval == 0)
+ {
+ ACE_NEW_RETURN (ping_ior, ASYS_TCHAR [ACE_OS::strlen (rec->ping_ior) + 1], -1);
+ ACE_OS::strcpy (ping_ior, rec->ping_ior);
+ }
-// Returns the number of entries in the repository.
+ return retval;
+}
-size_t
-Server_Repository::get_repository_size ()
+void
+Repository::dump (void)
{
- return this->repository_.current_size ();
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+
+ ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("Total size: %d\n"), this->repository_.total_size ()));
+ ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("Current size: %d\n"), this->repository_.current_size ()));
+ HASH_IR_ENTRY *entry;
+ size_t i = 0;
+
+ for (HASH_IR_ITER hash_iter (this->repository_);
+ hash_iter.next (entry) != 0;
+ hash_iter.advance ())
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ASYS_TEXT ("Record %d has server name \"%s\"\n"),
+ i,
+ ((ACE_TString) entry->ext_id_).c_str ()));
+ i++;
+ }
+
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
}
-
#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
-
-template class ACE_Hash_Map_Entry<ACE_TString, Server_Info *>;
-template class ACE_Hash_Map_Manager_Ex<ACE_TString, Server_Info *,ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_TString>, ACE_Null_Mutex>;
-template class ACE_Hash_Map_Iterator_Base_Ex<ACE_TString, Server_Info *,ACE_Hash<ACE_TString>, ACE_Equal_To<ACE_TString>, ACE_Null_Mutex>;
-template class ACE_Hash_Map_Iterator_Ex<ACE_TString, Server_Info *,ACE_Hash<ACE_TString>, ACE_Equal_To<ACE_TString>, ACE_Null_Mutex>;
-template class ACE_Hash_Map_Reverse_Iterator_Ex<ACE_TString, Server_Info *,ACE_Hash<ACE_TString>, ACE_Equal_To<ACE_TString>, ACE_Null_Mutex>;
-// The ACE_CString case is covered in TAO
-template class ACE_Equal_To<ACE_CString>;
-
+template class ACE_Hash_Map_Entry<ACE_TString, Repository_Record *>;
+template class ACE_Hash_Map_Manager_Ex<ACE_TString, Repository_Record *, ACE_Hash<ACE_TString>, ACE_Equal_To<ACE_TString>, ACE_Null_Mutex>;
+template class ACE_Hash_Map_Iterator_Base_Ex<ACE_TString, Repository_Record *, ACE_Hash<ACE_TString>, ACE_Equal_To<ACE_TString>, ACE_Null_Mutex>;
+template class ACE_Hash_Map_Iterator_Ex<ACE_TString, Repository_Record *, ACE_Hash<ACE_TString>, ACE_Equal_To<ACE_TString>, ACE_Null_Mutex>;
+template class ACE_Hash_Map_Reverse_Iterator_Ex<ACE_TString, Repository_Record *, ACE_Hash<ACE_TString>, ACE_Equal_To<ACE_TString>, ACE_Null_Mutex>;
#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
-
-#pragma instantiate ACE_Hash_Map_Entry<ACE_TString, Server_Info *>
-#pragma instantiate ACE_Hash_Map_Manager_Ex<ACE_CString, Server_Info *,ACE_Hash<ACE_TString>, ACE_Equal_To<ACE_TString>, ACE_Null_Mutex>
-#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex<ACE_CString, Server_Info *,ACE_Hash<ACE_TString>, ACE_Equal_To<ACE_TString>, ACE_Null_Mutex>
-#pragma instantiate ACE_Hash_Map_Iterator_Ex<ACE_TString, Server_Info *,ACE_Hash<ACE_TString>, ACE_Equal_To<ACE_TString>, ACE_Null_Mutex>
-#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex<ACE_TString, Server_Info *,ACE_Hash<ACE_TString>, ACE_Equal_To<ACE_TString>, ACE_Null_Mutex>
-// The ACE_CString case is covered in TAO
-#pragma instantiate ACE_Equal_To<ACE_CString>
-
+#pragma instantiate ACE_Hash_Map_Entry<ACE_TString, Repository_Record *>;
+#pragma instantiate ACE_Hash_Map_Manager_Ex<ACE_TString, Repository_Record *, ACE_Hash<ACE_TString>, ACE_Equal_To<ACE_TString>, ACE_Null_Mutex>;
+#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex<ACE_TString, Repository_Record *, ACE_Hash<ACE_TString>, ACE_Equal_To<ACE_TString>, ACE_Null_Mutex>;
+#pragma instantiate ACE_Hash_Map_Iterator_Ex<ACE_TString, Repository_Record *, ACE_Hash<ACE_TString>, ACE_Equal_To<ACE_TString>, ACE_Null_Mutex>;
+#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex<ACE_TString, Repository_Record *, ACE_Hash<ACE_TString>, ACE_Equal_To<ACE_TString>, ACE_Null_Mutex>;
#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */
+