TAO_RT_Protocols_Hooks Class Reference

#include <RT_Protocols_Hooks.h>

Inheritance diagram for TAO_RT_Protocols_Hooks:

Inheritance graph
[legend]
Collaboration diagram for TAO_RT_Protocols_Hooks:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TAO_RT_Protocols_Hooks (void)
 Constructor.
virtual ~TAO_RT_Protocols_Hooks (void)
 Destructor.
void init_hooks (TAO_ORB_Core *orb_core)
 Initialize the protocols hooks instance.
CORBA::Boolean set_client_network_priority (IOP::ProfileId protocol_tag, TAO_Stub *stub)
CORBA::Boolean set_server_network_priority (IOP::ProfileId protocol_tag, CORBA::Policy *policy)
void server_protocol_properties_at_orb_level (TAO_IIOP_Protocol_Properties &protocol_properties)
void client_protocol_properties_at_orb_level (TAO_IIOP_Protocol_Properties &protocol_properties)
void server_protocol_properties_at_orb_level (TAO_UIOP_Protocol_Properties &protocol_properties)
void client_protocol_properties_at_orb_level (TAO_UIOP_Protocol_Properties &protocol_properties)
void server_protocol_properties_at_orb_level (TAO_SHMIOP_Protocol_Properties &protocol_properties)
void client_protocol_properties_at_orb_level (TAO_SHMIOP_Protocol_Properties &protocol_properties)
void server_protocol_properties_at_orb_level (TAO_DIOP_Protocol_Properties &protocol_properties)
void client_protocol_properties_at_orb_level (TAO_DIOP_Protocol_Properties &protocol_properties)
void server_protocol_properties_at_orb_level (TAO_SCIOP_Protocol_Properties &protocol_properties)
void client_protocol_properties_at_orb_level (TAO_SCIOP_Protocol_Properties &protocol_properties)
CORBA::Long get_dscp_codepoint (void)
void rt_service_context (TAO_Stub *stub, TAO_Service_Context &service_context, CORBA::Boolean restart)
void add_rt_service_context_hook (TAO_Service_Context &service_context, CORBA::Policy *model_policy, CORBA::Short &client_priority)
void get_selector_hook (CORBA::Policy *model_policy, CORBA::Boolean &is_client_propagated, CORBA::Short &server_priority)
void get_selector_bands_policy_hook (CORBA::Policy *bands_policy, CORBA::Short priority, CORBA::Short &min_priority, CORBA::Short &max_priority, bool &in_range)
int get_thread_CORBA_priority (CORBA::Short &)
int get_thread_native_priority (CORBA::Short &)
int get_thread_CORBA_and_native_priority (CORBA::Short &, CORBA::Short &)
int set_thread_CORBA_priority (CORBA::Short)
int set_thread_native_priority (CORBA::Short)

Protected Member Functions

RTCORBA::ProtocolProperties_ptr server_protocol_properties (IOP::ProfileId protocol_tag, CORBA::Policy_ptr policy)
RTCORBA::ProtocolProperties_ptr client_protocol_properties (IOP::ProfileId protocol_tag, CORBA::Policy_ptr policy)
RTCORBA::ProtocolProperties_ptr server_protocol_properties_at_orb_level (IOP::ProfileId protocol_tag)
RTCORBA::ProtocolProperties_ptr client_protocol_properties_at_orb_level (IOP::ProfileId protocol_tag)
RTCORBA::ProtocolProperties_ptr client_protocol_properties_at_object_level (IOP::ProfileId protocol_tag, TAO_Stub *stub)
void extract_protocol_properties (TAO_IIOP_Protocol_Properties &to, RTCORBA::ProtocolProperties_ptr from)
void extract_protocol_properties (TAO_UIOP_Protocol_Properties &to, RTCORBA::ProtocolProperties_ptr from)
void extract_protocol_properties (TAO_SHMIOP_Protocol_Properties &to, RTCORBA::ProtocolProperties_ptr from)
void extract_protocol_properties (TAO_DIOP_Protocol_Properties &to, RTCORBA::ProtocolProperties_ptr from)
void extract_protocol_properties (TAO_SCIOP_Protocol_Properties &to, RTCORBA::ProtocolProperties_ptr from)
CORBA::Boolean set_network_priority (IOP::ProfileId protocol_tag, RTCORBA::ProtocolProperties_ptr protocol_properties)

Protected Attributes

TAO_ORB_Coreorb_core_
TAO_Priority_Mapping_Manager_var mapping_manager_
TAO_Network_Priority_Mapping_Manager_var network_mapping_manager_
RTCORBA::Current_var current_

Detailed Description

Definition at line 35 of file RT_Protocols_Hooks.h.


Constructor & Destructor Documentation

TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_RT_Protocols_Hooks::TAO_RT_Protocols_Hooks ( void   ) 

Constructor.

Definition at line 32 of file RT_Protocols_Hooks.cpp.

00033   : orb_core_ (0)
00034   , current_ ()
00035 {
00036 }

TAO_RT_Protocols_Hooks::~TAO_RT_Protocols_Hooks ( void   )  [virtual]

Destructor.

Definition at line 39 of file RT_Protocols_Hooks.cpp.

00040 {
00041 }


Member Function Documentation

void TAO_RT_Protocols_Hooks::add_rt_service_context_hook ( TAO_Service_Context service_context,
CORBA::Policy model_policy,
CORBA::Short client_priority 
) [virtual]

Implements TAO_Protocols_Hooks.

Definition at line 504 of file RT_Protocols_Hooks.cpp.

References TAO_PriorityModelPolicy::get_priority_model(), TAO_Service_Context::set_context(), and TAO_ENCAP_BYTE_ORDER.

Referenced by rt_service_context().

00510 {
00511   RTCORBA::PriorityModelPolicy_var model_policy_ptr =
00512     RTCORBA::PriorityModelPolicy::_narrow (model_policy);
00513 
00514   TAO_PriorityModelPolicy *priority_model =
00515     static_cast<TAO_PriorityModelPolicy *> (model_policy_ptr.in ());
00516 
00517   if (priority_model->get_priority_model () == RTCORBA::CLIENT_PROPAGATED)
00518     {
00519       // Encapsulate the priority of the current thread into
00520       // a service context.
00521       TAO_OutputCDR cdr;
00522       if ((cdr << ACE_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER) == 0)
00523           || (cdr << client_priority) == 0)
00524         {
00525           throw ::CORBA::MARSHAL ();
00526         }
00527 
00528       service_context.set_context (IOP::RTCorbaPriority, cdr);
00529     }
00530 }

RTCORBA::ProtocolProperties_ptr TAO_RT_Protocols_Hooks::client_protocol_properties ( IOP::ProfileId  protocol_tag,
CORBA::Policy_ptr  policy 
) [protected]

Definition at line 108 of file RT_Protocols_Hooks.cpp.

References RTCORBA::ProtocolProperties::_duplicate(), CORBA::is_nil(), and TAO_ClientProtocolPolicy::protocols_rep().

Referenced by client_protocol_properties_at_object_level(), and client_protocol_properties_at_orb_level().

00110 {
00111   if (CORBA::is_nil (policy))
00112     return 0;
00113 
00114   RTCORBA::ClientProtocolPolicy_var client_protocol_policy =
00115     RTCORBA::ClientProtocolPolicy::_narrow (policy);
00116 
00117   if (CORBA::is_nil (client_protocol_policy.in ()))
00118     return 0;
00119 
00120   TAO_ClientProtocolPolicy *client_protocols =
00121     dynamic_cast<TAO_ClientProtocolPolicy *> (client_protocol_policy.in ());
00122 
00123   if (client_protocols == 0)
00124     return 0;
00125 
00126   // TAO_ClientProtocolPolicy
00127   RTCORBA::ProtocolList &protocols =
00128     client_protocols->protocols_rep ();
00129 
00130   for (CORBA::ULong j = 0; j < protocols.length (); ++j)
00131     {
00132       if (protocols[j].protocol_type == protocol_tag)
00133         {
00134           return RTCORBA::ProtocolProperties::_duplicate (
00135                   protocols[j].transport_protocol_properties.in ());
00136         }
00137     }
00138 
00139   return 0;
00140 }

RTCORBA::ProtocolProperties_ptr TAO_RT_Protocols_Hooks::client_protocol_properties_at_object_level ( IOP::ProfileId  protocol_tag,
TAO_Stub stub 
) [protected]

Definition at line 163 of file RT_Protocols_Hooks.cpp.

References client_protocol_properties(), TAO_Stub::get_cached_policy(), TAO_Objref_Var_T< T >::in(), and TAO_CACHED_POLICY_RT_CLIENT_PROTOCOL.

Referenced by set_client_network_priority().

00166 {
00167   CORBA::Policy_var policy =
00168     stub->get_cached_policy (TAO_CACHED_POLICY_RT_CLIENT_PROTOCOL);
00169 
00170   return this->client_protocol_properties (protocol_tag, policy.in ());
00171 }

RTCORBA::ProtocolProperties_ptr TAO_RT_Protocols_Hooks::client_protocol_properties_at_orb_level ( IOP::ProfileId  protocol_tag  )  [protected]

Definition at line 153 of file RT_Protocols_Hooks.cpp.

References client_protocol_properties(), TAO_ORB_Core::get_cached_policy(), TAO_Objref_Var_T< T >::in(), orb_core_, and TAO_CACHED_POLICY_RT_CLIENT_PROTOCOL.

00155 {
00156   CORBA::Policy_var policy =
00157     this->orb_core_->get_cached_policy (TAO_CACHED_POLICY_RT_CLIENT_PROTOCOL);
00158 
00159   return this->client_protocol_properties (protocol_tag, policy.in ());
00160 }

void TAO_RT_Protocols_Hooks::client_protocol_properties_at_orb_level ( TAO_SCIOP_Protocol_Properties protocol_properties  )  [virtual]

Implements TAO_Protocols_Hooks.

Definition at line 340 of file RT_Protocols_Hooks.cpp.

References client_protocol_properties_at_orb_level(), extract_protocol_properties(), TAO_Objref_Var_T< T >::in(), CORBA::is_nil(), and TAO_TAG_SCIOP_PROFILE.

00342 {
00343   RTCORBA::ProtocolProperties_var from =
00344     this->client_protocol_properties_at_orb_level (TAO_TAG_SCIOP_PROFILE);
00345 
00346   if (!CORBA::is_nil (from.in ()))
00347     this->extract_protocol_properties (to, from.in ());
00348 }

void TAO_RT_Protocols_Hooks::client_protocol_properties_at_orb_level ( TAO_DIOP_Protocol_Properties protocol_properties  )  [virtual]

Implements TAO_Protocols_Hooks.

Definition at line 302 of file RT_Protocols_Hooks.cpp.

References client_protocol_properties_at_orb_level(), extract_protocol_properties(), TAO_Objref_Var_T< T >::in(), CORBA::is_nil(), and TAO_TAG_DIOP_PROFILE.

00304 {
00305   RTCORBA::ProtocolProperties_var from =
00306     this->client_protocol_properties_at_orb_level (TAO_TAG_DIOP_PROFILE);
00307 
00308   if (!CORBA::is_nil (from.in ()))
00309     this->extract_protocol_properties (to, from.in ());
00310 }

void TAO_RT_Protocols_Hooks::client_protocol_properties_at_orb_level ( TAO_SHMIOP_Protocol_Properties protocol_properties  )  [virtual]

Implements TAO_Protocols_Hooks.

Definition at line 267 of file RT_Protocols_Hooks.cpp.

References client_protocol_properties_at_orb_level(), extract_protocol_properties(), TAO_Objref_Var_T< T >::in(), CORBA::is_nil(), and TAO_TAG_SHMEM_PROFILE.

00269 {
00270   RTCORBA::ProtocolProperties_var from =
00271     this->client_protocol_properties_at_orb_level (TAO_TAG_SHMEM_PROFILE);
00272 
00273   if (!CORBA::is_nil (from.in ()))
00274     this->extract_protocol_properties (to, from.in ());
00275 }

void TAO_RT_Protocols_Hooks::client_protocol_properties_at_orb_level ( TAO_UIOP_Protocol_Properties protocol_properties  )  [virtual]

Implements TAO_Protocols_Hooks.

Definition at line 232 of file RT_Protocols_Hooks.cpp.

References client_protocol_properties_at_orb_level(), extract_protocol_properties(), TAO_Objref_Var_T< T >::in(), CORBA::is_nil(), and TAO_TAG_UIOP_PROFILE.

00234 {
00235   RTCORBA::ProtocolProperties_var from =
00236     this->client_protocol_properties_at_orb_level (TAO_TAG_UIOP_PROFILE);
00237 
00238   if (!CORBA::is_nil (from.in ()))
00239     this->extract_protocol_properties (to, from.in ());
00240 }

void TAO_RT_Protocols_Hooks::client_protocol_properties_at_orb_level ( TAO_IIOP_Protocol_Properties protocol_properties  )  [virtual]

Implements TAO_Protocols_Hooks.

Definition at line 199 of file RT_Protocols_Hooks.cpp.

References extract_protocol_properties(), TAO_Objref_Var_T< T >::in(), and CORBA::is_nil().

Referenced by client_protocol_properties_at_orb_level().

00200 {
00201   RTCORBA::ProtocolProperties_var from =
00202     this->client_protocol_properties_at_orb_level (IOP::TAG_INTERNET_IOP);
00203 
00204   if (!CORBA::is_nil (from.in ()))
00205     this->extract_protocol_properties (to, from.in ());
00206 }

void TAO_RT_Protocols_Hooks::extract_protocol_properties ( TAO_SCIOP_Protocol_Properties to,
RTCORBA::ProtocolProperties_ptr  from 
) [protected]

Definition at line 313 of file RT_Protocols_Hooks.cpp.

References TAO_SCIOP_Protocol_Properties::dont_route_, TAO_SCIOP_Protocol_Properties::enable_network_priority_, TAO_SCIOP_Protocol_Properties::keep_alive_, TAO_SCIOP_Protocol_Properties::no_delay_, TAO_SCIOP_Protocol_Properties::recv_buffer_size_, and TAO_SCIOP_Protocol_Properties::send_buffer_size_.

00316 {
00317   RTCORBA::StreamControlProtocolProperties_var protocol_properties =
00318     RTCORBA::StreamControlProtocolProperties::_narrow (from);
00319 
00320   to.send_buffer_size_ = protocol_properties->send_buffer_size ();
00321   to.recv_buffer_size_ = protocol_properties->recv_buffer_size ();
00322   to.keep_alive_ = protocol_properties->keep_alive ();
00323   to.dont_route_ = protocol_properties->dont_route ();
00324   to.no_delay_ = protocol_properties->no_delay ();
00325   to.enable_network_priority_ = protocol_properties->enable_network_priority ();
00326 }

void TAO_RT_Protocols_Hooks::extract_protocol_properties ( TAO_DIOP_Protocol_Properties to,
RTCORBA::ProtocolProperties_ptr  from 
) [protected]

Definition at line 278 of file RT_Protocols_Hooks.cpp.

References TAO_DIOP_Protocol_Properties::enable_network_priority_, TAO_DIOP_Protocol_Properties::recv_buffer_size_, and TAO_DIOP_Protocol_Properties::send_buffer_size_.

00281 {
00282   RTCORBA::UserDatagramProtocolProperties_var protocol_properties =
00283     RTCORBA::UserDatagramProtocolProperties::_narrow (from);
00284 
00285   to.enable_network_priority_ = protocol_properties->enable_network_priority ();
00286   to.send_buffer_size_ = protocol_properties->send_buffer_size ();
00287   to.recv_buffer_size_ = protocol_properties->recv_buffer_size ();
00288 }

void TAO_RT_Protocols_Hooks::extract_protocol_properties ( TAO_SHMIOP_Protocol_Properties to,
RTCORBA::ProtocolProperties_ptr  from 
) [protected]

Definition at line 243 of file RT_Protocols_Hooks.cpp.

References TAO_SHMIOP_Protocol_Properties::mmap_filename_, TAO_SHMIOP_Protocol_Properties::mmap_lockname_, and TAO_SHMIOP_Protocol_Properties::preallocate_buffer_size_.

00246 {
00247   RTCORBA::SharedMemoryProtocolProperties_var protocol_properties =
00248     RTCORBA::SharedMemoryProtocolProperties::_narrow (from);
00249 
00250   to.preallocate_buffer_size_ = protocol_properties->preallocate_buffer_size ();
00251   to.mmap_filename_ = protocol_properties->mmap_filename ();
00252   to.mmap_lockname_ = protocol_properties->mmap_lockname ();
00253 }

void TAO_RT_Protocols_Hooks::extract_protocol_properties ( TAO_UIOP_Protocol_Properties to,
RTCORBA::ProtocolProperties_ptr  from 
) [protected]

Definition at line 209 of file RT_Protocols_Hooks.cpp.

References TAO_UIOP_Protocol_Properties::recv_buffer_size_, and TAO_UIOP_Protocol_Properties::send_buffer_size_.

00212 {
00213   RTCORBA::UnixDomainProtocolProperties_var protocol_properties =
00214     RTCORBA::UnixDomainProtocolProperties::_narrow (from);
00215 
00216   to.send_buffer_size_ = protocol_properties->send_buffer_size ();
00217   to.recv_buffer_size_ = protocol_properties->recv_buffer_size ();
00218 }

void TAO_RT_Protocols_Hooks::extract_protocol_properties ( TAO_IIOP_Protocol_Properties to,
RTCORBA::ProtocolProperties_ptr  from 
) [protected]

Definition at line 174 of file RT_Protocols_Hooks.cpp.

References TAO_IIOP_Protocol_Properties::dont_route_, TAO_IIOP_Protocol_Properties::enable_network_priority_, TAO_IIOP_Protocol_Properties::keep_alive_, TAO_IIOP_Protocol_Properties::no_delay_, TAO_IIOP_Protocol_Properties::recv_buffer_size_, and TAO_IIOP_Protocol_Properties::send_buffer_size_.

Referenced by client_protocol_properties_at_orb_level(), and server_protocol_properties_at_orb_level().

00176 {
00177   RTCORBA::TCPProtocolProperties_var protocol_properties =
00178     RTCORBA::TCPProtocolProperties::_narrow (from);
00179 
00180   to.send_buffer_size_ = protocol_properties->send_buffer_size ();
00181   to.recv_buffer_size_ = protocol_properties->recv_buffer_size ();
00182   to.keep_alive_ = protocol_properties->keep_alive ();
00183   to.dont_route_ = protocol_properties->dont_route ();
00184   to.no_delay_ = protocol_properties->no_delay ();
00185   to.enable_network_priority_ = protocol_properties->enable_network_priority ();
00186 }

CORBA::Long TAO_RT_Protocols_Hooks::get_dscp_codepoint ( void   )  [virtual]

Implements TAO_Protocols_Hooks.

Definition at line 416 of file RT_Protocols_Hooks.cpp.

References ACE_DEBUG, ACE_ERROR, current_, LM_DEBUG, LM_ERROR, network_mapping_manager_, ACE_Event_Handler::priority(), TAO_debug_level, and TAO_Network_Priority_Mapping::to_network().

00417 {
00418   if (TAO_debug_level)
00419     ACE_DEBUG ((LM_DEBUG,
00420                 "TAO_RT_Protocols_Hooks::get_dscp_codepoint\n"));
00421 
00422   CORBA::Long codepoint = 0;
00423 
00424   try
00425     {
00426       // Make several invocation, changing the priority of this thread
00427       // for each.
00428 
00429       RTCORBA::NetworkPriorityMapping *pm =
00430         this->network_mapping_manager_->mapping ();
00431 
00432       CORBA::Short const priority = this->current_->the_priority ();
00433 
00434       if (pm->to_network (priority, codepoint) == 0)
00435         {
00436           if (TAO_debug_level > 0)
00437             {
00438               ACE_ERROR ((LM_ERROR,
00439                           "Cannot convert corba priority %d "
00440                           "to network priority\n",
00441                           priority));
00442             }
00443 
00444           return -1;
00445         }
00446     }
00447   catch (const ::CORBA::Exception& ex)
00448     {
00449       if (TAO_debug_level > 0)
00450         {
00451           ex._tao_print_exception (
00452             "TAO_RT_Protocols_Hooks::get_dscp_codepoint");
00453         }
00454 
00455       return -1;
00456     }
00457 
00458   return codepoint;
00459 }

void TAO_RT_Protocols_Hooks::get_selector_bands_policy_hook ( CORBA::Policy bands_policy,
CORBA::Short  priority,
CORBA::Short min_priority,
CORBA::Short max_priority,
bool &  in_range 
) [virtual]

Implements TAO_Protocols_Hooks.

Definition at line 558 of file RT_Protocols_Hooks.cpp.

References TAO_PriorityBandedConnectionPolicy::priority_bands_rep().

00565 {
00566   RTCORBA::PriorityBandedConnectionPolicy_var bands_policy_ptr =
00567     RTCORBA::PriorityBandedConnectionPolicy::_narrow (bands_policy);
00568 
00569   TAO_PriorityBandedConnectionPolicy *priority_bands_policy =
00570     static_cast<TAO_PriorityBandedConnectionPolicy *> (bands_policy_ptr.in ());
00571 
00572   // Find the band with the range covering our target priority.
00573   RTCORBA::PriorityBands &bands =
00574     priority_bands_policy->priority_bands_rep ();
00575 
00576   for (CORBA::ULong i = 0; i < bands.length (); ++i)
00577     {
00578       if (bands[i].low <= priority && bands[i].high >= priority)
00579         {
00580           min_priority = bands[i].low;
00581           max_priority = bands[i].high;
00582 
00583           in_range = true;
00584           break;
00585         }
00586     }
00587 }

void TAO_RT_Protocols_Hooks::get_selector_hook ( CORBA::Policy model_policy,
CORBA::Boolean is_client_propagated,
CORBA::Short server_priority 
) [virtual]

Implements TAO_Protocols_Hooks.

Definition at line 533 of file RT_Protocols_Hooks.cpp.

References TAO_PriorityModelPolicy::get_priority_model(), and TAO_PriorityModelPolicy::server_priority().

00537 {
00538   RTCORBA::PriorityModelPolicy_var model_policy_ptr =
00539     RTCORBA::PriorityModelPolicy::_narrow (model_policy);
00540 
00541   TAO_PriorityModelPolicy *priority_model_policy =
00542     static_cast<TAO_PriorityModelPolicy *> (model_policy_ptr.in ());
00543 
00544   if (priority_model_policy->get_priority_model () == RTCORBA::CLIENT_PROPAGATED)
00545     {
00546       is_client_propagated = true;
00547     }
00548 
00549   if (!is_client_propagated)
00550     {
00551       server_priority = priority_model_policy->server_priority ();
00552     }
00553 
00554   return;
00555 }

int TAO_RT_Protocols_Hooks::get_thread_CORBA_and_native_priority ( CORBA::Short ,
CORBA::Short  
) [virtual]

Accessor and modifier to the current thread priority, used to implement the RTCORBA::Current interface, but it is faster for some critical components.

Implements TAO_Protocols_Hooks.

Definition at line 626 of file RT_Protocols_Hooks.cpp.

References ACE_DEBUG, ACE_TEXT, TAO_Priority_Mapping_Manager_var::in(), LM_DEBUG, TAO_Priority_Mapping_Manager::mapping(), mapping_manager_, and TAO_Priority_Mapping::to_CORBA().

00629 {
00630   if (this->get_thread_native_priority (native_priority) == -1)
00631     {
00632       return -1;
00633     }
00634 
00635   TAO_Priority_Mapping *priority_mapping =
00636     this->mapping_manager_.in ()->mapping ();
00637 
00638   if (priority_mapping->to_CORBA (native_priority, priority) == 0)
00639     {
00640       ACE_DEBUG ((LM_DEBUG,
00641                   ACE_TEXT ("TAO (%P|%t) - ")
00642                   ACE_TEXT ("RT_Protocols_Hooks::get_thread_priority: ")
00643                   ACE_TEXT ("Priority_Mapping::to_CORBA\n")));
00644       return -1;
00645     }
00646 
00647   return 0;
00648 }

int TAO_RT_Protocols_Hooks::get_thread_CORBA_priority ( CORBA::Short  )  [virtual]

Accessor and modifier to the current thread priority, used to implement the RTCORBA::Current interface, but it is faster for some critical components.

Implements TAO_Protocols_Hooks.

Definition at line 590 of file RT_Protocols_Hooks.cpp.

Referenced by rt_service_context().

00591 {
00592   CORBA::Short native_priority = 0;
00593 
00594   if (this->get_thread_CORBA_and_native_priority (priority, native_priority) == -1)
00595     {
00596       return -1;
00597     }
00598 
00599   return 0;
00600 }

int TAO_RT_Protocols_Hooks::get_thread_native_priority ( CORBA::Short  )  [virtual]

Accessor and modifier to the current thread priority, used to implement the RTCORBA::Current interface, but it is faster for some critical components.

Implements TAO_Protocols_Hooks.

Definition at line 603 of file RT_Protocols_Hooks.cpp.

References ACE_DEBUG, ACE_TEXT, ACE_Thread::getprio(), LM_DEBUG, ACE_Event_Handler::priority(), and ACE_Thread::self().

00605 {
00606   ACE_hthread_t current;
00607   ACE_Thread::self (current);
00608 
00609   int priority;
00610 
00611   if (ACE_Thread::getprio (current, priority) == -1)
00612     {
00613       ACE_DEBUG ((LM_DEBUG,
00614                   ACE_TEXT ("TAO (%P|%t) - ")
00615                   ACE_TEXT ("RT_Protocols_Hooks::get_thread_priority: ")
00616                   ACE_TEXT (" ACE_Thread::get_prio\n")));
00617 
00618       return -1;
00619     }
00620 
00621   native_priority = CORBA::Short (priority);
00622   return 0;
00623 }

void TAO_RT_Protocols_Hooks::init_hooks ( TAO_ORB_Core orb_core  )  [virtual]

Initialize the protocols hooks instance.

Implements TAO_Protocols_Hooks.

Definition at line 44 of file RT_Protocols_Hooks.cpp.

References TAO_Network_Priority_Mapping_Manager::_narrow(), TAO_Priority_Mapping_Manager::_narrow(), current_, TAO_Pseudo_Var_T< T >::in(), mapping_manager_, network_mapping_manager_, TAO_ORB_Core::object_ref_table(), orb_core_, TAO_Object_Ref_Table::resolve_initial_reference(), TAO_OBJID_NETWORKPRIORITYMAPPINGMANAGER, TAO_OBJID_PRIORITYMAPPINGMANAGER, and TAO_OBJID_RTCURRENT.

00045 {
00046   this->orb_core_ = orb_core;
00047 
00048   // Save a reference to the priority mapping manager.
00049   CORBA::Object_var obj =
00050     orb_core->object_ref_table ().resolve_initial_reference (
00051       TAO_OBJID_PRIORITYMAPPINGMANAGER);
00052 
00053   this->mapping_manager_ =
00054     TAO_Priority_Mapping_Manager::_narrow (obj.in ());
00055 
00056   // Save a reference to the priority mapping manager.
00057   CORBA::Object_var object =
00058     orb_core->object_ref_table ().resolve_initial_reference (
00059       TAO_OBJID_NETWORKPRIORITYMAPPINGMANAGER);
00060 
00061   this->network_mapping_manager_ =
00062     TAO_Network_Priority_Mapping_Manager::_narrow (object.in ());
00063 
00064   object =
00065     this->orb_core_->object_ref_table ().resolve_initial_reference (
00066       TAO_OBJID_RTCURRENT);
00067 
00068   this->current_ = RTCORBA::Current::_narrow (object.in ());
00069 
00070 }

void TAO_RT_Protocols_Hooks::rt_service_context ( TAO_Stub stub,
TAO_Service_Context service_context,
CORBA::Boolean  restart 
) [virtual]

Implements TAO_Protocols_Hooks.

Definition at line 462 of file RT_Protocols_Hooks.cpp.

References add_rt_service_context_hook(), CORBA::COMPLETED_NO, TAO_RT_Stub::get_cached_policy(), get_thread_CORBA_priority(), TAO_Objref_Var_T< T >::in(), CORBA::is_nil(), and TAO_CACHED_POLICY_PRIORITY_MODEL.

00466 {
00467   // If the restart flag is true, then this call for a
00468   // reinvocation. We need not prepare the Service Context List once
00469   // again. We can use the already existing one.
00470   if (!restart)
00471     {
00472       TAO_RT_Stub *rt_stub =
00473         dynamic_cast<TAO_RT_Stub *> (stub);
00474 
00475       if (!rt_stub)
00476         throw CORBA::INTERNAL ();
00477 
00478       CORBA::Policy_var priority_model_policy =
00479         rt_stub->get_cached_policy (TAO_CACHED_POLICY_PRIORITY_MODEL);
00480 
00481       if (!CORBA::is_nil (priority_model_policy.in ()))
00482         {
00483           CORBA::Short client_priority;
00484 
00485           int const status =
00486             this->get_thread_CORBA_priority (client_priority);
00487 
00488           if (status == -1)
00489             throw ::CORBA::DATA_CONVERSION (1, CORBA::COMPLETED_NO);
00490 
00491           this->add_rt_service_context_hook (service_context,
00492                                              priority_model_policy.in (),
00493                                              client_priority);
00494         }
00495       else
00496         {
00497           // The Object does not contain PriorityModel policy in its IOR.
00498           // We must be talking to a non-RT ORB.  Do nothing.
00499         }
00500     }
00501 }

RTCORBA::ProtocolProperties_ptr TAO_RT_Protocols_Hooks::server_protocol_properties ( IOP::ProfileId  protocol_tag,
CORBA::Policy_ptr  policy 
) [protected]

Definition at line 73 of file RT_Protocols_Hooks.cpp.

References RTCORBA::ProtocolProperties::_duplicate(), CORBA::is_nil(), and TAO_ServerProtocolPolicy::protocols_rep().

Referenced by server_protocol_properties_at_orb_level(), and set_server_network_priority().

00075 {
00076   if (CORBA::is_nil (policy))
00077     return 0;
00078 
00079   RTCORBA::ServerProtocolPolicy_var server_protocol_policy =
00080     RTCORBA::ServerProtocolPolicy::_narrow (policy);
00081 
00082   if (CORBA::is_nil (server_protocol_policy.in ()))
00083     return 0;
00084 
00085   TAO_ServerProtocolPolicy *server_protocols =
00086     dynamic_cast<TAO_ServerProtocolPolicy *> (server_protocol_policy.in ());
00087 
00088   if (server_protocols == 0)
00089     return 0;
00090 
00091   // TAO_ServerProtocolPolicy
00092   RTCORBA::ProtocolList &protocols =
00093     server_protocols->protocols_rep ();
00094 
00095   for (CORBA::ULong j = 0; j < protocols.length (); ++j)
00096     {
00097       if (protocols[j].protocol_type == protocol_tag)
00098         {
00099           return RTCORBA::ProtocolProperties::_duplicate (
00100                   protocols[j].transport_protocol_properties.in ());
00101         }
00102     }
00103 
00104   return 0;
00105 }

RTCORBA::ProtocolProperties_ptr TAO_RT_Protocols_Hooks::server_protocol_properties_at_orb_level ( IOP::ProfileId  protocol_tag  )  [protected]

Definition at line 143 of file RT_Protocols_Hooks.cpp.

References TAO_ORB_Core::get_cached_policy(), TAO_Objref_Var_T< T >::in(), orb_core_, server_protocol_properties(), and TAO_CACHED_POLICY_RT_SERVER_PROTOCOL.

00145 {
00146   CORBA::Policy_var policy =
00147     this->orb_core_->get_cached_policy (TAO_CACHED_POLICY_RT_SERVER_PROTOCOL);
00148 
00149   return this->server_protocol_properties (protocol_tag, policy.in ());
00150 }

void TAO_RT_Protocols_Hooks::server_protocol_properties_at_orb_level ( TAO_SCIOP_Protocol_Properties protocol_properties  )  [virtual]

Implements TAO_Protocols_Hooks.

Definition at line 329 of file RT_Protocols_Hooks.cpp.

References extract_protocol_properties(), TAO_Objref_Var_T< T >::in(), CORBA::is_nil(), server_protocol_properties_at_orb_level(), and TAO_TAG_SCIOP_PROFILE.

00331 {
00332   RTCORBA::ProtocolProperties_var from =
00333     this->server_protocol_properties_at_orb_level (TAO_TAG_SCIOP_PROFILE);
00334 
00335   if (!CORBA::is_nil (from.in ()))
00336     this->extract_protocol_properties (to, from.in ());
00337 }

void TAO_RT_Protocols_Hooks::server_protocol_properties_at_orb_level ( TAO_DIOP_Protocol_Properties protocol_properties  )  [virtual]

Implements TAO_Protocols_Hooks.

Definition at line 291 of file RT_Protocols_Hooks.cpp.

References extract_protocol_properties(), TAO_Objref_Var_T< T >::in(), CORBA::is_nil(), server_protocol_properties_at_orb_level(), and TAO_TAG_DIOP_PROFILE.

00293 {
00294   RTCORBA::ProtocolProperties_var from =
00295     this->server_protocol_properties_at_orb_level (TAO_TAG_DIOP_PROFILE);
00296 
00297   if (!CORBA::is_nil (from.in ()))
00298     this->extract_protocol_properties (to, from.in ());
00299 }

void TAO_RT_Protocols_Hooks::server_protocol_properties_at_orb_level ( TAO_SHMIOP_Protocol_Properties protocol_properties  )  [virtual]

Implements TAO_Protocols_Hooks.

Definition at line 256 of file RT_Protocols_Hooks.cpp.

References extract_protocol_properties(), TAO_Objref_Var_T< T >::in(), CORBA::is_nil(), server_protocol_properties_at_orb_level(), and TAO_TAG_SHMEM_PROFILE.

00258 {
00259   RTCORBA::ProtocolProperties_var from =
00260     this->server_protocol_properties_at_orb_level (TAO_TAG_SHMEM_PROFILE);
00261 
00262   if (!CORBA::is_nil (from.in ()))
00263     this->extract_protocol_properties (to, from.in ());
00264 }

void TAO_RT_Protocols_Hooks::server_protocol_properties_at_orb_level ( TAO_UIOP_Protocol_Properties protocol_properties  )  [virtual]

Implements TAO_Protocols_Hooks.

Definition at line 221 of file RT_Protocols_Hooks.cpp.

References extract_protocol_properties(), TAO_Objref_Var_T< T >::in(), CORBA::is_nil(), server_protocol_properties_at_orb_level(), and TAO_TAG_UIOP_PROFILE.

00223 {
00224   RTCORBA::ProtocolProperties_var from =
00225     this->server_protocol_properties_at_orb_level (TAO_TAG_UIOP_PROFILE);
00226 
00227   if (!CORBA::is_nil (from.in ()))
00228     this->extract_protocol_properties (to, from.in ());
00229 }

void TAO_RT_Protocols_Hooks::server_protocol_properties_at_orb_level ( TAO_IIOP_Protocol_Properties protocol_properties  )  [virtual]

Implements TAO_Protocols_Hooks.

Definition at line 189 of file RT_Protocols_Hooks.cpp.

References extract_protocol_properties(), TAO_Objref_Var_T< T >::in(), and CORBA::is_nil().

Referenced by server_protocol_properties_at_orb_level().

00190 {
00191   RTCORBA::ProtocolProperties_var from =
00192     this->server_protocol_properties_at_orb_level (IOP::TAG_INTERNET_IOP);
00193 
00194   if (!CORBA::is_nil (from.in ()))
00195     this->extract_protocol_properties (to, from.in ());
00196 }

CORBA::Boolean TAO_RT_Protocols_Hooks::set_client_network_priority ( IOP::ProfileId  protocol_tag,
TAO_Stub stub 
) [virtual]

Implements TAO_Protocols_Hooks.

Definition at line 386 of file RT_Protocols_Hooks.cpp.

References client_protocol_properties_at_object_level(), TAO_Objref_Var_T< T >::in(), set_network_priority(), TAO_TAG_DIOP_PROFILE, and TAO_TAG_SCIOP_PROFILE.

00388 {
00389   if (protocol_tag != IOP::TAG_INTERNET_IOP &&
00390       protocol_tag != TAO_TAG_DIOP_PROFILE &&
00391       protocol_tag != TAO_TAG_SCIOP_PROFILE)
00392     return false;
00393 
00394   RTCORBA::ProtocolProperties_var protocol_properties =
00395     this->client_protocol_properties_at_object_level (protocol_tag, stub);
00396 
00397   return this->set_network_priority (protocol_tag, protocol_properties.in ());
00398 }

CORBA::Boolean TAO_RT_Protocols_Hooks::set_network_priority ( IOP::ProfileId  protocol_tag,
RTCORBA::ProtocolProperties_ptr  protocol_properties 
) [protected]

Definition at line 351 of file RT_Protocols_Hooks.cpp.

References CORBA::is_nil(), TAO_TAG_DIOP_PROFILE, and TAO_TAG_SCIOP_PROFILE.

Referenced by set_client_network_priority(), and set_server_network_priority().

00354 {
00355   if (CORBA::is_nil (protocol_properties))
00356       return false;
00357 
00358   if (protocol_tag == IOP::TAG_INTERNET_IOP)
00359     {
00360       RTCORBA::TCPProtocolProperties_var tcp_protocol_properties =
00361         RTCORBA::TCPProtocolProperties::_narrow (protocol_properties);
00362 
00363       return tcp_protocol_properties->enable_network_priority ();
00364     }
00365 
00366   if (protocol_tag == TAO_TAG_DIOP_PROFILE)
00367     {
00368       RTCORBA::UserDatagramProtocolProperties_var udp_protocol_properties =
00369         RTCORBA::UserDatagramProtocolProperties::_narrow (protocol_properties);
00370 
00371       return udp_protocol_properties->enable_network_priority ();
00372     }
00373 
00374   if (protocol_tag == TAO_TAG_SCIOP_PROFILE)
00375     {
00376       RTCORBA::StreamControlProtocolProperties_var sctp_protocol_properties =
00377         RTCORBA::StreamControlProtocolProperties::_narrow (protocol_properties);
00378 
00379       return sctp_protocol_properties->enable_network_priority ();
00380     }
00381 
00382   return false;
00383 }

CORBA::Boolean TAO_RT_Protocols_Hooks::set_server_network_priority ( IOP::ProfileId  protocol_tag,
CORBA::Policy policy 
) [virtual]

Implements TAO_Protocols_Hooks.

Definition at line 401 of file RT_Protocols_Hooks.cpp.

References TAO_Objref_Var_T< T >::in(), server_protocol_properties(), set_network_priority(), TAO_TAG_DIOP_PROFILE, and TAO_TAG_SCIOP_PROFILE.

00403 {
00404   if (protocol_tag != IOP::TAG_INTERNET_IOP &&
00405       protocol_tag != TAO_TAG_DIOP_PROFILE &&
00406       protocol_tag != TAO_TAG_SCIOP_PROFILE)
00407     return false;
00408 
00409   RTCORBA::ProtocolProperties_var protocol_properties =
00410     this->server_protocol_properties (protocol_tag, policy);
00411 
00412   return this->set_network_priority (protocol_tag, protocol_properties.in ());
00413 }

int TAO_RT_Protocols_Hooks::set_thread_CORBA_priority ( CORBA::Short   )  [virtual]

Accessor and modifier to the current thread priority, used to implement the RTCORBA::Current interface, but it is faster for some critical components.

Implements TAO_Protocols_Hooks.

Definition at line 651 of file RT_Protocols_Hooks.cpp.

References TAO_Priority_Mapping_Manager_var::in(), TAO_Priority_Mapping_Manager::mapping(), mapping_manager_, set_thread_native_priority(), and TAO_Priority_Mapping::to_native().

00652 {
00653   TAO_Priority_Mapping *priority_mapping =
00654     this->mapping_manager_.in ()->mapping ();
00655 
00656   CORBA::Short native_priority;
00657 
00658   if (priority_mapping->to_native (priority, native_priority) == 0)
00659     {
00660       return -1;
00661     }
00662 
00663   return this->set_thread_native_priority (native_priority);
00664 }

int TAO_RT_Protocols_Hooks::set_thread_native_priority ( CORBA::Short   )  [virtual]

Accessor and modifier to the current thread priority, used to implement the RTCORBA::Current interface, but it is faster for some critical components.

Implements TAO_Protocols_Hooks.

Definition at line 667 of file RT_Protocols_Hooks.cpp.

References ACE_ERROR_RETURN, ACE_TEXT, LM_ERROR, ACE_Thread::self(), and ACE_Thread::setprio().

Referenced by set_thread_CORBA_priority().

00669 {
00670   ACE_hthread_t current;
00671   ACE_Thread::self (current);
00672 
00673   if (ACE_Thread::setprio (current, native_priority) == -1)
00674     {
00675       ACE_ERROR_RETURN ((LM_ERROR,
00676                          ACE_TEXT ("(%N,%l) Error setting thread ")
00677                          ACE_TEXT ("priority to %d, errno %d %m\n"),
00678                          native_priority,
00679                          errno ),
00680                        -1);
00681     }
00682 
00683   return 0;
00684 }


Member Data Documentation

RTCORBA::Current_var TAO_RT_Protocols_Hooks::current_ [protected]

Definition at line 162 of file RT_Protocols_Hooks.h.

Referenced by get_dscp_codepoint(), and init_hooks().

TAO_Priority_Mapping_Manager_var TAO_RT_Protocols_Hooks::mapping_manager_ [protected]

Definition at line 159 of file RT_Protocols_Hooks.h.

Referenced by get_thread_CORBA_and_native_priority(), init_hooks(), and set_thread_CORBA_priority().

TAO_Network_Priority_Mapping_Manager_var TAO_RT_Protocols_Hooks::network_mapping_manager_ [protected]

Definition at line 160 of file RT_Protocols_Hooks.h.

Referenced by get_dscp_codepoint(), and init_hooks().

TAO_ORB_Core* TAO_RT_Protocols_Hooks::orb_core_ [protected]

Definition at line 156 of file RT_Protocols_Hooks.h.

Referenced by client_protocol_properties_at_orb_level(), init_hooks(), and server_protocol_properties_at_orb_level().


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:43:01 2010 for TAO_RTCORBA by  doxygen 1.4.7