TAO::Profile_Transport_Resolver Class Reference

Chooses the profile and a transport for a target object on which an invocation can be made. More...

#include <Profile_Transport_Resolver.h>

Collaboration diagram for TAO::Profile_Transport_Resolver:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Profile_Transport_Resolver (CORBA::Object *p, TAO_Stub *stub, bool block=true)
 Constructor.

 ~Profile_Transport_Resolver (void)
void resolve (ACE_Time_Value *val)
 Method where the bunch of the action takes place.

void transport_released (void) const
bool try_connect (TAO_Transport_Descriptor_Interface *desc, ACE_Time_Value *val)
bool try_parallel_connect (TAO_Transport_Descriptor_Interface *desc, ACE_Time_Value *val)
bool use_parallel_connect (void) const
void init_inconsistent_policies (void)
CORBA::PolicyListinconsistent_policies (void) const
CORBA::PolicyListsteal_inconsistent_policies (void)
Accessors and mutators for this class. The following methods
are used by the clients of this class to access strategies and other internal workings.

void profile (TAO_Profile *pfile)
 Mutator for profile.

TAO_Profileprofile (void) const
 Accessor for profile.

TAO_Stubstub (void) const
 Accessor for TAO_Stub.

CORBA::Objectobject (void) const
 Accessor for the target in use.

TAO_Transporttransport (void) const
 Accessor for the transport reserved for this invocation.

int find_transport (TAO_Transport_Descriptor_Interface *)
bool blocked_connect (void) const

Private Member Functions

bool get_connection_timeout (ACE_Time_Value &max_wait_time)
bool try_connect_i (TAO_Transport_Descriptor_Interface *desc, ACE_Time_Value *val, bool parallel)

Private Attributes

CORBA::Objectobj_
 Target object.

TAO_Stubstub_
 Stub object for the target object.

TAO::Transport_Selection_Guard transport_
 The transport selected for this invocation.

TAO_Profileprofile_
 The profile that has been selected for this invocation.

CORBA::PolicyListinconsistent_policies_
 List of inconsistent policies.

bool is_released_
 Has the transport been idle?

bool const  blocked_
 Should we block while trying to make a connection.


Detailed Description

Chooses the profile and a transport for a target object on which an invocation can be made.

A target object is represented by multiple profiles, which theoretically provides multiple paths to the same target object. This class helps in choosing the right profile, and pick a transport from cache (or create a new transport if needed) that represents the profile.

Definition at line 63 of file Profile_Transport_Resolver.h.


Constructor & Destructor Documentation

ACE_INLINE TAO::Profile_Transport_Resolver::Profile_Transport_Resolver CORBA::Object p,
TAO_Stub stub,
bool  block = true
 

Constructor.

With block we tell whether this resolved should always deliver a connection by blocking or unblock before the connection is completely established. Please note that this has *nothing* to do with the synchronous or asynch connect strategy used for making connections. This is a local flag used by the clients of this to dictate some local behavior.

Definition at line 11 of file Profile_Transport_Resolver.inl.

00015     : obj_ (p)
00016     , stub_ (stub)
00017     , transport_ (0)
00018     , profile_ (0)
00019     , inconsistent_policies_ (0)
00020     , is_released_ (false)
00021     , blocked_ (block)
00022   {
00023   }

TAO::Profile_Transport_Resolver::~Profile_Transport_Resolver void   ) 
 

Definition at line 36 of file Profile_Transport_Resolver.cpp.

References TAO_Profile::_decr_refcnt(), TAO::Transport_Selection_Guard::get(), inconsistent_policies_, and is_released_.

00037   {
00038     if (this->profile_)
00039       {
00040         this->profile_->_decr_refcnt ();
00041       }
00042 
00043     if (this->transport_.get ())
00044       {
00045         if (this->is_released_ == false)
00046           {
00047             this->transport_->make_idle ();
00048           }
00049 
00050         this->transport_->remove_reference ();
00051       }
00052 
00053     delete this->inconsistent_policies_;
00054   }


Member Function Documentation

ACE_INLINE bool TAO::Profile_Transport_Resolver::blocked_connect void   )  const
 

Accessor to indicate whether we should block while establishing a connection.

Definition at line 50 of file Profile_Transport_Resolver.inl.

References blocked_.

Referenced by TAO_IIOP_Connector::begin_connection(), TAO_Default_Endpoint_Selector::select_endpoint(), and TAO_Connector::wait_for_connection_completion().

00051   {
00052     return this->blocked_;
00053   }

int TAO::Profile_Transport_Resolver::find_transport TAO_Transport_Descriptor_Interface  ) 
 

See if the transport cache has an available transport and use that one rather than trying to connect via the connector. Separating this functionality enables the look up of many endpoints before trying the more time-consuming trip through the actual connector.

Definition at line 245 of file Profile_Transport_Resolver.cpp.

References TAO::Transport_Cache_Manager::find_transport(), TAO::Transport_Selection_Guard::get(), TAO_ORB_Core::lane_resources(), TAO_Profile::orb_core(), TAO::Transport_Selection_Guard::set(), and TAO_Thread_Lane_Resources::transport_cache().

00246   {
00247     TAO::Transport_Cache_Manager & cache =
00248       this->profile_->orb_core()->lane_resources ().transport_cache();
00249 
00250     // the cache increments the reference count on the transport if
00251     // the find is successful. Cache.find_transport returns 0 on success.
00252     // but we want to return a "boolean" of 0 for failure, 1 for success.
00253     TAO_Transport* tmp = this->transport_.get ();
00254     if (cache.find_transport(desc, tmp) != 0)
00255       return 0;
00256 
00257     this->transport_.set (tmp);
00258     return 1;
00259   }

bool TAO::Profile_Transport_Resolver::get_connection_timeout ACE_Time_Value max_wait_time  )  [private]
 

Helper method to access get the connection timeout from the ORB.

Definition at line 217 of file Profile_Transport_Resolver.cpp.

References TAO_ORB_Core::connection_timeout(), and TAO_Stub::orb_core().

Referenced by try_connect_i().

00219   {
00220     bool is_conn_timeout = false;
00221 
00222     // Check for the connection timout policy in the ORB
00223     this->stub_->orb_core ()->connection_timeout (this->stub_,
00224                                                   is_conn_timeout,
00225                                                   max_wait_time);
00226 
00227     return is_conn_timeout;
00228   }

ACE_INLINE CORBA::PolicyList * TAO::Profile_Transport_Resolver::inconsistent_policies void   )  const
 

Definition at line 62 of file Profile_Transport_Resolver.inl.

References inconsistent_policies_.

00063   {
00064     return this->inconsistent_policies_;
00065   }

void TAO::Profile_Transport_Resolver::init_inconsistent_policies void   ) 
 

Initialize the inconsistent policy list that this object has cached.

Definition at line 232 of file Profile_Transport_Resolver.cpp.

References ACE_NEW_THROW_EX, and CORBA::PolicyList.

Referenced by TAO::LocateRequest_Invocation_Adapter::invoke().

00233   {
00234     ACE_NEW_THROW_EX (this->inconsistent_policies_,
00235                       CORBA::PolicyList (0),
00236                       CORBA::NO_MEMORY (
00237                       CORBA::SystemException::_tao_minor_code (
00238                         0,
00239                         ENOMEM),
00240                       CORBA::COMPLETED_NO));
00241   }

ACE_INLINE CORBA::Object_ptr TAO::Profile_Transport_Resolver::object void   )  const
 

Accessor for the target in use.

Definition at line 32 of file Profile_Transport_Resolver.inl.

Referenced by TAO::Remote_Invocation::send_message().

00033   {
00034     return this->obj_;
00035   }

ACE_INLINE TAO_Profile * TAO::Profile_Transport_Resolver::profile void   )  const
 

Accessor for profile.

Definition at line 38 of file Profile_Transport_Resolver.inl.

00039   {
00040     return this->profile_;
00041   }

void TAO::Profile_Transport_Resolver::profile TAO_Profile pfile  ) 
 

Mutator for profile.

Definition at line 57 of file Profile_Transport_Resolver.cpp.

References TAO_Profile::_decr_refcnt(), and TAO_Profile::_incr_refcnt().

Referenced by TAO::LocateRequest_Invocation::check_reply(), TAO::Synch_Twoway_Invocation::check_reply_status(), TAO::Synch_Twoway_Invocation::handle_system_exception(), TAO::Remote_Invocation::init_target_spec(), TAO_Default_Endpoint_Selector::select_endpoint(), and TAO::Synch_Twoway_Invocation::wait_for_reply().

00058   {
00059     // Dont do anything if the incoming profile is null
00060     if (p)
00061       {
00062         // @note This is just a workaround for a more serious problem
00063         // with profile management. This would cover some potential
00064         // issues that Ossama is working on.  Ossama, please remove
00065         // them when you are done.
00066         TAO_Profile *tmp = this->profile_;
00067 
00068         (void) p->_incr_refcnt ();
00069         this->profile_ = p;
00070 
00071         if (tmp)
00072           {
00073             (void) tmp->_decr_refcnt ();
00074           }
00075       }
00076   }

void TAO::Profile_Transport_Resolver::resolve ACE_Time_Value val  ) 
 

Method where the bunch of the action takes place.

This is the entry point from the TAO::Invocation_Adapter class. This method accesses the endpoint selector factory from the ORB_Core to decide on the strategy to be used for selecting the profile.

Definition at line 80 of file Profile_Transport_Resolver.cpp.

References TAO_ORB_Core::codeset_manager(), TAO_ORB_Core::endpoint_selector_factory(), TAO::Transport_Selection_Guard::get(), TAO_Endpoint_Selector_Factory::get_selector(), TAO_GIOP_Message_Version::major, TAO_GIOP_Message_Version::minor, TAO_Stub::orb_core(), TAO_Invocation_Endpoint_Selector::select_endpoint(), TAO_Codeset_Manager::set_tcs(), and TAO_Profile::version().

Referenced by TAO::LocateRequest_Invocation_Adapter::invoke(), and TAO::Invocation_Adapter::invoke_remote_i().

00081   {
00082     ACE_Countdown_Time countdown (max_time_val);
00083 
00084     TAO_Invocation_Endpoint_Selector *es =
00085       this->stub_->orb_core ()->endpoint_selector_factory ()->get_selector ();
00086 
00087     // Select the endpoint
00088     es->select_endpoint (this, max_time_val);
00089 
00090     if (this->transport_.get () == 0)
00091       {
00092         throw ::CORBA::INTERNAL ();
00093       }
00094 
00095     TAO_GIOP_Message_Version const & version = this->profile_->version ();
00096 
00097     // Initialize the messaging object
00098     if (this->transport_->messaging_init (version.major, version.minor) == -1)
00099       {
00100         throw ::CORBA::INTERNAL (
00101                           CORBA::SystemException::_tao_minor_code (
00102                             0,
00103                             EINVAL),
00104                           CORBA::COMPLETED_NO);
00105       }
00106 
00107     if (!this->transport_->is_tcs_set ())
00108       {
00109         TAO_Codeset_Manager * const tcm =
00110           this->stub_->orb_core ()->codeset_manager ();
00111         if (tcm)
00112           tcm->set_tcs (*this->profile_, *this->transport_);
00113       }
00114   }

ACE_INLINE CORBA::PolicyList * TAO::Profile_Transport_Resolver::steal_inconsistent_policies void   ) 
 

Definition at line 68 of file Profile_Transport_Resolver.inl.

References inconsistent_policies_, and CORBA::PolicyList.

Referenced by TAO::LocateRequest_Invocation_Adapter::invoke().

00069   {
00070     CORBA::PolicyList *tmp = this->inconsistent_policies_;
00071     this->inconsistent_policies_ = 0;
00072     return tmp;
00073   }

ACE_INLINE TAO_Stub * TAO::Profile_Transport_Resolver::stub void   )  const
 

Accessor for TAO_Stub.

Definition at line 26 of file Profile_Transport_Resolver.inl.

Referenced by TAO::Synch_Twoway_Invocation::handle_system_exception(), TAO::Remote_Invocation::init_target_spec(), TAO::LocateRequest_Invocation_Adapter::invoke(), TAO::Invocation_Adapter::invoke_oneway(), TAO::Invocation_Adapter::invoke_twoway(), TAO::Synch_Oneway_Invocation::remote_oneway(), TAO::Synch_Twoway_Invocation::remote_twoway(), TAO_Default_Endpoint_Selector::select_endpoint(), TAO::Remote_Invocation::send_message(), and TAO::Synch_Twoway_Invocation::wait_for_reply().

00027   {
00028     return this->stub_;
00029   }

ACE_INLINE TAO_Transport * TAO::Profile_Transport_Resolver::transport void   )  const
 

Accessor for the transport reserved for this invocation.

Definition at line 44 of file Profile_Transport_Resolver.inl.

References TAO::Transport_Selection_Guard::get().

Referenced by TAO::LocateRequest_Invocation::check_reply(), TAO::Synch_Twoway_Invocation::check_reply_status(), TAO::LocateRequest_Invocation_Adapter::invoke(), TAO::LocateRequest_Invocation::invoke(), TAO::Invocation_Adapter::invoke_remote_i(), TAO::Synch_Oneway_Invocation::remote_oneway(), TAO::Synch_Twoway_Invocation::remote_twoway(), TAO::Remote_Invocation::send_message(), TAO::Synch_Twoway_Invocation::wait_for_reply(), and TAO::Remote_Invocation::write_header().

00045   {
00046     return this->transport_.get ();
00047   }

ACE_INLINE void TAO::Profile_Transport_Resolver::transport_released void   )  const
 

Signal to let the resolver know that the transport has been released back to the cache.

Definition at line 56 of file Profile_Transport_Resolver.inl.

References is_released_.

Referenced by TAO::LocateRequest_Invocation::invoke(), and TAO::Synch_Twoway_Invocation::remote_twoway().

00057   {
00058     this->is_released_ = true;
00059   }

bool TAO::Profile_Transport_Resolver::try_connect TAO_Transport_Descriptor_Interface desc,
ACE_Time_Value val
 

This is a callback method used by the endpoint selectors to delegate the responsibility of reserving a transport from the connection cache for this invocation. When the descriptor contains more than one endpoint (as part of a linked list) and the parallel flag is true then the connector will look for a connection on any of the endpoints if it supports that behavior, otherwise an ENOTSUP errno will be set and the method will return false.

Definition at line 117 of file Profile_Transport_Resolver.cpp.

References try_connect_i().

Referenced by TAO_Default_Endpoint_Selector::select_endpoint().

00120   {
00121     return this->try_connect_i (desc, timeout, false);
00122   }

bool TAO::Profile_Transport_Resolver::try_connect_i TAO_Transport_Descriptor_Interface desc,
ACE_Time_Value val,
bool  parallel
[private]
 

Definition at line 134 of file Profile_Transport_Resolver.cpp.

References ACE_ASSERT, blocked_, TAO_Connector::connect(), TAO_ORB_Core::connector_registry(), TAO_Transport_Descriptor_Interface::endpoint(), ETIME, TAO::Transport_Selection_Guard::get(), get_connection_timeout(), TAO_Connector_Registry::get_connector(), TAO_Stub::orb_core(), TAO_Connector::parallel_connect(), TAO::Transport_Selection_Guard::set(), TAO_Endpoint::tag(), and TAO_TIMEOUT_CONNECT_MINOR_CODE.

Referenced by try_connect(), and try_parallel_connect().

00138   {
00139     TAO_Connector_Registry *conn_reg =
00140       this->stub_->orb_core ()->connector_registry ();
00141 
00142     if (conn_reg == 0)
00143       {
00144         throw ::CORBA::INTERNAL (
00145           CORBA::SystemException::_tao_minor_code (
00146             0,
00147             EINVAL),
00148           CORBA::COMPLETED_NO);
00149       }
00150 
00151     ACE_Time_Value connection_timeout;
00152     bool has_con_timeout = this->get_connection_timeout (connection_timeout);
00153 
00154     if (has_con_timeout && !this->blocked_)
00155       {
00156         timeout = &connection_timeout;
00157       }
00158     else if (has_con_timeout)
00159       {
00160         if (timeout == 0 || connection_timeout < *timeout)
00161           timeout = &connection_timeout;
00162         else
00163           has_con_timeout = false;
00164       }
00165     else if (!this->blocked_)
00166       {
00167         timeout = 0;
00168       }
00169 
00170     TAO_Connector *con = conn_reg->get_connector (desc->endpoint ()->tag ());
00171     ACE_ASSERT(con != 0);
00172     if (parallel)
00173       {
00174         this->transport_.set (con->parallel_connect (this, desc, timeout));
00175       }
00176     else
00177       {
00178         this->transport_.set (con->connect (this, desc, timeout));
00179       }
00180     // A timeout error occurred.
00181     // If the user has set a roundtrip timeout policy, throw a timeout
00182     // exception.  Otherwise, just fall through and return false to
00183     // look at the next endpoint.
00184     if (this->transport_.get () == 0 &&
00185         has_con_timeout == false &&
00186         errno == ETIME)
00187       {
00188         throw ::CORBA::TIMEOUT (
00189           CORBA::SystemException::_tao_minor_code (
00190             TAO_TIMEOUT_CONNECT_MINOR_CODE,
00191             errno),
00192           CORBA::COMPLETED_NO);
00193       }
00194     else if (this->transport_.get () == 0)
00195       {
00196         return false;
00197       }
00198 
00199     return true;
00200   }

bool TAO::Profile_Transport_Resolver::try_parallel_connect TAO_Transport_Descriptor_Interface desc,
ACE_Time_Value val
 

Definition at line 125 of file Profile_Transport_Resolver.cpp.

References try_connect_i().

Referenced by TAO_Default_Endpoint_Selector::select_endpoint().

00128   {
00129     return this->try_connect_i (desc, timeout, true);
00130   }

bool TAO::Profile_Transport_Resolver::use_parallel_connect void   )  const
 

This method wraps a call to the orb core to see if parallel connection attempts are even desired. This is controlled by the -ORBUseParallelConnects 1|0 commandline option.

Definition at line 203 of file Profile_Transport_Resolver.cpp.

References TAO_ORB_Core::client_factory(), TAO_Client_Strategy_Factory::connect_strategy(), TAO_Stub::orb_core(), TAO_ORB_Core::orb_params(), and TAO_ORB_Parameters::use_parallel_connects().

Referenced by TAO_Default_Endpoint_Selector::select_endpoint().

00204   {
00205     TAO_ORB_Core *oc = this->stub_->orb_core();
00206     return (oc->orb_params()->use_parallel_connects()
00207 #if 0       // it was decided that even with blocked connects
00208             // parallel connects could be useful, at least for cache
00209             // processing.
00210             oc->client_factory()->connect_strategy() !=
00211             TAO_Client_Strategy_Factory::TAO_BLOCKED_CONNECT
00212 #endif /* 0 */
00213             );
00214   }


Member Data Documentation

bool const TAO::Profile_Transport_Resolver::blocked_ [private]
 

Should we block while trying to make a connection.

Definition at line 204 of file Profile_Transport_Resolver.h.

Referenced by blocked_connect(), and try_connect_i().

CORBA::PolicyList* TAO::Profile_Transport_Resolver::inconsistent_policies_ [private]
 

List of inconsistent policies.

If current effective policies cause the invocation to raise CORBA::INV_POLICY exception, the conflicting/problematic policies are stored in this list. This is used by

Parameters:
Object::_validate_connection method to inform clients about causes of invocation failure.
Conflicting policies are only stored in this list if
Parameters:
init_inconsistent_policies method has been called prior to the beginning of invocation. This saves extra work of conflicting policies 'logging' when it's not needed.
Note:
We don't use _var with a reason. Using _var would involve including the header file for at least Policy_ForwardC.h, and that is what we precisely want to avoid.

Definition at line 198 of file Profile_Transport_Resolver.h.

Referenced by inconsistent_policies(), steal_inconsistent_policies(), and ~Profile_Transport_Resolver().

bool TAO::Profile_Transport_Resolver::is_released_ [mutable, private]
 

Has the transport been idle?

Definition at line 201 of file Profile_Transport_Resolver.h.

Referenced by transport_released(), and ~Profile_Transport_Resolver().

CORBA::Object* TAO::Profile_Transport_Resolver::obj_ [mutable, private]
 

Target object.

Definition at line 166 of file Profile_Transport_Resolver.h.

TAO_Profile* TAO::Profile_Transport_Resolver::profile_ [private]
 

The profile that has been selected for this invocation.

Definition at line 178 of file Profile_Transport_Resolver.h.

TAO_Stub* TAO::Profile_Transport_Resolver::stub_ [private]
 

Stub object for the target object.

Definition at line 169 of file Profile_Transport_Resolver.h.

TAO::Transport_Selection_Guard TAO::Profile_Transport_Resolver::transport_ [private]
 

The transport selected for this invocation.

Using the wrapper guard ensures it is available for use with the Transport Current interfaces.

Definition at line 175 of file Profile_Transport_Resolver.h.


The documentation for this class was generated from the following files:
Generated on Sun Jan 27 13:18:29 2008 for TAO by doxygen 1.3.6