diff options
author | brunsch <brunsch@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-06-22 06:39:59 +0000 |
---|---|---|
committer | brunsch <brunsch@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-06-22 06:39:59 +0000 |
commit | e70112cfd6f16ac655112b21c89a91e72f798d88 (patch) | |
tree | cb9a502bee9930473b81ecdc04e5b0120e1de51e /TAO/orbsvcs/ImplRepo_Service/Repository.cpp | |
parent | 3f993cac2d96055feffbfd30e6c009465d52f083 (diff) | |
download | ATCD-e70112cfd6f16ac655112b21c89a91e72f798d88.tar.gz |
Reorganized and worked minimal support (or at least room) for future
inclusion of logical servers and Process information.
Diffstat (limited to 'TAO/orbsvcs/ImplRepo_Service/Repository.cpp')
-rw-r--r-- | TAO/orbsvcs/ImplRepo_Service/Repository.cpp | 305 |
1 files changed, 140 insertions, 165 deletions
diff --git a/TAO/orbsvcs/ImplRepo_Service/Repository.cpp b/TAO/orbsvcs/ImplRepo_Service/Repository.cpp index 4f6d2303a82..dc8578ace17 100644 --- a/TAO/orbsvcs/ImplRepo_Service/Repository.cpp +++ b/TAO/orbsvcs/ImplRepo_Service/Repository.cpp @@ -6,249 +6,224 @@ ACE_RCSID(ImplRepo_Service, Repository, "$Id$") -Repository_Record::Repository_Record () -: comm_line (ACE::strnew ("")), - env (ACE::strnew ("")), - wdir (ACE::strnew ("")), - host (ACE::strnew ("")), - port (0), - ping_ior (ACE::strnew ("")) + + +// 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_ ("") { // Nothing } -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)) + +Server_Info::~Server_Info () { // Nothing } + + +// Updates information that is relevant only when an instance +// of the server is running. -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)) +void +Server_Info::update_running_info (const ACE_TString host, + const unsigned short port, + const ACE_TString server_object_ior) { + this->host_ = host; + this->port_ = port; + this->server_object_ior_ = server_object_ior; } -Repository_Record::~Repository_Record () + +// Returns startup information. + +void +Server_Info::get_startup_info (ACE_TString &logical_server_name, + ACE_TString &startup_command, + ACE_TString &working_dir) { - delete [] this->comm_line; - delete [] this->env; - delete [] this->wdir; - delete [] this->host; - delete [] this->ping_ior; + logical_server_name = this->logical_server_name_; + startup_command = this->startup_command_; + working_dir = this->working_dir_; } -Repository_Record & -Repository_Record::operator= (Repository_Record &r) + +// Returns information about a running instance. + +void +Server_Info::get_running_info (ACE_TString &host, + unsigned short &port, + ACE_TString &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; + host = this->host_; + port = this->port_; + server_object_ior = this->server_object_ior_; } // Default Constructor -Repository::Repository () + +Server_Repository::Server_Repository () { // Nothing } -// Add a new server to the Repository -int -Repository::add (ACE_TString key, const Repository_Record &rec) -{ - 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); - // Store the record in the repository. - return this->repository_.bind (key, new_rec); -} +// Add a new server to the Repository int -Repository::update (ACE_TString key, const Repository_Record &rec) +Server_Repository::add (const ACE_TString POA_name, + const ACE_TString logical_server_name, + const ACE_TString startup_command, + const ACE_TString working_dir) { - if (OPTIONS::instance ()->debug () >= 2) - ACE_DEBUG ((LM_DEBUG, "Repository: Updating key %s\n", key.c_str ())); - - Repository_Record *new_rec = new Repository_Record (rec); - Repository_Record *old_rec; + Server_Info *new_server; + ACE_NEW_RETURN (new_server, + Server_Info (POA_name, logical_server_name, startup_command, working_dir), + -1); - // 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; + return this->repository_.bind (POA_name, new_server); } -// 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 ()); -} +// Update the associated process information. -// Find the key record in the Repository -int -Repository::resolve (ACE_TString key, Repository_Record &rec) +int +Server_Repository::update (const ACE_TString POA_name, + const ACE_TString host, + const unsigned short port, + const ACE_TString server_object_ior) { - 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); + Server_Info *server; + int retval = this->repository_.find (POA_name, server); + // Only fill in data if it was found if (retval == 0) - rec = *rep_rec; + server->update_running_info (host, port, server_object_ior); return retval; } -// = Accessor methods -int -Repository::get_comm_line (ACE_TString key, ASYS_TCHAR *&comm_line) + +// Returns information related to startup. + +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_Record *rec; - int retval = this->repository_.find (key, rec); + Server_Info *server; + int retval = this->repository_.find (POA_name, server); + // Only fill in data if it was found if (retval == 0) - { - ACE_NEW_RETURN (comm_line, ASYS_TCHAR [ACE_OS::strlen (rec->comm_line) + 1], -1); - ACE_OS::strcpy (comm_line, rec->comm_line); - } + server->get_startup_info (logical_server_name, startup_command, working_dir); return retval; } + +// Returns information related to a running copy. -int -Repository::get_env (ACE_TString key, ASYS_TCHAR *&env) +int +Server_Repository::get_running_info (const ACE_TString POA_name, + ACE_TString &host, + unsigned short &port, + ACE_TString &server_object_ior) { - Repository_Record *rec; - int retval = this->repository_.find (key, rec); + Server_Info *server; + int retval = this->repository_.find (POA_name, server); + // Only fill in data if it was found if (retval == 0) - { - ACE_NEW_RETURN (env, ASYS_TCHAR [ACE_OS::strlen (rec->env) + 1], -1); - ACE_OS::strcpy (env, rec->env); - } + server->get_running_info (host, port, server_object_ior); return retval; } -int -Repository::get_wdir (ACE_TString key, ASYS_TCHAR *&wdir) + +// 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_Record *rec; - int retval = this->repository_.find (key, rec); + Server_Info *server; + int retval = this->repository_.find (POA_name, server); + // Only fill in data if it was found if (retval == 0) - { - ACE_NEW_RETURN (wdir, ASYS_TCHAR [ACE_OS::strlen (rec->wdir) + 1], -1); - ACE_OS::strcpy (wdir, rec->wdir); - } + { + retval = server->starting_up_; + server->starting_up_ = new_value; + } return retval; } -int -Repository::get_hostport (ACE_TString key, ASYS_TCHAR *&host, unsigned short &port) + +// Same as above but does not alter the value + +int +Server_Repository::starting_up (const ACE_TString POA_name) { - Repository_Record *rec; - int retval = this->repository_.find (key, rec); + Server_Info *server; + int retval = this->repository_.find (POA_name, server); + // Only fill in data if it was found if (retval == 0) - { - host = rec->host; - port = rec->port; - } + retval = server->starting_up_; return retval; } -int -Repository::get_ping_ior (ACE_TString key, ASYS_TCHAR *&ping_ior) + +// Removes the server from the Repository. + +int +Server_Repository::remove (const ACE_TString POA_name) { - Repository_Record *rec; - int retval = this->repository_.find (key, rec); + return this->repository_.unbind (POA_name); +} - 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); - } - return retval; +// Returns a new iterator that travels over the repository. + +Server_Repository::HASH_IR_ITER * +Server_Repository::new_iterator () +{ + HASH_IR_ITER *hash_iter; + ACE_NEW_RETURN (hash_iter, + Server_Repository::HASH_IR_ITER (this->repository_), + 0); + return hash_iter; } -void -Repository::dump (void) + +// Returns the number of entries in the repository. + +size_t +Server_Repository::get_repository_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)); + return this->repository_.current_size (); } + #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) -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, 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 */ |