TAO_Optimized_Connection_Endpoint_Selector Class Reference

More efficient connection strategy for endpoint selection. More...

#include <Optimized_Connection_Endpoint_Selector.h>

Inheritance diagram for TAO_Optimized_Connection_Endpoint_Selector:

Inheritance graph
[legend]
Collaboration diagram for TAO_Optimized_Connection_Endpoint_Selector:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TAO_Optimized_Connection_Endpoint_Selector (const ACE_Time_Value &tv)
 Constructor.
virtual ~TAO_Optimized_Connection_Endpoint_Selector (void)
 Destructor.
virtual void select_endpoint (TAO::Profile_Transport_Resolver *, ACE_Time_Value *max_wait_time)

Static Public Member Functions

static void hook (TAO_ORB_Core *, TAO_Stub *, bool &has_timeout, ACE_Time_Value &tv)

Private Member Functions

int check_profile (TAO_Profile *, TAO::Profile_Transport_Resolver *)

Static Private Attributes

static ACE_Time_Value timeout_

Detailed Description

More efficient connection strategy for endpoint selection.

This strategy builds on the default by first querying the connection cache for all potential endpoints before iterating over the list to attempt to create new connections.

Definition at line 51 of file Optimized_Connection_Endpoint_Selector.h.


Constructor & Destructor Documentation

TAO_Optimized_Connection_Endpoint_Selector::TAO_Optimized_Connection_Endpoint_Selector ( const ACE_Time_Value tv  ) 

Constructor.

Definition at line 26 of file Optimized_Connection_Endpoint_Selector.cpp.

References ACE_DEBUG, ACE_TEXT, TAO_ORB_Core::connection_timeout_hook(), hook(), LM_DEBUG, TAO_debug_level, timeout_, and ACE_Time_Value::zero.

00027 {
00028   TAO_Optimized_Connection_Endpoint_Selector::timeout_ = tv;
00029   if (TAO_debug_level)
00030     {
00031       ACE_DEBUG ((LM_DEBUG,
00032                   ACE_TEXT ("TAO(%P|%t) Optimized Connection Enpoint Selector: ")
00033                   ACE_TEXT ("Initializing timeout hook tv = %d sec, %d usec\n"),
00034               tv.sec(), tv.usec()));
00035     }
00036   if (tv > ACE_Time_Value::zero)
00037     {
00038       TAO_ORB_Core::connection_timeout_hook
00039         (TAO_Optimized_Connection_Endpoint_Selector::hook);
00040     }
00041 }

TAO_Optimized_Connection_Endpoint_Selector::~TAO_Optimized_Connection_Endpoint_Selector ( void   )  [virtual]

Destructor.

Definition at line 44 of file Optimized_Connection_Endpoint_Selector.cpp.

00045 {
00046 }


Member Function Documentation

int TAO_Optimized_Connection_Endpoint_Selector::check_profile ( TAO_Profile ,
TAO::Profile_Transport_Resolver *   
) [private]

Definition at line 63 of file Optimized_Connection_Endpoint_Selector.cpp.

References TAO_Profile::endpoint(), and TAO_Profile::endpoint_count().

00065 {
00066   TAO_Endpoint *effective_endpoint = 0;
00067 
00068   r->profile(p);
00069   effective_endpoint = p->endpoint ();
00070   size_t endpoint_count = p->endpoint_count();
00071   for (size_t i = 0; i < endpoint_count; ++i)
00072     {
00073       TAO_Base_Transport_Property desc (effective_endpoint);
00074       if (r->find_transport(&desc))
00075         return 1;
00076       // Go to the next endpoint in this profile
00077       effective_endpoint = effective_endpoint->next();
00078     }
00079   return 0;
00080 }

void TAO_Optimized_Connection_Endpoint_Selector::hook ( TAO_ORB_Core ,
TAO_Stub ,
bool &  has_timeout,
ACE_Time_Value tv 
) [static]

Definition at line 50 of file Optimized_Connection_Endpoint_Selector.cpp.

References timeout_, and ACE_Time_Value::zero.

Referenced by TAO_Optimized_Connection_Endpoint_Selector().

00054 {
00055   has_timeout =
00056     TAO_Optimized_Connection_Endpoint_Selector::
00057     timeout_ > ACE_Time_Value::zero;
00058   if (has_timeout)
00059     tv = TAO_Optimized_Connection_Endpoint_Selector::timeout_;
00060 }

void TAO_Optimized_Connection_Endpoint_Selector::select_endpoint ( TAO::Profile_Transport_Resolver *  ,
ACE_Time_Value max_wait_time 
) [virtual]

Reimplemented from TAO_Default_Endpoint_Selector.

Definition at line 84 of file Optimized_Connection_Endpoint_Selector.cpp.

References CORBA::COMPLETED_NO, TAO_Profile::endpoint_count(), TAO_Stub::forward_profiles(), TAO_MProfile::get_profile(), TAO_Stub::next_profile_retry(), CORBA::OMGVMCID, TAO_MProfile::profile_count(), TAO_Stub::profile_in_use(), and TAO_Stub::reset_profiles().

00086 {
00087   TAO_Stub *stub = r->stub();
00088   TAO_Profile *p = stub->profile_in_use();
00089 
00090   // first, look for the endpoints for the current profile in use.
00091   // if that is available then go for it.
00092 
00093   if (this->check_profile (p, r) != 0)
00094     return;
00095 
00096   // next, look for any other profiles. If the stub has any forward profiles,
00097   // use those, otherwise look at the base profiles. This separation is
00098   // necessary to avoid re-using a corbaloc or other previously forwarded
00099   // profile.
00100 
00101   const TAO_MProfile *profiles = stub->forward_profiles();
00102   if (profiles != 0)
00103     {
00104       for (CORBA::ULong count = 0; count <  profiles->profile_count(); count++)
00105         {
00106           p = const_cast<TAO_Profile *>(profiles->get_profile(count));
00107           if (this->check_profile (p, r) != 0)
00108             {
00109               if (stub->profile_in_use() != p)
00110                 {
00111                   // thread-safe way to coerse stub to this profile.
00112                   stub->reset_profiles();
00113                   while (stub->profile_in_use() != p)
00114                     if (stub->next_profile_retry() == 0)
00115                       break;
00116                 }
00117               return;
00118             }
00119         }
00120     }
00121   else
00122     {
00123       do
00124         {
00125           p = stub->profile_in_use();
00126           if (this->check_profile(p, r) != 0)
00127             return;
00128         }
00129       while (stub->next_profile_retry () != 0);
00130     }
00131 
00132 
00133 
00134   // at this point, we do not have an existing transport, so we must
00135   // reset the profile list and try establishing connections via the
00136   // connector(s).
00137 
00138   do
00139     {
00140       r->profile (r->stub ()->profile_in_use ());
00141 
00142       // Check whether we need to do a blocked wait or we have a
00143       // non-blocked wait and we support that.  If this is not the
00144       // case we can't use this profile so try the next.
00145       if (r->blocked_connect () ||
00146          (!r->blocked_connect () && r->profile ()->supports_non_blocking_oneways ()))
00147         {
00148           const size_t endpoint_count = r->profile ()->endpoint_count ();
00149 
00150           TAO_Endpoint *ep = r->profile ()->endpoint ();
00151 
00152           for (size_t i = 0; i < endpoint_count; ++i)
00153             {
00154               TAO_Base_Transport_Property desc (ep);
00155               const bool retval = r->try_connect (&desc, max_wait_time);
00156 
00157               // Check if the connect has completed.
00158               if (retval)
00159                 return;
00160 
00161               // Go to the next endpoint in this profile.
00162               ep = ep->next ();
00163             }
00164         }
00165     }
00166   while (r->stub ()->next_profile_retry () != 0);
00167 
00168   // If we get here, we completely failed to find an endpoint selector
00169   // that we know how to use, so throw an exception.
00170   throw ::CORBA::TRANSIENT (CORBA::OMGVMCID | 2, CORBA::COMPLETED_NO);
00171 }


Member Data Documentation

TAO_BEGIN_VERSIONED_NAMESPACE_DECL ACE_Time_Value TAO_Optimized_Connection_Endpoint_Selector::timeout_ [static, private]

Definition at line 73 of file Optimized_Connection_Endpoint_Selector.h.

Referenced by hook(), and TAO_Optimized_Connection_Endpoint_Selector().


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:47:32 2010 for TAO_Strategies by  doxygen 1.4.7