diff options
author | sjiang <sjiang@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2006-08-22 23:59:52 +0000 |
---|---|---|
committer | sjiang <sjiang@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2006-08-22 23:59:52 +0000 |
commit | f7db760582e87b40a791c9e9555d75c6a8c4accb (patch) | |
tree | 8c7ab8c940671feec6a07d9c86e08c83e83ed582 | |
parent | 6c4c7fc10846f0d4f1b7c63aaa5123323ee81e26 (diff) | |
download | ATCD-f7db760582e87b40a791c9e9555d75c6a8c4accb.tar.gz |
ChangeLog Tag: Tue Aug 22 23:47:06 UTC 2006 Shanshan Jiang <shanshan.jiang@vanderbilt.edu>
-rw-r--r-- | CIAO/DAnCE/Plan_Launcher/PCVisitor.cpp | 222 | ||||
-rw-r--r-- | CIAO/DAnCE/Plan_Launcher/PCVisitor.h | 131 | ||||
-rw-r--r-- | CIAO/DAnCE/Plan_Launcher/PCVisitorBase.cpp | 24 | ||||
-rw-r--r-- | CIAO/DAnCE/Plan_Launcher/PCVisitorBase.h | 181 | ||||
-rw-r--r-- | CIAO/DAnCE/Plan_Launcher/PCVisitorBase.inl | 155 | ||||
-rw-r--r-- | CIAO/DAnCE/Plan_Launcher/Plan_Launcher.cpp | 76 | ||||
-rw-r--r-- | CIAO/DAnCE/Plan_Launcher/Plan_Launcher.mpc | 4 | ||||
-rw-r--r-- | CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Impl.cpp | 215 | ||||
-rw-r--r-- | CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Impl.h | 25 |
9 files changed, 954 insertions, 79 deletions
diff --git a/CIAO/DAnCE/Plan_Launcher/PCVisitor.cpp b/CIAO/DAnCE/Plan_Launcher/PCVisitor.cpp new file mode 100644 index 00000000000..5d89db10680 --- /dev/null +++ b/CIAO/DAnCE/Plan_Launcher/PCVisitor.cpp @@ -0,0 +1,222 @@ +/* -*- C++ -*- */ + +//======================================================================== +/* + * @file PCVisitor.cpp + * + * $Id$ + * + * This file contains the implementation of the PackageConfiguration + * Visitor class PCVisitor which derives from PCVisitorBase. Each + * Visit function focuses on the functionality necessary to process + * the PackageConfiguration element which is passed to it as an argument + * and on dispatching the next sequence of calls in the correct order! + * + * This implementation takes a PackageConfiguration and tries to modify + * a DeploymentPlan bases on it by expanding the latter in width and depth + * simultaneously. At each level of the PackageConfiguration the + * PCVisitor first expands the DeploymentPlan vertically at the + * corrsponding level and then dispatches the children of the current + * PackageConfiguration element. This in turn might and most probably + * will cause another vertical expansion of the DeploymentPlan, however + * for a different element. This effect is produced due to the flattened + * structure of the DeploymentPlan. + * + * @author Stoyan Paunov <spaunov@isis.vanderbilt.edu> + * Shanshan Jiang <shanshan.jiang@vanderbilt.edu> + */ +//======================================================================== + +#include "PCVisitorBase.h" +#include "PCVisitor.h" + +#include "ace/OS_Memory.h" //for ACE_NEW* macros +#include "ace/SString.h" //for ACE_CString + +#include "ciao/DeploymentC.h" +#include "ciao/Deployment_DataC.h" +#include "ciao/Packaging_DataC.h" + +#include "Config_Handlers/DnC_Dump.h" + +#include <iostream> +using namespace std; + +//Constructor +PCVisitor::PCVisitor (Deployment::DeploymentPlan &plan, + Deployment::PackageConfiguration &pc) + : PCVisitorBase (), + plan_ (plan), + pc_ (pc) +{ +} + +//entry point for the protected visitor to get it do start +//the visitation process +void PCVisitor::Visit () +{ + Accept (*this, this->pc_); +} + +// A whole slew of overloaded routines for different IDL +// data types part of the PackageConfiguration. + +void PCVisitor::Visit (Deployment::PackageConfiguration &pc) +{ + cout << "Flattening: " << pc.label << endl; + + //visit the ComponentPackageDescription + if (pc.basePackage.length ()) + { + //currently no support for that anywhere + //for (size_t r = 0; r = pc.selectRequirement.length (); ++r); + + Accept (*this, pc.basePackage); + } + else + ACE_DEBUG ((LM_WARNING, + "[PCVisitor - PackageConfiguration] We currently " + "do NOT support package references, specializedConfigs", + "or imports!\n")); +} + +//ComponentPackageDescription descendents + +void PCVisitor::Visit (Deployment::ComponentPackageDescription &cpd) +{ + Accept (*this, cpd.realizes); + //for (size_t impl = 0; impl < cpd.implementation.length (); ++impl) + Accept (*this, cpd.implementation[0]); +} + + +void PCVisitor::Visit (Deployment::ComponentInterfaceDescription &) +{ + //Might want to populate this too once PICML starts supporting it +} + + +void PCVisitor::Visit (Deployment::PackagedComponentImplementation &pci) +{ + Accept (*this, pci.referencedImplementation); +} + + +void PCVisitor::Visit (Deployment::ComponentImplementationDescription &cid) +{ + if (cid.assemblyImpl.length ()) + Accept (*this, cid.assemblyImpl); + else + //;//Do nothing - monolithic component deployment not supported + Accept (*this, cid.monolithicImpl); +} + + +void PCVisitor::Visit (Deployment::ComponentAssemblyDescription &cad) +{ + //visit the SubcomponentInstantiationDescription + Accept (*this, cad.instance); + //visit the connections + Accept (*this, cad.connection); +} + + +void PCVisitor::Visit (Deployment::SubcomponentInstantiationDescription &sid) +{ + //visit the ComponentPackageDescription (again) + if (sid.basePackage.length ()) + { + Accept (*this, sid.basePackage); + } + else + ACE_DEBUG ((LM_WARNING, + "[PCVisitor - SubcomponentInstantiationDescription] ", + "We currently do NOT support package references, ", + "specializedConfigs or imports!\n")); +} + + +void PCVisitor::Visit (Deployment::MonolithicImplementationDescription &mid) +{ + //NOTE: There are usually 3 NamedImplementationArtifacts per + //MonolithicImplementationDescription *_stub, *_svnt & *_exec + + //visit the NamedImplementationArtifacts + Accept (*this, mid.primaryArtifact); +} + + +void PCVisitor::Visit (Deployment::NamedImplementationArtifact &nia) +{ + //visit the actual ImplementationArtifactDescriptor + Accept (*this, nia.referencedArtifact); +} + + +void PCVisitor::Visit (Deployment::ImplementationArtifactDescription &iad) +{ + size_t num_arti = plan_.artifact.length (); + for (size_t i = 0; i < num_arti; ++i) + { + if (ACE_OS::strstr (iad.location[0], plan_.artifact[i].location[0])) + plan_.artifact[i].location[0] = iad.location[0]; + } +} + + +//ComponentPackageReference descendents + +void PCVisitor::Visit (Deployment::ComponentPackageReference &) +{ + //not implemented +} + + +//properties + +void PCVisitor::Visit (Deployment::AssemblyPropertyMapping &) +{ +} + + +void PCVisitor::Visit (Deployment::Property &) +{ +} + + +//requirements & capabilities + +void PCVisitor::Visit (Deployment::Requirement &) +{ +} + + +void PCVisitor::Visit (Deployment::Capability &) +{ +} + + +void PCVisitor::Visit (Deployment::ImplementationRequirement &) +{ +} + + +void PCVisitor::Visit (Deployment::ImplementationDependency &) +{ +} + +//ports and connections + +void PCVisitor::Visit (Deployment::AssemblyConnectionDescription &acd) +{ +} + + +void PCVisitor::Visit (Deployment::SubcomponentPortEndpoint &) +{ +} + + +void PCVisitor::Visit (Deployment::ComponentExternalPortEndpoint &) +{ +} diff --git a/CIAO/DAnCE/Plan_Launcher/PCVisitor.h b/CIAO/DAnCE/Plan_Launcher/PCVisitor.h new file mode 100644 index 00000000000..2e892f44b6c --- /dev/null +++ b/CIAO/DAnCE/Plan_Launcher/PCVisitor.h @@ -0,0 +1,131 @@ +/* -*- C++ -*- */ + +//======================================================================== +/** + * file PCVisitor.h + * + * $Id$ + * + * This file contains a number of Visitor classes which are used to + * traverse the PackageConfiguration element defined in the + * PackagingData.idl + * + * author Stoyan Paunov <spaunov@isis.vanderbilt.edu> + */ +//======================================================================== + +#ifndef PC_VISITOR_H +#define PC_VISITOR_H + +#include /**/ "ace/pre.h" +#include "ace/SString.h" //for the ACE_CString + +#include "PCVisitorBase.h" //for the base visitor +#include "ace/Containers_T.h" //for ACE_Double_Linked_List + +#include "ciao/DeploymentC.h" +#include "ciao/Deployment_BaseC.h" +#include "ciao/Deployment_DataC.h" +#include "ciao/Packaging_DataC.h" + + +//=========================================================================== +/** + * class PCVisitor + * + * This class is is the actual implementation for the PackageConfiguration + * Visitor. It derives from PCVisitorBase and overloads the functions which + * deal with single elements. Sequences are handled in the base class. + */ +//=========================================================================== + + +class PCVisitor : public PCVisitorBase +{ +public: + + //constructor + PCVisitor (Deployment::DeploymentPlan &plan, + Deployment::PackageConfiguration &pc); + + ///Entry point to protected Visitor functions + void Visit (); + +protected: + /// A whole slew of overloaded routines for different IDL + /// data types part of the PackageConfiguration. + + virtual + void Visit (Deployment::PackageConfiguration &pc); + + //ComponentPackageDescription descendents + virtual + void Visit (Deployment::ComponentPackageDescription &cpd); + + virtual + void Visit (Deployment::ComponentInterfaceDescription &cid); + + virtual + void Visit (Deployment::PackagedComponentImplementation &pci); + + virtual + void Visit (Deployment::ComponentImplementationDescription &cid); + + virtual + void Visit (Deployment::ComponentAssemblyDescription &cad); + + virtual + void Visit (Deployment::SubcomponentInstantiationDescription &sid); + + virtual + void Visit (Deployment::MonolithicImplementationDescription &mid); + + virtual + void Visit (Deployment::NamedImplementationArtifact &nia); + + virtual + void Visit (Deployment::ImplementationArtifactDescription &iad); + + //ComponentPackageReference descendents + virtual + void Visit (Deployment::ComponentPackageReference &cpr); + + //properties + virtual + void Visit (Deployment::AssemblyPropertyMapping &apm); + + virtual + void Visit (Deployment::Property &property); + + //requirements & capabilities + virtual + void Visit (Deployment::Requirement &requirement); + + virtual + void Visit (Deployment::Capability &capability); + + virtual + void Visit (Deployment::ImplementationRequirement &ir); + + virtual + void Visit (Deployment::ImplementationDependency &id); + + //ports and connections + virtual + void Visit (Deployment::AssemblyConnectionDescription &acd); + + virtual + void Visit (Deployment::SubcomponentPortEndpoint &spe); + + virtual + void Visit (Deployment::ComponentExternalPortEndpoint &cepe); + + +private: + Deployment::DeploymentPlan& plan_; + Deployment::PackageConfiguration& pc_; +}; + +#include /**/ "ace/post.h" + +#endif /* PC_VISITOR_H */ diff --git a/CIAO/DAnCE/Plan_Launcher/PCVisitorBase.cpp b/CIAO/DAnCE/Plan_Launcher/PCVisitorBase.cpp new file mode 100644 index 00000000000..da3c2e4c0a6 --- /dev/null +++ b/CIAO/DAnCE/Plan_Launcher/PCVisitorBase.cpp @@ -0,0 +1,24 @@ +/* -*- C++ -*- */ + +//======================================================================== +/* + * file PCVisitorBase.cpp + * + * $Id$ + * + * This file is a dummy which either includes the PCVisitorBase.inl or + * is ignored. + * + * author Stoyan Paunov <spaunov@isis.vanderbilt.edu> + */ +//======================================================================== + +#include "PCVisitorBase.h" + +PCVisitorBase::PCVisitorBase (void) +{ +} + +#if !defined (__ACE_INLINE__) +#include "PCVisitorBase.inl" +#endif /* __ACE_INLINE__ */ diff --git a/CIAO/DAnCE/Plan_Launcher/PCVisitorBase.h b/CIAO/DAnCE/Plan_Launcher/PCVisitorBase.h new file mode 100644 index 00000000000..35daee0d7bb --- /dev/null +++ b/CIAO/DAnCE/Plan_Launcher/PCVisitorBase.h @@ -0,0 +1,181 @@ +/* -*- C++ -*- */ + +//======================================================================== +/** + * file PCVisitorBase.h + * + * $Id$ + * + * This file contains the virtual base class for the PackageConfiguration + * Visitor which is used to traverse the PackageConfiguration element + * defined in the PackagingData.idl. The PackageConfiguration has a + * number of sequence elements. This class actually implements the + * operations which involve sequences and delegates the calls to + * the operations which handle single elements from the sequence type. + * + * author Stoyan Paunov <spaunov@isis.vanderbilt.edu> + */ +//======================================================================== + +#ifndef PC_VISITOR_BASE_H +#define PC_VISITOR_BASE_H + +#include /**/ "ace/pre.h" +#include "ciao/DeploymentC.h" +#include "ciao/Deployment_DataC.h" +#include "ciao/Packaging_DataC.h" +#include "ace/SString.h" //for the ACE_CString +#include "ace/Containers_T.h" //for ACE_Unbounded_Stack + +//forward declaration +class PCVisitorBase; + +template <typename T> +void Accept (PCVisitorBase &v, T& element_to_visit) +{ + v.Visit (element_to_visit); +} + +//======================================================================== +/** + * function - visit_sequence + * + * This function is used to handle sequences of elements where each + * element takes the form of a Visitor Node. + */ +//======================================================================== + + +/// I am using this to dispatch sequences +template <typename SEQ> +void visit_sequence (SEQ &seq, PCVisitorBase& v) +{ + const CORBA::ULong size = seq.length (); + + for (CORBA::ULong i = 0; i < size; ++i) + { + Accept(v, seq[i]); + } +} + +//======================================================================== +/** + * class PCVisitorBase + * + * This class is a virtual base class for the PackageConfiguration Visitor + * The operation which deal with sequences are implemented here by means + * of the visit_sequence function above, in order to make the logic of + * derived classes easier to write. Writers of derived classes need only + * overload the functions which deal with single elements. Sequences are + * always handled here. + */ +//======================================================================== + + +class PCVisitorBase +{ +public: + + //constructor + PCVisitorBase (void); + + ///function what dispatches sequences + template <typename SEQ> + friend void visit_sequence (SEQ &seq, PCVisitorBase& v); + + /// A whole slew of overloaded routines for different IDL + /// data types part of the PackageConfiguration. + + virtual + void Visit (Deployment::PackageConfiguration &pc) = 0; + void Visit (Deployment::PackageConfigurations &pcs); + + //ComponentPackageDescription descendents + virtual + void Visit (Deployment::ComponentPackageDescription &cpd) = 0; + void Visit (Deployment::ComponentPackageDescriptions &cpds); + + virtual + void Visit (Deployment::ComponentInterfaceDescription &cid) = 0; + //void Visit (Deployment::ComponentInterfaceDescriptions &cids); + + virtual + void Visit (Deployment::PackagedComponentImplementation &pci) = 0; + void Visit (Deployment::PackagedComponentImplementations &pcis); + + virtual + void Visit (Deployment::ComponentImplementationDescription &cid) = 0; + //void Visit (Deployment::ComponentImplementationDescriptions &cids); + + virtual + void Visit (Deployment::ComponentAssemblyDescription &cad) = 0; + void Visit (Deployment::ComponentAssemblyDescriptions &cads); + + virtual + void Visit (Deployment::SubcomponentInstantiationDescription &sid) = 0; + void Visit (Deployment::SubcomponentInstantiationDescriptions &sids); + + virtual + void Visit (Deployment::MonolithicImplementationDescription &mid) = 0; + void Visit (Deployment::MonolithicImplementationDescriptions &mids); + + virtual + void Visit (Deployment::NamedImplementationArtifact &nia) = 0; + void Visit (Deployment::NamedImplementationArtifacts &nias); + + virtual + void Visit (Deployment::ImplementationArtifactDescription &iad) = 0; + //void Visit (Deployment::ImplementationArtifactDescriptions &iads); + + //ComponentPackageReference descendents + virtual + void Visit (Deployment::ComponentPackageReference &cpr) = 0; + void Visit (Deployment::ComponentPackageReferences &cprs); + + //properties + virtual + void Visit (Deployment::AssemblyPropertyMapping &apm) = 0; + void Visit (Deployment::AssemblyPropertyMappings &apms); + + virtual + void Visit (Deployment::Property &property) = 0; + void Visit (Deployment::Properties &properties); + + //requirements & capabilities + virtual + void Visit (Deployment::Requirement &requirement) = 0; + void Visit (Deployment::Requirements &requirements); + + virtual + void Visit (Deployment::Capability &capability) = 0; + void Visit (Deployment::Capabilities &capabilities); + + virtual + void Visit (Deployment::ImplementationRequirement &ir) = 0; + void Visit (Deployment::ImplementationRequirements &irs); + + virtual + void Visit (Deployment::ImplementationDependency &id) = 0; + void Visit (Deployment::ImplementationDependencies &ids); + + //ports and connections + virtual + void Visit (Deployment::AssemblyConnectionDescription &acd) = 0; + void Visit (Deployment::AssemblyConnectionDescriptions &acds); + + virtual + void Visit (Deployment::SubcomponentPortEndpoint &spe) = 0; + void Visit (Deployment::SubcomponentPortEndpoints &spes); + + virtual + void Visit (Deployment::ComponentExternalPortEndpoint &cepe) = 0; + void Visit (Deployment::ComponentExternalPortEndpoints &cepes); +}; + +#if defined (__ACE_INLINE__) +#include "PCVisitorBase.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" + +#endif /* PC_VISITOR_BASE_H */ diff --git a/CIAO/DAnCE/Plan_Launcher/PCVisitorBase.inl b/CIAO/DAnCE/Plan_Launcher/PCVisitorBase.inl new file mode 100644 index 00000000000..955aefb7c4e --- /dev/null +++ b/CIAO/DAnCE/Plan_Launcher/PCVisitorBase.inl @@ -0,0 +1,155 @@ +/* -*- C++ -*- */ + +//======================================================================== +/* + * file PCVisitorBase.inl + * + * $Id$ + * + * This file contains the implementation of the sequence-based + * PackageConfiguration Visitor functions. By implementing these + * we relieve developers of derived classes of the burden of handling + * the correct traversal of sequence-based elements. This implementation + * used the visit_sequence templatized function to do the heavy lifting. + * + * author Stoyan Paunov <spaunov@isis.vanderbilt.edu> + */ +//======================================================================== + + +/// A whole slew of overloaded routines for different IDL +/// data types part of the PackageConfiguration. + +ACE_INLINE void PCVisitorBase::Visit +(Deployment::PackageConfigurations &pcs) +{ + visit_sequence (pcs, *this); +} + +//ComponentPackageDescription descendents + +ACE_INLINE void PCVisitorBase::Visit +(Deployment::ComponentPackageDescriptions &cpds) +{ + visit_sequence (cpds, *this); +} + +//NOT a member of Deployment + +//ACE_INLINE void PCVisitorBase::Visit +// (Deployment::ComponentInterfaceDescriptions &cids) +//{ +// visit_sequence (cids, *this); +//} + +ACE_INLINE void PCVisitorBase::Visit +(Deployment::PackagedComponentImplementations &pcis) +{ + visit_sequence (pcis, *this); +} + +//NOT a member of Deployment + +//ACE_INLINE void PCVisitorBase::Visit +// (Deployment::ComponentImplementationDescriptions &cids) +//{ +// visit_sequence (cids, *this); +//} + +ACE_INLINE void PCVisitorBase::Visit +(Deployment::ComponentAssemblyDescriptions &cads) +{ + visit_sequence (cads, *this); +} + +ACE_INLINE void PCVisitorBase::Visit +(Deployment::SubcomponentInstantiationDescriptions &sids) +{ + visit_sequence (sids, *this); +} + +ACE_INLINE void PCVisitorBase::Visit +(Deployment::MonolithicImplementationDescriptions &mids) +{ + visit_sequence (mids, *this); +} + +ACE_INLINE void PCVisitorBase::Visit +(Deployment::NamedImplementationArtifacts &nias) +{ + visit_sequence (nias, *this); +} + +//ACE_INLINE void PCVisitorBase::Visit +// (Deployment::ImplementationArtifactDescriptions &iads) +//{ +// visit_sequence (iads, *this); +//} + +//ComponentPackageReference descendents + +ACE_INLINE void PCVisitorBase::Visit +(Deployment::ComponentPackageReferences &cprs) +{ + visit_sequence (cprs, *this); +} + +//properties + +ACE_INLINE void PCVisitorBase::Visit +(Deployment::AssemblyPropertyMappings &apms) +{ + visit_sequence (apms, *this); +} + +ACE_INLINE void PCVisitorBase::Visit +(Deployment::Properties &properties) +{ + visit_sequence (properties, *this); +} + +//requirements & capabilities + +ACE_INLINE void PCVisitorBase::Visit +(Deployment::Requirements &requirements) +{ + visit_sequence (requirements, *this); +} + +ACE_INLINE void PCVisitorBase::Visit +(Deployment::Capabilities &capabilities) +{ + visit_sequence (capabilities, *this); +} + +ACE_INLINE void PCVisitorBase::Visit +(Deployment::ImplementationRequirements &irs) +{ + visit_sequence (irs, *this); +} + +ACE_INLINE void PCVisitorBase::Visit +(Deployment::ImplementationDependencies &ids) +{ + visit_sequence (ids, *this); +} + +//ports and connections + +ACE_INLINE void PCVisitorBase::Visit +(Deployment::AssemblyConnectionDescriptions &acds) +{ + visit_sequence (acds, *this); +} + +ACE_INLINE void PCVisitorBase::Visit +(Deployment::SubcomponentPortEndpoints &spes) +{ + visit_sequence (spes, *this); +} + +ACE_INLINE void PCVisitorBase::Visit +(Deployment::ComponentExternalPortEndpoints &cepes) +{ + visit_sequence (cepes, *this); +} diff --git a/CIAO/DAnCE/Plan_Launcher/Plan_Launcher.cpp b/CIAO/DAnCE/Plan_Launcher/Plan_Launcher.cpp index 141e1ff7e9a..05532bb0b5a 100644 --- a/CIAO/DAnCE/Plan_Launcher/Plan_Launcher.cpp +++ b/CIAO/DAnCE/Plan_Launcher/Plan_Launcher.cpp @@ -13,11 +13,18 @@ namespace CIAO namespace Plan_Launcher { // deployment plan URL - const char* package_url = 0; + const char* deployment_plan_url = 0; + bool use_package_name = true; + const char* package_names = 0; + const char* package_types = 0; const char* new_package_url = 0; const char* plan_uuid = 0; - bool use_naming = false; - const char* ior_file = "file://em.ior"; + bool em_use_naming = false; + const char* em_ior_file = "file://em.ior"; + bool rm_use_naming = false; + bool use_repoman = false; + const char* rm_ior_file = "file://rm.ior"; + const char* repoman_name_ = "RepositoryManager"; const char* dap_ior_filename = 0; const char* dap_ior = 0; @@ -37,11 +44,16 @@ namespace CIAO { ACE_ERROR ((LM_ERROR, ACE_TEXT ("[(%P|%t) Executor] Usage: %s\n") - ACE_TEXT ("-p <PACKAGE_URI>\n") + ACE_TEXT ("-p <PACKAGE_NAMES>\n") + ACE_TEXT ("-e <PACKAGE_TYPES>\n") + ACE_TEXT ("-d <DEPLOYMENT_PLAN_URL>\n") + ACE_TEXT ("-n : Use naming service to fetch EM") ACE_TEXT ("-k <EXECUTION_MANAGER_IOR>") ACE_TEXT (" : Default file://em.ior\n") - ACE_TEXT ("-n : Use naming service to fetch") - ACE_TEXT (" Execution Manager IOR Alternative to -k\n") + ACE_TEXT ("-l <REPOSITORY_MANAGER_IOR>") + ACE_TEXT (" : Default file://rm.ior\n") + ACE_TEXT ("-v <REPOSITORY_MANAGER_NAME>: Use naming service to fetch RM with the given name") + ACE_TEXT (" : Default RepositoryManager\n") ACE_TEXT ("-t <PLAN_UUID>\n") ACE_TEXT ("-o <DOMAIN_APPLICATION_MANAGER_IOR_OUTPUT_FILE>\n") ACE_TEXT ("-i <DOMAIN_APPLICATION_MANAGER_IOR_FOR_INPUT>\n") @@ -56,7 +68,7 @@ namespace CIAO { ACE_Get_Opt get_opt (argc, argv, - ACE_TEXT ("p:nk:t:o:i:r:h")); + ACE_TEXT ("p:e:d:nk:l:v:t:o:i:r:h")); int c; while ((c = get_opt ()) != EOF) @@ -64,13 +76,30 @@ namespace CIAO switch (c) { case 'p': - package_url = get_opt.opt_arg (); + package_names = get_opt.opt_arg (); + use_package_name = true; + break; + case 'e': + package_types = get_opt.opt_arg (); + use_package_name = false; + break; + case 'd': + deployment_plan_url = get_opt.opt_arg (); break; case 'n': - use_naming = true; + em_use_naming = true; break; case 'k': - ior_file = get_opt.opt_arg (); + em_ior_file = get_opt.opt_arg (); + break; + case 'l': + use_repoman = true; + rm_ior_file = get_opt.opt_arg (); + break; + case 'v': + use_repoman = true; + rm_use_naming = true; + repoman_name_ = get_opt.opt_arg (); break; case 'o': dap_ior_filename = get_opt.opt_arg (); @@ -97,8 +126,10 @@ namespace CIAO if ((mode != pl_mode_stop_by_dam) && (mode != pl_mode_stop_by_uuid) && - (package_url == 0) && - (new_package_url ==0)) + (package_names == 0) && + (package_types == 0) && + (deployment_plan_url == 0) && + (new_package_url == 0)) { usage (argv[0]); return false; @@ -155,11 +186,13 @@ namespace CIAO if (parse_args (argc, argv) == false) return -1; - Plan_Launcher_i launcher; - if (!launcher.init (use_naming ? 0 : ior_file, - orb.in ())) + if (!launcher.init (em_use_naming ? 0 : em_ior_file, + orb.in (), + use_repoman, + rm_use_naming, + rm_use_naming ? repoman_name_ : rm_ior_file)) { ACE_ERROR ((LM_ERROR, "(%P|%t) Plan_Launcher: Error initializing the EM.\n")); return -1; @@ -169,7 +202,18 @@ namespace CIAO if (mode == pl_mode_start || mode == pl_mode_interactive) // initial deployment { - const char* uuid = launcher.launch_plan (package_url); + const char* uuid; + + if (package_names != 0) + uuid = launcher.launch_plan (deployment_plan_url, + package_names, + use_package_name, + use_repoman); + else + uuid = launcher.launch_plan (deployment_plan_url, + package_types, + use_package_name, + use_repoman); if (uuid == 0) { diff --git a/CIAO/DAnCE/Plan_Launcher/Plan_Launcher.mpc b/CIAO/DAnCE/Plan_Launcher/Plan_Launcher.mpc index 391912025b4..c69a8a8cfe3 100644 --- a/CIAO/DAnCE/Plan_Launcher/Plan_Launcher.mpc +++ b/CIAO/DAnCE/Plan_Launcher/Plan_Launcher.mpc @@ -11,11 +11,15 @@ project(Plan_Launcher_Impl) : ciao_servant_dnc, ciao_config_handlers { Source_Files { Plan_Launcher_Impl.cpp ../ExecutionManager/DAM_Map.cpp + PCVisitor.cpp + PCVisitorBase.cpp } Header_Files { ../ExecutionManager/DAM_Map.h Plan_Launcher_Impl_Export.h + PCVisitor.h + PCVisitorBase.h } } diff --git a/CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Impl.cpp b/CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Impl.cpp index 7f5aa59ceda..0103936f75d 100644 --- a/CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Impl.cpp +++ b/CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Impl.cpp @@ -12,7 +12,9 @@ namespace CIAO { static CORBA::Object_ptr - fetch_reference_naming (CORBA::ORB_ptr orb + fetch_reference_naming (CORBA::ORB_ptr orb, + bool use_repoman = 0, + const char *repoman_name = 0 ACE_ENV_ARG_DECL) { CORBA::Object_var tmp = @@ -27,24 +29,36 @@ namespace CIAO CosNaming::Name name (1); name.length (1); - name[0].id = - CORBA::string_dup ("ExecutionManager"); + + if (!use_repoman) + { + name[0].id = CORBA::string_dup ("ExecutionManager"); + } + else + { + name[0].id = CORBA::string_dup (repoman_name); + } return pns->resolve (name ACE_ENV_ARG_PARAMETER); } Plan_Launcher_i::Plan_Launcher_i () - : em_ () + : em_ (), rm_ () { } bool Plan_Launcher_i::init (const char *em_ior, - CORBA::ORB_ptr orb ACE_ENV_ARG_DECL) + CORBA::ORB_ptr orb, + bool use_repoman, + bool rm_use_naming, + const char *rm_ior + ACE_ENV_ARG_DECL) { CORBA::Object_var obj; + // EM if (em_ior == 0) { obj = fetch_reference_naming (orb ACE_ENV_ARG_PARAMETER); @@ -74,71 +88,149 @@ namespace CIAO "(%P|%t) CIAO_PlanLauncher: Obtained Execution" " Manager ref \n")); + // RM + if (use_repoman) + { + if (rm_use_naming) + { + obj = fetch_reference_naming (orb, use_repoman, rm_ior ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } + else + { + obj = orb->string_to_object (rm_ior + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } + + this->rm_ = Deployment::RepositoryManager::_narrow (obj.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (CORBA::is_nil (this->rm_.in ())) + { + ACE_ERROR ((LM_ERROR, + "(%P|%t) CIAO_PlanLauncher: nil Repository" + " Manager reference, narrow failed\n")); + return false; + } + + if (CIAO::debug_level () > 9) + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) CIAO_PlanLauncher: Obtained Repository" + " Manager ref \n")); + } + return true; } const char * - Plan_Launcher_i::launch_plan (const char *plan_uri ACE_ENV_ARG_DECL) + Plan_Launcher_i::launch_plan (const char *deployment_plan_uri, + const char *package_uri, + bool use_package_name, + bool use_repoman + ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((Plan_Launcher_i::Deployment_Failure)) { ACE_DEBUG ((LM_DEBUG, "Parsing plan...\n")); - CIAO::Config_Handlers::XML_File_Intf intf (plan_uri); + CIAO::Config_Handlers::XML_File_Intf intf (deployment_plan_uri); ::Deployment::DeploymentPlan_var plan = intf.get_plan (); - ACE_DEBUG ((LM_DEBUG, "Parsing complete....\n")); - return this->launch_plan (plan.in ()); - } - const char * - Plan_Launcher_i::launch_plan (const ::Deployment::DeploymentPlan &plan ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((Plan_Launcher_i::Deployment_Failure)) - { + if (use_repoman) + { + ::Deployment::PackageConfiguration_var pc; - if (CORBA::is_nil (this->em_.in ())) - { - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("CIAO::Plan_Launcher_i: ") - ACE_TEXT ("launch_plan called witn an uninitialized EM.\n"))); - return 0; - } + ACE_TCHAR package[PACKAGE_NAME_LEN]; - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("CIAO::Plan_Launcher_i: " ) - ACE_TEXT ("about to call this->em_->preparePlan\n"))); - ::Deployment::DomainApplicationManager_var dam (this->em_->preparePlan (plan, 1)); - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("CIAO::Plan_Launcher_i: " ) - ACE_TEXT ("after to call this->em_->preparePlan\n"))); + size_t length = ACE_OS::strlen (package_uri); + + size_t pos1 = 0; + size_t pos2 = ACE_OS::strcspn (package_uri + pos1, "+"); - if (CORBA::is_nil (dam.in ())) + while (pos1 < length) { - ACE_DEBUG ((LM_DEBUG, - "(%P|%t) CIAO_PlanLauncher:preparePlan call failed: " - "nil DomainApplicationManager reference\n")); - return 0; + ACE_OS::strsncpy (package, package_uri + pos1, pos2 + 1); + + if (use_package_name) + { + pc = rm_->findPackageByName (package); + + PCVisitor pcv (plan, *pc); + pcv.Visit (); + } + else + { + CORBA::StringSeq_var seq = rm_->findNamesByType (package); + + for (size_t i = 0; i < seq->length (); ++i) + { + pc = rm_->findPackageByName (seq[i]); + + PCVisitor pcv (plan, *pc); + pcv.Visit (); + } + } + + pos1 += pos2 + 1; + pos2 = ACE_OS::strcspn (package_uri + pos1, "+"); } + } - if (CIAO::debug_level () > 9) - ACE_DEBUG ((LM_DEBUG, - "CIAO_PlanLauncher: Obtained DAM ref \n")); - - ::Deployment::Properties_var properties; - ACE_NEW_RETURN (properties, - Deployment::Properties, - 0); - - if (CIAO::debug_level ()) - ACE_DEBUG ((LM_DEBUG, - "CIAO_PlanLauncher: start Launch application...\n")); + ACE_DEBUG ((LM_DEBUG, "Parsing complete....\n")); + + return this->launch_plan (plan.in ()); + } - // Dont not start the Application immediately since it vialtes - // the semantics of component activation sequence - int start = 0; + const char * + Plan_Launcher_i::launch_plan (const ::Deployment::DeploymentPlan &plan ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((Plan_Launcher_i::Deployment_Failure)) + { ACE_TRY { + if (CORBA::is_nil (this->em_.in ())) + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("CIAO::Plan_Launcher_i: ") + ACE_TEXT ("launch_plan called witn an uninitialized EM.\n"))); + return 0; + } + + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("CIAO::Plan_Launcher_i: " ) + ACE_TEXT ("about to call this->em_->preparePlan\n"))); + ::Deployment::DomainApplicationManager_var dam (this->em_->preparePlan (plan, 1)); + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("CIAO::Plan_Launcher_i: " ) + ACE_TEXT ("after to call this->em_->preparePlan\n"))); + + if (CORBA::is_nil (dam.in ())) + { + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) CIAO_PlanLauncher:preparePlan call failed: " + "nil DomainApplicationManager reference\n")); + return 0; + } + + if (CIAO::debug_level () > 9) + ACE_DEBUG ((LM_DEBUG, + "CIAO_PlanLauncher: Obtained DAM ref \n")); + + ::Deployment::Properties_var properties; + ACE_NEW_RETURN (properties, + Deployment::Properties, + 0); + + if (CIAO::debug_level ()) + ACE_DEBUG ((LM_DEBUG, + "CIAO_PlanLauncher: start Launch application...\n")); + + // Dont not start the Application immediately since it vialtes + // the semantics of component activation sequence + int start = 0; dam->startLaunch (properties.in (), 0); @@ -184,7 +276,7 @@ namespace CIAO ex.propertyName.in (), ex.elementName.in (), ex.resourceName.in ())); - ACE_THROW (Deployment_Failure ()); + ACE_THROW (Deployment_Failure ("")); } ACE_CATCH (Deployment::StartError, ex) { @@ -192,7 +284,7 @@ namespace CIAO "EXCEPTION: StartError exception caught: %s, %s\n", ex.name.in (), ex.reason.in ())); - ACE_THROW (Deployment_Failure ()); + ACE_THROW (Deployment_Failure ("")); } ACE_CATCH (Deployment::InvalidProperty, ex) { @@ -200,7 +292,7 @@ namespace CIAO "EXCEPTION: InvalidProperty exception caught: %s, %s\n", ex.name.in (), ex.reason.in ())); - ACE_THROW (Deployment_Failure ()); + ACE_THROW (Deployment_Failure ("")); } ACE_CATCH (Deployment::InvalidConnection, ex) { @@ -208,20 +300,20 @@ namespace CIAO "EXCEPTION: InvalidConnection exception caught: %s, %s\n", ex.name.in (), ex.reason.in ())); - ACE_THROW (Deployment_Failure ()); + ACE_THROW (Deployment_Failure ("")); } ACE_CATCHANY { ACE_ERROR ((LM_ERROR, "CORBA EXCEPTION: %s\n", ACE_ANY_EXCEPTION._info().fast_rep())); - ACE_THROW (Deployment_Failure ()); + ACE_THROW (Deployment_Failure ("")); } ACE_CATCHALL { ACE_ERROR ((LM_ERROR, "EXCEPTION: non-CORBA exception\n")); - ACE_THROW (Deployment_Failure ()); + ACE_THROW (Deployment_Failure ("")); } ACE_ENDTRY; ACE_CHECK_RETURN (0); @@ -256,13 +348,16 @@ namespace CIAO ::Deployment::DomainApplicationManager_var dapp_mgr = this->em_->getManager (uuid); - dapp_mgr->destroyApplication (); - if (CIAO::debug_level ()) - ACE_DEBUG ((LM_DEBUG, "[success]\n")); + if (!::CORBA::is_nil (dapp_mgr)) + { + dapp_mgr->destroyApplication (); + if (CIAO::debug_level ()) + ACE_DEBUG ((LM_DEBUG, "[success]\n")); - // Note that we should ask the DAM to tell EM whether the DAM should - // be destroyed - this->destroy_dam_by_plan (uuid); + // Note that we should ask the DAM to tell EM whether the DAM should + // be destroyed + this->destroy_dam_by_plan (uuid); + } } ACE_CATCHANY { diff --git a/CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Impl.h b/CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Impl.h index e91711332d4..c45366774f2 100644 --- a/CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Impl.h +++ b/CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Impl.h @@ -9,6 +9,10 @@ #ifndef PLAN_LAUNCHER_IMPL_H #define PLAN_LAUNCHER_IMPL_H +#include "ciao/RepositoryManagerC.h" +#include "PCVisitor.h" +#include "PCVisitorBase.h" + #include "Plan_Launcher_Impl_Export.h" #include "ciao/DeploymentS.h" #include "ciao/CIAO_common.h" @@ -19,6 +23,7 @@ namespace CIAO { namespace Plan_Launcher { + const size_t PACKAGE_NAME_LEN = 1024; /** * @class Plan_Launcher_i @@ -27,13 +32,24 @@ namespace CIAO class Plan_Launcher_Impl_Export Plan_Launcher_i { public: - class Deployment_Failure {}; + class Deployment_Failure { + public: + Deployment_Failure (const ACE_CString &error) + : error_ (error) + { + } + + ACE_CString error_; + }; Plan_Launcher_i (); bool init (const char *em_ior, - CORBA::ORB_ptr orb + CORBA::ORB_ptr orb, + bool use_repoman = 0, + bool rm_use_naming = 0, + const char *rm_ior = 0 ACE_ENV_ARG_DECL_WITH_DEFAULTS); /** @@ -42,7 +58,8 @@ namespace CIAO * @param plan_uri A uri that points ot a valid deployment plan * @returns a string containing the UUID of the plan. Null indicates failure. */ - const char * launch_plan (const char *plan_uri + const char * launch_plan (const char *deployment_plan_uri, const char *package_uri = 0, + bool use_package_name = 1, bool use_repoman = 0 ACE_ENV_ARG_DECL_WITH_DEFAULTS) ACE_THROW_SPEC ((Deployment_Failure)); @@ -83,6 +100,8 @@ namespace CIAO private: ::CIAO::ExecutionManagerDaemon_var em_; + Deployment::RepositoryManager_var rm_; + /// Local map for DAMs, to save expensive UUID lookups. Execution_Manager::DAM_Map map_; }; |