diff options
Diffstat (limited to 'TAO/orbsvcs/ImplRepo_Service/Locator_Repository.h')
-rw-r--r-- | TAO/orbsvcs/ImplRepo_Service/Locator_Repository.h | 181 |
1 files changed, 160 insertions, 21 deletions
diff --git a/TAO/orbsvcs/ImplRepo_Service/Locator_Repository.h b/TAO/orbsvcs/ImplRepo_Service/Locator_Repository.h index 7d7092769bc..204f1541c70 100644 --- a/TAO/orbsvcs/ImplRepo_Service/Locator_Repository.h +++ b/TAO/orbsvcs/ImplRepo_Service/Locator_Repository.h @@ -20,6 +20,10 @@ #include "Activator_Info.h" #include "Locator_Options.h" +#include "tao/IORTable/IORTable.h" +#include "tao/PortableServer/PortableServer.h" +#include "orbsvcs/IOR_Multicast.h" + #include "ace/Hash_Map_Manager.h" #include "ace/Configuration.h" #include "ace/Auto_Ptr.h" @@ -28,6 +32,8 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ +class ACE_Reactor; + /** * @class Locator_Repository * @@ -37,22 +43,23 @@ class Locator_Repository { public: - typedef ACE_Hash_Map_Manager_Ex<ACE_CString, + typedef ACE_CString ServerKey; + typedef ACE_Hash_Map_Manager_Ex<ServerKey, Server_Info_Ptr, - ACE_Hash<ACE_CString>, - ACE_Equal_To<ACE_CString>, + ACE_Hash<ServerKey>, + ACE_Equal_To<ServerKey>, ACE_Null_Mutex> SIMap; - typedef ACE_Hash_Map_Manager_Ex<ACE_CString, + typedef ACE_CString ActivatorKey; + typedef ACE_Hash_Map_Manager_Ex<ActivatorKey, Activator_Info_Ptr, - ACE_Hash<ACE_CString>, - ACE_Equal_To<ACE_CString>, + ACE_Hash<ActivatorKey>, + ACE_Equal_To<ActivatorKey>, ACE_Null_Mutex> AIMap; - Locator_Repository(); + Locator_Repository(const Options& opts, CORBA::ORB_ptr orb); - /// Initializes the Server Repository - int init (const Options& opts); + virtual ~Locator_Repository(); int unregister_if_address_reused (const ACE_CString& server_id, const ACE_CString& name, @@ -61,6 +68,7 @@ public: /// Add a new server to the Repository int add_server (const ACE_CString& server_id, const ACE_CString& name, + bool jacorbs, const ACE_CString& aname, const ACE_CString& startup_command, const ImplementationRepository::EnvironmentList& environment_vars, @@ -69,19 +77,21 @@ public: int start_limit, const ACE_CString& partial_ior = ACE_CString(""), const ACE_CString& ior = ACE_CString(""), - ImplementationRepository::ServerObject_ptr svrobj = ImplementationRepository::ServerObject::_nil() + ImplementationRepository::ServerObject_ptr svrobj = + ImplementationRepository::ServerObject::_nil() ); /// Add a new activator to the Repository int add_activator (const ACE_CString& name, const CORBA::Long token, const ACE_CString& ior = ACE_CString(""), - ImplementationRepository::Activator_ptr act = ImplementationRepository::Activator::_nil() + ImplementationRepository::Activator_ptr act = + ImplementationRepository::Activator::_nil() ); /// Update the associated information. - int update_server (const Server_Info& info); + int update_server (const Server_Info_Ptr& info); /// Update the associated information. - int update_activator (const Activator_Info& info); + int update_activator (const Activator_Info_Ptr& info); /// Returns information related to startup. Server_Info_Ptr get_server (const ACE_CString& name); @@ -97,25 +107,154 @@ public: /// Returns the internal hash map containing the server information. SIMap& servers(void); + const SIMap& servers(void) const; /// Returns the internal hash map containing the activator information. AIMap& activators(void); + const AIMap& activators(void) const; + + /// indicate the persistence mode for the repository + virtual const ACE_TCHAR* repo_mode() const = 0; + + /// convert to lower case + static ACE_CString lcase (const ACE_CString& s); + + /// Initialize the repo + int init(PortableServer::POA_ptr root_poa, + PortableServer::POA_ptr imr_poa, + const char* this_ior); + + /// Indicate if multicast should be used + bool multicast() const; + +protected: + /// perform repo mode specific initialization + virtual int init_repo(PortableServer::POA_ptr imr_poa) = 0; + + /// perform sync of repo with backing store + /// defaults to no-op, only shared backing stores + /// need to sync + virtual int sync_load(); + + /// perform server persistent update + virtual int persistent_update(const Server_Info_Ptr& info, bool add) = 0; + + /// perform activator persistent update + virtual int persistent_update(const Activator_Info_Ptr& info, bool add) = 0; + + /// perform persistent remove + virtual int persistent_remove(const ACE_CString& name, bool activator) = 0; + + /// report the ImR Locator's IOR + virtual int report_ior(PortableServer::POA_ptr imr_poa); + + int setup_multicast (ACE_Reactor* reactor, const char* imr_ior); + void teardown_multicast(); - const char* repo_mode(); + bool registered() const; + + const Options& opts_; + TAO_IOR_Multicast ior_multicast_; + const CORBA::ORB_var orb_; + CORBA::String_var imr_ior_; private: - /// Type mechanism to use for persistence. - Options::RepoMode rmode_; + bool registered_; /// The in-memory list of the server information. SIMap server_infos_; /// The in-memory list of the activator information. AIMap activator_infos_; - /// Several rmode_ values require this. - ACE_Auto_Ptr<ACE_Configuration> config_; - /// XML requires the file name - ACE_CString fname_; +}; + +/** +* @class XML_Backing_Store +* +* @brief XML backing store interface containing all ImR persistent information +* in a single file +* +*/ +class No_Backing_Store : public Locator_Repository +{ +public: + No_Backing_Store(const Options& opts, + CORBA::ORB_ptr orb); - unsigned int debug_; + virtual ~No_Backing_Store(); + + /// indicate the persistence mode for the repository + virtual const ACE_TCHAR* repo_mode() const; + +private: + /// perform repo mode specific initialization (no-op) + virtual int init_repo(PortableServer::POA_ptr imr_poa); + + /// perform server persistent update (no-op) + virtual int persistent_update(const Server_Info_Ptr& info, bool add); + + /// perform activator persistent update (no-op) + virtual int persistent_update(const Activator_Info_Ptr& info, bool add); + + /// perform persistent remove (no-op) + virtual int persistent_remove(const ACE_CString& name, bool activator); }; +/** +* @class UpdateableServerInfo +* +* @brief Class for managing changes to ServerInfo memory to ensure +* it is persisted +* +*/ +class UpdateableServerInfo +{ +public: + /// constructor + /// @param repo the repo to report updates to + /// @param name the name of the server to retrieve + UpdateableServerInfo(Locator_Repository* repo, const ACE_CString& name); + + /// constructor + /// @param repo the repo to report updates to + /// @param si an already retrieved Server_Info_Ptr + UpdateableServerInfo(Locator_Repository* repo, const Server_Info_Ptr& si); + + /// constructor (no repo updates will be performed) + /// @param si a Server_Info to create a non-stored Server_Info_Ptr from + UpdateableServerInfo(const Server_Info& si); + + /// destructor (updates repo if needed) + ~UpdateableServerInfo(); + + /// explicitly update repo if needed + void update_repo(); + + /// const Server_Info access + const Server_Info* operator->() const; + + /// const Server_Info& access + const Server_Info& operator*() const; + + /// retrieve smart pointer to non-const Server_Info + /// and indicate repo update required + const Server_Info_Ptr& edit(); + + /// force indication of update needed + void needs_update(); + + /// indicate it Server_Info_Ptr is null + bool null() const; +private: + UpdateableServerInfo(const UpdateableServerInfo& ); + const UpdateableServerInfo& operator=(const UpdateableServerInfo& ); + + /// the repo + Locator_Repository* const repo_; + + /// the retrieved, passed, or non-stored server info + const Server_Info_Ptr si_; + + /// the server info has changes and needs to be updated to the repo + bool needs_update_; +}; + #endif /* REPOSITORY_H */ |