From 5c89a74445c83fc84fdc8e151baa016ec824af38 Mon Sep 17 00:00:00 2001 From: dengg Date: Sat, 21 Jan 2006 20:09:29 +0000 Subject: *** empty log message *** --- .../DomainApplicationManager_Impl.cpp | 134 ++++++++++++++++----- .../DomainApplicationManager_Impl.h | 31 ++++- .../ExecutionManager/Execution_Manager_Impl.cpp | 17 ++- TAO/CIAO/DAnCE/NodeManager/NodeManager_Impl.cpp | 102 +++++++++++----- TAO/CIAO/DAnCE/NodeManager/NodeManager_Impl.h | 33 +++-- TAO/CIAO/ciao/Deployment.idl | 13 +- .../deploymentplan_shared_components.cdp | 4 +- 7 files changed, 254 insertions(+), 80 deletions(-) diff --git a/TAO/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.cpp b/TAO/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.cpp index b6560c1b924..580bb00d904 100644 --- a/TAO/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.cpp +++ b/TAO/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.cpp @@ -41,6 +41,10 @@ DomainApplicationManager_Impl (CORBA::ORB_ptr orb, ACE_NEW_THROW_EX (this->all_connections_, Deployment::Connections (), CORBA::NO_MEMORY ()); + + ACE_NEW_THROW_EX (this->shared_, + Deployment::ComponentPlans (), + CORBA::NO_MEMORY ()); ACE_CHECK; } @@ -611,6 +615,8 @@ startLaunch (const ::Deployment::Properties & configProperty, // the hash table. (entry->int_id_).node_application_ = my_na._retn (); } + + this->synchronize_shared_components_with_node_managers (); } ACE_CATCHANY { @@ -829,34 +835,22 @@ post_finishLaunch (void) { ACE_TRY { - for (CORBA::ULong i = 0; i < this->num_child_plans_; ++i) + // For each "external" component... + CORBA::ULong length = this->shared_->length (); + for (CORBA::ULong j = 0; j < length; ++j) { - // Get the shared components from all the NodeManagers - ACE_Hash_Map_Entry * entry = 0; - this->artifact_map_.find (this->node_manager_names_[i],entry); - - ::Deployment::NodeManager_ptr - my_node_manager = (entry->int_id_).node_manager_.in (); - - CORBA::StringSeq_var - shared = my_node_manager->get_shared_components (); + // Construct struct for the component + Execution_Manager::Execution_Manager_Impl:: + Component_Binding_Info * + binding = this->populate_binding_info ( + this->shared_[j].name.in (), + this->shared_[j].plan_uuid.in ()); // Invoke on ExecutionManager - CORBA::ULong length = shared->length (); - for (CORBA::ULong j = 0; j < length; ++j) - { - // Construct struct for the component - Execution_Manager::Execution_Manager_Impl:: - Component_Binding_Info * binding; - - binding = this->populate_binding_info (shared[j].in (), - ""); - - this->execution_manager_->finalize_global_binding ( - *binding, true); + this->execution_manager_->finalize_global_binding ( + *binding, true); - delete binding; - } + delete binding; } } ACE_CATCHANY @@ -872,7 +866,8 @@ post_finishLaunch (void) CIAO::Execution_Manager::Execution_Manager_Impl::Component_Binding_Info * CIAO::DomainApplicationManager_Impl:: -populate_binding_info (const char * name, const char * child_uuid) +populate_binding_info (const ACE_CString& name, + const ACE_CString& child_uuid) { Execution_Manager::Execution_Manager_Impl::Component_Binding_Info * retv; ACE_NEW_RETURN (retv, @@ -881,19 +876,23 @@ populate_binding_info (const char * name, const char * child_uuid) retv->name_ = name; - // @@TODO: Finish the parsing up... + // Parse the child_uuid string and populate the "node" name and "plan_uuid" fields. + // Our protocol here is searching for the "@", the substring *before* that is the + // global plan uuid, and the substring *after* that is the node name. + size_t pos = child_uuid.find ('@'); + + retv->plan_uuid_ = + child_uuid.substring (0, pos); - // Parse the child_uuid string and populate the "node" name as well as the - // parent plan uuid - //retv.node_ = - //retv.plan_uuid_ = + retv->node_ = + child_uuid.substring (pos+1, -1); // get the rest of the string Deployment::Connections_var connections; ACE_NEW_RETURN (connections, Deployment::Connections, 0); - this->get_outgoing_connections_i (name, + this->get_outgoing_connections_i (name.c_str (), connections.inout (), false, // get *all* connections true); // search current plan @@ -903,6 +902,74 @@ populate_binding_info (const char * name, const char * child_uuid) return retv; } +void +CIAO::DomainApplicationManager_Impl:: +add_shared_components (const Deployment::ComponentPlans & shared) +{ + for (CORBA::ULong i = 0; i < shared.length (); ++i) + { + CORBA::ULong curr_len = this->shared_->length (); + this->shared_->length (curr_len + 1); + this->shared_[curr_len] = shared[i]; + } +} + +bool +CIAO::DomainApplicationManager_Impl:: +is_shared_component (const char * name) +{ + for (CORBA::ULong i = 0; i < this->shared_->length (); ++i) + { + if (ACE_OS::strcmp (this->shared_[i].name.in (), + name) == 0) + return true; + } + + return false; +} + +void +CIAO::DomainApplicationManager_Impl:: +synchronize_shared_components_with_node_managers (void) +{ + for (CORBA::ULong i = 0; i < this->num_child_plans_; ++i) + { + // Get the NodeManager object reference. + ACE_Hash_Map_Entry + *entry = 0; + + if (this->artifact_map_.find (this->node_manager_names_[i], + entry) != 0) + { + ACE_ERROR ((LM_ERROR, + "DAnCE (%P|%t) DomainApplicationManager_Impl.cpp -" + "CIAO::DomainApplicationManager_Impl::startLaunch -" + "ERROR while finding the node specific plan " + "for the node [%s] \n", + this->node_manager_names_[i].c_str ())); + + ACE_CString error + ("Unable to resolve a reference to node manager: "); + error += this->node_manager_names_[i]; + + ACE_TRY_THROW + (Deployment::StartError + ("DomainApplicationManager_Impl:startLaunch", + error.c_str ())); + } + + // Update the shared components list + ::Deployment::NodeManager_ptr + my_node_manager = (entry->int_id_).node_manager_.in (); + + Deployment::ComponentPlans_var + shared = my_node_manager->get_shared_components (); + + this->add_shared_components (shared.in ()); + } +} + Deployment::Connections * CIAO::DomainApplicationManager_Impl:: @@ -920,7 +987,10 @@ get_outgoing_connections (const Deployment::DeploymentPlan &plan, // For each component instance in the child plan ... for (CORBA::ULong i = 0; i < plan.instance.length (); ++i) { - // Get the component instance name + if (this->is_shared_component (plan.instance[i].name.in ())) + continue; + + // Get the outgoing connections of the component if (!get_outgoing_connections_i (plan.instance[i].name.in (), connections.inout (), is_getting_all_connections, diff --git a/TAO/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.h b/TAO/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.h index 0848599ea97..f0f206e4f61 100644 --- a/TAO/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.h +++ b/TAO/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.h @@ -248,9 +248,34 @@ namespace CIAO * Construct struct for the component instance. * * @para name component instance name + * @para child_uuid child plan uuid string */ Execution_Manager::Execution_Manager_Impl::Component_Binding_Info * - populate_binding_info (const char * name, const char * child_uuid); + populate_binding_info (const ACE_CString& name, + const ACE_CString& child_uuid); + + + /** + * Contact each NodeManager to get shared compnents information + * and then update its internal cache. + */ + void synchronize_shared_components_with_node_managers (void); + + /** + * A helper function to add a list of shared components into + * the cached shared component list. + * + * @para shared A list of shared components to be added. + */ + void add_shared_components (const Deployment::ComponentPlans & shared); + + /** + * A private function to check whether a component is in the shared + * component list. + * + * @para name The name of a component instance. + */ + bool is_shared_component (const char * name); /** * Cache the incoming connections, which is a sequence of Connections, @@ -306,8 +331,8 @@ namespace CIAO /// to pass CORBA object reference back and forth. Execution_Manager::Execution_Manager_Impl * execution_manager_; - /// Cache a object reference to this servant. - /// Deployment::DomainApplicationManager_var objref_; + /// Cache a list of shared components + Deployment::ComponentPlans_var shared_; /// Cache the ior of the previous reference CORBA::String_var ior_; diff --git a/TAO/CIAO/DAnCE/ExecutionManager/Execution_Manager_Impl.cpp b/TAO/CIAO/DAnCE/ExecutionManager/Execution_Manager_Impl.cpp index 365cbb12e04..86c1fc1e5d3 100644 --- a/TAO/CIAO/DAnCE/ExecutionManager/Execution_Manager_Impl.cpp +++ b/TAO/CIAO/DAnCE/ExecutionManager/Execution_Manager_Impl.cpp @@ -211,7 +211,7 @@ namespace CIAO ACE_DEBUG ((LM_ERROR, "DAnCE (%P|%t) ExecutionManager_Impl.cpp -" "CIAO::Execution_Manager_Impl::perform_redeployment -" - "Invalid plan uuid: %s!\n", plan.UUID.in ())); + "Invalid plan uuid: %s\n", plan.UUID.in ())); ACE_THROW (Deployment::PlanError ( "Execution_Manager_Impl::perform_redeployment", "Invalid plan uuid specified.")); @@ -247,7 +247,7 @@ namespace CIAO ACE_DEBUG ((LM_ERROR, "DAnCE (%P|%t) ExecutionManager_Impl.cpp -" "CIAO::Execution_Manager_Impl::getPlan -" - "Invalid plan uuid: %s!\n", plan_uuid)); + "Invalid plan uuid: %s\n", plan_uuid)); ACE_THROW (::CORBA::BAD_PARAM ()); } @@ -273,6 +273,9 @@ namespace CIAO ::CORBA::SystemException, ::Deployment::InvalidConnection)) { + ACE_DEBUG ((LM_ERROR, + "Execution_Manage::finalizing global bindings.\n")); + // Find the NodeApplication hosting the component, and then call // on it ACE_TRY @@ -280,6 +283,14 @@ namespace CIAO Deployment::NodeApplication_var node_app = this->find_node_application (binding); + if (CORBA::is_nil (node_app.in ())) + { + ACE_DEBUG ((LM_ERROR, + "Execution_Manager_Impl::finalize_global_binding - " + "nil NodeApplication object reference.\n")); + ACE_THROW (Deployment::InvalidConnection ()); + } + node_app->finishLaunch (binding.providedReference_.in (), true, // start true); // add_connection @@ -310,7 +321,7 @@ namespace CIAO ACE_DEBUG ((LM_ERROR, "DAnCE (%P|%t) ExecutionManager_Impl.cpp -" "CIAO::Execution_Manager_Impl::find_node_application -" - "Invalid plan uuid: %s!\n", binding.plan_uuid_.c_str ())); + "Invalid plan uuid: %s\n", binding.plan_uuid_.c_str ())); ACE_THROW (::CORBA::BAD_PARAM ()); } diff --git a/TAO/CIAO/DAnCE/NodeManager/NodeManager_Impl.cpp b/TAO/CIAO/DAnCE/NodeManager/NodeManager_Impl.cpp index cffa9c3b582..ac2ae8d5cc9 100644 --- a/TAO/CIAO/DAnCE/NodeManager/NodeManager_Impl.cpp +++ b/TAO/CIAO/DAnCE/NodeManager/NodeManager_Impl.cpp @@ -129,27 +129,6 @@ set_all_consumers (ACE_CString &name, this->comp_consumers_map_.rebind (name, consumers); } -CORBA::StringSeq * -CIAO::NodeManager_Impl_Base::shared_components_seq (void) -{ - CORBA::StringSeq * retv; - ACE_NEW_RETURN (retv, CORBA::StringSeq, 0); - retv->length (0); - - ACE_Unbounded_Set::iterator end = this->shared_components_.end (); - for (ACE_Unbounded_Set::iterator - iter = this->shared_components_.begin (); - iter != end; - ++iter) - { - CORBA::ULong curr_len = retv->length (); - retv->length (curr_len + 1); - (*retv)[curr_len] = (*iter).c_str (); - } - - return retv; -} - Deployment::NodeApplicationManager_ptr CIAO::NodeManager_Impl_Base::preparePlan (const Deployment::DeploymentPlan &plan ACE_ENV_ARG_DECL) @@ -177,13 +156,17 @@ CIAO::NodeManager_Impl_Base::preparePlan (const Deployment::DeploymentPlan &plan Reference_Count_Map::ENTRY *entry = 0; if (this->ref_count_map_.find (plan.instance[i].name.in (), entry) != 0) { - // Initial ref count is set to "1" - this->ref_count_map_.bind (plan.instance[i].name.in (), 1); + // Create a new entry, set the initial ref count "1", and insert to the map. + Ref_Count_Info new_entry; + new_entry.plan_uuid_ = plan.UUID.in (); + new_entry.count_ = 1; + this->ref_count_map_.bind (plan.instance[i].name.in (), new_entry); } else { + // Increase the ref count by 1 this->shared_components_.insert (plan.instance[i].name.in ()); - ++entry->int_id_; // increase ref count by 1 + ++ entry->int_id_.count_; } } @@ -358,9 +341,9 @@ destroyPlan (const Deployment::DeploymentPlan & plan Reference_Count_Map::ENTRY *entry = 0; if (this->ref_count_map_.find (plan.instance[i].name.in (), entry) == 0) { - --entry->int_id_; // decrease ref count by 1 + --entry->int_id_.count_; // decrease ref count by 1 - if (entry->int_id_ == 0) + if (entry->int_id_.count_ == 0) { // Remove this component from the shared set this->shared_components_.remove (plan.instance[i].name.in ()); @@ -407,11 +390,74 @@ destroyPlan (const Deployment::DeploymentPlan & plan // there are some components that are shared by other plans. } -CORBA::StringSeq * +Deployment::ComponentPlans * CIAO::NodeManager_Impl_Base:: get_shared_components (ACE_ENV_SINGLE_ARG_DECL) { - return this->shared_components_seq (); + return this->get_shared_components_i (); +} + +Deployment::ComponentPlans * +CIAO::NodeManager_Impl_Base::get_shared_components_i (void) +{ + Deployment::ComponentPlans_var retv; + ACE_NEW_RETURN (retv, + Deployment::ComponentPlans, + 0); + retv->length (0); + + ACE_Unbounded_Set::iterator + end = this->shared_components_.end (); + + for (ACE_Unbounded_Set::iterator + iter = this->shared_components_.begin (); + iter != end; + ++iter) + { + CORBA::ULong curr_len = retv->length (); + retv->length (curr_len + 1); + (*retv)[curr_len].name = (*iter).c_str (); + + // Fill in the plan_uuid information about this component, by + // searching in the ref_count_map_ + Reference_Count_Map::ENTRY *entry = 0; + if (this->ref_count_map_.find ((*iter).c_str (), entry) == 0) + { + // Get the plan_uuid_ info and populate the field + (*retv)[curr_len].plan_uuid = entry->int_id_.plan_uuid_.c_str (); + } + else + { + // should never happen + ACE_DEBUG ((LM_ERROR, "Component [%s] in the list of shared component, " + "was not found in the NodeManager ref count map.\n", + (*iter).c_str ())); + } + } + + return retv._retn (); +} + + +CORBA::StringSeq * +CIAO::NodeManager_Impl_Base::shared_components_seq (void) +{ + CORBA::StringSeq * retv; + ACE_NEW_RETURN (retv, CORBA::StringSeq, 0); + retv->length (0); + + ACE_Unbounded_Set::iterator end = this->shared_components_.end (); + for (ACE_Unbounded_Set::iterator + iter = this->shared_components_.begin (); + iter != end; + ++iter) + { + CORBA::ULong curr_len = retv->length (); + retv->length (curr_len + 1); + (*retv)[curr_len] = (*iter).c_str (); + } + + return retv; } bool diff --git a/TAO/CIAO/DAnCE/NodeManager/NodeManager_Impl.h b/TAO/CIAO/DAnCE/NodeManager/NodeManager_Impl.h index 59b2a98ae90..93da1abe2bb 100644 --- a/TAO/CIAO/DAnCE/NodeManager/NodeManager_Impl.h +++ b/TAO/CIAO/DAnCE/NodeManager/NodeManager_Impl.h @@ -6,13 +6,14 @@ * $Id$ * * This file contains servant implementation for Deployment:NodeManager - * interface. In the current design of the NodeManager, as with the - * legacy implementation of CIAO, Each NodeManager corresponds to - * ONE NodeApplication Manager. Though, the name intuitively suggests + * interface. In the current design of the NodeManager, each NodeManager + * could manage one or more NodeApplication Managers. + * Though, the name intuitively suggests * that there be one NodeManager for every node, our design, allows * the end-user to have multiple components run on the same node. * * @author Arvind S. Krishna + * @author Gan Deng */ //============================================================================= @@ -47,6 +48,14 @@ namespace CIAO : public virtual POA_CIAO::NodeManager { public: + /// A struct that tracks the reference count of a particular + /// component as well as the "child_plan_uuid" where the component is + /// actually installed + typedef struct _ref_count_info + { + ACE_CString plan_uuid_; + size_t count_; + } Ref_Count_Info; /// Constructor NodeManager_Impl_Base (const char *name, @@ -103,7 +112,7 @@ namespace CIAO ::Deployment::StopError)); /// CIAO specific extension, return a set of shared components - virtual CORBA::StringSeq * + virtual ::Deployment::ComponentPlans * get_shared_components (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) ACE_THROW_SPEC ((::CORBA::SystemException)); @@ -144,6 +153,13 @@ namespace CIAO ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException))=0; + /// Actual implementation of the IDL operation + virtual ::Deployment::ComponentPlans * + get_shared_components_i (void); + + /// A helper method that convert ACE_Unbounded_Set to CORBA StringSeq + CORBA::StringSeq * shared_components_seq (void); + /// Keep a pointer to the managing ORB serving this servant. CORBA::ORB_var orb_; @@ -170,24 +186,21 @@ namespace CIAO NAM_Map map_; /// A reference count map for the components installed on this node + /// @@TODO We should also keep the information about *where* the + /// component is installed typedef ACE_Hash_Map_Manager_Ex , ACE_Equal_To, ACE_Null_Mutex> Reference_Count_Map; typedef Reference_Count_Map::iterator Ref_Count_Iterator; - /// @@TODO We should also keep the information about *where* the - /// component is installed Reference_Count_Map ref_count_map_; /// A set to track the names of shared component instances - //CORBA::StringSeq shared_components_; ACE_Unbounded_Set shared_components_; - CORBA::StringSeq * shared_components_seq (void); - /// Cached object references of ports (facets/consumers) of /// all components. This is useful for getting the port object /// references of "shared components". The key in the map diff --git a/TAO/CIAO/ciao/Deployment.idl b/TAO/CIAO/ciao/Deployment.idl index b7d1b975a4c..6fc81445bc3 100644 --- a/TAO/CIAO/ciao/Deployment.idl +++ b/TAO/CIAO/ciao/Deployment.idl @@ -1,7 +1,6 @@ // $Id$ #include "Packaging_Data.idl" #include "ServerResources.idl" -#include module Deployment { @@ -44,6 +43,16 @@ module Deployment { exception PlanNotExist { }; + // CIAO specific struct type used for shared component management + // mapping the name of component to its plan_uuid + struct ComponentPlan + { + string name; + string plan_uuid; + }; + + typedef sequence < ComponentPlan > ComponentPlans; + interface ApplicationManager { Application startLaunch (in Properties configProperty, out Connections providedReference, @@ -199,7 +208,7 @@ module Deployment { /// CIAO specific extension /// Get all the shared components installed in this node - CORBA::StringSeq get_shared_components (); + ComponentPlans get_shared_components (); }; interface RepositoryManager { diff --git a/TAO/CIAO/examples/Hello/descriptors_shared_components/deploymentplan_shared_components.cdp b/TAO/CIAO/examples/Hello/descriptors_shared_components/deploymentplan_shared_components.cdp index 19922142f8a..4565256398b 100644 --- a/TAO/CIAO/examples/Hello/descriptors_shared_components/deploymentplan_shared_components.cdp +++ b/TAO/CIAO/examples/Hello/descriptors_shared_components/deploymentplan_shared_components.cdp @@ -138,7 +138,7 @@ - + -- cgit v1.2.1