diff options
author | jai <jai@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2004-07-01 20:47:27 +0000 |
---|---|---|
committer | jai <jai@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2004-07-01 20:47:27 +0000 |
commit | 9b0f2409db24a92dc2ebcfd47f514832e0f99c3e (patch) | |
tree | 96110f1d55b453480337e15377661bda922fa7c0 | |
parent | 6dfb465cd15847eb2c2111f7b8ba608482aee495 (diff) | |
download | ATCD-9b0f2409db24a92dc2ebcfd47f514832e0f99c3e.tar.gz |
Thu Jul 1 15:45:48 2004 Jaiganesh B <jai@dre.vanderbilt.edu>
-rw-r--r-- | TAO/CIAO/ChangeLog | 12 | ||||
-rw-r--r-- | TAO/CIAO/DAnCE/RepositoryManager/RepositoryManager.idl | 12 | ||||
-rw-r--r-- | TAO/CIAO/DAnCE/RepositoryManager/RepositoryManager.mpc | 25 | ||||
-rw-r--r-- | TAO/CIAO/DAnCE/RepositoryManager/RepositoryManager_Impl.cpp | 243 | ||||
-rw-r--r-- | TAO/CIAO/DAnCE/RepositoryManager/RepositoryManager_Impl.h | 175 | ||||
-rw-r--r-- | TAO/CIAO/DAnCE/RepositoryManager/Repository_Manager.cpp | 278 | ||||
-rw-r--r-- | TAO/CIAO/DAnCE/RepositoryManager/Update_Plan.cpp | 357 | ||||
-rw-r--r-- | TAO/CIAO/DAnCE/RepositoryManager/Update_Plan.h | 97 |
8 files changed, 1199 insertions, 0 deletions
diff --git a/TAO/CIAO/ChangeLog b/TAO/CIAO/ChangeLog index fe15c9e8f8c..8ecf8a8ac64 100644 --- a/TAO/CIAO/ChangeLog +++ b/TAO/CIAO/ChangeLog @@ -1,3 +1,15 @@ +Thu Jul 1 15:45:48 2004 Jaiganesh B <jai@dre.vanderbilt.edu> + + * DAnCE/RepositoryManager/RepositoryManager.idl: + * DAnCE/RepositoryManager/RepositoryManager.mpc: + * DAnCE/RepositoryManager/RepositoryManager_Impl.cpp: + * DAnCE/RepositoryManager/RepositoryManager_Impl.h: + * DAnCE/RepositoryManager/Repository_Manager.cpp: + * DAnCE/RepositoryManager/Update_Plan.cpp: + * DAnCE/RepositoryManager/Update_Plan.h: + + Moved the RepositoryManager directory here. + Thu Jul 1 15:40:06 2004 Jaiganesh B <jai@dre.vanderbilt.edu> * DAnCE/ciao/CCM_Base.idl: diff --git a/TAO/CIAO/DAnCE/RepositoryManager/RepositoryManager.idl b/TAO/CIAO/DAnCE/RepositoryManager/RepositoryManager.idl new file mode 100644 index 00000000000..1fc19b0d1be --- /dev/null +++ b/TAO/CIAO/DAnCE/RepositoryManager/RepositoryManager.idl @@ -0,0 +1,12 @@ +// $Id$ + +#include "Deployment.idl" + +module CIAO +{ + interface RepositoryManagerDaemon : Deployment::RepositoryManager + { + // Shutdown the daemon process. + oneway void shutdown (); + }; +}; diff --git a/TAO/CIAO/DAnCE/RepositoryManager/RepositoryManager.mpc b/TAO/CIAO/DAnCE/RepositoryManager/RepositoryManager.mpc new file mode 100644 index 00000000000..ffb391133e3 --- /dev/null +++ b/TAO/CIAO/DAnCE/RepositoryManager/RepositoryManager.mpc @@ -0,0 +1,25 @@ +// -*- MPC -*- +// $Id$ + +project(Repository_Manager): ciao_server_dnc,ciao_deployment_svnt, ciao_deployment_stub, taoexe { + exename = executor + after += Config_Handlers ExecutionManager_stub NodeDaemon_stub + macros += XML_USE_PTHREADS + includes += /usr/include $(XERCESCROOT)/include + libpaths += /usr/lib $(XERCESCROOT)/lib + libs += xerces-c Config_Handlers NodeDaemon_stub + libs += ExecutionManager_stub CIAO_DnC_Server + after += Config_Handlers + + IDL_Files { + RepositoryManager.idl + } + + Source_Files { + RepositoryManagerC.cpp + RepositoryManagerS.cpp + Update_Plan.cpp + Repository_Manager.cpp + RepositoryManager_Impl.cpp + } +} diff --git a/TAO/CIAO/DAnCE/RepositoryManager/RepositoryManager_Impl.cpp b/TAO/CIAO/DAnCE/RepositoryManager/RepositoryManager_Impl.cpp new file mode 100644 index 00000000000..a9443280afa --- /dev/null +++ b/TAO/CIAO/DAnCE/RepositoryManager/RepositoryManager_Impl.cpp @@ -0,0 +1,243 @@ +/* -*- C++ -*- */ +// $Id$ + +#include "RepositoryManager_Impl.h" +#include "Config_Handlers/TPD_Handler.h" + +CIAO::RepositoryManager_Impl::RepositoryManager_Impl + (CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa) + : orb_ (CORBA::ORB::_duplicate (orb)), + poa_ (PortableServer::POA::_duplicate (poa)) + // @@ (OO) The default size for an ACE_Hash_Map_Mapanger is quiet + // large. The maximum size of an ACE_Hash_Map_Manager is + // also fixed, i.e. it does not grow dynamically on demand. + // Make sure the default size of component_map_ is + // appropriate for your needs. You may also want to make + // the size configurable at compile-time, at least. +{ +} + +CIAO::RepositoryManager_Impl::RepositoryManager_Impl () + // @@ (OO) The default size for an ACE_Hash_Map_Mapanger is quiet + // large. The maximum size of an ACE_Hash_Map_Manager is + // also fixed, i.e. it does not grow dynamically on demand. + // Make sure the default size of component_map_ is + // appropriate for your needs. You may also want to make + // the size configurable at compile-time, at least. +{ +} + +CIAO::RepositoryManager_Impl::~RepositoryManager_Impl () +{ +} + +// @@ (OO) Method definitions should never use "_WITH_DEFAULTS" +// versions of emulated exception parameters. Please remove +// the "_WITH_DEFAULTS" +void +CIAO::RepositoryManager_Impl:: +installPackage (const char* installation_name, + const char* location + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Deployment::NameExists, + Deployment::PackageError)) +{ + try + { + xercesc::XMLPlatformUtils::Initialize(); + } + catch (const XMLException& xml_e) + { + char* message = XMLString::transcode (xml_e.getMessage()); + ACE_Auto_Basic_Array_Ptr<char> cleanup_message (message); + ACE_DEBUG ((LM_DEBUG, "Error during initialization : %s\n", message)); + return; + } + try + { + CIAO::Config_Handler::Config_Error_Handler tpd_err_handler; + CIAO::Config_Handler::Config_Error_Handler pc_err_handler; + std::auto_ptr<DOMBuilder> tpd_parser (CIAO::Config_Handler::Utils:: + create_parser ()); + tpd_parser->setErrorHandler(&tpd_err_handler); + DOMDocument* tpd_doc = tpd_parser->parseURI (location); + + if (tpd_err_handler.getErrors()) + { + throw DOMException (); + } + + CIAO::Config_Handler::TPD_Handler top_pc_handler + (tpd_doc, + DOMNodeFilter::SHOW_ELEMENT | + DOMNodeFilter::SHOW_TEXT); + ACE_TString package_location = top_pc_handler. + process_TopLevelPackageDescription (); + + std::auto_ptr<DOMBuilder> pc_parser (CIAO::Config_Handler::Utils:: + create_parser ()); + pc_parser->setErrorHandler(&pc_err_handler); + DOMDocument* pc_doc = pc_parser->parseURI (package_location.c_str()); + + if (pc_err_handler.getErrors()) + { + throw DOMException (); + } + + CIAO::Config_Handler::PC_Handler pc_handler (pc_doc, + DOMNodeFilter::SHOW_ELEMENT | + DOMNodeFilter::SHOW_TEXT); + pc_handler.process_PackageConfiguration (this->pc_); + this->pc_table_.bind (installation_name, &(pc_)); + } + catch (CORBA::Exception& ex) + { + ACE_PRINT_EXCEPTION (ex, "Caught CORBA Exception: "); + return; + } + catch (const DOMException& e) + { + const unsigned int maxChars = 2047; + XMLCh errText[maxChars + 1]; + + ACE_ERROR ((LM_ERROR, "\nException occured while parsing %s: \ + \n",location)); + ACE_ERROR ((LM_ERROR, "DOMException code: %d\n ", e.code)); + if (DOMImplementation::loadDOMExceptionMsg (e.code, errText, maxChars)) + { + char* message = XMLString::transcode (errText); + ACE_Auto_Basic_Array_Ptr<char> cleanup_message (message); + ACE_ERROR ((LM_ERROR, "Message is: %s\n", message)); + } + ACE_ERROR ((LM_ERROR, "Caught DOM exception\n")); + return; + } + catch (...) + { + ACE_ERROR ((LM_ERROR, "Caught unknown exception\n")); + return; + } +} + +// @@ (OO) Method definitions should never use "_WITH_DEFAULTS" +// versions of emulated exception parameters. Please remove +// the "_WITH_DEFAULTS" +void +CIAO::RepositoryManager_Impl:: +createPackage (const char*, + const Deployment::PackageConfiguration&, + const char*, + CORBA::Boolean + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Deployment::NameExists, + Deployment::PackageError)) +{ + // @@ (OO) It appears that you should be throwing a + // CORBA::NO_IMPLEMENT exception here. Please confirm. +} + +// @@ (OO) Method definitions should never use "_WITH_DEFAULTS" +// versions of emulated exception parameters. Please remove +// the "_WITH_DEFAULTS" +Deployment::PackageConfiguration* +CIAO::RepositoryManager_Impl:: +findPackageByName (const char* name + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Deployment::NoSuchName)) +{ + Deployment::PackageConfiguration* pc = 0; + if (pc_table_.find (name, pc) == 0) + { + // @@ (OO) It appears that you should be returning a + // duplicated/copied version of the found + // PackageConfiguration. + return pc; + } + + // @@ (OO) It appears that you should be throwing a + // Deployment::NoSuchName exception here. Please confirm. + return 0; +} + +// @@ (OO) Method definitions should never use "_WITH_DEFAULTS" +// versions of emulated exception parameters. Please remove +// the "_WITH_DEFAULTS" +Deployment::PackageConfiguration* +CIAO::RepositoryManager_Impl:: +findPackageByUUID (const char* + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Deployment::NoSuchName)) +{ + // @@ (OO) It appears that you should be throwing a + // CORBA::NO_IMPLEMENT exception here. Please confirm. + return 0; +} + +// @@ (OO) Method definitions should never use "_WITH_DEFAULTS" +// versions of emulated exception parameters. Please remove +// the "_WITH_DEFAULTS" +CORBA::StringSeq* +CIAO::RepositoryManager_Impl:: +findNamesByType (const char* + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // @@ (OO) It appears that you should returning a sequence of length + // zero. Please confirm. + return 0; +} + +// @@ (OO) Method definitions should never use "_WITH_DEFAULTS" +// versions of emulated exception parameters. Please remove +// the "_WITH_DEFAULTS" +CORBA::StringSeq* +CIAO::RepositoryManager_Impl:: +getAllNames (ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // @@ (OO) It appears that you should returning a sequence of length + // zero. Please confirm. + return 0; +} + +// @@ (OO) Method definitions should never use "_WITH_DEFAULTS" +// versions of emulated exception parameters. Please remove +// the "_WITH_DEFAULTS" +CORBA::StringSeq* +CIAO::RepositoryManager_Impl:: +getAllTypes (ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // @@ (OO) It appears that you should returning a sequence of length + // zero. Please confirm. + return 0; +} + +// @@ (OO) Method definitions should never use "_WITH_DEFAULTS" +// versions of emulated exception parameters. Please remove +// the "_WITH_DEFAULTS" +void +CIAO::RepositoryManager_Impl:: +deletePackage (const char* + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Deployment::NoSuchName)) +{ +} + +// @@ (OO) Method definitions should never use "_WITH_DEFAULTS" +// versions of emulated exception parameters. Please remove +// the "_WITH_DEFAULTS" +void +CIAO::RepositoryManager_Impl::shutdown (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // @@ (OO) Wrong emulated exception argument. Use + // ACE_ENV_ARG_PARAMETER instead. + this->orb_->shutdown (1 ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS); +} diff --git a/TAO/CIAO/DAnCE/RepositoryManager/RepositoryManager_Impl.h b/TAO/CIAO/DAnCE/RepositoryManager/RepositoryManager_Impl.h new file mode 100644 index 00000000000..c22e24ad367 --- /dev/null +++ b/TAO/CIAO/DAnCE/RepositoryManager/RepositoryManager_Impl.h @@ -0,0 +1,175 @@ +/*======================================================================= + * + * @file RepositoryManager_Impl.h + * + * $Id$ + * + * @brief This file contains implementation for + * Deployment::RepositoryManager interface. + * + * @author Jaiganesh Balasubramanian <jai@dre.vanderbilt.edu> + * + *======================================================================*/ + +#ifndef REPOSITORYMANAGER_IMPL_H +#define REPOSITORYMANAGER_IMPL_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/DnC/Config_Handlers/XercesString.h" +#include <xercesc/util/XMLUniDefs.hpp> +#include <xercesc/parsers/XercesDOMParser.hpp> +#include <xercesc/parsers/AbstractDOMParser.hpp> +#include "CIAO/DnC/Config_Handlers/Config_Handler_export.h" +#include "CIAO/DnC/Config_Handlers/Domain_Handler.h" +#include "CIAO/DnC/Config_Handlers/PC_Handler.h" +#include "CIAO/DnC/Config_Handlers/Plan_Handler.h" +#include "CIAO/DnC/Config_Handlers/CompImplDesc_Handler.h" +#include "CIAO/DnC/Config_Handlers/DnC_Dump.h" +#include "CIAO/DnC/Config_Handlers/Utils.h" +#include "CIAO/DnC/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; + +#if !defined (ACE_LACKS_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 +{ + class RepositoryManager_Impl + : public virtual POA_CIAO::RepositoryManagerDaemon, + public virtual PortableServer::RefCountServantBase + { + + public: + + RepositoryManager_Impl (); + + /// Constructor. + RepositoryManager_Impl (CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa + ACE_ENV_ARG_DECL); + + // @@ (OO) Since this class is reference counted, please make this + // destructor protected to enforce proper memory managment + // through the reference counting mechanism (i.e. to + // disallow calling operator delete() on an instance of + // this class. + /// Destructor. + ~RepositoryManager_Impl (); + + 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: + + // @@ (OO) You may want to change the external ID to an + // ACE_CString to ease memory management. + 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_; + + // @@ (OO) Does this really need to be cached? Can't you just + // keep it local to the installPackage() method, the + // only place where it is used? Please confirm. + // Package Configuration element + Deployment::PackageConfiguration pc_; + + pc_table pc_table_; + }; +}; + +#include /**/ "ace/post.h" +#endif /* REPOSITORYMANAGER_IMPL_H */ diff --git a/TAO/CIAO/DAnCE/RepositoryManager/Repository_Manager.cpp b/TAO/CIAO/DAnCE/RepositoryManager/Repository_Manager.cpp new file mode 100644 index 00000000000..d8531775896 --- /dev/null +++ b/TAO/CIAO/DAnCE/RepositoryManager/Repository_Manager.cpp @@ -0,0 +1,278 @@ +// $Id$ + +#include "RepositoryManager_Impl.h" +#include "Update_Plan.h" +#include "ExecutionManager/ExecutionManagerC.h" +#include "NodeManager/NodeDaemonC.h" +#include "ace/OS_NS_stdio.h" +#include "ace/streams.h" +using namespace std; + +const char * exec_ior = "file://exec_mgr.ior"; +const char * node_daemon_ior = 0; + +static void +usage (const ACE_TCHAR* program) +{ + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("Usage: %s -p <URI> -d <URI> -k <EX_IOR> \ + -t <NODE_MANAGER_IOR> \n") + ACE_TEXT (" <URI>: URI identifying the package\n"), + program)); +} + +int +ACE_TMAIN (int argc, ACE_TCHAR *argv[]) +{ + // top level package URL + char* package_url = 0; + + // deployment plan URL + char* plan_url = 0; + + ACE_Get_Opt get_opt (argc, argv, ACE_TEXT ("p:d:k:t:")); + int c; + + while ((c = get_opt ()) != EOF) + { + switch (c) + { + case 'p': + package_url = get_opt.opt_arg (); + break; + case 'd': + plan_url = get_opt.opt_arg (); + break; + case 'k': + exec_ior = get_opt.opt_arg (); + break; + case 't': + node_daemon_ior = get_opt.opt_arg (); + break; + default: + usage(argv[0]); + return -1; + } + } + + if (package_url == 0) { + usage(argv[0]); + return -1; + } + + if (plan_url == 0) { + usage(argv[0]); + return -1; + } + + // Initialize the ORB so that CORBA::Any will work + // + CORBA::ORB_var orb = CORBA::ORB_init (argc, argv, ""); + + try + { + xercesc::XMLPlatformUtils::Initialize(); + } + + catch (const XMLException& xml_e) + { + char* message = XMLString::transcode (xml_e.getMessage()); + ACE_Auto_Basic_Array_Ptr<char> cleanup_message (message); + ACE_DEBUG ((LM_DEBUG, "Error during initialization : %s\n", message)); + return 1; + } + try + { + // get a reference to the parser. + std::auto_ptr<DOMBuilder> plan_parser (CIAO::Config_Handler::Utils:: + create_parser ()); + CIAO::Config_Handler::Config_Error_Handler handler; + plan_parser->setErrorHandler(&handler); + + std::auto_ptr<DOMBuilder> tpd_parser (CIAO::Config_Handler::Utils:: + create_parser ()); + CIAO::Config_Handler::Config_Error_Handler tpd_handler; + tpd_parser->setErrorHandler(&tpd_handler); + + // use the parser to parse the deployment plan URL and create + // a DOM document. + DOMDocument* plan_doc = plan_parser->parseURI (plan_url); + if (handler.getErrors()) + { + return 1; + } + + DOMDocument* tpd_doc = tpd_parser->parseURI (package_url); + if (tpd_handler.getErrors()) + { + return 1; + } + + if (plan_doc == NULL) + { + ACE_DEBUG ((LM_DEBUG, "Null DOM Document obtained, \ + May be the URL is wrong!!\n")); + throw Null_Dom_Document (); + } + + // free up DOMBuilder. DOMBuilder also deletes the DOMDocument memory. + //auto_ptr<DOMBuilder> cleanup_parser (parser); + + // call the Deployment Plan handler to parse the XML descriptor. + CIAO::Config_Handler::Plan_Handler plan_handler (plan_doc, + DOMNodeFilter::SHOW_ELEMENT | + DOMNodeFilter::SHOW_TEXT); + Deployment::DeploymentPlan plan; + plan_handler.process_plan (plan); + + // call the PackageConfiguration handler to parse the XML descriptor. + Deployment::PackageConfiguration* pc; + CIAO::RepositoryManager_Impl rep_impl; + rep_impl.installPackage ("PC", package_url); + pc = rep_impl.findPackageByName ("PC"); + + REF_MAP ref_map; + REF_MAP primary_ref_map; + + // traverse the PackageConfiguration IDL data structure and + // update the deployment plan IDL data structure. + traverse_package (pc, plan, ref_map, primary_ref_map); + + //Deployment::DnC_Dump::dump (plan); + + // Pass the parsed plan to the Execution Manager to start the + // Deployment Process. + + CORBA::Object_var obj = orb->string_to_object (exec_ior + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + CIAO::ExecutionManagerDaemon_var exec_mgr = + CIAO::ExecutionManagerDaemon::_narrow (obj.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (CORBA::is_nil (exec_mgr.in ())) + { + ACE_DEBUG ((LM_DEBUG, + "Executor: nil Execution Manager reference, \ + narrow failed\n")); + return 1; + + } + + CIAO::NodeDaemon_var node_mgr; + if (node_daemon_ior != 0) + { + CORBA::Object_var node_mgr_obj = orb->string_to_object + (node_daemon_ior + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + node_mgr = + CIAO::NodeDaemon::_narrow (node_mgr_obj.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (CORBA::is_nil (node_mgr.in ())) + { + ACE_DEBUG ((LM_DEBUG, + "Executor: nil Node Manager reference, \ + narrow failed\n")); + return 1; + } + } + + ACE_DEBUG ((LM_DEBUG, "Executor: Obtained Execution Manager ref \n")); + Deployment::DomainApplicationManager_var dapp_mgr = + exec_mgr->preparePlan (plan, 1); + + if (CORBA::is_nil (dapp_mgr.in ())) + { + ACE_DEBUG ((LM_DEBUG, + "Executor:preparePlan call failed:nil \ + DomainApplicationManager reference\n")); + return 1; + } + ACE_DEBUG ((LM_DEBUG, + "Executor: Obtained DomainApplication Manager ref \n")); + + // Create a dummy set of properties and start the + // Launching of applications + Deployment::Properties_var properties; + ACE_NEW_RETURN (properties, + Deployment::Properties, + 1); + ACE_DEBUG ((LM_DEBUG, "Executor: start Launch application.....")); + // Start the Application immediately + int start = 1; + dapp_mgr->startLaunch (properties.in (), start); + ACE_DEBUG ((LM_DEBUG, "[success]\n")); + + ACE_DEBUG ((LM_DEBUG, "Executor: finish Launch application.....")); + // Call finish Launch to complete the connections + dapp_mgr->finishLaunch (start); + ACE_DEBUG ((LM_DEBUG, "[success]\n")); + + ACE_DEBUG ((LM_DEBUG, "Executor: Application Deployed successfully \n")); + ACE_DEBUG ((LM_DEBUG, "Press <Enter> to tear down application \n")); + + char dummy [256]; + cin.getline (dummy, 256); + // Tear down the assembly + + ACE_DEBUG ((LM_DEBUG, "Executor: destroy the application.....")); + dapp_mgr->destroyApplication (); + ACE_DEBUG ((LM_DEBUG, "[success]\n")); + + ACE_DEBUG ((LM_DEBUG, "Executor: destroy the manager.....")); + exec_mgr->destroyManager (dapp_mgr.in ()); + ACE_DEBUG ((LM_DEBUG, "[success]\n")); + + if (node_daemon_ior != 0) + { + ACE_DEBUG ((LM_DEBUG, "shutting down node manager \n")); + exec_mgr->shutdown (); // shut down execution manager. + ACE_DEBUG ((LM_DEBUG, "[success]\n")); + + ACE_DEBUG ((LM_DEBUG, "shutting down node manager \n")); + node_mgr->shutdown (); // shut down the node manager. + ACE_DEBUG ((LM_DEBUG, "[success]\n")); + } + + orb->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } + catch (CORBA::Exception& ex) + { + ACE_PRINT_EXCEPTION (ex, "Caught CORBA Exception: "); + while (true); // @@ (OO) What purpose does this server? + return -1; + } + catch (const DOMException& e) + { + const unsigned int maxChars = 2047; + XMLCh errText[maxChars + 1]; + + ACE_ERROR ((LM_ERROR, "\nException occured while parsing %s: \ + \n",plan_url)); + ACE_ERROR ((LM_ERROR, "DOMException code: %d\n ", e.code)); + if (DOMImplementation::loadDOMExceptionMsg (e.code, errText, maxChars)) + { + char* message = XMLString::transcode (errText); + ACE_Auto_Basic_Array_Ptr<char> cleanup_message (message); + ACE_ERROR ((LM_ERROR, "Message is: %s\n", message)); + } + //ACE_PRINT_EXCEPTION ("Caught DOM Exception: "); + ACE_ERROR ((LM_ERROR, "Caught DOM exception\n")); + while (true); // @@ (OO) What purpose does this server? + return -1; + } + catch (...) + { + ACE_ERROR ((LM_ERROR, "Caught unknown exception\n")); + while (true); // @@ (OO) What purpose does this server? + return -1; + } + + return 0; +} diff --git a/TAO/CIAO/DAnCE/RepositoryManager/Update_Plan.cpp b/TAO/CIAO/DAnCE/RepositoryManager/Update_Plan.cpp new file mode 100644 index 00000000000..81cde782078 --- /dev/null +++ b/TAO/CIAO/DAnCE/RepositoryManager/Update_Plan.cpp @@ -0,0 +1,357 @@ +// $Id$ + +#include "RepositoryManager_Impl.h" +#include "Update_Plan.h" +#include "DeploymentC.h" +#include "ace/Hash_Map_Manager.h" +#include "ace/OS_NS_stdio.h" +#include "ace/streams.h" + +void traverse_package (Deployment::PackageConfiguration* &pc, + Deployment::DeploymentPlan &plan, + REF_MAP &ref_map, REF_MAP &primary_ref_map) +{ + // @@ (OO) The three loops in this function are nested, meaning that + // performance will be O(n^3). On top of that, each of the + // loops makes function calls that execute nested loops + // themselves, potentially increasing the execution time by + // several additonal orders of magnitude (e.g. O(n^6). Is + // this really the only way to implement the required + // functionality? This is really only a problem if the sets + // being traversed are large. + + // @@ (OO) The "continue loop" condition portion of the for + // statement is executed during each loop iteration. To + // improve performance execute it only once outside the + // for-loop. + + // traverse the package configuration structure to get to the + // BasePackage which consists of assemblies. + // + for (CORBA::ULong x = 0; x < pc->basePackage.length (); ++x) + { + // @@ (OO) The "continue loop" condition portion of the for + // statement is executed during each loop iteration. To + // improve performance execute it only once outside the + // for-loop. + for (CORBA::ULong y = 0; + y < pc->basePackage[x].implementation.length (); ++y) + { + // @@ (OO) The "continue loop" condition portion of the for + // statement is executed during each loop iteration. To + // improve performance execute it only once outside the + // for-loop. + + // traverse the .cpd file and get to the referenced .cid file + // + Deployment::ComponentImplementationDescription cid = + pc->basePackage[x].implementation[y].referencedImplementation; + for (CORBA::ULong z = 0; z < cid.assemblyImpl.length (); ++z) + { + // traverse the .cid file and get to each + // of the "assemblyImpl" tags. + // + Deployment::ComponentAssemblyDescription assembly = + cid.assemblyImpl[z]; + // + // traverse the individual assembly. + // + traverse_assembly (assembly, plan, ref_map, primary_ref_map); + } + } + } +} + +void traverse_assembly (Deployment::ComponentAssemblyDescription &assembly, + Deployment::DeploymentPlan &plan, + REF_MAP &ref_map, REF_MAP &primary_ref_map) +{ + // traverse the assembly (ComponentAssemblyDescription) and + // processes the instances and the connection within the assembly. + // + for (CORBA::ULong k = 0; k < assembly.instance.length (); ++k) + { + Deployment::SubcomponentInstantiationDescription ins = + assembly.instance[k]; + const char* in_name = ins.name; + for (CORBA::ULong l = 0; l < plan.instance.length (); ++l) + { + const char* plan_name = plan.instance[l].name; + if (strcmp (plan_name, in_name) == 0) + { + traverse_assembly_instance (ins, plan, l, + ref_map, primary_ref_map); + } + } + } + for (CORBA::ULong m = 0; m < assembly.connection.length (); ++m) + { + Deployment::AssemblyConnectionDescription + assembly_connection = assembly.connection[m]; + traverse_assembly_connection (assembly, + assembly_connection, + plan); + } +} + +void traverse_assembly_connection (Deployment::ComponentAssemblyDescription + &assembly, + Deployment::AssemblyConnectionDescription + &assembly_connection, + Deployment::DeploymentPlan &plan) +{ + // traverse the assembly connection and get information about the + // portName and the instances at each end of the connection. + // Also traverse the InterfaceDescriptions for each of those instances + // and populate the portKind information. + // + CORBA::ULong con_length (plan.connection.length ()); + plan.connection.length (con_length + 1); + for (CORBA::ULong n = 0; + n < assembly_connection.internalEndpoint.length (); + ++n) + { + CORBA::ULong iep_len (plan.connection[con_length]. + internalEndpoint.length ()); + plan.connection[con_length].internalEndpoint + .length (iep_len + 1); + plan.connection[con_length].internalEndpoint + [iep_len].portName = assembly_connection. + internalEndpoint[n].portName; + CORBA::ULong ins_ref = assembly_connection.internalEndpoint[n]. + instanceRef; + const char* ins_name = assembly.instance[ins_ref].name; + for (CORBA::ULong w = 0; w < plan.instance.length (); + ++w) + { + const char* pl_name = plan.instance[w].name; + if (strcmp (pl_name, ins_name) == 0) + { + plan.connection[con_length].internalEndpoint + [iep_len].instanceRef = w; + break; + } + } + traverse_interface (assembly.instance[ins_ref], + plan.connection[con_length]. + internalEndpoint[iep_len]); + } +} + +void traverse_interface (Deployment::SubcomponentInstantiationDescription + &instance, + Deployment::PlanSubcomponentPortEndpoint + &pspe) +{ + // traverse the InterfaceDescription of the instance and get information + // about the portkind of the port. + // + for (CORBA::ULong m = 0; m < instance.package.length (); ++m) + { + Deployment::ComponentPackageDescription + package = instance.package[m]; + + Deployment::ComponentInterfaceDescription + cid = package.realizes; + + for (CORBA::ULong n = 0; n < cid.port.length (); ++n) + { + const char* main_port_name = cid.port[n].name; + const char* port_name = pspe.portName; + if (strcmp (main_port_name, port_name) == 0) + { + pspe.kind = cid.port[n].kind; + } + } + } +} + +void traverse_assembly_instance (Deployment:: + SubcomponentInstantiationDescription + &instance, + Deployment::DeploymentPlan &plan, int l, + REF_MAP &ref_map, REF_MAP &primary_ref_map) +{ + // Each instance has a package. + // Each package has an implementation and their correspoding artifacts. + // Traverse this information and populate the artifact and the + // implementation information within the DeploymentPlan. + // + ART_REF_MAP art_ref_map; + + for (CORBA::ULong m = 0; m < instance.package.length (); ++m) + { + Deployment::ComponentPackageDescription + package = instance.package[m]; + + for (CORBA::ULong n = 0; n < package.implementation.length (); ++n) + { + Deployment::PackagedComponentImplementation + impl = package.implementation[n]; + CORBA::ULong impl_length (plan.implementation.length ()); + plan.implementation.length (impl_length + 1); + plan.implementation[impl_length].name = plan.instance[l].name; + plan.instance[l].implementationRef = impl_length; + + for (CORBA::ULong p = 0; + p < impl.referencedImplementation.monolithicImpl.length (); ++p) + { + Deployment::MonolithicImplementationDescription + mid = impl.referencedImplementation.monolithicImpl[p]; + + update_artifacts (mid, plan, plan.instance[l], + ref_map, primary_ref_map, art_ref_map, + plan.implementation[impl_length]); + } + update_impl_config_property (impl, plan.implementation[impl_length], + plan.instance[l]); + } + } +} + +void update_artifacts (Deployment::MonolithicImplementationDescription &mid, + Deployment::DeploymentPlan &plan, + Deployment::InstanceDeploymentDescription &instance, + REF_MAP &ref_map, REF_MAP &primary_ref_map, + ART_REF_MAP &art_ref_map, + Deployment::MonolithicDeploymentDescription &mdd) +{ + for (CORBA::ULong q = 0; q < mid.primaryArtifact.length (); ++q) + { + Deployment::ImplementationArtifactDescription + pack_iad = mid.primaryArtifact[q].referencedArtifact; + ACE_TString artifact_name = (const char*)mid.primaryArtifact[q].name; + int arti_len; + CORBA::ULong art_length (plan.artifact.length ()); + + if (ref_map.find (artifact_name, arti_len) != 0) + { + plan.artifact.length (art_length + 1); + plan.artifact[art_length].name = mid.primaryArtifact[q].name; + plan.artifact[art_length].node = instance.node; + ref_map.bind (artifact_name, art_length); + primary_ref_map.bind (artifact_name, art_length); + CORBA::ULong art_ref_len (mdd.artifactRef.length ()); + mdd.artifactRef.length (art_ref_len + 1); + mdd.artifactRef[art_ref_len] = art_length; + update_artifact_location (pack_iad, + plan.artifact[art_length]); + update_artifact_property (pack_iad, + plan.artifact[art_length]); + } + update_common_artifact_and_art_ref (pack_iad, + primary_ref_map, ref_map, + art_ref_map, mdd, + plan, instance); + } +} + +void update_common_artifact_and_art_ref (Deployment:: + ImplementationArtifactDescription + &pack_iad, + REF_MAP &primary_ref_map, + REF_MAP &ref_map, + ART_REF_MAP &art_ref_map, + Deployment:: + MonolithicDeploymentDescription &mid, + Deployment::DeploymentPlan &plan, + Deployment:: + InstanceDeploymentDescription + &instance) +{ + for (CORBA::ULong g = 0; + g < pack_iad.dependsOn.length (); ++g) + { + ACE_TString dep_name = + (const char*)pack_iad.dependsOn[g].name; + int arti_len; + + if (ref_map.find (dep_name, arti_len) == 0) + { + if (primary_ref_map.find (dep_name, arti_len) != 0) + { + if (art_ref_map.find (arti_len, arti_len) != 0) + { + update_impl_art_ref (mid, arti_len); + art_ref_map.bind (arti_len, arti_len); + } + } + } + else + { + Deployment::ImplementationArtifactDescription + depends_iad = pack_iad.dependsOn[g]. + referencedArtifact; + CORBA::ULong new_art_length (plan.artifact.length ()); + plan.artifact.length (new_art_length + 1); + plan.artifact[new_art_length].name = + pack_iad.dependsOn[g].name; + plan.artifact[new_art_length].node = instance.node; + update_artifact_location (depends_iad, + plan.artifact + [new_art_length]); + ref_map.bind ( + (const char*)plan.artifact[new_art_length].name, + new_art_length); + update_impl_art_ref (mid, new_art_length); + art_ref_map.bind (new_art_length, new_art_length); + } + } +} + +void update_impl_config_property (Deployment::PackagedComponentImplementation + &impl, + Deployment::MonolithicDeploymentDescription + &mid, + Deployment:: + InstanceDeploymentDescription + &instance) +{ + for (CORBA::ULong x = 0; + x < impl.referencedImplementation.configProperty.length (); ++x) + { + CORBA::ULong impl_pro_len (mid.execParameter.length ()); + mid.execParameter.length (impl_pro_len + 1); + mid.execParameter[impl_pro_len] + = impl.referencedImplementation.configProperty[x]; + CORBA::ULong ins_pro_len (instance.configProperty. length ()); + instance.configProperty.length (ins_pro_len + 1); + instance.configProperty[ins_pro_len] + = impl.referencedImplementation.configProperty[x]; + } +} + +void update_impl_art_ref (Deployment::MonolithicDeploymentDescription + &mid, int arti_len) +{ + CORBA::ULong new_art_ref_len (mid.artifactRef.length ()); + mid.artifactRef.length (new_art_ref_len + 1); + mid.artifactRef[new_art_ref_len] = arti_len; +} + +void update_artifact_location (Deployment::ImplementationArtifactDescription + &pack_iad, + Deployment::ArtifactDeploymentDescription + &plan_artifact) +{ + for (CORBA::ULong e = 0; e < pack_iad.location.length (); ++e) + { + CORBA::ULong art_loc_len (plan_artifact.location.length ()); + plan_artifact.location.length (art_loc_len + 1); + plan_artifact.location[art_loc_len] = pack_iad.location[e]; + } +} + +void update_artifact_property (Deployment::ImplementationArtifactDescription + &pack_iad, + Deployment::ArtifactDeploymentDescription + &plan_artifact) +{ + for (CORBA::ULong f = 0; + f < pack_iad.execParameter.length (); ++f) + { + CORBA::ULong art_pro_len (plan_artifact.execParameter.length ()); + plan_artifact.execParameter.length (art_pro_len + 1); + plan_artifact.execParameter[art_pro_len] = pack_iad.execParameter[f]; + } +} diff --git a/TAO/CIAO/DAnCE/RepositoryManager/Update_Plan.h b/TAO/CIAO/DAnCE/RepositoryManager/Update_Plan.h new file mode 100644 index 00000000000..018a090cb94 --- /dev/null +++ b/TAO/CIAO/DAnCE/RepositoryManager/Update_Plan.h @@ -0,0 +1,97 @@ +/*======================================================================= + * + * @file Update_Plan.h + * + * $Id$ + * + * @brief This file contains declarations for helper functions + * used in updating the deployment plan data structure from + * PackageConfiguration data structure. + * + * @author Jaiganesh Balasubramanian <jai@dre.vanderbilt.edu> + * + *======================================================================*/ + +#ifndef UPDATE_PLAN_H +#define UPDATE_PLAN_H + +#include "DeploymentC.h" +#include "ace/Hash_Map_Manager.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +class Null_Dom_Document { }; +// exception thrown when we have a null dom document. + +typedef ACE_Hash_Map_Manager<ACE_TString, int, ACE_Null_Mutex> REF_MAP; +typedef ACE_Hash_Map_Manager<int, int, ACE_Null_Mutex> ART_REF_MAP; + +void traverse_assembly_instance (Deployment:: + SubcomponentInstantiationDescription + &instance, + Deployment::DeploymentPlan &plan, int l, + REF_MAP &ref_map, REF_MAP &primary_ref_map); + +void traverse_assembly (Deployment::ComponentAssemblyDescription &assembly, + Deployment::DeploymentPlan &plan, + REF_MAP &ref_map, REF_MAP &primary_ref_map); + +void traverse_interface (Deployment::SubcomponentInstantiationDescription + &instance, + Deployment::PlanSubcomponentPortEndpoint + &pspe); + +void traverse_assembly_connection (Deployment::ComponentAssemblyDescription + &assembly, + Deployment::AssemblyConnectionDescription + &assembly_connection, + Deployment::DeploymentPlan &plan); + +void traverse_package (Deployment::PackageConfiguration* &pc, + Deployment::DeploymentPlan &plan, + REF_MAP &ref_map, REF_MAP &primary_ref_map); + +void update_artifacts (Deployment::MonolithicImplementationDescription &mid, + Deployment::DeploymentPlan &plan, + Deployment::InstanceDeploymentDescription &instance, + REF_MAP &ref_map, REF_MAP &primary_ref_map, + ART_REF_MAP &art_ref_map, + Deployment::MonolithicDeploymentDescription &mdd); + +void update_artifact_location (Deployment::ImplementationArtifactDescription + &pack_iad, + Deployment::ArtifactDeploymentDescription + &plan_artifact); + +void update_artifact_property (Deployment::ImplementationArtifactDescription + &pack_iad, + Deployment::ArtifactDeploymentDescription + &plan_artifact); + +void update_impl_art_ref (Deployment::MonolithicDeploymentDescription + &mid, int art_len); + +void update_impl_config_property (Deployment:: + PackagedComponentImplementation &impl, + Deployment:: + MonolithicDeploymentDescription &mid, + Deployment:: + InstanceDeploymentDescription + &instance); + +void update_common_artifact_and_art_ref (Deployment:: + ImplementationArtifactDescription &pack_iad, + REF_MAP &primary_ref_map, + REF_MAP &ref_map, + ART_REF_MAP &art_ref_map, + Deployment::MonolithicDeploymentDescription + &mid, + Deployment::DeploymentPlan &plan, + Deployment:: + InstanceDeploymentDescription + &instance); + +#include /**/ "ace/post.h" +#endif /* UPDATE_PLAN_H */ |