diff options
Diffstat (limited to 'TAO/CIAO/DAnCE/NodeManager/NodeManager_Impl.cpp')
-rw-r--r-- | TAO/CIAO/DAnCE/NodeManager/NodeManager_Impl.cpp | 460 |
1 files changed, 41 insertions, 419 deletions
diff --git a/TAO/CIAO/DAnCE/NodeManager/NodeManager_Impl.cpp b/TAO/CIAO/DAnCE/NodeManager/NodeManager_Impl.cpp index f657129ebf0..c040b75859f 100644 --- a/TAO/CIAO/DAnCE/NodeManager/NodeManager_Impl.cpp +++ b/TAO/CIAO/DAnCE/NodeManager/NodeManager_Impl.cpp @@ -2,9 +2,8 @@ #include "NodeManager_Impl.h" #include "../NodeApplicationManager/NodeApplicationManager_Impl.h" -#include "ace/Log_Msg.h" -CIAO::NodeManager_Impl_Base::NodeManager_Impl_Base (const char *name, +CIAO::NodeManager_Impl::NodeManager_Impl (const char *name, CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, const char * nodeapp_loc, @@ -21,12 +20,13 @@ CIAO::NodeManager_Impl_Base::NodeManager_Impl_Base (const char *name, { } -CIAO::NodeManager_Impl_Base::~NodeManager_Impl_Base () +CIAO::NodeManager_Impl::~NodeManager_Impl () { + } void -CIAO::NodeManager_Impl_Base::init (ACE_ENV_SINGLE_ARG_DECL) +CIAO::NodeManager_Impl::init (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { ACE_TRY @@ -42,6 +42,7 @@ CIAO::NodeManager_Impl_Base::init (ACE_ENV_SINGLE_ARG_DECL) 0 ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; + } ACE_CATCHANY { @@ -54,21 +55,21 @@ CIAO::NodeManager_Impl_Base::init (ACE_ENV_SINGLE_ARG_DECL) } PortableServer::POA_ptr -CIAO::NodeManager_Impl_Base::_default_POA (void) +CIAO::NodeManager_Impl::_default_POA (void) { return PortableServer::POA::_duplicate (this->poa_.in ()); } char * -CIAO::NodeManager_Impl_Base::name (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) +CIAO::NodeManager_Impl::name (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) ACE_THROW_SPEC ((CORBA::SystemException)) { return CORBA::string_dup (this->name_.in ()); } void -CIAO::NodeManager_Impl_Base::shutdown (ACE_ENV_SINGLE_ARG_DECL) +CIAO::NodeManager_Impl::shutdown (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { this->orb_->shutdown (0 ACE_ENV_ARG_PARAMETER); @@ -76,120 +77,27 @@ CIAO::NodeManager_Impl_Base::shutdown (ACE_ENV_SINGLE_ARG_DECL) } void -CIAO::NodeManager_Impl_Base::joinDomain (const Deployment::Domain & domain, - Deployment::TargetManager_ptr target, +CIAO::NodeManager_Impl::joinDomain (const Deployment::Domain & , + Deployment::TargetManager_ptr , Deployment::Logger_ptr ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { -// ACE_THROW (CORBA::NO_IMPLEMENT ()); -// Here start the Monitor - CIAO_TRACE("CIAO::NodeManager_Impl_Base::joinDomain"); - - ::Deployment::Domain this_domain = domain; -// MonitorController* monitor_controller - monitor_controller_.reset ( - new MonitorController (orb_.in (), - this_domain, - target)); - - if (CIAO::debug_level () > 9) - { - ACE_DEBUG ((LM_DEBUG , "Before Activate")); - } - /// Activate the Monitor Controller to - //start the monitoring - monitor_controller_->activate (); - - if (CIAO::debug_level () > 9) - { - ACE_DEBUG ((LM_DEBUG , "After Activate")); - } + ACE_THROW (CORBA::NO_IMPLEMENT ()); } void -CIAO::NodeManager_Impl_Base::leaveDomain (ACE_ENV_SINGLE_ARG_DECL) +CIAO::NodeManager_Impl::leaveDomain (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { //Implementation undefined. ACE_THROW (CORBA::NO_IMPLEMENT ()); } -::Components::FacetDescriptions * -CIAO::NodeManager_Impl_Base:: -get_all_facets (ACE_CString & name) -{ - Component_Facets_Map::ENTRY *entry = 0; - - if (this->comp_facets_map_.find (name.c_str (), entry) != 0) - ACE_DEBUG ((LM_ERROR, "(%P|%t) - NodeManager_Impl_Base::get_all_facets - " - "No component with name [%s] was found in the NodeManager\n", name.c_str ())); - - CORBA::ULong facet_len = entry->int_id_->length (); - - Components::FacetDescriptions_var retv; - ACE_NEW_RETURN (retv, - Components::FacetDescriptions, - 0); - - retv->length (facet_len); - - for (CORBA::ULong i = 0; i < facet_len; ++i) - { - retv[i] = entry->int_id_[i]; - } - - return retv._retn (); -} - -::Components::ConsumerDescriptions * -CIAO::NodeManager_Impl_Base:: -get_all_consumers (ACE_CString & name) -{ - Component_Consumers_Map::ENTRY *entry = 0; - - if (this->comp_consumers_map_.find (name.c_str (), entry) != 0) - ACE_DEBUG ((LM_ERROR, "(%P|%t) - NodeManager_Impl_Base::get_all_facets - " - "Component [%s] was not found in the NodeManager\n", name.c_str ())); - - CORBA::ULong consumer_len = entry->int_id_->length (); - - Components::ConsumerDescriptions_var retv; - ACE_NEW_RETURN (retv, - Components::ConsumerDescriptions, - 0); - - retv->length (consumer_len); - - for (CORBA::ULong i = 0; i < consumer_len; ++i) - { - retv[i] = entry->int_id_[i]; - } - - return retv._retn (); -} - -void -CIAO::NodeManager_Impl_Base:: -set_all_facets (ACE_CString &name, - const ::Components::FacetDescriptions_var & facets) -{ - this->comp_facets_map_.rebind (name, facets); -} - -void -CIAO::NodeManager_Impl_Base:: -set_all_consumers (ACE_CString &name, - const ::Components::ConsumerDescriptions_var & consumers) -{ - this->comp_consumers_map_.rebind (name, consumers); -} - Deployment::NodeApplicationManager_ptr -CIAO::NodeManager_Impl_Base:: -preparePlan (const Deployment::DeploymentPlan &plan - ACE_ENV_ARG_DECL) +CIAO::NodeManager_Impl::preparePlan (const Deployment::DeploymentPlan &plan + ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, Deployment::StartError, Deployment::PlanError)) @@ -198,7 +106,7 @@ preparePlan (const Deployment::DeploymentPlan &plan if (! this->validate_plan (plan)) { - ACE_DEBUG ((LM_DEBUG, "(%P|%t) NodeManager <%s>:prepare_plan:Plan_Error.\n", + ACE_DEBUG ((LM_DEBUG, "(%P|%t) NodeManager <%s>:prepare_plan:Plan_Error.\n", plan.instance[0].node.in ())); ACE_DEBUG ((LM_DEBUG, "(%P|%t) All component instances hosted in the " "same component server must have the " @@ -208,35 +116,6 @@ preparePlan (const Deployment::DeploymentPlan &plan Deployment::NodeApplicationManager::_nil ()); } - // Update the reference count map based on the deployment plan input - for (CORBA::ULong i = 0; i < plan.instance.length (); ++i) - { - Reference_Count_Map::ENTRY *entry = 0; - if (this->ref_count_map_.find (plan.instance[i].name.in (), entry) != 0) - { - // 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 - { - // If the instance is within the same deployment plan, e.g., - // when ReDaC service is used, then just do nothing since it is NOT - // actually a shared component at all. - if (ACE_OS::strcmp (plan.UUID.in (), - entry->int_id_.plan_uuid_.c_str ()) == 0) - continue; - - // Otherwise, it is really a shared component, so let's increase - // the ref count by 1 - this->shared_components_.insert (plan.instance[i].name.in ()); - ++ entry->int_id_.count_; - } - } - - // Create/find NodeApplicationManager and set/reset plan on it ACE_TRY { if (!this->map_.is_available (plan.UUID.in ())) @@ -249,45 +128,28 @@ preparePlan (const Deployment::DeploymentPlan &plan } //Implementation undefined. - CIAO::NodeApplicationManager_Impl_Base *node_app_mgr; - node_app_mgr = - this->create_node_app_manager (this->orb_.in (), this->poa_.in () - ACE_ENV_ARG_PARAMETER); + CIAO::NodeApplicationManager_Impl *app_mgr; + ACE_NEW_THROW_EX (app_mgr, + CIAO::NodeApplicationManager_Impl (this->orb_.in (), + this->poa_.in ()), + CORBA::NO_MEMORY ()); ACE_TRY_CHECK; - PortableServer::ServantBase_var safe (node_app_mgr); + PortableServer::ServantBase_var safe (app_mgr); //@@ Note: after the init call the servant ref count would // become 2. so we can leave the safeservant along and be // dead. Also note that I added PortableServer::ObjectId_var oid = - node_app_mgr->init (this->nodeapp_location_.in (), - this->nodeapp_options_.in (), - this->spawn_delay_, - plan, - this->callback_poa_.in (), - this // pass in a copy of ourself (servant object) - ACE_ENV_ARG_PARAMETER); + app_mgr->init (this->nodeapp_location_, + this->nodeapp_options_.in (), + this->spawn_delay_, + plan, + this->callback_poa_.in () + ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; this->map_.insert_nam (plan.UUID.in (), oid.in ()); - - CORBA::Object_var obj = - this->poa_->id_to_reference (this->map_.get_nam (plan.UUID.in ())); - ACE_TRY_CHECK; - - // We should inform NAM about "shared" components, so they - // won't be instantiated again - Deployment::NodeApplicationManager_var nam = - Deployment::NodeApplicationManager::_narrow (obj.in ()); - - // Convert the ACE Set into CORBA sequence, and make the remote invocation - Deployment::ComponentPlans_var shared = - this->get_shared_components_i (); - nam->set_shared_components (shared.in ()); - - // narrow should return a nil reference if it fails. - return Deployment::NodeApplicationManager::_narrow (nam.in ()); } else { @@ -297,28 +159,16 @@ preparePlan (const Deployment::DeploymentPlan &plan "with UUID: %s\n", plan.UUID.in ())); } + } - 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; - - nam->reset_plan (plan); - ACE_TRY_CHECK; - // Similarly, we should inform NAM about "shared" components, so - // they won't be instantiated again - Deployment::ComponentPlans_var shared = - this->get_shared_components_i (); - nam->set_shared_components (shared.in ()); + CORBA::Object_var obj = + this->poa_->id_to_reference (this->map_.get_nam (plan.UUID.in ())); + ACE_TRY_CHECK; - // Potentially we could reset many other configuration settings - // such as command line options, service configuration file, etc. - return nam._retn (); - } + // narrow should return a nil reference if it fails. + return + Deployment::NodeApplicationManager::_narrow (obj.in ()); } ACE_CATCH (PortableServer::POA::ObjectNotActive, ex) { @@ -338,7 +188,7 @@ preparePlan (const Deployment::DeploymentPlan &plan } void -CIAO::NodeManager_Impl_Base::destroyManager +CIAO::NodeManager_Impl::destroyManager (Deployment::NodeApplicationManager_ptr manager ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, @@ -348,14 +198,13 @@ CIAO::NodeManager_Impl_Base::destroyManager CIAO_TRACE("CIAO::NodeManager_Impl::destroyManager"); ACE_TRY { - printf("Entering NM_Impl::destroyManager\n"); // Deactivate this object PortableServer::ObjectId_var id = this->poa_->reference_to_id (manager ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; - if (!this->map_.remove_nam (id.in ())) + if (!this->map_.remove_nam (id)) { ACE_ERROR ((LM_ERROR, "NodeManager_Impl::destroyManager: " @@ -365,14 +214,13 @@ CIAO::NodeManager_Impl_Base::destroyManager this->poa_->deactivate_object (id.in () ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; - printf("Exiting NM_Impl::destroyManager\n"); } ACE_CATCH (PortableServer::POA::WrongAdapter, ex) { - ACE_ERROR ((LM_ERROR, + ACE_ERROR ((LM_ERROR, "NodeManager_Impl::destroyManager: EXCEPTION - " "Invalid reference passed to destroyManager\n")); - + ACE_THROW (::Deployment::InvalidReference ()); } ACE_CATCH (PortableServer::POA::ObjectNotActive, ex) @@ -391,143 +239,8 @@ CIAO::NodeManager_Impl_Base::destroyManager ACE_ENDTRY; } -void -CIAO::NodeManager_Impl_Base:: -destroyPlan (const Deployment::DeploymentPlan & plan - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((::CORBA::SystemException, - ::Deployment::StopError)) -{ - // Update the reference counting map (subtract by 1 for each instance) - // If the ref count becomes 0, then remove this component, otherwise, - // 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 - // if their ref count become 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_.count_; // decrease ref count by 1 - - if (entry->int_id_.count_ == 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 ()); - - // Unbind this component from the facet/consumer maps - 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")); - } - } - } - } - - // Find the NAM from the map and invoke the destroyPlan() operation on - // it, which will actuall remove components and connections in this plan. - // If - CORBA::Object_var obj = - this->poa_->id_to_reference (this->map_.get_nam (plan.UUID.in ())); - - Deployment::NodeApplicationManager_var nam = - Deployment::NodeApplicationManager::_narrow (obj.in ()); - - // Reset each NAM about the shared components information - Deployment::ComponentPlans_var shared = this->get_shared_components_i (); - nam->set_shared_components (shared.in ()); - - nam->destroyApplication (0); - - // @@ The problem is that we should NOT actually kill the NA process if - // there are some components that are shared by other plans. -} - -Deployment::ComponentPlans * -CIAO::NodeManager_Impl_Base:: -get_shared_components (ACE_ENV_SINGLE_ARG_DECL) - ACE_THROW_SPEC ((::CORBA::SystemException)) -{ - 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<ACE_CString>::iterator - end = this->shared_components_.end (); - - for (ACE_Unbounded_Set<ACE_CString>::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<ACE_CString>::iterator end = this->shared_components_.end (); - for (ACE_Unbounded_Set<ACE_CString>::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 -CIAO::NodeManager_Impl_Base:: -validate_plan (const Deployment::DeploymentPlan &plan) +CIAO::NodeManager_Impl::validate_plan (const Deployment::DeploymentPlan &plan) { const char * resource_id = 0; CORBA::ULong i = 0; @@ -540,7 +253,7 @@ validate_plan (const Deployment::DeploymentPlan &plan) // the "resourceValue" field represents the policy_set_id, so we // are checking to make sure that all component instances have // the same server_resource_id. - resource_id = + resource_id = plan.instance[i].deployedResource[0].resourceName.in (); break; } @@ -557,7 +270,7 @@ validate_plan (const Deployment::DeploymentPlan &plan) } else { - my_resource_id = + my_resource_id = plan.instance[i].deployedResource[0].resourceName.in ();; if (ACE_OS::strcmp (resource_id, my_resource_id) != 0) { @@ -568,94 +281,3 @@ validate_plan (const Deployment::DeploymentPlan &plan) } return true; } - -CIAO::NodeManager_Impl::~NodeManager_Impl () -{ -} - -CIAO::NodeManager_Impl:: -NodeManager_Impl (const char *name, - CORBA::ORB_ptr orb, - PortableServer::POA_ptr poa, - const char * nodeapp_loc, - const char * nodeapp_options, - int spawn_delay) - : NodeManager_Impl_Base (name, orb, poa, nodeapp_loc, nodeapp_options, spawn_delay) -{} - - -::CIAO::NodeApplicationManager_Impl_Base * -CIAO::NodeManager_Impl:: -create_node_app_manager (CORBA::ORB_ptr orb, - PortableServer::POA_ptr poa - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException)) -{ - CIAO::NodeApplicationManager_Impl_Base *app_mgr; - ACE_NEW_THROW_EX (app_mgr, - CIAO::NodeApplicationManager_Impl (orb, - poa), - CORBA::NO_MEMORY ()); - return app_mgr; -} - -CIAO::Static_NodeManager_Impl::~Static_NodeManager_Impl () -{ -} - -CIAO::Static_NodeManager_Impl:: -Static_NodeManager_Impl (const char *name, - CORBA::ORB_ptr orb, - PortableServer::POA_ptr poa, - const char * nodeapp_loc, - const char * nodeapp_options, - int spawn_delay, - Static_Config_EntryPoints_Maps* static_config_entrypoints_maps) - : NodeManager_Impl_Base (name, orb, poa, nodeapp_loc, nodeapp_options, spawn_delay), - static_config_entrypoints_maps_ (static_config_entrypoints_maps) -{} - -::CIAO::NodeApplicationManager_Impl_Base * -CIAO::Static_NodeManager_Impl:: -create_node_app_manager (CORBA::ORB_ptr orb, - PortableServer::POA_ptr poa - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException)) -{ - ACE_DEBUG ((LM_DEBUG, "creating static_node_app_manager\n")); - CIAO::NodeApplicationManager_Impl_Base *app_mgr; - ACE_NEW_THROW_EX (app_mgr, - CIAO::Static_NodeApplicationManager_Impl (orb, - poa, - this->static_config_entrypoints_maps_), - CORBA::NO_MEMORY ()); - return app_mgr; -} - -void -CIAO::Static_NodeManager_Impl::destroyManager - (Deployment::NodeApplicationManager_ptr manager - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, - Deployment::StopError, - Deployment::InvalidReference)) -{ - CIAO_TRACE("CIAO::Static_NodeManager_Impl::destroyManager"); - ACE_TRY - { - CIAO::NodeManager_Impl_Base::destroyManager (manager ACE_ENV_ARG_PARAMETER); - - this->orb_->shutdown (0 ACE_ENV_ARG_PARAMETER); - - ACE_TRY_CHECK; - } - ACE_CATCHANY - { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, - "Static_NodeManager_Impl::destroyManager\t\n"); - ACE_RE_THROW; - } - ACE_ENDTRY; - - ACE_CHECK; -} |