diff options
author | dengg <dengg@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2006-02-22 01:06:08 +0000 |
---|---|---|
committer | dengg <dengg@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2006-02-22 01:06:08 +0000 |
commit | 1c7a3d436e77b6afc97d719b58687d6ba26be030 (patch) | |
tree | e1a2c19397859ddddbc69b18d2a6ab6035f7ae1d | |
parent | 1b4e6655aee389db0423a7a3d7e8bf39960c8016 (diff) | |
download | ATCD-1c7a3d436e77b6afc97d719b58687d6ba26be030.tar.gz |
Tue Feb 21 23:59:05 UTC 2006 Gan Deng <gan.deng@vanderbilt.edu>
8 files changed, 208 insertions, 54 deletions
diff --git a/TAO/CIAO/ChangeLog b/TAO/CIAO/ChangeLog index 27ac5681e78..ab01254b361 100644 --- a/TAO/CIAO/ChangeLog +++ b/TAO/CIAO/ChangeLog @@ -1,3 +1,68 @@ +Tue Feb 21 23:59:05 UTC 2006 Gan Deng <gan.deng@vanderbilt.edu> + + * ciao/Deployment.idl + + Added a parameter to the perform_redeployment() operation + to the NodeApplicationManager interface to separate the + "installation of new components" from the "removal of + existing components". + + * DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.cpp + + Modified the logic of perform_redeployment() functionality + to enforce correct order of ReDaC, which is: + (1) Install new components, + (2) Set up new connections, + (3) Remove old connections, and + (4) Remove old components. + + * DAnCE/NodeApplicationManager/NodeApplicationManager_Impl.cpp + * DAnCE/NodeApplicationManager/NodeApplicationManager_Impl.h + + Fixed a bug about removing components when using ReDaC. + In NodeApplicationManager, after the perform_redeployment() + call calls the remove_components() method to actually + destroy components from the component server, DAnCE NAM doesn't + unbind those components from the cached component_map_, hence + when the create_connections() method is called afterwords, + NAM tries to access the destroyed components to get + their port information, which causes the Object_Not_Exist + exception thrown. + + The fix will unbind the removed components from the + cached component map. However, the trick is that after + we unbind these components, the port iinformation of + these components are also lost, then the + DomainApplicaitonManager could not handle the + "removal" of connections correctly. + + The Right Fix is to enforce correct call sequence, which + are illustrated above. + Thanks Sandro Andrade <sandro @dcc.ufba.br> for reporting + a bug about removing component error. + + * DAnCE/NodeApplication/NodeApplication_Impl.h + * DAnCE/NodeApplication/NodeApplication_Impl.cpp + + Added a component state map to keep track of component state + information. With this map, components will be activated + only when they are newly created, and will be passivated + only when they are currently active. This will also fix + a bug about the component initialization sequence. Earlier, + when components are installed, they are immediately activated + by explicitly calling ciao_preactivate, ciao_activate, and + ciao_postactivate on the comopnent object reference, + which is not compliant to the Spec defined semantics. + This fix shall ensure that the components are activated AFTER + their connections have been setup. + + * DAnCE/NodeApplication/Container_Impl.cpp + + Fixed a bug when passing object reference to a local function. + Earlier the memory of the object reference is released by + the callee, which causes the object reference becomes invalid + after the function returns. + Tue Feb 21 19:43:11 UTC 2006 William R. Otte <wotte@dre.vanderbilt.edu> * performance-tests/Benchmark/RoundTripClient/RoundTripClient.mpc diff --git a/TAO/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.cpp b/TAO/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.cpp index e978ffbbdcf..f0e3b10ac89 100644 --- a/TAO/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.cpp +++ b/TAO/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.cpp @@ -5,6 +5,7 @@ #include "ace/Null_Mutex.h" #include "ace/OS_NS_string.h" #include "ace/SString.h" +#include "ace/Assert.h" #if !defined (__ACE_INLINE__) # include "DomainApplicationManager_Impl.inl" @@ -571,9 +572,16 @@ startLaunch (const ::Deployment::Properties & configProperty, } else { + //============================================================= + // Add New Components Logic + //============================================================= + // Let's add new components only now, the to-be-removed + // components should be removed AFTER the connections + // are removed. temp_application = my_nam->perform_redeployment (configProperty, retn_connections.out (), + true, // add new components only now 0); } @@ -629,7 +637,7 @@ startLaunch (const ::Deployment::Properties & configProperty, void CIAO::DomainApplicationManager_Impl:: finishLaunch (CORBA::Boolean start, - CORBA::Boolean is_ReDAC + CORBA::Boolean is_ReDaC ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, Deployment::StartError)) @@ -681,13 +689,13 @@ finishLaunch (CORBA::Boolean start, "==============================================\n")); } - // Get the Connections variable, if ReDAC is true, then we get + // Get the Connections variable, if ReDaC is true, then we get // those new connections only. NOTE: get_outgoing_connections // by default will get *all* connections. Deployment::Connections * my_connections = this->get_outgoing_connections ( (entry->int_id_).child_plan_.in (), - !is_ReDAC, + !is_ReDaC, true, // we search *new* plan DomainApplicationManager_Impl::Internal_Connections ACE_ENV_ARG_PARAMETER); @@ -732,7 +740,11 @@ finishLaunch (CORBA::Boolean start, ACE_TRY_CHECK; } - if (is_ReDAC) // We should also remove unnecessary connections + //============================================================= + // Remove Old Connections Logic + //============================================================= + + if (is_ReDaC) // We should also *REMOVE* unnecessary connections { // If this is a brand new child plan, then continue. if ((entry->int_id_).old_child_plan_ == 0) @@ -782,6 +794,7 @@ finishLaunch (CORBA::Boolean start, // Invoke finishLaunch() operation on NodeApplication. if (unnecessary_connections->length () != 0) { + ACE_ASSERT (!CORBA::is_nil (entry->int_id_.node_application_.in ())); entry->int_id_.node_application_->finishLaunch (*unnecessary_connections, start, @@ -789,6 +802,23 @@ finishLaunch (CORBA::Boolean start, ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; } + + //============================================================= + // Remove Old Components Logic + //============================================================= + // Finally we need to remove those to-be-removed components + ::Deployment::Properties_var configProperty; + ACE_NEW (configProperty, + Deployment::Properties); + + ::Deployment::Connections_var retn_connections; + + Deployment::Application_var temp_application = + entry->int_id_.node_application_manager_-> + perform_redeployment (configProperty, + retn_connections.out (), + false, // remove old components only + false);// do not "start" } } @@ -1033,7 +1063,7 @@ get_outgoing_connections_i (const char * instname, Deployment::Connections & retv, bool is_getting_all_connections, bool is_search_new_plan - ACE_ENV_ARG_DECL) + ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((Deployment::StartError)) { CIAO_TRACE("CIAO::DomainApplicationManager_Impl::get_outoing_connections_i"); @@ -1467,13 +1497,15 @@ perform_redeployment ( this->startLaunch (properties.in (), false); - // finishLaunch() will not only establish new connections, but also - // should get rid of those non-existing connections. As we know, in the + // finishLaunch will (1) establish new connections, and (2) + // get rid of those non-existing connections. As we know, in the // node level, the connections are cached within the NodeApplication *and* // Container, then we should modify the implementation of the // <finishLaunch> on the NodeApplication to accomplish this. this->finishLaunch (true, true); // true means start activation also. - // ture means "ReDAC" is desired + // ture means "ReDaC" is desired + + this->start (); } ACE_CATCHANY { diff --git a/TAO/CIAO/DAnCE/NodeApplication/Container_Impl.cpp b/TAO/CIAO/DAnCE/NodeApplication/Container_Impl.cpp index 29d42eea342..93433b65851 100644 --- a/TAO/CIAO/DAnCE/NodeApplication/Container_Impl.cpp +++ b/TAO/CIAO/DAnCE/NodeApplication/Container_Impl.cpp @@ -1,6 +1,7 @@ // $Id$ #include "Container_Impl.h" #include "ciao/CCM_ComponentC.h" // for calling StandardConfigurator interface +#include "ace/Assert.h" #include "orbsvcs/CosNamingC.h" @@ -176,10 +177,13 @@ CIAO::Container_Impl::install ( // Register the component with the naming service ACE_DEBUG ((LM_DEBUG, "Register component with naming service.\n")); - bool result = register_with_ns (naming_context, - this->orb_.in (), - comp.in () - ACE_ENV_ARG_PARAMETER); + bool result = + register_with_ns ( + naming_context, + this->orb_.in (), + Components::CCMObject::_duplicate (comp.in ()) + ACE_ENV_ARG_PARAMETER + ); ACE_TRY_CHECK; if (!result) @@ -437,7 +441,7 @@ CIAO::Container_Impl::remove_components (ACE_ENV_SINGLE_ARG_DECL) // Below method is not used actually. void -CIAO::Container_Impl::remove_component (const char * comp_ins_name +CIAO::Container_Impl::remove_component (const char * str ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, Components::RemoveFailure)) @@ -445,7 +449,7 @@ CIAO::Container_Impl::remove_component (const char * comp_ins_name Components::CCMObject_var comp; Components::CCMHome_ptr home; - ACE_CString str (comp_ins_name); + //ACE_CString str (comp_ins_name); /* Before we do remove component we have to inform the homeservant so * Component::ccm_passivate () diff --git a/TAO/CIAO/DAnCE/NodeApplication/NodeApplication_Impl.cpp b/TAO/CIAO/DAnCE/NodeApplication/NodeApplication_Impl.cpp index 1104e20cd41..bd5eee218e5 100644 --- a/TAO/CIAO/DAnCE/NodeApplication/NodeApplication_Impl.cpp +++ b/TAO/CIAO/DAnCE/NodeApplication/NodeApplication_Impl.cpp @@ -92,9 +92,9 @@ CIAO::NodeApplication_Impl::finishLaunch_i ( for (CORBA::ULong i = 0; i < length; ++i) { ACE_CString name = providedReference[i].instanceName.in (); - Components::CCMObject_var comp; + Component_State_Info comp_state; - if (this->component_objref_map_.find (name, comp) != 0) + if (this->component_state_map_.find (name, comp_state) != 0) { ACE_ERROR ((LM_ERROR, "CIAO (%P|%t) - NodeApplication_Impl.cpp, " @@ -105,6 +105,8 @@ CIAO::NodeApplication_Impl::finishLaunch_i ( ACE_TRY_THROW (Deployment::InvalidConnection ()); } + Components::CCMObject_var comp = comp_state.objref_; + Components::EventConsumerBase_var consumer; // Since we know CCMObject inherits from @@ -355,13 +357,18 @@ CIAO::NodeApplication_Impl::ciao_preactivate (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, Deployment::StartError)) { - Component_Iterator end = this->component_objref_map_.end (); - for (Component_Iterator iter (this->component_objref_map_.begin ()); + Component_Iterator end = this->component_state_map_.end (); + for (Component_Iterator iter (this->component_state_map_.begin ()); iter != end; ++iter) { - ((*iter).int_id_)->ciao_preactivate (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_CHECK; + if (((*iter).int_id_).state_ == NEW_BORN) + { + ((*iter).int_id_).objref_->ciao_preactivate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + } + + ((*iter).int_id_).state_ = PRE_ACTIVE; } } @@ -370,13 +377,18 @@ CIAO::NodeApplication_Impl::start (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, Deployment::StartError)) { - Component_Iterator end = this->component_objref_map_.end (); - for (Component_Iterator iter (this->component_objref_map_.begin ()); + Component_Iterator end = this->component_state_map_.end (); + for (Component_Iterator iter (this->component_state_map_.begin ()); iter != end; ++iter) { - ((*iter).int_id_)->ciao_activate (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_CHECK; + if (((*iter).int_id_).state_ == PRE_ACTIVE) + { + ((*iter).int_id_).objref_->ciao_activate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + } + + ((*iter).int_id_).state_ = ACTIVE; } } @@ -385,13 +397,18 @@ CIAO::NodeApplication_Impl::ciao_postactivate (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, Deployment::StartError)) { - Component_Iterator end = this->component_objref_map_.end (); - for (Component_Iterator iter (this->component_objref_map_.begin ()); + Component_Iterator end = this->component_state_map_.end (); + for (Component_Iterator iter (this->component_state_map_.begin ()); iter != end; ++iter) { - ((*iter).int_id_)->ciao_postactivate (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_CHECK; + if (((*iter).int_id_).state_ == ACTIVE) + { + ((*iter).int_id_).objref_->ciao_postactivate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + ((*iter).int_id_).state_ = POST_ACTIVE; + } } } @@ -400,13 +417,15 @@ CIAO::NodeApplication_Impl::ciao_passivate (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, Deployment::StopError)) { - Component_Iterator end = this->component_objref_map_.end (); - for (Component_Iterator iter (this->component_objref_map_.begin ()); + Component_Iterator end = this->component_state_map_.end (); + for (Component_Iterator iter (this->component_state_map_.begin ()); iter != end; ++iter) { - ((*iter).int_id_)->ciao_passivate (ACE_ENV_SINGLE_ARG_PARAMETER); + ((*iter).int_id_).objref_->ciao_passivate (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK; + + ((*iter).int_id_).state_ = PASSIVE; } } @@ -440,7 +459,7 @@ CIAO::NodeApplication_Impl::install ( // @@(GD): The "create_all_containers" mechanism needs to be refined, so // we should always try to reuse existing containers as much as possible! // We need not only factory pattern, but also finder pattern here as well. - if (CIAO::debug_level () > 9) + if (CIAO::debug_level () > 15) { ACE_DEBUG ((LM_DEBUG, "CIAO (%P|%t) NodeApplication_Impl.cpp -" @@ -457,7 +476,7 @@ CIAO::NodeApplication_Impl::install ( ACE_DEBUG ((LM_DEBUG, "CIAO (%P|%t) NodeApplication_Impl.cpp -" "CIAO::NodeApplication_Impl::install -" - "created all the containers. \n")); + "create_all_containers() called.\n")); } // For each container, invoke <install> operation, this will return @@ -491,11 +510,15 @@ CIAO::NodeApplication_Impl::install ( len < comp_len; ++len) { + Component_State_Info tmp; + + tmp.state_ = NEW_BORN; + tmp.objref_ = + Components::CCMObject::_duplicate (retv[len].component_ref.in ()); + //Since we know the type ahead of time...narrow is omitted here. - if (this->component_objref_map_.bind ( - retv[len].component_instance_name.in(), - Components::CCMObject::_duplicate (retv[len]. - component_ref.in ()))) + if (this->component_state_map_.rebind ( + retv[len].component_instance_name.in(), tmp)) { ACE_DEBUG ((LM_DEBUG, "CIAO (%P|%t) NodeApplication_Impl.cpp -" @@ -542,7 +565,7 @@ CIAO::NodeApplication_Impl::remove_component (const char * inst_name // Remove this component instance from the node application ACE_CString name (inst_name); this->component_container_map_.unbind (name); - this->component_objref_map_.unbind (name); + this->component_state_map_.unbind (name); container_ref->remove_component (inst_name); } @@ -551,7 +574,7 @@ CIAO::NodeApplication_Impl::remove (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { // If we still have components installed, then do nothing - if (this->component_objref_map_.current_size () != 0) + if (this->component_state_map_.current_size () != 0) return; // For each container, invoke <remove> operation to remove home and components. diff --git a/TAO/CIAO/DAnCE/NodeApplication/NodeApplication_Impl.h b/TAO/CIAO/DAnCE/NodeApplication/NodeApplication_Impl.h index dde2a353750..8ca1f415cab 100644 --- a/TAO/CIAO/DAnCE/NodeApplication/NodeApplication_Impl.h +++ b/TAO/CIAO/DAnCE/NodeApplication/NodeApplication_Impl.h @@ -62,6 +62,17 @@ namespace CIAO : public virtual POA_Deployment::NodeApplication { public: + enum Component_State + { + NEW_BORN, PRE_ACTIVE, ACTIVE, POST_ACTIVE, PASSIVE, DEACTIVATED + }; + + typedef struct _component_state_info + { + Components::CCMObject_var objref_; + Component_State state_; + } Component_State_Info; + NodeApplication_Impl (CORBA::ORB_ptr o, PortableServer::POA_ptr p, NodeApp_Configurator &c, @@ -224,14 +235,14 @@ namespace CIAO Component_Container_Map component_container_map_; - /// To store all created Component object. + /// To store all created Component object as well as their state. typedef ACE_Hash_Map_Manager_Ex<ACE_CString, - Components::CCMObject_var, + Component_State_Info, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, ACE_Null_Mutex> CCMComponent_Map; typedef CCMComponent_Map::iterator Component_Iterator; - CCMComponent_Map component_objref_map_; + CCMComponent_Map component_state_map_; /// A Map which stores all the connection cookies typedef ACE_Hash_Map_Manager_Ex<ACE_CString, diff --git a/TAO/CIAO/DAnCE/NodeApplicationManager/NodeApplicationManager_Impl.cpp b/TAO/CIAO/DAnCE/NodeApplicationManager/NodeApplicationManager_Impl.cpp index 02bc4f6ba1f..33e712f19e5 100644 --- a/TAO/CIAO/DAnCE/NodeApplicationManager/NodeApplicationManager_Impl.cpp +++ b/TAO/CIAO/DAnCE/NodeApplicationManager/NodeApplicationManager_Impl.cpp @@ -3,6 +3,7 @@ #include "NodeApplicationManager_Impl.h" #include "ace/Process.h" #include "ace/OS_NS_stdio.h" +#include "ace/Vector_T.h" #include "ciao/Container_Base.h" #include "NodeApplication/NodeApplication_Impl.h" @@ -335,6 +336,7 @@ Deployment::Application_ptr CIAO::NodeApplicationManager_Impl_Base:: perform_redeployment (const Deployment::Properties & configProperty, Deployment::Connections_out providedReference, + CORBA::Boolean add_or_remove, // true means "add" only CORBA::Boolean start ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((::CORBA::SystemException, @@ -363,7 +365,7 @@ perform_redeployment (const Deployment::Properties & configProperty, // // // (1) If this is an brand new NAM, then only new installation is needed. - // (2) Then we could pretty much clone the "startLaunch" implementation. + // (2) Then we could pretty much replicate the "startLaunch" implementation. // This capability is useful to install a set of new components into // some totally new nodes. @@ -379,8 +381,14 @@ perform_redeployment (const Deployment::Properties & configProperty, { if (! CORBA::is_nil (this->nodeapp_.in ())) { - this->add_new_components (); - this->remove_existing_components (); + if (add_or_remove == true) + { + this->add_new_components (); + } + else + { + this->remove_existing_components (); + } // NOTE: We are propogating back "all" the facets/consumers object // references to the DAM, including the previous existing ones. @@ -461,6 +469,10 @@ add_new_components () } } + // If there are no new components to be installed ... + if (tmp_plan.instance.length () == 0) + return; + // package the components NodeImplementationInfoHandler handler (tmp_plan, this->shared_components_); @@ -505,10 +517,6 @@ add_new_components () ("NodeApplicationManager_Impl::startLaunch", error.c_str ())); } - - comp_info[len].component_ref->ciao_preactivate (); - comp_info[len].component_ref->ciao_activate (); - comp_info[len].component_ref->ciao_postactivate (); } } ACE_CATCHANY @@ -530,21 +538,26 @@ remove_existing_components () { ACE_TRY { - const Component_Iterator end (this->component_map_.end ()); + ACE_Vector<ACE_CString> gone_component_list; + for (Component_Iterator iter (this->component_map_.begin ()); - iter != end; - ++iter) + iter != this->component_map_.end (); + ++iter) { - // If this component is not in the new deployment plan, then we - // should remove it ACE_CString comp_name ((*iter).ext_id_.c_str ()); + // If this component is not in the new deployment plan, then we + // should destroy this component and unbind from the map. if (this->is_to_be_removed (comp_name.c_str ())) { ((*iter).int_id_)->ciao_passivate (); this->nodeapp_->remove_component (comp_name.c_str ()); + gone_component_list.push_back (comp_name); } } + + for (size_t i = 0; i < gone_component_list.size (); ++i) + this->component_map_.unbind (gone_component_list[i]); } ACE_CATCHANY { diff --git a/TAO/CIAO/DAnCE/NodeApplicationManager/NodeApplicationManager_Impl.h b/TAO/CIAO/DAnCE/NodeApplicationManager/NodeApplicationManager_Impl.h index 40093064d52..d5dd57d0972 100644 --- a/TAO/CIAO/DAnCE/NodeApplicationManager/NodeApplicationManager_Impl.h +++ b/TAO/CIAO/DAnCE/NodeApplicationManager/NodeApplicationManager_Impl.h @@ -7,6 +7,7 @@ * @file NodeApplicationManager_Impl.h * * @author Tao Lu <lu@dre.vanderbilt.edu> + * @author Gan Deng <dengg@dre.vanderbilt.edu> * * This file contains implementation for the servant of * Deployment::NodeApplicationManager. @@ -76,6 +77,7 @@ namespace CIAO virtual Deployment::Application_ptr perform_redeployment (const Deployment::Properties & configProperty, Deployment::Connections_out providedReference, + CORBA::Boolean add_or_remove, CORBA::Boolean start ACE_ENV_ARG_DECL_WITH_DEFAULTS) ACE_THROW_SPEC ((::CORBA::SystemException, @@ -164,6 +166,8 @@ namespace CIAO ::Deployment::PlanError, ::Components::RemoveFailure)); + /// Determine whether a component is absent in the new_plan + /// Return true if absent virtual bool is_to_be_removed (const char * name); diff --git a/TAO/CIAO/ciao/Deployment.idl b/TAO/CIAO/ciao/Deployment.idl index 089bc145c9d..7c303d61a66 100644 --- a/TAO/CIAO/ciao/Deployment.idl +++ b/TAO/CIAO/ciao/Deployment.idl @@ -154,8 +154,10 @@ module Deployment { /// and reconfiguration /// This operation could handle dynamic redeployment for /// a node-level deployment plan within a node + /// @para add_or_remove If true, we add new components only, vice vesa. Application perform_redeployment (in Properties configProperty, out Connections providedReference, + in boolean add_or_remove, in boolean start) raises (PlanError, InstallationFailure, |