Profile_Transport_Resolver.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    Profile_Transport_Resolver.h
00006  *
00007  *  $Id: Profile_Transport_Resolver.h 78128 2007-04-20 08:07:58Z johnnyw $
00008  *
00009  *
00010  *  @author Balachandran Natarajan <bala@dre.vanderbilt.edu>
00011  */
00012 //=============================================================================
00013 
00014 #ifndef TAO_PROFILE_TRANSPORT_RESOLVER_H
00015 #define TAO_PROFILE_TRANSPORT_RESOLVER_H
00016 
00017 #include /**/ "ace/pre.h"
00018 #include "ace/Global_Macros.h"
00019 
00020 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00021 # pragma once
00022 #endif /* ACE_LACKS_PRAGMA_ONCE */
00023 
00024 #include "tao/Transport_Selection_Guard.h"
00025 
00026 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00027 class ACE_Time_Value;
00028 ACE_END_VERSIONED_NAMESPACE_DECL
00029 
00030 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00031 
00032 class TAO_Stub;
00033 class TAO_Profile;
00034 class TAO_Transport;
00035 class TAO_Endpoint;
00036 class TAO_Transport_Descriptor_Interface;
00037 
00038 namespace CORBA
00039 {
00040   class Object;
00041   class PolicyList;
00042 
00043   class Object;
00044   typedef Object *Object_ptr;
00045 }
00046 
00047 namespace TAO
00048 {
00049   class Synch_Twoway_Invocation;
00050 
00051   /**
00052    * @class Profile_Transport_Resolver
00053    *
00054    * @brief Chooses the profile and a transport for a target object on
00055    * which an invocation can be made.
00056    *
00057    * A target object is represented by multiple profiles, which
00058    * theoretically provides multiple paths to the same target
00059    * object. This class helps in choosing the right profile, and pick
00060    * a transport from cache (or create a new transport if needed) that
00061    * represents the profile.
00062    */
00063   class TAO_Export Profile_Transport_Resolver
00064   {
00065   public:
00066     /// Constructor
00067     /**
00068      * With @a block we tell whether this resolved should always deliver
00069      * a connection by blocking or unblock before the connection is
00070      * completely established. Please note that this has *nothing* to
00071      * do with the synchronous or asynch connect strategy used for
00072      * making connections. This is a local flag used by the clients of
00073      * this to dictate some local behavior.
00074      */
00075     Profile_Transport_Resolver (CORBA::Object *p,
00076                                 TAO_Stub *stub,
00077                                 bool block = true);
00078 
00079     ~Profile_Transport_Resolver (void);
00080 
00081     /// Method where the bunch of the action takes place.
00082     /**
00083      * This is the entry point from the TAO::Invocation_Adapter
00084      * class. This method accesses the endpoint selector factory from
00085      * the ORB_Core to decide on the strategy to be used for selecting
00086      * the profile.
00087      */
00088     void resolve (ACE_Time_Value *val);
00089 
00090     //@{
00091     /**
00092      * @name Accessors and mutators for this class. The following methods
00093      * are used by the clients of this class to access strategies and
00094      * other internal workings.
00095      */
00096 
00097     /// Mutator for profile.
00098     void profile (TAO_Profile *pfile);
00099 
00100     /// Accessor for profile.
00101     TAO_Profile *profile (void) const;
00102 
00103     /// Accessor for TAO_Stub
00104     TAO_Stub *stub (void) const;
00105 
00106     /// Accessor for the target in use
00107     CORBA::Object *object (void) const;
00108 
00109     /// Accessor for the transport reserved for this invocation.
00110     TAO_Transport *transport (void) const;
00111 
00112     /// See if the transport cache has an available transport and
00113     /// use that one rather than trying to connect via the connector.
00114     /// Separating this functionality enables the look up of many
00115     /// endpoints before trying the more time-consuming trip through
00116     /// the actual connector.
00117     int find_transport (TAO_Transport_Descriptor_Interface *);
00118 
00119     /// Accessor to indicate whether we should block while
00120     /// establishing a connection.
00121     bool blocked_connect (void) const;
00122     //@}
00123 
00124     /// Signal to let the resolver know that the transport has been
00125     /// released back to the cache.
00126     void transport_released (void) const;
00127 
00128     /// This is a callback method used by the endpoint selectors to
00129     /// delegate the responsibility of reserving a transport from the
00130     /// connection cache for this invocation. When the descriptor
00131     /// contains more than one endpoint (as part of a linked list) and
00132     /// the parallel flag is true then the connector will look for a
00133     /// connection on any of the endpoints if it supports that
00134     /// behavior, otherwise an ENOTSUP errno will be set and the
00135     /// method will return false.
00136     bool try_connect (TAO_Transport_Descriptor_Interface *desc,
00137                       ACE_Time_Value *val);
00138 
00139     bool try_parallel_connect (TAO_Transport_Descriptor_Interface *desc,
00140                                ACE_Time_Value *val);
00141 
00142     /// This method wraps a call to the orb core to see if parallel
00143     /// connection attempts are even desired. This is controlled by
00144     /// the -ORBUseParallelConnects 1|0 commandline option.
00145     bool use_parallel_connect (void) const;
00146 
00147     /// Initialize the inconsistent policy list that this object has
00148     /// cached.
00149     void init_inconsistent_policies (void);
00150 
00151     CORBA::PolicyList *inconsistent_policies (void) const;
00152 
00153     CORBA::PolicyList *steal_inconsistent_policies (void);
00154   private:
00155 
00156     /// Helper method to access get the connection timeout from the
00157     /// ORB.
00158     bool get_connection_timeout (ACE_Time_Value &max_wait_time);
00159 
00160   private:
00161     bool try_connect_i (TAO_Transport_Descriptor_Interface *desc,
00162                         ACE_Time_Value *val,
00163                         bool parallel);
00164 
00165     /// Target object
00166     mutable CORBA::Object *obj_;
00167 
00168     /// Stub object for the target object.
00169     TAO_Stub *stub_;
00170 
00171     /// The transport selected for this invocation.
00172 
00173     /// Using the wrapper guard ensures it is available for use with
00174     /// the Transport Current interfaces.
00175     TAO::Transport_Selection_Guard transport_;
00176 
00177     /// The profile that has been selected for this invocation.
00178     TAO_Profile *profile_;
00179 
00180     /// List of inconsistent policies
00181     /**
00182      * If current effective policies cause the invocation to raise
00183      * CORBA::INV_POLICY exception, the conflicting/problematic policies
00184      * are stored in this list.  This is used by \param
00185      * Object::_validate_connection method to inform clients about
00186      * causes of invocation failure.
00187      * @par
00188      * Conflicting policies are only stored in this list if \param
00189      * init_inconsistent_policies method has been called prior to the
00190      * beginning of invocation.  This saves extra work of conflicting
00191      * policies 'logging' when it's not needed.
00192      *
00193      * @note We don't use _var with a reason. Using _var would
00194      * involve including the  header file for at least
00195      * Policy_ForwardC.h, and that is what we precisely want to
00196      * avoid.
00197      */
00198     CORBA::PolicyList *inconsistent_policies_;
00199 
00200     /// Has the transport been idle?
00201     mutable bool is_released_;
00202 
00203     /// Should we block while trying to make a connection
00204     bool const blocked_;
00205   };
00206 } // TAO namespace end
00207 
00208 TAO_END_VERSIONED_NAMESPACE_DECL
00209 
00210 #if defined (__ACE_INLINE__)
00211 # include "tao/Profile_Transport_Resolver.inl"
00212 #endif /* __ACE_INLINE__ */
00213 
00214 #include /**/ "ace/post.h"
00215 
00216 #endif /*TAO_PROFILE_TRANSPORT_RESOLVER_H*/

Generated on Tue Feb 2 17:37:52 2010 for TAO by  doxygen 1.4.7