From a9f6172a5433153779a9c87fd7a797b963fcc294 Mon Sep 17 00:00:00 2001 From: dengg Date: Fri, 20 Jan 2006 02:49:58 +0000 Subject: *** empty log message *** --- .../DAnCE/NodeApplication/NodeApplication_Impl.cpp | 10 +-- TAO/CIAO/DAnCE/NodeManager/NodeManager_Impl.cpp | 76 ++++++++++++++++++---- TAO/CIAO/DAnCE/NodeManager/NodeManager_Impl.h | 10 ++- TAO/CIAO/DAnCE/Plan_Launcher/Plan_Launcher.cpp | 8 +++ 4 files changed, 83 insertions(+), 21 deletions(-) diff --git a/TAO/CIAO/DAnCE/NodeApplication/NodeApplication_Impl.cpp b/TAO/CIAO/DAnCE/NodeApplication/NodeApplication_Impl.cpp index 36966457426..9e9b35a5c49 100644 --- a/TAO/CIAO/DAnCE/NodeApplication/NodeApplication_Impl.cpp +++ b/TAO/CIAO/DAnCE/NodeApplication/NodeApplication_Impl.cpp @@ -575,8 +575,8 @@ CIAO::NodeApplication_Impl::create_container ( ::Components::CreateFailure, ::Components::InvalidConfiguration)) { - if (CIAO::debug_level () > 1) - ACE_DEBUG ((LM_DEBUG, "ENTERING: NodeApplication_Impl::create_container()\n")); + //if (CIAO::debug_level () > 1) + // ACE_DEBUG ((LM_DEBUG, "ENTERING: NodeApplication_Impl::create_container()\n")); CORBA::PolicyList_var policies = this->configurator_.find_container_policies (properties); @@ -627,9 +627,9 @@ CIAO::NodeApplication_Impl::create_container ( this->container_set_.add (ci.in ()); } - if (CIAO::debug_level () > 1) - ACE_DEBUG ((LM_DEBUG, - "LEAVING: NodeApplication_Impl::create_container()\n")); + //if (CIAO::debug_level () > 1) + // ACE_DEBUG ((LM_DEBUG, + // "LEAVING: NodeApplication_Impl::create_container()\n")); return ci._retn (); } diff --git a/TAO/CIAO/DAnCE/NodeManager/NodeManager_Impl.cpp b/TAO/CIAO/DAnCE/NodeManager/NodeManager_Impl.cpp index 6803f142b25..5e99d7e7896 100644 --- a/TAO/CIAO/DAnCE/NodeManager/NodeManager_Impl.cpp +++ b/TAO/CIAO/DAnCE/NodeManager/NodeManager_Impl.cpp @@ -118,7 +118,7 @@ CIAO::NodeManager_Impl_Base:: set_all_facets (ACE_CString &name, const ::Components::FacetDescriptions_var & facets) { - this->comp_facets_map_.bind (name, facets); + this->comp_facets_map_.rebind (name, facets); } void @@ -126,7 +126,28 @@ CIAO::NodeManager_Impl_Base:: set_all_consumers (ACE_CString &name, const ::Components::ConsumerDescriptions_var & consumers) { - this->comp_consumers_map_.bind (name, consumers); + 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 @@ -161,9 +182,7 @@ CIAO::NodeManager_Impl_Base::preparePlan (const Deployment::DeploymentPlan &plan } else { - CORBA::ULong len = this->shared_components_.length (); - shared_components_.length (len + 1); - this->shared_components_[len] = plan.instance[i].name.in (); + this->shared_components_.insert (plan.instance[i].name.in ()); ++entry->int_id_; // increase ref count by 1 } } @@ -212,11 +231,11 @@ CIAO::NodeManager_Impl_Base::preparePlan (const Deployment::DeploymentPlan &plan // won't be instantiated again Deployment::NodeApplicationManager_var nam = Deployment::NodeApplicationManager::_narrow (obj.in ()); - ACE_TRY_CHECK; - - nam->set_shared_components (this->shared_components_); - ACE_TRY_CHECK; + // Convert the ACE Set into CORBA sequence, and make the remote invocation + CORBA::StringSeq_var shared = this->shared_components_seq (); + nam->set_shared_components (shared.in ()); + // narrow should return a nil reference if it fails. return Deployment::NodeApplicationManager::_narrow (nam.in ()); } @@ -242,8 +261,8 @@ CIAO::NodeManager_Impl_Base::preparePlan (const Deployment::DeploymentPlan &plan // Similarly, we should inform NAM about "shared" components, so // they won't be instantiated again - nam->set_shared_components (this->shared_components_); - ACE_TRY_CHECK; + CORBA::StringSeq_var shared; + nam->set_shared_components (shared.in ()); // Potentially we could reset many other configuration settings // such as command line options, service configuration file, etc. @@ -331,6 +350,35 @@ destroyPlan (const Deployment::DeploymentPlan & plan // we should remove the necesary bindings on this component specified // in the deployment plan. + // Clean up the cached "Facets" and "Consumers" map of the components + // whose ref count is 0 + CORBA::ULong const length = plan.instance.length (); + for (CORBA::ULong i = 0; i < length; ++i) + { + 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 + + if (entry->int_id_ == 0) + { + // Remove this component from the shared set + this->shared_components_.remove (plan.instance[i].name.in ()); + + // Unbind this component from the ref_count_map_ + this->ref_count_map_.unbind (plan.instance[i].name.in ()); + } + } + + if (this->comp_facets_map_.unbind (plan.instance[i].name.in ()) != 0 || + this->comp_consumers_map_.unbind (plan.instance[i].name.in ()) != 0) + { + ACE_TRY_THROW + (Deployment::StopError ("NodeManager_Impl_Base::destroyPlan ", + "Unable to find component instance")); + } + } + // Create a list of components that are not to be removed, and send // this list to the NAM, who will delegate to appropriate NAs to // remove bindings from these components. @@ -344,11 +392,13 @@ destroyPlan (const Deployment::DeploymentPlan & plan // If CORBA::Object_var obj = this->poa_->id_to_reference (this->map_.get_nam (plan.UUID.in ())); - ACE_TRY_CHECK; Deployment::NodeApplicationManager_var nam = Deployment::NodeApplicationManager::_narrow (obj.in ()); - ACE_TRY_CHECK; + + // Convert the ACE Set into CORBA sequence, and reset it. + CORBA::StringSeq_var shared = this->shared_components_seq (); + nam->set_shared_components (shared.in ()); nam->destroyApplication (0); diff --git a/TAO/CIAO/DAnCE/NodeManager/NodeManager_Impl.h b/TAO/CIAO/DAnCE/NodeManager/NodeManager_Impl.h index 6eb12a49433..70efed019dc 100644 --- a/TAO/CIAO/DAnCE/NodeManager/NodeManager_Impl.h +++ b/TAO/CIAO/DAnCE/NodeManager/NodeManager_Impl.h @@ -175,12 +175,16 @@ namespace CIAO Reference_Count_Map ref_count_map_; - /// A list to track the names of shared component instances - CORBA::StringSeq shared_components_; + /// 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". + /// references of "shared components". The key in the map + /// is the component instance name. typedef ACE_Hash_Map_Manager_Ex to tear down application\n")); char dummy [256]; std::cin.getline (dummy, 256); + + // Tear down the assembly + ACE_DEBUG ((LM_DEBUG, + "Plan_Launcher: destroy the application.....")); + if (! launcher.teardown_plan (uuid)) + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) CIAO_PlanLauncher:tear down assembly failed: " + "unkonw plan uuid.\n")); } } else if (mode == pl_mode_redeployment && new_package_url != 0) // do redeployment -- cgit v1.2.1