From 8812e864cedbc91da1fbffd0c4575d523683cc59 Mon Sep 17 00:00:00 2001 From: dengg Date: Mon, 20 Dec 2004 23:48:39 +0000 Subject: *** empty log message *** --- TAO/CIAO/DAnCE/ciao/CCM_Core.mpc | 1 + TAO/CIAO/DAnCE/ciao/Deployment_Core.idl | 75 ++++--- TAO/CIAO/DAnCE/ciao/NodeApplication_Impl.cpp | 323 +-------------------------- TAO/CIAO/DAnCE/ciao/NodeApplication_Impl.h | 113 +--------- TAO/CIAO/DAnCE/ciao/NodeApplication_Impl.inl | 3 +- 5 files changed, 52 insertions(+), 463 deletions(-) diff --git a/TAO/CIAO/DAnCE/ciao/CCM_Core.mpc b/TAO/CIAO/DAnCE/ciao/CCM_Core.mpc index 68fa3aa93fc..dae88118ae6 100644 --- a/TAO/CIAO/DAnCE/ciao/CCM_Core.mpc +++ b/TAO/CIAO/DAnCE/ciao/CCM_Core.mpc @@ -131,6 +131,7 @@ project (CIAO_DnC_Server) : orbsvcslib, portableserver, valuetype, ifr_client, u Source_Files { Container_Base.cpp + Container_Impl.cpp NodeApplication_Impl.cpp Context_Impl_Base.cpp Home_Servant_Impl_Base.cpp diff --git a/TAO/CIAO/DAnCE/ciao/Deployment_Core.idl b/TAO/CIAO/DAnCE/ciao/Deployment_Core.idl index 6dac65c2fda..f39c7390b2a 100644 --- a/TAO/CIAO/DAnCE/ciao/Deployment_Core.idl +++ b/TAO/CIAO/DAnCE/ciao/Deployment_Core.idl @@ -107,6 +107,47 @@ module Deployment // This NodeApplication contains the semantic from both Container and // the new DnC NodeApplication --Tao + + // I separated the Container and NodeApplication interfaces for the + // RT-CCM integration purpose. + + interface NodeApplication; // Forward decl. + typedef sequence NodeApplications; + + interface Container + { + readonly attribute ::Deployment::Properties properties; + + NodeApplication get_node_application (); + + //@@ The properties will contain + //1 component instance name as the key. + //2 dll/so name of the exec + //3 entry point of the exec + //4 dll/so name of the svnt + //5 entry point of the svnt + //6 Poosible other configuration for container/home/component + //Note:: We have to decide later how container/home/component could be configured. + // These properties could be passed in here or at higher level + // according to the plan(@ NodeApplicationManager/NodeApplication?) + // + ::Components::CCMHome install_home (in ImplementationInfo impl_info) + raises (UnknownImplId, + ImplEntryPointNotFound, + InstallationFailure, + ::Components::InvalidConfiguration); + + void remove_home (in string comp_ins_name) + raises (::Components::RemoveFailure); + + ::Components::CCMHomes get_homes (); + + void remove () + raises (::Components::RemoveFailure); + }; + typedef sequence Containers; + + interface NodeApplication : Application { readonly attribute ::Deployment::Properties properties; @@ -145,38 +186,16 @@ module Deployment //@@ We know that Dployment::NodeApplicationManager will be returned, // however to avoid the size of the shared object of CIAO_Server. // we return an Object. - Object get_node_application_manager (); - - //@@ The properties will contain - //1 component instance name as the key. - //2 dll/so name of the exec - //3 entry point of the exec - //4 dll/so name of the svnt - //5 entry point of the svnt - //6 Poosible other configuration for container/home/component - //Note:: We have to decide later how container/home/component could be configured. - // These properties could be passed in here or at higher level - // according to the plan(@ NodeApplicationManager/NodeApplication?) - // - //The reason that I want to expose these operation in IDL (can be called remotely) - //is 1. for easy testing. - // 2. Might comes in handy in the future. - // --Tao - ::Components::CCMHome install_home (in ImplementationInfo impl_info) - raises (UnknownImplId, - ImplEntryPointNotFound, - InstallationFailure, - ::Components::InvalidConfiguration); + Object get_node_application_manager (); - void remove_home (in string comp_ins_name) - raises (::Components::RemoveFailure); - - ::Components::CCMHomes get_homes (); + Container create_container (in ::Components::ConfigValues config) + raises (::Components::CreateFailure, + ::Components::InvalidConfiguration); - void remove () + void remove_container (in Container cref) raises (::Components::RemoveFailure); - + Containers get_containers (); }; }; diff --git a/TAO/CIAO/DAnCE/ciao/NodeApplication_Impl.cpp b/TAO/CIAO/DAnCE/ciao/NodeApplication_Impl.cpp index 5c8c4fcf553..a8343d1631c 100644 --- a/TAO/CIAO/DAnCE/ciao/NodeApplication_Impl.cpp +++ b/TAO/CIAO/DAnCE/ciao/NodeApplication_Impl.cpp @@ -8,7 +8,7 @@ CIAO::NodeApplication_Impl::~NodeApplication_Impl (void) { - delete this->container_; + //@@ Unbind the container map } void @@ -142,265 +142,11 @@ CIAO::NodeApplication_Impl::start_i (Funct_Ptr functor } } -Deployment::Properties * -CIAO::NodeApplication_Impl::properties (ACE_ENV_SINGLE_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException)) -{ - Deployment::Properties * tmp; - - ACE_NEW_THROW_EX (tmp, - Deployment::Properties (this->properties_), - CORBA::NO_MEMORY ()); - ACE_CHECK_RETURN (0); - - return tmp; -} - -Deployment::ComponentInfos * -CIAO::NodeApplication_Impl::install ( - const ::Deployment::ImplementationInfos & impl_infos - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, - Deployment::UnknownImplId, - Deployment::ImplEntryPointNotFound, - Deployment::InstallationFailure, - Components::InvalidConfiguration)) -{ - Deployment::ComponentInfos_var retv; - ACE_TRY - { - Deployment::ComponentInfos * tmp; - ACE_NEW_THROW_EX (tmp, - Deployment::ComponentInfos, - CORBA::NO_MEMORY ()); - ACE_TRY_CHECK; - - retv = tmp; - - const CORBA::ULong len = impl_infos.length (); - - retv->length (len); - - // @@ (OO) There is no need to declare these variables outside of - // the loop. Some folks doing so is an optimization but - // doing so generally defeats some compiler optimizations. - // Please move these declaration within the loop. - Components::CCMHome_var home; - Components::CCMObject_var comp; - - for (CORBA::ULong i = 0; i < len; ++i) - { - home = this->install_home (impl_infos[i] - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - Components::KeylessCCMHome_var kh = - Components::KeylessCCMHome::_narrow (home.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (CORBA::is_nil (kh.in ())) - ACE_THROW_RETURN (Deployment::InstallationFailure (), 0); - - // @@ Note, here we are missing the CreateFailure. - // Sometime I will come back to add exception rethrow. - comp = kh->create_component (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (this->component_map_.bind (impl_infos[i].component_instance_name.in (), - Components::CCMObject::_duplicate (comp.in ()))) - ACE_TRY_THROW (Deployment::InstallationFailure ()); - - // Set the return value. - (*retv)[i].component_instance_name - = impl_infos[i].component_instance_name.in (); - - (*retv)[i].component_ref = Components::CCMObject::_duplicate (comp.in ()); - - // Deal with Component instance related Properties. - // Now I am only concerning about the COMPOENTIOR and here is only - // the hardcoded version of the configuration. Hopefully we will - // reach an agreement after the RTWS about how the configuration - // should be done. - - const CORBA::ULong clen = impl_infos[i].component_config.length (); - for (CORBA::ULong prop_len = 0; prop_len < clen; ++prop_len) - { - if (ACE_OS::strcmp (impl_infos[i].component_config[prop_len].name.in (), - "ComponentIOR") == 0) - { - if (CIAO::debug_level () > 1) - ACE_DEBUG ((LM_DEBUG, "Found property to write the IOR.\n")); - const char * path; - impl_infos[i].component_config[prop_len].value >>= path; - - CORBA::String_var ior = - this->orb_->object_to_string (comp.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (write_IOR (path, ior.in ()) != 0) - { - if (CIAO::debug_level () > 1) - ACE_DEBUG ((LM_DEBUG, "Failed to write the IOR.\n")); - - ACE_TRY_THROW (CORBA::INTERNAL ()); - } - - } - } - } - } - ACE_CATCHANY - { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, - "CIAO_NodeApplication::install error\t\n"); - ACE_RE_THROW; - } - ACE_ENDTRY; - ACE_CHECK_RETURN (0); - - return retv._retn (); -} - -// @@ (OO) Method definitions should never use "_WITH_DEFAULTS" -// versions of emulated exception parameters. Please remove -// the "_WITH_DEFAULTS" -Components::CCMHome_ptr -CIAO::NodeApplication_Impl::install_home ( - const ::Deployment::ImplementationInfo & impl_info - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, - Deployment::UnknownImplId, - Deployment::ImplEntryPointNotFound, - Deployment::InstallationFailure, - Components::InvalidConfiguration)) -{ - Components::CCMHome_var newhome = - this->container_->ciao_install_home - (impl_info.executor_dll.in (), - impl_info.executor_entrypt.in (), - impl_info.servant_dll.in (), - impl_info.servant_entrypt.in () - ACE_ENV_ARG_PARAMETER); - - ACE_CHECK_RETURN (Components::CCMHome::_nil ()); - // We don't have to do _narrow since the generated code makes sure of - // the object type for us - - // Bind the home in the map. - if (this->home_map_.bind (impl_info.component_instance_name.in (), - Components::CCMHome::_duplicate (newhome.in ()))) - ACE_THROW_RETURN (Deployment::InstallationFailure (), - Components::CCMHome::_nil ()); - - //Note: If the return value will be discarded, it must be kept in a var or - // release () will have to be called explicitly. - return newhome._retn (); -} - -void -CIAO::NodeApplication_Impl::remove (ACE_ENV_SINGLE_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, - Components::RemoveFailure)) -{ - // Remove all components first. - remove_components (); - - ACE_CHECK; - - // Even if above op failed we should still remove homes. - const Home_Iterator end (this->home_map_.end ()); - for (Home_Iterator iter (this->home_map_.begin ()); - iter != end; - ++iter) - { - this->container_->ciao_uninstall_home ( (*iter).int_id_ - ACE_ENV_ARG_PARAMETER); - ACE_CHECK; - - CORBA::release ( (*iter).int_id_); - } - - this->home_map_.unbind_all (); - - if (CIAO::debug_level () > 1) - ACE_DEBUG ((LM_DEBUG, "Shutting down this NodeApplication!\n")); - - this->orb_->shutdown (0 ACE_ENV_ARG_PARAMETER); -} - -void -CIAO::NodeApplication_Impl::remove_home (const char * comp_ins_name - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, - Components::RemoveFailure)) -{ - Components::CCMHome_ptr home; - ACE_CString str (comp_ins_name); - - if (this->home_map_.find (str, home) != 0) - ACE_THROW (CORBA::BAD_PARAM ()); - - // We should remove all components created by this home as well. - // This is not implemented yet. - - this->container_->ciao_uninstall_home (home - ACE_ENV_ARG_PARAMETER); - ACE_CHECK; - - // If the previous calls failed, what should we do here?? - CORBA::release (home); - - // @@ Still need to remove the home if the previous operation fails? - if (this->home_map_.unbind (str) == -1) - ACE_THROW (::Components::RemoveFailure ()); -} - -Components::CCMHomes * -CIAO::NodeApplication_Impl::get_homes (ACE_ENV_SINGLE_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException)) -{ - Components::CCMHomes * tmp; - ACE_NEW_THROW_EX (tmp, - Components::CCMHomes (), - CORBA::NO_MEMORY ()); - ACE_CHECK_RETURN (0); - - Components::CCMHomes_var retval (tmp); - - // @@ (OO) Please declare len as "const". - CORBA::ULong len = this->home_map_.current_size (); - retval->length (len); - - - CORBA::ULong i = 0; - const Home_Iterator end = this->home_map_.end (); - for (Home_Iterator iter (this->home_map_.begin ()); - iter != end; - ++iter, ++i) - { - retval[i] = Components::CCMHome::_duplicate ( (*iter).int_id_); - } - - return retval._retn (); -} - CORBA::Long CIAO::NodeApplication_Impl::init (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { - ACE_NEW_THROW_EX (this->container_, - CIAO::Session_Container (this->orb_.in (), - 0, - 0), - CORBA::NO_MEMORY ()); - ACE_CHECK_RETURN (-1); - - return this->container_->init (0, - 0 - ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (-1); + //@@ What to do here? return 0; } @@ -420,71 +166,6 @@ CIAO::NodeApplication_Impl::_default_POA (void) return PortableServer::POA::_duplicate (this->poa_.in ()); } -void -CIAO::NodeApplication_Impl::remove_components (ACE_ENV_SINGLE_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, - Components::RemoveFailure)) -{ - //Remove all the components in the NodeApplication/Container - // Release all component servant object. - const Component_Iterator end (this->component_map_.end ()); - for (Component_Iterator iter (this->component_map_.begin ()); - iter != end; - ++iter) - { - Components::CCMHome_ptr home; - if (this->home_map_.find ( (*iter).ext_id_, home) != 0) - ACE_THROW (CORBA::BAD_PARAM ()); - - // This will call ccm_passivate on the component executor. - home->remove_component ((*iter).int_id_); - ACE_CHECK; - - CORBA::release ((*iter).int_id_); - } - - this->component_map_.unbind_all (); - // To this point the servant should have been destroyed. However, - // if someone is still making calls on the servant, terrible thing - // will happen. -} - -void -CIAO::NodeApplication_Impl::remove_component (const char * comp_ins_name - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, - Components::RemoveFailure)) -{ - Components::CCMObject_ptr comp; - Components::CCMHome_ptr home; - - ACE_CString str (comp_ins_name); - - /* Before we do remove component we have to inform the homeservant so - * Component::ccm_passivate () - * constainer::ninstall_component () ->deactivate_object () will be called. - * - * ccm_remove will be called when the poa destroys the servant. - */ - - if (this->component_map_.find (str, comp) != 0) - ACE_THROW (CORBA::BAD_PARAM ()); - - if (this->home_map_.find (str, home) != 0) - ACE_THROW (CORBA::BAD_PARAM ()); - - // This will call ccm_passivate on the component executor. - home->remove_component (comp); - ACE_CHECK; - - // If the previous calls failed, what should we do here?? - CORBA::release (comp); - - // @@ Still need to remove the home if the previous operation fails? - if (this->component_map_.unbind (str) == -1) - ACE_THROW (::Components::RemoveFailure ()); -} - // The code below is obsolete now. However I want to keep it arround as a // start point for configurations. /* diff --git a/TAO/CIAO/DAnCE/ciao/NodeApplication_Impl.h b/TAO/CIAO/DAnCE/ciao/NodeApplication_Impl.h index 64e497f2fdb..a426f147f59 100644 --- a/TAO/CIAO/DAnCE/ciao/NodeApplication_Impl.h +++ b/TAO/CIAO/DAnCE/ciao/NodeApplication_Impl.h @@ -7,6 +7,7 @@ * the NodeApplication interface. * * @auther Tao Lu + * @author Gan Deng *========================================================*/ #ifndef NODEAPPLICATION_IMPL_H @@ -40,11 +41,6 @@ using CIAO::Utility::write_IOR; * complexity of the framework by omitting the componentserver layer. * * @@TODO add configuration capabilities. Threading is one of them. - * - * @@Assumptions: - * 1. There is only 1 container for all components/homes associating - * with 1 NodeApplication - * 2. Now the implementation is not thread safe. **/ namespace CIAO @@ -99,57 +95,6 @@ namespace CIAO virtual CORBA::Long init (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) ACE_THROW_SPEC ((CORBA::SystemException)); - // Start install homes and components. - virtual ::Deployment::ComponentInfos * - install (const ::Deployment::ImplementationInfos & impl_infos - ACE_ENV_ARG_DECL_WITH_DEFAULTS) - ACE_THROW_SPEC ((CORBA::SystemException, - ::Deployment::UnknownImplId, - ::Deployment::ImplEntryPointNotFound, - ::Deployment::InstallationFailure, - ::Components::InvalidConfiguration)); - - // Access the readonly attribute. - virtual ::Deployment::Properties * - properties (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) - ACE_THROW_SPEC ((CORBA::SystemException)); - - virtual ::Components::CCMHome_ptr - install_home (const ::Deployment::ImplementationInfo & impl_info - ACE_ENV_ARG_DECL_WITH_DEFAULTS) - ACE_THROW_SPEC ((CORBA::SystemException, - Deployment::UnknownImplId, - Deployment::ImplEntryPointNotFound, - Deployment::InstallationFailure, - Components::InvalidConfiguration)); - - /** - * @@Note: I don't know how to remove a home right now. - * I assume that user will only call remove instead. - * This is true at least for DnC run time. - * - * Right now, in this implementation I assumpe that there will be - * same number of homes as the components even if the components - * are of the same type. I don't think that we have the modeling - * side support of this either. So bear me if you think I avoid - * the real thinking for easiness. - */ - virtual void remove_home (const char * comp_ins_name - ACE_ENV_ARG_DECL_WITH_DEFAULTS) - ACE_THROW_SPEC ((CORBA::SystemException, - Components::RemoveFailure)); - - // Remove everything inside including all components and homes. - // User must be sure that no connection is active before calling this!! - virtual void remove (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) - ACE_THROW_SPEC ((CORBA::SystemException, - Components::RemoveFailure)); - - // Return all homes. - virtual ::Components::CCMHomes * - get_homes (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) - ACE_THROW_SPEC ((CORBA::SystemException)); - /*------------- CIAO specific helper functions (C++)--------- * *-----------------------------------------------------------*/ @@ -166,23 +111,6 @@ namespace CIAO protected: - // @@ (OO) Methods internal to the class, e.g. protected and not - // defined in IDL should not be using default arguments. - // Please drop the "_WITH_DEFAULTS" in all of the below - // protected methods. - - // This is a helper method to clean up components - // should only be called when we are sure that there is no - // active connection on this component. - virtual void remove_components (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) - ACE_THROW_SPEC ((CORBA::SystemException, - Components::RemoveFailure)); - - virtual void remove_component (const char * comp_ins_name - ACE_ENV_ARG_DECL_WITH_DEFAULTS) - ACE_THROW_SPEC ((CORBA::SystemException, - Components::RemoveFailure)); - // This function is a helper for start call. Bala's // Idea of adding those pre/post activate calls doesn't work // with the new sepc. @@ -195,53 +123,14 @@ namespace CIAO ACE_THROW_SPEC ((CORBA::SystemException, Deployment::StartError)); - // To store all created CCMHome object - typedef ACE_Hash_Map_Manager_Ex, - ACE_Equal_To, - ACE_Null_Mutex> CCMHome_Map; - typedef CCMHome_Map::iterator Home_Iterator; - CCMHome_Map home_map_; - - // To sotre all created Component object. - typedef ACE_Hash_Map_Manager_Ex, - ACE_Equal_To, - ACE_Null_Mutex> CCMComponent_Map; - typedef CCMComponent_Map::iterator Component_Iterator; - CCMComponent_Map component_map_; - // Keep a pointer to the managing ORB serving this servant. CORBA::ORB_var orb_; // Keep a pointer to the managing POA. PortableServer::POA_var poa_; - // Internal container implementation. - CIAO::Container *container_; - - // Cached properties - Deployment::Properties properties_; - // And a reference to the NodeApplicationManager that created us. ::CORBA::Object_var node_app_manager_; - - // Synchronize access to the object set. - // This will be needed in the case when component/home run in different thread - // TAO_SYNCH_MUTEX lock_; - - //@@ As I have stated in the idl we are not going to use properties for now. - // parse The Properties - /*void parse_config_values (const ::Deployment::Properties & properties, - struct home_installation_info &component_install_info - ACE_ENV_ARG_DECL_WITH_DEFAULTS) - ACE_THROW_SPEC ((CORBA::SystemException, - Deployment::UnknownImplId, - Deployment::ImplEntryPointNotFound, - Components::InvalidConfiguration)); - */ }; } diff --git a/TAO/CIAO/DAnCE/ciao/NodeApplication_Impl.inl b/TAO/CIAO/DAnCE/ciao/NodeApplication_Impl.inl index dd541db9b70..ba573d98b52 100644 --- a/TAO/CIAO/DAnCE/ciao/NodeApplication_Impl.inl +++ b/TAO/CIAO/DAnCE/ciao/NodeApplication_Impl.inl @@ -7,8 +7,7 @@ NodeApplication_Impl (CORBA::ORB_ptr o, PortableServer::POA_ptr p) : orb_ (CORBA::ORB::_duplicate (o)), - poa_ (PortableServer::POA::_duplicate (p)), - container_ (0) + poa_ (PortableServer::POA::_duplicate (p)) // @@ (OO) The default size for an ACE_Hash_Map_Mapanger is quiet // large. The maximum size of an ACE_Hash_Map_Manager is -- cgit v1.2.1