Profile_Transport_Resolver.cpp File Reference

#include "tao/Profile_Transport_Resolver.h"
#include "tao/Profile.h"
#include "tao/Stub.h"
#include "tao/Transport.h"
#include "tao/Invocation_Endpoint_Selectors.h"
#include "tao/ORB_Core.h"
#include "tao/Thread_Lane_Resources.h"
#include "tao/Transport_Cache_Manager.h"
#include "tao/Transport_Descriptor_Interface.h"
#include "tao/Endpoint_Selector_Factory.h"
#include "tao/Codeset_Manager.h"
#include "tao/Connector_Registry.h"
#include "tao/Transport_Connector.h"
#include "tao/Endpoint.h"
#include "tao/SystemException.h"
#include "tao/Client_Strategy_Factory.h"
#include "ace/Countdown_Time.h"
#include "ace/CORBA_macros.h"
Include dependency graph for Profile_Transport_Resolver.cpp:

Go to the source code of this file.

Functions

 ACE_RCSID (tao, Profile_Transport_Resolver,"$Id: Profile_Transport_Resolver.cpp 84272 2009-01-30 11:58:40Z johnnyw $") 1 namespace TAO

Function Documentation

ACE_RCSID ( tao  ,
Profile_Transport_Resolver  ,
"$Id: Profile_Transport_Resolver.cpp 84272 2009-01-30 11:58:40Z johnnyw $"   
)

Definition at line 27 of file Profile_Transport_Resolver.cpp.

00029                : Profile_Transport_Resolver.cpp 84272 2009-01-30 11:58:40Z johnnyw $")
00030 
00031 
00032 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00033 
00034 namespace TAO
00035 {
00036 
00037   Profile_Transport_Resolver::~Profile_Transport_Resolver (void)
00038   {
00039     if (this->profile_)
00040       {
00041         this->profile_->_decr_refcnt ();
00042       }
00043 
00044     if (this->transport_.get ())
00045       {
00046         if (this->is_released_ == false)
00047           {
00048             this->transport_->make_idle ();
00049           }
00050 
00051         this->transport_->remove_reference ();
00052       }
00053 
00054     delete this->inconsistent_policies_;
00055   }
00056 
00057   void
00058   Profile_Transport_Resolver::profile (TAO_Profile *p)
00059   {
00060     // Dont do anything if the incoming profile is null
00061     if (p)
00062       {
00063         // @note This is just a workaround for a more serious problem
00064         // with profile management. This would cover some potential
00065         // issues that Ossama is working on.  Ossama, please remove
00066         // them when you are done.
00067         TAO_Profile *tmp = this->profile_;
00068 
00069         (void) p->_incr_refcnt ();
00070         this->profile_ = p;
00071 
00072         if (tmp)
00073           {
00074             (void) tmp->_decr_refcnt ();
00075           }
00076       }
00077   }
00078 
00079 
00080   void
00081   Profile_Transport_Resolver::resolve (ACE_Time_Value *max_time_val)
00082   {
00083     ACE_Countdown_Time countdown (max_time_val);
00084 
00085     TAO_Invocation_Endpoint_Selector *es =
00086       this->stub_->orb_core ()->endpoint_selector_factory ()->get_selector ();
00087 
00088     // Select the endpoint
00089     es->select_endpoint (this, max_time_val);
00090 
00091     if (this->transport_.get () == 0)
00092       {
00093         // No useable endpoint could be found. We will not
00094         // be able to send the message. Wait to throw an exception until
00095         // after the send_request interception point has been called.
00096         return;
00097       }
00098 
00099     TAO_GIOP_Message_Version const & version = this->profile_->version ();
00100 
00101     // Initialize the messaging object
00102     this->transport_->messaging_init (version);
00103 
00104     if (!this->transport_->is_tcs_set ())
00105       {
00106         TAO_Codeset_Manager * const tcm =
00107           this->stub_->orb_core ()->codeset_manager ();
00108         if (tcm)
00109           tcm->set_tcs (*this->profile_, *this->transport_);
00110       }
00111   }
00112 
00113   bool
00114   Profile_Transport_Resolver::try_connect (
00115       TAO_Transport_Descriptor_Interface *desc,
00116       ACE_Time_Value *timeout)
00117   {
00118     return this->try_connect_i (desc, timeout, false);
00119   }
00120 
00121   bool
00122   Profile_Transport_Resolver::try_parallel_connect (
00123        TAO_Transport_Descriptor_Interface *desc,
00124        ACE_Time_Value *timeout)
00125   {
00126     return this->try_connect_i (desc, timeout, true);
00127   }
00128 
00129 
00130   bool
00131   Profile_Transport_Resolver::try_connect_i (
00132        TAO_Transport_Descriptor_Interface *desc,
00133        ACE_Time_Value *timeout,
00134        bool parallel)
00135   {
00136     TAO_Connector_Registry *conn_reg =
00137       this->stub_->orb_core ()->connector_registry ();
00138 
00139     if (conn_reg == 0)
00140       {
00141         throw ::CORBA::INTERNAL (
00142           CORBA::SystemException::_tao_minor_code (
00143             0,
00144             EINVAL),
00145           CORBA::COMPLETED_NO);
00146       }
00147 
00148     ACE_Time_Value connection_timeout;
00149     bool has_con_timeout = this->get_connection_timeout (connection_timeout);
00150 
00151     if (has_con_timeout && !this->blocked_)
00152       {
00153         timeout = &connection_timeout;
00154       }
00155     else if (has_con_timeout)
00156       {
00157         if (timeout == 0 || connection_timeout < *timeout)
00158           timeout = &connection_timeout;
00159         else
00160           has_con_timeout = false;
00161       }
00162     else if (!this->blocked_)
00163       {
00164         timeout = 0;
00165       }
00166 
00167     TAO_Connector *con = conn_reg->get_connector (desc->endpoint ()->tag ());
00168     ACE_ASSERT(con != 0);
00169     if (parallel)
00170       {
00171         this->transport_.set (con->parallel_connect (this, desc, timeout));
00172       }
00173     else
00174       {
00175         this->transport_.set (con->connect (this, desc, timeout));
00176       }
00177     // A timeout error occurred.
00178     // If the user has set a roundtrip timeout policy, throw a timeout
00179     // exception.  Otherwise, just fall through and return false to
00180     // look at the next endpoint.
00181     if (this->transport_.get () == 0 &&
00182         has_con_timeout == false &&
00183         errno == ETIME)
00184       {
00185         throw ::CORBA::TIMEOUT (
00186           CORBA::SystemException::_tao_minor_code (
00187             TAO_TIMEOUT_CONNECT_MINOR_CODE,
00188             errno),
00189           CORBA::COMPLETED_NO);
00190       }
00191     else if (this->transport_.get () == 0)
00192       {
00193         return false;
00194       }
00195     else
00196       {
00197         // Determine the sync scope (if any)
00198         Messaging::SyncScope sync_scope;
00199         bool has_synchronization = false;
00200         this->stub_->orb_core ()->call_sync_scope_hook (this->stub_,
00201                                                         has_synchronization,
00202                                                         sync_scope);
00203 
00204         // If this stub has synchronization that's not "none", we need to
00205         // have the transport schedule output at the appropriate time.
00206         if (has_synchronization && sync_scope != Messaging::SYNC_NONE)
00207           {
00208             this->transport_->set_flush_in_post_open ();
00209           }
00210       }
00211 
00212     return true;
00213   }
00214 
00215   bool
00216   Profile_Transport_Resolver::use_parallel_connect (void) const
00217   {
00218     TAO_ORB_Core *oc = this->stub_->orb_core();
00219     return (oc->orb_params()->use_parallel_connects()
00220 #if 0       // it was decided that even with blocked connects
00221             // parallel connects could be useful, at least for cache
00222             // processing.
00223             oc->client_factory()->connect_strategy() !=
00224             TAO_Client_Strategy_Factory::TAO_BLOCKED_CONNECT
00225 #endif /* 0 */
00226             );
00227   }
00228 
00229   bool
00230   Profile_Transport_Resolver::get_connection_timeout (
00231     ACE_Time_Value &max_wait_time)
00232   {
00233     bool is_conn_timeout = false;
00234 
00235     // Check for the connection timout policy in the ORB
00236     this->stub_->orb_core ()->connection_timeout (this->stub_,
00237                                                   is_conn_timeout,
00238                                                   max_wait_time);
00239 
00240     return is_conn_timeout;
00241   }
00242 
00243 
00244   void
00245   Profile_Transport_Resolver::init_inconsistent_policies (void)
00246   {
00247     ACE_NEW_THROW_EX (this->inconsistent_policies_,
00248                       CORBA::PolicyList (0),
00249                       CORBA::NO_MEMORY (
00250                       CORBA::SystemException::_tao_minor_code (
00251                         0,
00252                         ENOMEM),
00253                       CORBA::COMPLETED_NO));
00254   }
00255 
00256 
00257   int
00258   Profile_Transport_Resolver::find_transport (TAO_Transport_Descriptor_Interface *desc)
00259   {
00260     TAO::Transport_Cache_Manager & cache =
00261       this->profile_->orb_core()->lane_resources ().transport_cache();
00262 
00263     // the cache increments the reference count on the transport if
00264     // the find is successful. We want to return a "boolean" of 0 for
00265     // failure, 1 for success.
00266     size_t busy_count;
00267     TAO_Transport* tmp = this->transport_.get ();
00268     if (cache.find_transport(desc, tmp, busy_count) !=
00269         Transport_Cache_Manager::CACHE_FOUND_AVAILABLE)
00270       return 0;
00271 
00272     this->transport_.set (tmp);
00273     return 1;
00274   }
00275 
00276 }

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on Sat Nov 21 23:27:30 2009 for TAO by  doxygen 1.6.1