diff options
author | nanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2003-08-01 18:55:15 +0000 |
---|---|---|
committer | nanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2003-08-01 18:55:15 +0000 |
commit | fdb23b266f7b85386ea955d8a844c7b911a8e7a3 (patch) | |
tree | 9dc46af75dbc851189f1c63440ea117fef8c5846 | |
parent | 2e31846b7060a81bff37df0c345728f9cf899169 (diff) | |
download | ATCD-fdb23b266f7b85386ea955d8a844c7b911a8e7a3.tar.gz |
*** empty log message ***
-rw-r--r-- | TAO/CIAO/tools/RTComponentServer/ChangeLog | 9 | ||||
-rw-r--r-- | TAO/CIAO/tools/RTComponentServer/RTComponentServer.mpc | 6 | ||||
-rw-r--r-- | TAO/CIAO/tools/RTComponentServer/RTConfig_Manager.cpp | 231 | ||||
-rw-r--r-- | TAO/CIAO/tools/RTComponentServer/RTConfig_Manager.h | 151 | ||||
-rw-r--r-- | TAO/CIAO/tools/RTComponentServer/RTConfig_Manager.inl | 28 | ||||
-rw-r--r-- | TAO/CIAO/tools/RTComponentServer/RTConfiguration.idl | 93 |
6 files changed, 518 insertions, 0 deletions
diff --git a/TAO/CIAO/tools/RTComponentServer/ChangeLog b/TAO/CIAO/tools/RTComponentServer/ChangeLog index 7a1dd9235d3..12033c115c0 100644 --- a/TAO/CIAO/tools/RTComponentServer/ChangeLog +++ b/TAO/CIAO/tools/RTComponentServer/ChangeLog @@ -1,3 +1,12 @@ +Fri Aug 01 13:50:34 2003 Nanbor Wang <nanbor@cs.wustl.edu> + + * tools/RTComponentServer/RTComponentServer.mpc: + * tools/RTComponentServer/RTConfig_Manager.cpp: + * tools/RTComponentServer/RTConfig_Manager.h: + * tools/RTComponentServer/RTConfig_Manager.inl: + * tools/RTComponentServer/RTConfiguration.idl: Added code for + managing named collection of RTCORBA related policies. + Sun Jul 06 21:37:22 2003 Nanbor Wang <nanbor@cs.wustl.edu> * tools/RTComponentServer/ComponentServer_Task.cpp (svc): Changed diff --git a/TAO/CIAO/tools/RTComponentServer/RTComponentServer.mpc b/TAO/CIAO/tools/RTComponentServer/RTComponentServer.mpc index 3f93756a9d2..333506ec65d 100644 --- a/TAO/CIAO/tools/RTComponentServer/RTComponentServer.mpc +++ b/TAO/CIAO/tools/RTComponentServer/RTComponentServer.mpc @@ -4,9 +4,15 @@ project(RTComponentServer): ciao_server,rt_server { exename = RTComponentServer + IDL_Files { + RTConfiguration.idl + } + Source_Files { + RTConfigurationC.cpp ComponentServer_Task.cpp RTComponentServer.cpp + RTConfig_Manager.cpp } } diff --git a/TAO/CIAO/tools/RTComponentServer/RTConfig_Manager.cpp b/TAO/CIAO/tools/RTComponentServer/RTConfig_Manager.cpp new file mode 100644 index 00000000000..ba898238ef2 --- /dev/null +++ b/TAO/CIAO/tools/RTComponentServer/RTConfig_Manager.cpp @@ -0,0 +1,231 @@ +// $Id$ + +#include "RTConfig_Manager.h" + +#if !defined (__ACE_INLINE__) +# include "RTConfig_Manager.inl" +#endif /* __ACE_INLINE__ */ + +void +CIAO::RTResource_Config_Manager::init +(const CIAO::RTConfiguration::RTORB_Resources_Info &info + ACE_ENV_ARG_DECL) + // @@ THROW SPEC HERE? +{ + CORBA::ULong i; + + // Creating and binding name with RT Threadpool + for (i = 0; i < info.tp_configs.length (); ++i) + { + RTCORBA::ThreadpoolId thr_id = + this->rtorb_->create_threadpool + (info.tp_configs[i].stacksize, + info.tp_configs[i].static_threads, + info.tp_configs[i].dynamic_threads, + info.tp_configs[i].default_priority, + info.tp_configs[i].allow_request_buffering, + info.tp_configs[i].max_buffered_requests, + info.tp_configs[i].max_request_buffer_size + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; // Simply pass back the exception here + // for now. We need to have a better way + // to handle execption here. + if (this->threadpool_map_.bind (info.tp_configs[i].name.in (), + thr_id) != 0) + { + ACE_DEBUG ((LM_DEBUG, "Error binding thread pool name: %s to map when initializing RTComponentServer resources.\n", info.tp_configs[i].name.in ())); + ACE_THROW (CORBA::INTERNAL ()); + } + } + + for (i = 0; i < info.tpl_configs.length (); ++i) + { + RTCORBA::ThreadpoolId thr_id = + this->rtorb_->create_threadpool_with_lanes + (info.tpl_configs[i].stacksize, + info.tpl_configs[i].lanes, + info.tpl_configs[i].allow_borrowing, + info.tpl_configs[i].allow_request_buffering, + info.tpl_configs[i].max_buffered_requests, + info.tpl_configs[i].max_request_buffer_size + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; // Simply pass back the exception here + // for now. We need to have a better way + // to handle execption here. + + if (this->threadpool_map_.bind (info.tpl_configs[i].name.in (), + thr_id) != 0) + { + ACE_DEBUG ((LM_DEBUG, "Error binding thread pool name: %s to map when initializing RTComponentServer resources.\n", info.tpl_configs[i].name.in ())); + ACE_THROW (CORBA::INTERNAL ()); + } + } +} + +void +CIAO::RTResource_Config_Manager::fini (ACE_ENV_SINGLE_ARG_DECL) + // @@ THROW SPEC? +{ + TP_MAP::ITERATOR iter = this->threadpool_map_.begin (); + TP_MAP::ITERATOR end = this->threadpool_map_.end (); + + for (; iter != end; ++iter) + { + this->rtorb_->destroy_threadpool ((*iter).int_id_ + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } + +} + +RTCORBA::ThreadpoolId +CIAO::RTResource_Config_Manager::find_threadpool_by_name (const char *name + ACE_ENV_ARG_DECL) + // @@ THROW SPEC? +{ + if (name == 0) + { + ACE_DEBUG ((LM_DEBUG, + "Invalid name string found in \"find_threadpool_by_name\"\n")); + ACE_THROW_RETURN (CORBA::INTERNAL (), 0); + } + + + RTCORBA::ThreadpoolId ret_id; // return id + + if (this->threadpool_map_.find (name, ret_id) != 0) + { + ACE_DEBUG ((LM_DEBUG, + "Unable to find a threadpool named %s\n", + name)); + ACE_THROW_RETURN (CORBA::INTERNAL (), 0); + } + + return ret_id; +} + +/* + +RTCORBA::PriorityBands * +CIAO::RTResource_Config_Manager::find_priority_bands_by_name (const char *name + ACE_ENV_ARG_DECL) + // @@ THROW SPEC? +{ +} +*/ + +void +CIAO::RTPolicy_Set_Manager::init (const CIAO::RTConfiguration::Policy_Sets &sets + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + for (CORBA::ULong i = 0; i < sets.length (); ++i) + { + CORBA::ULong np = sets[i].configs.length (); + if (np == 0) + continue; + + CORBA::PolicyList_var policy_list = new CORBA::PolicyList (np); + policy_list->length (np); + + // Create a list of policies + for (CORBA::ULong pc = 0; pc < np; ++pc) + { + policy_list[pc] = this->create_single_policy (sets[i].configs[pc] + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } + + // Bind the policy list to the name. The bind operation should + // surrender the ownership of the newly created PolicyList + // sequence to the map. + if (this->policy_map_.bind (sets[i].name.in (), + policy_list) != 0) + { + ACE_DEBUG ((LM_DEBUG, + "Error binding Policy_Set with name: %s\n", + sets[i].name.in ())); + ACE_THROW (CORBA::INTERNAL ()); + } + } +} + +void +CIAO::RTPolicy_Set_Manager::fini (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // We are keeping the PolicyList in var variables in the map. + // There's no need to release them explicitly. +} + +CORBA::PolicyList * +CIAO::RTPolicy_Set_Manager::find_policies_by_name (const char *name + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + if (name == 0) + { + ACE_DEBUG ((LM_DEBUG, + "Invalid name string found in \"find_policies_by_name\"\n")); + ACE_THROW_RETURN (CORBA::INTERNAL (), 0); + } + + + POLICY_MAP::ENTRY *entry; + + if (this->policy_map_.find (name, entry) != 0) + { + ACE_DEBUG ((LM_DEBUG, + "Unable to find a PolicyList named %s\n", + name)); + ACE_THROW_RETURN (CORBA::INTERNAL (), 0); + } + + // duplicate the sequence PolicyList. + CORBA::PolicyList_var retv = new CORBA::PolicyList (entry->int_id_); + return retv._retn (); +} + +CORBA::Policy_ptr +CIAO::RTPolicy_Set_Manager::create_single_policy +(const CIAO::RTConfiguration::Policy_Config &policy_config + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + CORBA::Policy_var retv; + + switch (policy_config.type) + { + case RTCORBA::PRIORITY_MODEL_POLICY_TYPE: + CIAO::RTConfiguration::Priority_Model_Config *tmp; + + if (policy_config.configuration >>= t CORBA::PolicyList::_duplicate (entry->int_id_.in ()); CORBA::PolicyList::_duplicate (entry->int_id_.in ());mp) + { + retv = this->rtorb_->create_priority_model_policy (tmp->model, + tmp->default_priority + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + } + else + { + ACE_DEBUG ((LM_DEBUG, + "Error extracting PriorityModelPolicy configuration\n")); + ACE_THROW_RETURN (CORBA::INTERNAL (), 0); + } + break; + + case RTCORBA::THREADPOOL_POLICY_TYPE: + retv = this->orb_->create_policy (RTCORBA::THREADPOOL_POLICY_TYPE, + policy_config.configuration + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + break; + + default: + ACE_DEBUG ((LM_DEBUG, + "Invalid policy type - RTPolicy_Set_Manager::create_single_policy\n")); + ACE_THROW_RETURN (CORBA::INTERNAL (), 0); + } + + return retv._retn (); +} diff --git a/TAO/CIAO/tools/RTComponentServer/RTConfig_Manager.h b/TAO/CIAO/tools/RTComponentServer/RTConfig_Manager.h new file mode 100644 index 00000000000..9bac65c82ad --- /dev/null +++ b/TAO/CIAO/tools/RTComponentServer/RTConfig_Manager.h @@ -0,0 +1,151 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file RTConfig_Manager.h + * + * $Id$ + * + * This file contains classes that manage name to configuration + * mapping info in a RTComponentServer. + * + * @author Nanbor Wang <nanbor@cs.wustl.edu> + */ +//============================================================================= + + +#ifndef CIAO_RTCONFIG_MANAGER_H +#define CIAO_RTCONFIG_MANAGER_H +#include "ace/pre.h" + +#include "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "RTConfigurationC.h" + +namespace CIAO +{ + /** + * @brief RTResource_Config_Manager maintains a collection of + * RTCORBA related resources. + * + * This class is responsible to create and manage a list of RTCORBA + * related resources that are global to an RT ComponentServer. The + * information required to create and configure these resources are + * passed in via the @a info argument in the @c init method. These + * resources are identified by names. This class is used by the + * RTPolicy_Set_Manager for associating these resources with related + * RTPolicies. These resources are destoryed along with this class. + * + * Currently, the only resources supported (and managed) by this + * class are Threadpool and Threadpool_with_Lanes. + */ + class RTResource_Config_Manager + { + public: + RTResource_Config_Manager (RTCORBA::RTORB_ptr orb); + ~RTResource_Config_Manager (); + + /// Initializing the RTResource_Config_Manager + void init (const CIAO::RTConfiguration::RTORB_Resources_Info &info + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + /// Finalizing the RTResource_Config_Manager and the resources it + /// manages. + void fini (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + /// Query a thread pool by name. + RTCORBA::ThreadpoolId find_threadpool_by_name (const char *name + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + /* + /// Query a priority bands infor by name. + RTCORBA::PriorityBands *find_priority_bands_by_name (const char *name + ACE_ENV_ARG_DECL_WITH_DEFAULTS); + // @@ THROW SPEC? + */ + + private: + // Cached an RTORB reference. + RTCORBA::RTORB_var rtorb_; + + /// Hash_Map stuff. + typedef ACE_Hash_Map_Manager_Ex<ACE_CString, + RTCORBA::ThreadpoolId, + ACE_Hash<ACE_CString>, + ACE_Equal_To<ACE_CString>, + ACE_Null_Mutex> TP_MAP; + + /// Internal TP names to id map. + TP_MAP threadpool_map_; + }; + + /** + * @brief This class creates and maintains named policy sets which + * can be indexed via names. + * + * This class requires to use the RTResource_Config_Manager. + */ + class RTPolicy_Set_Manager + { + public: + RTPolicy_Set_Manager (RTResource_Config_Manager &resource_config, + CORBA::ORB_ptr orb, + RTCORBA::RTORB_ptr rtorb); + ~RTPolicy_Set_Manager (); + + /// Initialize the RTPolicy_Set_Manager and the policies it manages. + void init (const CIAO::RTConfiguration::Policy_Sets &sets + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + /// Finalizing the RTPolicy_Set_Manager and the policies it + /// creates. + void fini (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + /// Query a policy set by name + CORBA::PolicyList *find_policies_by_name (const char *name + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + private: + /// Reference to Resource Manager + RTResource_Config_Manager &resource_manager_; + + /// Cached an ORB reference. + CORBA::ORB_var orb_; + + /// Cached an RTORB reference. + RTCORBA::RTORB_var rtorb_; + + /// create a single policy + CORBA::Policy_ptr create_single_policy + (const CIAO::RTConfiguration::Policy_Config &policy_config + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + /// Hash_Map stuff. + typedef ACE_Hash_Map_Manager_Ex<ACE_CString, + CORBA::PolicyList_var, + ACE_Hash<ACE_CString>, + ACE_Equal_To<ACE_CString>, + ACE_Null_Mutex> POLICY_MAP; + + /// Internal TP names to id map. + POLICY_MAP policy_map_; + }; +} + +#if defined (__ACE_INLINE__) +# include "RTConfig_Manager.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* CIAO_RTCONFIG_MANAGER_H */ diff --git a/TAO/CIAO/tools/RTComponentServer/RTConfig_Manager.inl b/TAO/CIAO/tools/RTComponentServer/RTConfig_Manager.inl new file mode 100644 index 00000000000..f4d84c022e1 --- /dev/null +++ b/TAO/CIAO/tools/RTComponentServer/RTConfig_Manager.inl @@ -0,0 +1,28 @@ +// $Id$ + +ACE_INLINE +CIAO::RTResource_Config_Manager::RTResource_Config_Manager (RTCORBA::RTORB_ptr orb) + : rtorb_ (RTCORBA::RTORB::_duplicate (orb)) +{ +} + +ACE_INLINE +CIAO::RTResource_Config_Manager::~RTResource_Config_Manager () +{ +} + +ACE_INLINE +CIAO::RTPolicy_Set_Manager::RTPolicy_Set_Manager +(CIAO::RTResource_Config_Manager &resource_config, + CORBA::ORB_ptr orb, + RTCORBA::RTORB_ptr rtorb) + : resource_manager_ (resource_config), + orb_ (CORBA::ORB::_duplicate (orb)), + rtorb_ (RTCORBA::RTORB::_duplicate (rtorb)) + +{ +} + +CIAO::RTPolicy_Set_Manager::~RTPolicy_Set_Manager () +{ +} diff --git a/TAO/CIAO/tools/RTComponentServer/RTConfiguration.idl b/TAO/CIAO/tools/RTComponentServer/RTConfiguration.idl new file mode 100644 index 00000000000..e13df43f294 --- /dev/null +++ b/TAO/CIAO/tools/RTComponentServer/RTConfiguration.idl @@ -0,0 +1,93 @@ +// $Id$ + +/** + * @file RTConfiguration.idl + * + * @brief Define the data structure for configuraing RTComponentServer. + * + * Define the data structure for configuraing RTComponentServer. + */ + +#include "RTCORBA/RTCORBA.pidl" + +module CIAO +{ + module RTConfiguration + { + struct ThreadPool_Configuration + { + string name; + unsigned long stacksize; + unsigned long static_threads; + unsigned long dynamic_threads; + RTCORBA::Priority default_priority; + boolean allow_request_buffering; + unsigned long max_buffered_requests; + unsigned long max_request_buffer_size; + }; + + struct ThreadPoolLanes_Configuration + { + string name; + unsigned long stacksize; + RTCORBA::ThreadpoolLanes lanes; + boolean allow_borrowing; + boolean allow_request_buffering; + unsigned long max_buffered_requests; + unsigned long max_request_buffer_size; + }; + + typedef sequence<ThreadPool_Configuration> ThreadPool_Configurations; + typedef sequence<ThreadPoolLanes_Configuration> ThreadPoolLanes_Configurations; + + struct PriorityBands_Configuration + { + string name; + + RTCORBA::PriorityBands bands; + }; + typedef sequence<PriorityBands_Configuration> PriorityBands_Configurations; + + /** + * @brief RT-related resources global to a component server. + * + * These are Real-time related resources that are global within an + * RT component server. They can be shared by several containers. + */ + struct RTORB_Resources_Info + { + ThreadPool_Configurations tp_configs; + + ThreadPoolLanes_Configurations tpl_configs; + + PriorityBands_Configurations pb_configs; + }; + + // --------------------------------------------------------------- + // PolicySet + + struct Priority_Model_Config + { + RTCORBA::PriorityModel model; + RTCORBA::Priority default_priority; + }; + + struct Policy_Config + { + CORBA::PolicyType type; + + any configuration; + }; + + typedef sequence<Policy_Config> Policy_Configs; + + struct Policy_Set + { + string name; + + Policy_Configs configs; + }; + + typedef sequence<Policy_Set> Policy_Sets; + }; +}; |