diff options
Diffstat (limited to 'TAO/CIAO/DAnCE/RepositoryManager/RepositoryManager_Impl.h')
-rw-r--r-- | TAO/CIAO/DAnCE/RepositoryManager/RepositoryManager_Impl.h | 430 |
1 files changed, 280 insertions, 150 deletions
diff --git a/TAO/CIAO/DAnCE/RepositoryManager/RepositoryManager_Impl.h b/TAO/CIAO/DAnCE/RepositoryManager/RepositoryManager_Impl.h index cfb9e4f715b..4f5f2b4efd0 100644 --- a/TAO/CIAO/DAnCE/RepositoryManager/RepositoryManager_Impl.h +++ b/TAO/CIAO/DAnCE/RepositoryManager/RepositoryManager_Impl.h @@ -1,162 +1,292 @@ -/*======================================================================= - * +/* -*- C++ -*- */ + +//====================================================================== +/** * @file RepositoryManager_Impl.h * * $Id$ * - * @brief This file contains implementation for - * Deployment::RepositoryManager interface. + * Description: + * This file is the main implementation file for the RepositoryManager + * in CIAO. We have used a number of techniques in order to increase + * scalability of the RepoMan while still maintaining complience with + * the D&C spec * - * @author Jaiganesh Balasubramanian <jai@dre.vanderbilt.edu> - * - *======================================================================*/ - -#ifndef REPOSITORYMANAGER_IMPL_H -#define REPOSITORYMANAGER_IMPL_H -#include /**/ "ace/pre.h" - -#include "RepositoryManagerS.h" -#include "ace/Get_Opt.h" -#include "RepositoryManager_Impl.h" -#include "ace/Synch.h" -#include "ace/Hash_Map_Manager.h" -#include "ace/Auto_Ptr.h" -#include "ace/Log_Msg.h" -#include "ace/OS_main.h" -#include "tao/Exception.h" -#include "CIAO/DAnCE/Old_Config_Handlers/XercesString.h" -#include <xercesc/util/XMLUniDefs.hpp> -#include <xercesc/parsers/XercesDOMParser.hpp> -#include <xercesc/parsers/AbstractDOMParser.hpp> -#include "CIAO/DAnCE/Old_Config_Handlers/Config_Handler_export.h" -#include "CIAO/DAnCE/Old_Config_Handlers/Domain_Handler.h" -#include "CIAO/DAnCE/Old_Config_Handlers/PC_Handler.h" -#include "CIAO/DAnCE/Old_Config_Handlers/Plan_Handler.h" -#include "CIAO/DAnCE/Old_Config_Handlers/CompImplDesc_Handler.h" -#include "CIAO/DAnCE/Old_Config_Handlers/DnC_Dump.h" -#include "CIAO/DAnCE/Old_Config_Handlers/Utils.h" -#include "CIAO/DAnCE/Old_Config_Handlers/Config_Error_Handler.h" - -using Config_Handler::XStr; -using xercesc::XMLUni; -using xercesc::XMLString; -using xercesc::XMLException; -using xercesc::DOMException; -using xercesc::DOMBuilder; -using xercesc::DOMImplementationRegistry; -using xercesc::DOMImplementationLS; -using xercesc::DOMImplementation; -using xercesc::DOMAttr; -using xercesc::DOMNamedNodeMap; -using xercesc::DOMLocator; -using xercesc::DOMError; -using xercesc::DOMNodeList; -using xercesc::DOMDocument; -using xercesc::DOMDocumentTraversal; -using xercesc::DOMNodeIterator; -using xercesc::DOMNode; -using xercesc::DOMNodeFilter; -using xercesc::XercesDOMParser; -using xercesc::AbstractDOMParser; + * @author Stoyan Paunov + */ +//====================================================================== + +#ifndef REPOSITORYMANAGERI_H_ +#define REPOSITORYMANAGERI_H_ + + +//-----------------------------NOTE--------------------------------- +//I need to disable all the code which has to do with interface +//type information because we currently do not support assembly +//interfaces which causes undesired behavior with respect to the +//hash tables because the specificType field in assembly interfaces +//is empty, so two unrelated intefaces appear to be related. + +//uncomment this line to turn on the code that relates to interface types +//#define ASSEMBLY_INTERFACE_SUPPORT 1 + +#include "RepositoryManagerDaemonS.h" + +#include "ace/Hash_Map_Manager.h" //for the ACE_Hash_Map_Manager +#include "ace/Null_Mutex.h" //for ACE_Null_Mutex +#include "ace/RW_Mutex.h" //for ACE_RW_Mutex +#include "ace/OS_NS_string.h" //for ACE_CString +#include "ace/SString.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once +#pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ -/** - * - * @class ReposityManager_Impl - * - * @brief This class implements the RepositoryManager. RepositoryManager - * assists the execution process after the planning stage. - * - */ -namespace CIAO +namespace { - class RepositoryManager_Impl - : public virtual POA_CIAO::RepositoryManagerDaemon - { - - public: - - RepositoryManager_Impl (); - - /// Constructor. - RepositoryManager_Impl (CORBA::ORB_ptr orb, - PortableServer::POA_ptr poa - ACE_ENV_ARG_DECL); - - virtual void installPackage (const char* installation_name, - const char* location - ACE_ENV_ARG_DECL_WITH_DEFAULTS) - ACE_THROW_SPEC ((CORBA::SystemException, - Deployment::NameExists, - Deployment::PackageError)); - - virtual void createPackage (const char* installation_name, - const Deployment::PackageConfiguration& pc, - const char* base_location, - CORBA::Boolean replace - ACE_ENV_ARG_DECL_WITH_DEFAULTS) - ACE_THROW_SPEC ((CORBA::SystemException, - Deployment::NameExists, - Deployment::PackageError)); - - virtual Deployment::PackageConfiguration* - findPackageByName (const char* name - ACE_ENV_ARG_DECL_WITH_DEFAULTS) - ACE_THROW_SPEC ((CORBA::SystemException, - Deployment::NoSuchName)); - - virtual Deployment::PackageConfiguration* - findPackageByUUID (const char* name - ACE_ENV_ARG_DECL_WITH_DEFAULTS) - ACE_THROW_SPEC ((CORBA::SystemException, - Deployment::NoSuchName)); - - virtual CORBA::StringSeq* - findNamesByType (const char* type - ACE_ENV_ARG_DECL_WITH_DEFAULTS) - ACE_THROW_SPEC ((CORBA::SystemException)); - - virtual CORBA::StringSeq* - getAllNames (ACE_ENV_ARG_DECL_WITH_DEFAULTS) - ACE_THROW_SPEC ((CORBA::SystemException)); - - virtual CORBA::StringSeq* - getAllTypes (ACE_ENV_ARG_DECL_WITH_DEFAULTS) - ACE_THROW_SPEC ((CORBA::SystemException)); - - virtual void - deletePackage (const char* name - ACE_ENV_ARG_DECL_WITH_DEFAULTS) - ACE_THROW_SPEC ((CORBA::SystemException, - Deployment::NoSuchName)); - - virtual void - shutdown (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) - ACE_THROW_SPEC ((CORBA::SystemException)); - - protected: - - ~RepositoryManager_Impl (); - // destructor - - typedef ACE_Hash_Map_Manager_Ex<const char *, - Deployment::PackageConfiguration, - ACE_Hash<const char *>, ACE_Equal_To<const char *>, - TAO_SYNCH_MUTEX> pc_table; - - typedef pc_table::iterator pc_iterator; - // Cached ORB pointer - CORBA::ORB_var orb_; - - // Cached POA pointer - PortableServer::POA_var poa_; - - pc_table pc_table_; - }; + /// Directory where the packages will be stored locally + const static char* INSTALL_PATH = "RepositoryDir"; + + const static size_t TEMP_LEN = 512; + + const static char* PC_EXTENSION = ".epc"; } -#include /**/ "ace/post.h" -#endif /* REPOSITORYMANAGER_IMPL_H */ +class CIAO_RepositoryManagerDaemon_i : + public virtual POA_CIAO::RepositoryManagerDaemon +{ +public: + /// Constructor + CIAO_RepositoryManagerDaemon_i (CORBA::ORB_ptr the_orb, + const char* server = "http://localhost:5432/"); + + /// Destructor + virtual ~CIAO_RepositoryManagerDaemon_i (void); + + virtual + void shutdown ( + + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual + void installPackage ( + const char * installationName, + const char * location + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + ::Deployment::NameExists, + ::Deployment::PackageError + )); + + virtual + void createPackage ( + const char * installationName, + const ::Deployment::PackageConfiguration & package, + const char * baseLocation, + ::CORBA::Boolean replace + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + ::Deployment::NameExists, + ::Deployment::PackageError + )); + + virtual + ::Deployment::PackageConfiguration * findPackageByName ( + const char * name + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + ::Deployment::NoSuchName + )); + + virtual + ::Deployment::PackageConfiguration * findPackageByUUID ( + const char * UUID + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + ::Deployment::NoSuchName + )); + + virtual + ::CORBA::StringSeq * findNamesByType ( + const char * type + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual + ::CORBA::StringSeq * getAllNames ( + + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual + ::CORBA::StringSeq * getAllTypes ( + + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual + void deletePackage ( + const char * installationName + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + ::Deployment::NoSuchName + )); + + protected: + + /// Function to parse and return the PackageConfiguration from a specified + /// package + Deployment::PackageConfiguration* retrieve_PC_from_package (char* package); + + /// Find out what the name of the PackageConfiguration file is + void find_PC_name (char* package, ACE_CString& pcd_name); + + /// Function to parse and return the PackageConfiguration from the already + /// extracted descriptor files + Deployment::PackageConfiguration* retrieve_PC_from_descriptors (const char* pc_name, + const char* descriptor_dir); + + + /// Function to retrieve a file via HTTP + /// stores the file in the passed preallocated ACE_Message_Block + /// @retval 1 success + /// @retval 0 error + + int HTTP_Get (const char* URL, ACE_Message_Block &mb); + + /// Function to extract all necessary files for parsing the + /// PackageConfiguration descriptor and populating the idl struct. + /// @retval 1 success + /// @retval 0 error + /// + /// @note ACE_CString& pcd_name is an out parameter + + int extract_descriptor_files (char* package, + ACE_CString& pcd_name); + + + ///function to remove the files extracted for parsing the PackageConfiguration + ///descriptor and populating the idl struct. It reads the names of the files + ///from the package. They correspond to the names on disk. + ///return 1 on success + /// 0 on error + + int remove_descriptor_files (char* package); + + + ///function to remove the files extracted from the package upon istallation + ///It reads the names of the files from the package. They correspond to the + ///names on disk. It deletes each file, then it deletes the directories that + ///contain them. + ///NOTE: extraction location is path/*archive_name*/ + ///returns 1 on success + /// 0 on error + + int remove_extracted_package (const char* package_path, const char* extraction_location); + +#if defined ASSEMBLY_INTERFACE_SUPPORT + ///function to extract the type of the component from + ///the PackageConfiguration and update the interface map + ///returns 1 on success + /// 0 on error + + int add_type (::Deployment::PackageConfiguration& pc, + const char* name); + + ///function to remove the interface type of the component + ///being removed from the interface map + ///returns 1 on success + /// 0 on error + + int remove_type (::Deployment::PackageConfiguration& pc, + const char* name); + +#endif + + ///function to dump the state of the RepositoryManager + void dump (void); + + private: + /// Cached information about the installed PackageConfigurations + /// A separate map for the installation names and their UUID's + /// Key: PackageConfiguration name or its UUID (CString type) + /// Value: The location of the local copy of the package + + ///Based on the synchronization needed we can parametrize this with either + ///ACE_Null_Mutex or ACE_RW_Mutex + + typedef ACE_Hash_Map_Manager_Ex<ACE_CString, + ACE_CString, + ACE_Hash<ACE_CString>, + ACE_Equal_To<ACE_CString>, + ACE_RW_Mutex> PCMap; + + + typedef PCMap::iterator PCMap_Iterator; + typedef ACE_Hash_Map_Entry <ACE_CString,ACE_CString> PCEntry; + + + /// Cached information about the installed Component Interfaces + /// A map which associates Component Interface UUIDs with the + /// names of packages which implement this component type + /// Key: Component Interface UUID + /// Value: linked list of the names of installed packages which + /// implement this component type + + ///Based on the synchronization needed we can parametrize this with either + ///ACE_Null_Mutex or ACE_RW_Mutex + + typedef ACE_Hash_Map_Manager_Ex<ACE_CString, + ACE_CString, + ACE_Hash<ACE_CString>, + ACE_Equal_To<ACE_CString>, + ACE_RW_Mutex> CIMap; + + + typedef CIMap::iterator CIMap_Iterator; + typedef ACE_Hash_Map_Entry <ACE_CString,ACE_CString> CIEntry; + typedef ACE_Hash_Map_Bucket_Iterator<ACE_CString, + ACE_CString, + ACE_Hash<ACE_CString>, + ACE_Equal_To<ACE_CString>, + ACE_RW_Mutex> CIBucket_Iterator; + + //a hash map that associates the names of + //PackageConfigurations with their location + PCMap names_; + + /// a hash map that associates the UUIDs of + /// PackageConfigurations with their location + PCMap uuids_; + +#if defined ASSEMBLY_INTERFACE_SUPPORT + //a hash map which associates Component Interface + //UUIDs with their implementations + CIMap types_; +#endif + + //the ORB + CORBA::ORB_var the_orb_; + + char cwd_ [TEMP_LEN]; //will hold the current working directory + ACE_CString install_root_; //full path for the install directory + ACE_CString HTTP_server_; //location of the server + +}; + +#endif /* REPOSITORYMANAGER_H_ */ + |