TAO_RT_ORBInitializer Class Reference

RTCORBA ORB initializer. More...

#include <RT_ORBInitializer.h>

Inheritance diagram for TAO_RT_ORBInitializer:

Inheritance graph
[legend]
Collaboration diagram for TAO_RT_ORBInitializer:

Collaboration graph
[legend]
List of all members.

Public Types

enum  { TAO_PRIORITY_MAPPING_CONTINUOUS, TAO_PRIORITY_MAPPING_LINEAR, TAO_PRIORITY_MAPPING_DIRECT }
 Priority mapping types. More...

enum  { TAO_NETWORK_PRIORITY_MAPPING_LINEAR }

Public Member Functions

 TAO_RT_ORBInitializer (int priority_mapping_type, int network_priority_mapping_type, int ace_sched_policy, long sched_policy, long scope_policy, ACE_Time_Value const &dynamic_thread_idle_timeout)
virtual void pre_init (PortableInterceptor::ORBInitInfo_ptr info) throw (CORBA::SystemException)
virtual void post_init (PortableInterceptor::ORBInitInfo_ptr info) throw (CORBA::SystemException)

Private Member Functions

void register_policy_factories (PortableInterceptor::ORBInitInfo_ptr info)
 Register RTCORBA policy factories.


Private Attributes

PortableInterceptor::PolicyFactory_var policy_factory_
 Instance of the RTCorba policy factory.

int const  priority_mapping_type_
 Priority mapping type.

int const  network_priority_mapping_type_
 Network Priority mapping type.

int const  ace_sched_policy_
 Scheduling policy.

long const  sched_policy_
 Scheduling policy flag.

long const  scope_policy_
 Scheduling scope flag.

ACE_Time_Value const  dynamic_thread_idle_timeout_
 Dynamic thread idle timeout.


Detailed Description

RTCORBA ORB initializer.

Definition at line 43 of file RT_ORBInitializer.h.


Member Enumeration Documentation

anonymous enum
 

Priority mapping types.

Enumeration values:
TAO_PRIORITY_MAPPING_CONTINUOUS 
TAO_PRIORITY_MAPPING_LINEAR 
TAO_PRIORITY_MAPPING_DIRECT 

Definition at line 49 of file RT_ORBInitializer.h.

anonymous enum
 

Enumeration values:
TAO_NETWORK_PRIORITY_MAPPING_LINEAR 

Definition at line 56 of file RT_ORBInitializer.h.

00057     {
00058       TAO_NETWORK_PRIORITY_MAPPING_LINEAR
00059     };


Constructor & Destructor Documentation

TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_RT_ORBInitializer::TAO_RT_ORBInitializer int  priority_mapping_type,
int  network_priority_mapping_type,
int  ace_sched_policy,
long  sched_policy,
long  scope_policy,
ACE_Time_Value const &  dynamic_thread_idle_timeout
 

Definition at line 49 of file RT_ORBInitializer.cpp.

00055   : priority_mapping_type_ (priority_mapping_type),
00056     network_priority_mapping_type_ (network_priority_mapping_type),
00057     ace_sched_policy_ (ace_sched_policy),
00058     sched_policy_ (sched_policy),
00059     scope_policy_ (scope_policy),
00060     dynamic_thread_idle_timeout_ (dynamic_thread_idle_timeout)
00061 {
00062 }


Member Function Documentation

void TAO_RT_ORBInitializer::post_init PortableInterceptor::ORBInitInfo_ptr  info  )  throw (CORBA::SystemException) [virtual]
 

Definition at line 228 of file RT_ORBInitializer.cpp.

References ACE_CHECK, and ACE_ENV_ARG_PARAMETER.

00232 {
00233   this->register_policy_factories (info
00234                                    ACE_ENV_ARG_PARAMETER);
00235 
00236   ACE_CHECK;
00237 }

void TAO_RT_ORBInitializer::pre_init PortableInterceptor::ORBInitInfo_ptr  info  )  throw (CORBA::SystemException) [virtual]
 

Definition at line 65 of file RT_ORBInitializer.cpp.

References CORBA::Object::_nil(), ACE_CHECK, ACE_ENV_ARG_PARAMETER, ACE_ERROR, ACE_NEW, ACE_NEW_THROW_EX, ACE_TEXT_ALWAYS_CHAR, ACE_THROW, CORBA::is_nil(), LM_ERROR, ACE_Service_Config::process_directive(), rt_poa_factory_directive, rt_poa_factory_name, TAO_ORB_Core::set_endpoint_selector_factory(), TAO_ORB_Core::set_poa_factory(), TAO_ORB_Core::set_protocols_hooks(), TAO_ORB_Core::set_stub_factory(), TAO_ORB_Core::set_thread_lane_resources_manager_factory(), TAO_debug_level, TAO_OBJID_RTCURRENT, and TAO_OBJID_RTORB.

00069 {
00070   //
00071   // Register all of the RT related services.
00072   //
00073 
00074   // Set the name of the Protocol_Hooks to be RT_Protocols_Hooks.
00075   TAO_ORB_Core::set_protocols_hooks ("RT_Protocols_Hooks");
00076   ACE_Service_Config::process_directive (ace_svc_desc_TAO_RT_Protocols_Hooks);
00077 
00078   // Set the name of the stub factory to be RT_Stub_Factory.
00079   TAO_ORB_Core::set_stub_factory ("RT_Stub_Factory");
00080   ACE_Service_Config::process_directive (ace_svc_desc_TAO_RT_Stub_Factory);
00081 
00082   // Set the name of the stub factory to be RT_Stub_Factory.
00083   TAO_ORB_Core::set_endpoint_selector_factory ("RT_Endpoint_Selector_Factory");
00084   ACE_Service_Config::process_directive (ace_svc_desc_RT_Endpoint_Selector_Factory);
00085 
00086   // Set the name of the thread lane resources manager to be RT_Thread_Lane_Resources_Manager.
00087   TAO_ORB_Core::set_thread_lane_resources_manager_factory ("RT_Thread_Lane_Resources_Manager_Factory");
00088   ACE_Service_Config::process_directive (ace_svc_desc_TAO_RT_Thread_Lane_Resources_Manager_Factory);
00089 
00090   // If the application resolves the root POA, make sure we load the RT POA.
00091   TAO_ORB_Core::set_poa_factory (rt_poa_factory_name,
00092                                  ACE_TEXT_ALWAYS_CHAR (rt_poa_factory_directive));
00093 
00094   // Create the initial priority mapping instance.
00095   TAO_Priority_Mapping *pm = 0;
00096   switch (this->priority_mapping_type_)
00097     {
00098     case TAO_PRIORITY_MAPPING_CONTINUOUS:
00099       ACE_NEW (pm,
00100                TAO_Continuous_Priority_Mapping (this->ace_sched_policy_));
00101       break;
00102     case TAO_PRIORITY_MAPPING_LINEAR:
00103       ACE_NEW (pm,
00104                TAO_Linear_Priority_Mapping (this->ace_sched_policy_));
00105       break;
00106     default:
00107     case TAO_PRIORITY_MAPPING_DIRECT:
00108       ACE_NEW (pm,
00109                TAO_Direct_Priority_Mapping (this->ace_sched_policy_));
00110       break;
00111     }
00112 
00113   // Set the Priority_Mapping_Manager
00114   TAO_Priority_Mapping_Manager *manager = 0;
00115 
00116   ACE_NEW_THROW_EX (manager,
00117                     TAO_Priority_Mapping_Manager (pm),
00118                     CORBA::NO_MEMORY (
00119                       CORBA::SystemException::_tao_minor_code (
00120                         TAO::VMCID,
00121                         ENOMEM),
00122                       CORBA::COMPLETED_NO));
00123   ACE_CHECK;
00124 
00125   TAO_Priority_Mapping_Manager_var safe_manager = manager;
00126 
00127   info->register_initial_reference ("PriorityMappingManager",
00128                                     manager
00129                                     ACE_ENV_ARG_PARAMETER);
00130   ACE_CHECK;
00131 
00132   // Create the initial priority mapping instance.
00133   TAO_Network_Priority_Mapping *npm = 0;
00134   switch (this->network_priority_mapping_type_)
00135     {
00136     default:
00137     case TAO_NETWORK_PRIORITY_MAPPING_LINEAR:
00138       ACE_NEW (npm,
00139                TAO_Linear_Network_Priority_Mapping (this->ace_sched_policy_));
00140       break;
00141     }
00142 
00143   // Set the Priority_Mapping_Manager
00144   TAO_Network_Priority_Mapping_Manager * network_manager = 0;
00145 
00146   // @@ There is a potential memory leak here.  If the new() below
00147   //    throws an exception, the memory for the network priority
00148   //    mapping allocated above will be leaked.  Use an auto_ptr<> or
00149   //    the appropriate memory management tool.
00150 
00151   ACE_NEW_THROW_EX (network_manager,
00152                     TAO_Network_Priority_Mapping_Manager (npm),
00153                     CORBA::NO_MEMORY (
00154                       CORBA::SystemException::_tao_minor_code (
00155                         TAO::VMCID,
00156                         ENOMEM),
00157                       CORBA::COMPLETED_NO));
00158   ACE_CHECK;
00159 
00160   TAO_Network_Priority_Mapping_Manager_var safe_network_manager =
00161     network_manager;
00162 
00163   info->register_initial_reference ("NetworkPriorityMappingManager",
00164                                     network_manager
00165                                     ACE_ENV_ARG_PARAMETER);
00166   ACE_CHECK;
00167 
00168   // Narrow to a TAO_ORBInitInfo object to get access to the
00169   // orb_core() TAO extension.
00170   TAO_ORBInitInfo_var tao_info =
00171     TAO_ORBInitInfo::_narrow (info
00172                               ACE_ENV_ARG_PARAMETER);
00173   ACE_CHECK;
00174 
00175   if (CORBA::is_nil (tao_info.in ()))
00176     {
00177       if (TAO_debug_level > 0)
00178         ACE_ERROR ((LM_ERROR,
00179                     "(%P|%t) TAO_RT_ORBInitializer::pre_init:\n"
00180                     "(%P|%t)    Unable to narrow "
00181                     "\"PortableInterceptor::ORBInitInfo_ptr\" to\n"
00182                     "(%P|%t)   \"TAO_ORBInitInfo *.\"\n"));
00183 
00184       ACE_THROW (CORBA::INTERNAL ());
00185     }
00186 
00187   // Create the RT_ORB.
00188   CORBA::Object_ptr rt_orb = CORBA::Object::_nil ();
00189   ACE_NEW_THROW_EX (rt_orb,
00190                     TAO_RT_ORB (tao_info->orb_core (),
00191                     dynamic_thread_idle_timeout_),
00192                     CORBA::NO_MEMORY (
00193                       CORBA::SystemException::_tao_minor_code (
00194                         TAO::VMCID,
00195                         ENOMEM),
00196                       CORBA::COMPLETED_NO));
00197   ACE_CHECK;
00198   CORBA::Object_var safe_rt_orb = rt_orb;
00199 
00200   info->register_initial_reference (TAO_OBJID_RTORB,
00201                                     rt_orb
00202                                     ACE_ENV_ARG_PARAMETER);
00203   ACE_CHECK;
00204 
00205   // Create the RT_Current.
00206   CORBA::Object_ptr current = CORBA::Object::_nil ();
00207   ACE_NEW_THROW_EX (current,
00208                     TAO_RT_Current (tao_info->orb_core ()),
00209                     CORBA::NO_MEMORY (
00210                       CORBA::SystemException::_tao_minor_code (
00211                         TAO::VMCID,
00212                         ENOMEM),
00213                       CORBA::COMPLETED_NO));
00214   ACE_CHECK;
00215   CORBA::Object_var safe_rt_current = current;
00216 
00217   info->register_initial_reference (TAO_OBJID_RTCURRENT,
00218                                     current
00219                                     ACE_ENV_ARG_PARAMETER);
00220   ACE_CHECK;
00221 
00222   tao_info->orb_core ()->orb_params ()->scope_policy (this->scope_policy_);
00223   tao_info->orb_core ()->orb_params ()->sched_policy (this->sched_policy_);
00224   tao_info->orb_core ()->orb_params ()->ace_sched_policy (this->ace_sched_policy_);
00225 }

void TAO_RT_ORBInitializer::register_policy_factories PortableInterceptor::ORBInitInfo_ptr  info  )  [private]
 

Register RTCORBA policy factories.

Definition at line 240 of file RT_ORBInitializer.cpp.

References ACE_CATCH, ACE_CATCHANY, ACE_CHECK, ACE_ENDTRY, ACE_ENV_ARG_PARAMETER, ACE_NEW_THROW_EX, ACE_RE_THROW, ACE_TRY, ACE_TRY_CHECK, CORBA::is_nil(), and policy_factory_.

00243 {
00244   // The RTCorba policy factory is stateless and reentrant, so share a
00245   // single instance between all ORBs.
00246   if (CORBA::is_nil (this->policy_factory_.in ()))
00247     {
00248       PortableInterceptor::PolicyFactory_ptr policy_factory;
00249       ACE_NEW_THROW_EX (policy_factory,
00250                         TAO_RT_PolicyFactory,
00251                           CORBA::NO_MEMORY (
00252                             CORBA::SystemException::_tao_minor_code (
00253                               TAO::VMCID,
00254                               ENOMEM),
00255                             CORBA::COMPLETED_NO));
00256       ACE_CHECK;
00257 
00258       this->policy_factory_ = policy_factory;
00259     }
00260 
00261   // Bind the same policy factory to all RTCORBA related policy
00262   // types since a single policy factory is used to create each of
00263   // the different types of RTCORBA policies.
00264   static CORBA::PolicyType const type[] = {
00265     RTCORBA::PRIORITY_MODEL_POLICY_TYPE,
00266     RTCORBA::THREADPOOL_POLICY_TYPE,
00267     RTCORBA::SERVER_PROTOCOL_POLICY_TYPE,
00268     RTCORBA::CLIENT_PROTOCOL_POLICY_TYPE,
00269     RTCORBA::PRIVATE_CONNECTION_POLICY_TYPE,
00270     RTCORBA::PRIORITY_BANDED_CONNECTION_POLICY_TYPE
00271   };
00272 
00273   const CORBA::PolicyType *end =
00274     type + sizeof (type) / sizeof (type[0]);
00275 
00276   for (CORBA::PolicyType const * i = type;
00277        i != end;
00278        ++i)
00279     {
00280       ACE_TRY
00281         {
00282           info->register_policy_factory (*i,
00283                                          this->policy_factory_.in ()
00284                                          ACE_ENV_ARG_PARAMETER);
00285           ACE_TRY_CHECK;
00286         }
00287       ACE_CATCH (CORBA::BAD_INV_ORDER, ex)
00288         {
00289           if (ex.minor () == (CORBA::OMGVMCID | 16))
00290             {
00291               // The factory is already there, it happens because the
00292               // magic initializer in PortableServer.cpp registers
00293               // with the ORB multiple times.  This is an indication
00294               // that we should do no more work in this
00295               // ORBInitializer.
00296               return;
00297             }
00298           ACE_RE_THROW;
00299         }
00300       ACE_CATCHANY
00301         {
00302           // Rethrow any other exceptions...
00303           ACE_RE_THROW;
00304         }
00305       ACE_ENDTRY;
00306       ACE_CHECK;
00307     }
00308 }


Member Data Documentation

int const TAO_RT_ORBInitializer::ace_sched_policy_ [private]
 

Scheduling policy.

Scheduling policy specified by the user through the -ORBSchedPolicy option. This value is typically used by functions like ACE_OS::thr_setprio() and ACE_Sched_Params::priority_min(). Legal values are ACE_SCHED_RR, ACE_SCHED_FIFO, and ACE_SCHED_OTHER.

Definition at line 105 of file RT_ORBInitializer.h.

ACE_Time_Value const TAO_RT_ORBInitializer::dynamic_thread_idle_timeout_ [private]
 

Dynamic thread idle timeout.

When using thread pool a certain number of dynamic threads can be created. By default these threads are created when needed but never end, when this timeout is specified the threads end themselves at the moment they have not been serving any requests for the specified amount of time

Definition at line 132 of file RT_ORBInitializer.h.

int const TAO_RT_ORBInitializer::network_priority_mapping_type_ [private]
 

Network Priority mapping type.

Definition at line 95 of file RT_ORBInitializer.h.

PortableInterceptor::PolicyFactory_var TAO_RT_ORBInitializer::policy_factory_ [private]
 

Instance of the RTCorba policy factory.

The RTCorba policy factory is stateless and reentrant, so share a single instance between all ORBs.

Definition at line 89 of file RT_ORBInitializer.h.

Referenced by register_policy_factories().

int const TAO_RT_ORBInitializer::priority_mapping_type_ [private]
 

Priority mapping type.

Definition at line 92 of file RT_ORBInitializer.h.

long const TAO_RT_ORBInitializer::sched_policy_ [private]
 

Scheduling policy flag.

Scheduling policy specified by the user through the -ORBSchedPolicy option. This value is typically used by ACE thread creation functions. Legal values are THR_SCHED_RR, THR_SCHED_FIFO, and THR_SCHED_DEFAULT.

Definition at line 114 of file RT_ORBInitializer.h.

long const TAO_RT_ORBInitializer::scope_policy_ [private]
 

Scheduling scope flag.

Scheduling policy specified by the user through the -ORBScopePolicy option. This value is typically used by ACE thread creation functions. Legal values are THR_SCOPE_SYSTEM and THR_SCOPE_PROCESS.

Definition at line 123 of file RT_ORBInitializer.h.


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 12:59:39 2006 for TAO_RTCORBA by doxygen 1.3.6