Public Member Functions | Private Member Functions | Private Attributes

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::PolicyList * inconsistent_policies (void) const
CORBA::PolicyList * steal_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)
void operator= (const Profile_Transport_Resolver &)
 Profile_Transport_Resolver (const Profile_Transport_Resolver &)
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::PolicyList * inconsistent_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

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.

    : obj_ (p)
    , stub_ (stub)
    , transport_ (0)
    , profile_ (0)
    , inconsistent_policies_ (0)
    , is_released_ (false)
    , blocked_ (block)
  {
  }

TAO::Profile_Transport_Resolver::~Profile_Transport_Resolver ( void   ) 

Definition at line 37 of file Profile_Transport_Resolver.cpp.

  {
    if (this->profile_)
      {
        this->profile_->_decr_refcnt ();
      }

    if (this->transport_.get ())
      {
        if (this->is_released_ == false)
          {
            this->transport_->make_idle ();
          }

        this->transport_->remove_reference ();
      }

    delete this->inconsistent_policies_;
  }

TAO::Profile_Transport_Resolver::Profile_Transport_Resolver ( const Profile_Transport_Resolver  )  [private]

Member Function Documentation

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.

  {
    return this->blocked_;
  }

int TAO::Profile_Transport_Resolver::find_transport ( TAO_Transport_Descriptor_Interface desc  ) 

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 258 of file Profile_Transport_Resolver.cpp.

  {
    TAO::Transport_Cache_Manager & cache =
      this->profile_->orb_core()->lane_resources ().transport_cache();

    // the cache increments the reference count on the transport if
    // the find is successful. We want to return a "boolean" of 0 for
    // failure, 1 for success.
    size_t busy_count;
    TAO_Transport* tmp = this->transport_.get ();
    if (cache.find_transport(desc, tmp, busy_count) !=
        Transport_Cache_Manager::CACHE_FOUND_AVAILABLE)
      return 0;

    this->transport_.set (tmp);
    return 1;
  }

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 230 of file Profile_Transport_Resolver.cpp.

  {
    bool is_conn_timeout = false;

    // Check for the connection timout policy in the ORB
    this->stub_->orb_core ()->connection_timeout (this->stub_,
                                                  is_conn_timeout,
                                                  max_wait_time);

    return is_conn_timeout;
  }

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

Definition at line 62 of file Profile_Transport_Resolver.inl.

  {
    return this->inconsistent_policies_;
  }

void TAO::Profile_Transport_Resolver::init_inconsistent_policies ( void   ) 

Initialize the inconsistent policy list that this object has cached.

Definition at line 245 of file Profile_Transport_Resolver.cpp.

  {
    ACE_NEW_THROW_EX (this->inconsistent_policies_,
                      CORBA::PolicyList (0),
                      CORBA::NO_MEMORY (
                      CORBA::SystemException::_tao_minor_code (
                        0,
                        ENOMEM),
                      CORBA::COMPLETED_NO));
  }

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.

  {
    return this->obj_;
  }

void TAO::Profile_Transport_Resolver::operator= ( const Profile_Transport_Resolver  )  [private]
void TAO::Profile_Transport_Resolver::profile ( TAO_Profile pfile  ) 

Mutator for profile.

Definition at line 58 of file Profile_Transport_Resolver.cpp.

  {
    // Dont do anything if the incoming profile is null
    if (p)
      {
        // @note This is just a workaround for a more serious problem
        // with profile management. This would cover some potential
        // issues that Ossama is working on.  Ossama, please remove
        // them when you are done.
        TAO_Profile *tmp = this->profile_;

        (void) p->_incr_refcnt ();
        this->profile_ = p;

        if (tmp)
          {
            (void) tmp->_decr_refcnt ();
          }
      }
  }

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

Accessor for profile.

Definition at line 38 of file Profile_Transport_Resolver.inl.

  {
    return this->profile_;
  }

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 81 of file Profile_Transport_Resolver.cpp.

  {
    ACE_Countdown_Time countdown (max_time_val);

    TAO_Invocation_Endpoint_Selector *es =
      this->stub_->orb_core ()->endpoint_selector_factory ()->get_selector ();

    // Select the endpoint
    es->select_endpoint (this, max_time_val);

    if (this->transport_.get () == 0)
      {
        // No useable endpoint could be found. We will not
        // be able to send the message. Wait to throw an exception until
        // after the send_request interception point has been called.
        return;
      }

    TAO_GIOP_Message_Version const & version = this->profile_->version ();

    // Initialize the messaging object
    this->transport_->messaging_init (version);

    if (!this->transport_->is_tcs_set ())
      {
        TAO_Codeset_Manager * const tcm =
          this->stub_->orb_core ()->codeset_manager ();
        if (tcm)
          tcm->set_tcs (*this->profile_, *this->transport_);
      }
  }

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

Definition at line 68 of file Profile_Transport_Resolver.inl.

  {
    CORBA::PolicyList *tmp = this->inconsistent_policies_;
    this->inconsistent_policies_ = 0;
    return tmp;
  }

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

Accessor for TAO_Stub.

Definition at line 26 of file Profile_Transport_Resolver.inl.

  {
    return this->stub_;
  }

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.

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

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.

  {
    this->is_released_ = true;
  }

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 114 of file Profile_Transport_Resolver.cpp.

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

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

Definition at line 131 of file Profile_Transport_Resolver.cpp.

  {
    TAO_Connector_Registry *conn_reg =
      this->stub_->orb_core ()->connector_registry ();

    if (conn_reg == 0)
      {
        throw ::CORBA::INTERNAL (
          CORBA::SystemException::_tao_minor_code (
            0,
            EINVAL),
          CORBA::COMPLETED_NO);
      }

    ACE_Time_Value connection_timeout;
    bool has_con_timeout = this->get_connection_timeout (connection_timeout);

    if (has_con_timeout && !this->blocked_)
      {
        timeout = &connection_timeout;
      }
    else if (has_con_timeout)
      {
        if (timeout == 0 || connection_timeout < *timeout)
          timeout = &connection_timeout;
        else
          has_con_timeout = false;
      }
    else if (!this->blocked_)
      {
        timeout = 0;
      }

    TAO_Connector *con = conn_reg->get_connector (desc->endpoint ()->tag ());
    ACE_ASSERT(con != 0);
    if (parallel)
      {
        this->transport_.set (con->parallel_connect (this, desc, timeout));
      }
    else
      {
        this->transport_.set (con->connect (this, desc, timeout));
      }
    // A timeout error occurred.
    // If the user has set a roundtrip timeout policy, throw a timeout
    // exception.  Otherwise, just fall through and return false to
    // look at the next endpoint.
    if (this->transport_.get () == 0 &&
        has_con_timeout == false &&
        errno == ETIME)
      {
        throw ::CORBA::TIMEOUT (
          CORBA::SystemException::_tao_minor_code (
            TAO_TIMEOUT_CONNECT_MINOR_CODE,
            errno),
          CORBA::COMPLETED_NO);
      }
    else if (this->transport_.get () == 0)
      {
        return false;
      }
    else
      {
        // Determine the sync scope (if any)
        Messaging::SyncScope sync_scope;
        bool has_synchronization = false;
        this->stub_->orb_core ()->call_sync_scope_hook (this->stub_,
                                                        has_synchronization,
                                                        sync_scope);

        // If this stub has synchronization that's not "none", we need to
        // have the transport schedule output at the appropriate time.
        if (has_synchronization && sync_scope != Messaging::SYNC_NONE)
          {
            this->transport_->set_flush_in_post_open ();
          }
      }

    return true;
  }

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

Definition at line 122 of file Profile_Transport_Resolver.cpp.

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

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 216 of file Profile_Transport_Resolver.cpp.

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


Member Data Documentation

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

Should we block while trying to make a connection.

Definition at line 207 of file Profile_Transport_Resolver.h.

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 201 of file Profile_Transport_Resolver.h.

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

Has the transport been idle?

Definition at line 204 of file Profile_Transport_Resolver.h.

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

Target object.

Definition at line 169 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 181 of file Profile_Transport_Resolver.h.

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

Stub object for the target object.

Definition at line 172 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 178 of file Profile_Transport_Resolver.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines