OpenDDS::DCPS::TransportImpl Class Reference

#include <TransportImpl.h>

Inheritance diagram for OpenDDS::DCPS::TransportImpl:
Inheritance graph
[legend]
Collaboration diagram for OpenDDS::DCPS::TransportImpl:
Collaboration graph
[legend]

List of all members.

Classes

struct  AcceptConnectResult
struct  ConnectionAttribs
struct  RemoteTransport

Public Types

typedef ACE_SYNCH_MUTEX LockType
typedef ACE_Guard< LockTypeGuardType

Public Member Functions

virtual ~TransportImpl ()
virtual void unbind_link (DataLink *link)
 Remove any pending_release mappings.
bool release_link_resources (DataLink *link)
TransportInstconfig () const
virtual bool connection_info_i (TransportLocator &local_info) const =0
virtual void register_for_reader (const RepoId &, const RepoId &, const RepoId &, const TransportLocatorSeq &, OpenDDS::DCPS::DiscoveryListener *)
virtual void unregister_for_reader (const RepoId &, const RepoId &, const RepoId &)
virtual void register_for_writer (const RepoId &, const RepoId &, const RepoId &, const TransportLocatorSeq &, DiscoveryListener *)
virtual void unregister_for_writer (const RepoId &, const RepoId &, const RepoId &)
ACE_Reactor_Timer_Interfacetimer () const
 Interface to the transport's reactor for scheduling timers.
ACE_Reactorreactor () const
ACE_thread_t reactor_owner () const
bool is_shut_down () const
void create_reactor_task (bool useAsyncSend=false)
void dump ()
 Diagnostic aid.
OPENDDS_STRING dump_to_str ()
void report ()
int acquire ()
int tryacquire ()
int release ()
int remove ()
virtual OPENDDS_STRING transport_type () const =0
bool connection_info (TransportLocator &local_info) const

Public Attributes

LockType lock_
 Lock to protect the config_ and reactor_task_ data members.
TransportInstconfig_
TransportReactorTask_rch reactor_task_
DataLinkCleanupTask dl_clean_task_
 smart ptr to the associated DL cleanup task
Monitormonitor_
 Monitor object for this entity.

Protected Member Functions

 TransportImpl (TransportInst &config)
bool open ()
virtual AcceptConnectResult connect_datalink (const RemoteTransport &remote, const ConnectionAttribs &attribs, const TransportClient_rch &client)=0
virtual AcceptConnectResult accept_datalink (const RemoteTransport &remote, const ConnectionAttribs &attribs, const TransportClient_rch &client)=0
virtual void stop_accepting_or_connecting (const TransportClient_wrch &client, const RepoId &remote_id)=0
virtual void shutdown_i ()=0
TransportReactorTask_rch reactor_task ()
typedef OPENDDS_MULTIMAP (TransportClient_wrch, DataLink_rch) PendConnMap
void add_pending_connection (const TransportClient_rch &client, DataLink_rch link)
void shutdown ()

Protected Attributes

PendConnMap pending_connections_
std::size_t last_link_
 Id of the last link established.
bool is_shut_down_

Private Member Functions

virtual void release_datalink (DataLink *link)=0
DataLinkfind_connect_i (const RepoId &local_id, const AssociationData &remote_association, const ConnectionAttribs &attribs, bool active, bool connect)

Friends

class TransportInst
class TransportClient
class DataLink

Detailed Description

The TransportImpl class includes the abstract methods that must be implemented by any implementation to provide data delivery service to the DCPS implementation. This includes methods to send data, received data, configure the operation, and manage associations and datalinks between local and remote objects of the implementation.

Notes about object ownership: 1)Has longer lifetime than the publisher and subscriber objects. The publishers and subscribers are owned by the DomainParticipant and transport factory shutdown is always after DomainParticipant factory shutdown. 2)The concrete transport object owns the datalink objects. 3)Own a DataLinkCleanup object. 4)Reference to TransportInst object and TransportReactorTask object owned by TransportRegistry. 5)During transport shutdown, if this object does not have ownership of an object but has a references via smart pointer then the reference should be freed; if this object has ownership of task objects then the tasks should be closed.

Definition at line 62 of file TransportImpl.h.


Member Typedef Documentation

typedef ACE_SYNCH_MUTEX OpenDDS::DCPS::TransportImpl::LockType

Constructor & Destructor Documentation

OpenDDS::DCPS::TransportImpl::~TransportImpl (  )  [virtual]

Definition at line 44 of file TransportImpl.cpp.

References DBG_ENTRY_LVL.

00045 {
00046   DBG_ENTRY_LVL("TransportImpl", "~TransportImpl", 6);
00047 }

OpenDDS::DCPS::TransportImpl::TransportImpl ( TransportInst config  )  [protected]

Definition at line 32 of file TransportImpl.cpp.

References DBG_ENTRY_LVL, monitor_, and TheServiceParticipant.

00033   : config_(config)
00034   , monitor_(0)
00035   , last_link_(0)
00036   , is_shut_down_(false)
00037 {
00038   DBG_ENTRY_LVL("TransportImpl", "TransportImpl", 6);
00039   if (TheServiceParticipant->monitor_factory_) {
00040     monitor_ = TheServiceParticipant->monitor_factory_->create_transport_monitor(this);
00041   }
00042 }


Member Function Documentation

virtual AcceptConnectResult OpenDDS::DCPS::TransportImpl::accept_datalink ( const RemoteTransport remote,
const ConnectionAttribs attribs,
const TransportClient_rch client 
) [protected, pure virtual]

accept_datalink() is called from TransportClient to initiate an association as the passive peer. A DataLink may be returned if one is already connected and ready to use, otherwise passively wait for a physical connection from the active side (either in the form of a connection event or handshaking message). Upon completion of the physical connection, the transport calls back to TransportClient::use_datalink().

Implemented in OpenDDS::DCPS::MulticastTransport, OpenDDS::DCPS::RtpsUdpTransport, OpenDDS::DCPS::ShmemTransport, OpenDDS::DCPS::TcpTransport, and OpenDDS::DCPS::UdpTransport.

int OpenDDS::DCPS::TransportImpl::acquire (  ) 

Called by our friends, the TransportClient, and the DataLink. Since this TransportImpl can be attached to many TransportClient objects, and each TransportClient object could be "running" in a separate thread, we need to protect all of the "reservation" methods with a lock. The protocol is that a client of ours must "acquire" our reservation_lock_ before it can proceed to call any methods that affect the DataLink reservations. It should release the reservation_lock_ as soon as it is done.

void OpenDDS::DCPS::TransportImpl::add_pending_connection ( const TransportClient_rch client,
DataLink_rch  link 
) [protected]

Definition at line 103 of file TransportImpl.cpp.

References pending_connections_.

Referenced by OpenDDS::DCPS::TcpTransport::accept_datalink(), OpenDDS::DCPS::TcpTransport::connect_datalink(), OpenDDS::DCPS::RtpsUdpTransport::connect_datalink(), and OpenDDS::DCPS::TcpTransport::find_datalink_i().

00104 {
00105   pending_connections_.insert( PendConnMap::value_type(client, link));
00106 }

Here is the caller graph for this function:

OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE OpenDDS::DCPS::TransportInst & OpenDDS::DCPS::TransportImpl::config (  )  const

Expose the configuration information so others can see what we can do.

Reimplemented in OpenDDS::DCPS::MulticastTransport, OpenDDS::DCPS::RtpsUdpTransport, OpenDDS::DCPS::ShmemTransport, OpenDDS::DCPS::TcpTransport, and OpenDDS::DCPS::UdpTransport.

Definition at line 19 of file TransportImpl.inl.

References config_.

Referenced by OpenDDS::DCPS::DataLink::DataLink(), and OpenDDS::DCPS::TransportSendStrategy::direct_send().

00020 {
00021   return this->config_;
00022 }

Here is the caller graph for this function:

virtual AcceptConnectResult OpenDDS::DCPS::TransportImpl::connect_datalink ( const RemoteTransport remote,
const ConnectionAttribs attribs,
const TransportClient_rch client 
) [protected, pure virtual]

connect_datalink() is called from TransportClient to initiate an association as the active peer. A DataLink may be returned if one is already connected and ready to use, otherwise initiate a connection to the passive side and return from this method. Upon completion of the physical connection, the transport calls back to TransportClient::use_datalink().

Implemented in OpenDDS::DCPS::MulticastTransport, OpenDDS::DCPS::RtpsUdpTransport, OpenDDS::DCPS::ShmemTransport, OpenDDS::DCPS::TcpTransport, and OpenDDS::DCPS::UdpTransport.

Referenced by OpenDDS::DCPS::TransportClient::initiate_connect_i().

Here is the caller graph for this function:

ACE_INLINE bool OpenDDS::DCPS::TransportImpl::connection_info ( TransportLocator local_info  )  const

Called by our friend, the TransportClient. Accessor for the TransportInterfaceInfo. Accepts a reference to a TransportInterfaceInfo object that will be "populated" with this TransportImpl's connection information (ie, how another process would connect to this TransportImpl).

Definition at line 52 of file TransportImpl.inl.

Referenced by OpenDDS::DCPS::TransportClient::enable_transport_using_config().

00053 {
00054   return this->connection_info_i(local_info);
00055 }

Here is the caller graph for this function:

virtual bool OpenDDS::DCPS::TransportImpl::connection_info_i ( TransportLocator local_info  )  const [pure virtual]

Called by our connection_info() method to allow the concrete TransportImpl subclass to do the dirty work since it really is the one that knows how to populate the supplied TransportLocator object.

Implemented in OpenDDS::DCPS::MulticastTransport, OpenDDS::DCPS::RtpsUdpTransport, OpenDDS::DCPS::ShmemTransport, OpenDDS::DCPS::TcpTransport, and OpenDDS::DCPS::UdpTransport.

Referenced by OpenDDS::DCPS::UdpDataLink::open().

Here is the caller graph for this function:

void OpenDDS::DCPS::TransportImpl::create_reactor_task ( bool  useAsyncSend = false  ) 

Create the reactor task using sync send or optionally async send by parameter on supported Windows platforms only.

Definition at line 109 of file TransportImpl.cpp.

References OpenDDS::DCPS::RcHandle< T >::in(), is_shut_down_, and reactor_task_.

Referenced by OpenDDS::DCPS::UdpTransport::configure_i(), OpenDDS::DCPS::TcpTransport::configure_i(), OpenDDS::DCPS::RtpsUdpTransport::configure_i(), and OpenDDS::DCPS::MulticastTransport::configure_i().

00110 {
00111   if (is_shut_down_ || this->reactor_task_.in()) {
00112     return;
00113   }
00114 
00115   this->reactor_task_= make_rch<TransportReactorTask>(useAsyncSend);
00116   if (0 != this->reactor_task_->open(0)) {
00117     throw Transport::MiscProblem(); // error already logged by TRT::open()
00118   }
00119 }

Here is the call graph for this function:

Here is the caller graph for this function:

void OpenDDS::DCPS::TransportImpl::dump ( void   ) 

Diagnostic aid.

Definition at line 149 of file TransportImpl.cpp.

References ACE_TEXT(), dump_to_str(), and LM_DEBUG.

00150 {
00151   ACE_DEBUG((LM_DEBUG,
00152              ACE_TEXT("(%P|%t) TransportImpl::dump() -\n%C"),
00153              dump_to_str().c_str()));
00154 }

Here is the call graph for this function:

OPENDDS_STRING OpenDDS::DCPS::TransportImpl::dump_to_str (  ) 

Definition at line 157 of file TransportImpl.cpp.

References config_, and OpenDDS::DCPS::TransportInst::dump_to_str().

Referenced by dump(), and open().

00158 {
00159   return config_.dump_to_str();
00160 }

Here is the call graph for this function:

Here is the caller graph for this function:

DataLink* OpenDDS::DCPS::TransportImpl::find_connect_i ( const RepoId local_id,
const AssociationData remote_association,
const ConnectionAttribs attribs,
bool  active,
bool  connect 
) [private]
bool OpenDDS::DCPS::TransportImpl::is_shut_down (  )  const
bool OpenDDS::DCPS::TransportImpl::open ( void   )  [protected]

Definition at line 75 of file TransportImpl.cpp.

References ACE_TEXT(), dl_clean_task_, dump_to_str(), LM_DEBUG, LM_ERROR, monitor_, OpenDDS::DCPS::QueueTaskBase< T >::open(), OpenDDS::DCPS::Monitor::report(), and OpenDDS::DCPS::Transport_debug_level.

Referenced by OpenDDS::DCPS::MulticastTransport::MulticastTransport(), OpenDDS::DCPS::RtpsUdpTransport::RtpsUdpTransport(), OpenDDS::DCPS::ShmemTransport::ShmemTransport(), OpenDDS::DCPS::TcpTransport::TcpTransport(), and OpenDDS::DCPS::UdpTransport::UdpTransport().

00076 {
00077   // Open the DL Cleanup task
00078   // We depend upon the existing config logic to ensure the
00079   // DL Cleanup task is opened only once
00080   if (this->dl_clean_task_.open()) {
00081     ACE_ERROR_RETURN((LM_ERROR,
00082                       "(%P|%t) ERROR: DL Cleanup task failed to open : %p\n",
00083                       ACE_TEXT("open")), false);
00084   }
00085 
00086   // Success.
00087   if (this->monitor_) {
00088     this->monitor_->report();
00089   }
00090 
00091   if (Transport_debug_level > 0) {
00092 
00093     ACE_DEBUG((LM_DEBUG,
00094                ACE_TEXT("(%P|%t) TransportImpl::open()\n%C"),
00095                dump_to_str().c_str()));
00096   }
00097 
00098 
00099   return true;
00100 }

Here is the call graph for this function:

Here is the caller graph for this function:

typedef OpenDDS::DCPS::TransportImpl::OPENDDS_MULTIMAP ( TransportClient_wrch  ,
DataLink_rch   
) [protected]
ACE_INLINE ACE_Reactor * OpenDDS::DCPS::TransportImpl::reactor ( void   )  const

Definition at line 38 of file TransportImpl.inl.

References OpenDDS::DCPS::RcHandle< T >::is_nil(), and reactor_task_.

Referenced by timer().

00039 {
00040   TransportReactorTask_rch task = this->reactor_task_;
00041   return task.is_nil() ? 0 : task->get_reactor();
00042 }

Here is the call graph for this function:

Here is the caller graph for this function:

ACE_INLINE ACE_thread_t OpenDDS::DCPS::TransportImpl::reactor_owner (  )  const

Definition at line 45 of file TransportImpl.inl.

References reactor_task_.

00046 {
00047   return this->reactor_task_->get_reactor_owner();
00048 }

ACE_INLINE OpenDDS::DCPS::TransportReactorTask_rch OpenDDS::DCPS::TransportImpl::reactor_task (  )  [protected]

Accessor to obtain a "copy" of the reference to the reactor task. Caller is responsible for the "copy" of the reference that is returned.

Definition at line 25 of file TransportImpl.inl.

References DBG_ENTRY_LVL, and reactor_task_.

Referenced by OpenDDS::DCPS::TcpTransport::configure_i(), OpenDDS::DCPS::TcpTransport::connect_tcp_datalink(), OpenDDS::DCPS::UdpTransport::make_datalink(), OpenDDS::DCPS::RtpsUdpTransport::make_datalink(), OpenDDS::DCPS::MulticastTransport::make_datalink(), and OpenDDS::DCPS::DataLink::notify_reactor().

00026 {
00027   DBG_ENTRY_LVL("TransportImpl","reactor_task",6);
00028   return this->reactor_task_;
00029 }

Here is the caller graph for this function:

virtual void OpenDDS::DCPS::TransportImpl::register_for_reader ( const RepoId ,
const RepoId ,
const RepoId ,
const TransportLocatorSeq ,
OpenDDS::DCPS::DiscoveryListener  
) [inline, virtual]

Reimplemented in OpenDDS::DCPS::RtpsUdpTransport.

Definition at line 85 of file TransportImpl.h.

00089                                                                                { }

virtual void OpenDDS::DCPS::TransportImpl::register_for_writer ( const RepoId ,
const RepoId ,
const RepoId ,
const TransportLocatorSeq ,
DiscoveryListener  
) [inline, virtual]

Reimplemented in OpenDDS::DCPS::RtpsUdpTransport.

Definition at line 95 of file TransportImpl.h.

00099                                                                     { }

int OpenDDS::DCPS::TransportImpl::release (  ) 
virtual void OpenDDS::DCPS::TransportImpl::release_datalink ( DataLink link  )  [private, pure virtual]

Called by the TransportRegistry when this TransportImpl object is released while the TransportRegistry is handling a release() "event". The DataLink itself calls this method when it thinks it is no longer used for any associations. This occurs during a "remove associations" operation being performed by some TransportClient that uses this TransportImpl. The TransportClient is known to have acquired our reservation_lock_, so there won't be any reserve_datalink() calls being made from any other threads while we perform this release.

Implemented in OpenDDS::DCPS::MulticastTransport, OpenDDS::DCPS::RtpsUdpTransport, OpenDDS::DCPS::ShmemTransport, OpenDDS::DCPS::TcpTransport, and OpenDDS::DCPS::UdpTransport.

Referenced by OpenDDS::DCPS::DataLink::release_reservations().

Here is the caller graph for this function:

bool OpenDDS::DCPS::TransportImpl::release_link_resources ( DataLink link  ) 

Callback from the DataLink to clean up any associated resources. This usually is done when the DataLink is lost. The call is made with no transport/DCPS locks held.

Definition at line 130 of file TransportImpl.cpp.

References OpenDDS::DCPS::QueueTaskBase< T >::add(), DBG_ENTRY_LVL, dl_clean_task_, and OpenDDS::DCPS::rchandle_from().

Referenced by OpenDDS::DCPS::DataLink::release_resources().

00131 {
00132   DBG_ENTRY_LVL("TransportImpl", "release_link_resources",6);
00133 
00134   // Create a smart pointer without ownership (bumps up ref count)
00135   dl_clean_task_.add(rchandle_from(link));
00136 
00137   return true;
00138 }

Here is the call graph for this function:

Here is the caller graph for this function:

int OpenDDS::DCPS::TransportImpl::remove (  ) 
void OpenDDS::DCPS::TransportImpl::report ( void   ) 

Definition at line 141 of file TransportImpl.cpp.

References monitor_, and OpenDDS::DCPS::Monitor::report().

00142 {
00143   if (this->monitor_) {
00144     this->monitor_->report();
00145   }
00146 }

Here is the call graph for this function:

void OpenDDS::DCPS::TransportImpl::shutdown ( void   )  [protected]

Definition at line 56 of file TransportImpl.cpp.

References OpenDDS::DCPS::QueueTaskBase< T >::close(), DBG_ENTRY_LVL, dl_clean_task_, OpenDDS::DCPS::RcHandle< T >::is_nil(), is_shut_down_, reactor_task_, and shutdown_i().

Referenced by OpenDDS::DCPS::TcpTransport::TcpTransport().

00057 {
00058   DBG_ENTRY_LVL("TransportImpl", "shutdown", 6);
00059 
00060   is_shut_down_ = true;
00061 
00062   // Stop datalink clean task.
00063   this->dl_clean_task_.close(1);
00064 
00065   if (!this->reactor_task_.is_nil()) {
00066     this->reactor_task_->stop();
00067   }
00068 
00069   // Tell our subclass about the "shutdown event".
00070   this->shutdown_i();
00071 }

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void OpenDDS::DCPS::TransportImpl::shutdown_i (  )  [protected, pure virtual]

Called during the shutdown() method in order to give the concrete TransportImpl subclass a chance to do something when the shutdown "event" occurs.

Implemented in OpenDDS::DCPS::MulticastTransport, OpenDDS::DCPS::RtpsUdpTransport, OpenDDS::DCPS::ShmemTransport, OpenDDS::DCPS::TcpTransport, and OpenDDS::DCPS::UdpTransport.

Referenced by shutdown().

Here is the caller graph for this function:

virtual void OpenDDS::DCPS::TransportImpl::stop_accepting_or_connecting ( const TransportClient_wrch client,
const RepoId remote_id 
) [protected, pure virtual]

stop_accepting_or_connecting() is called from TransportClient to terminate the accepting process begun by accept_datalink() or connect_datalink(). This allows the TransportImpl to clean up any resources associated with this pending connection. The TransportClient* passed in to accept or connect is not valid after this method is called.

Implemented in OpenDDS::DCPS::MulticastTransport, OpenDDS::DCPS::RtpsUdpTransport, OpenDDS::DCPS::ShmemTransport, OpenDDS::DCPS::TcpTransport, and OpenDDS::DCPS::UdpTransport.

ACE_INLINE ACE_Reactor_Timer_Interface * OpenDDS::DCPS::TransportImpl::timer ( void   )  const

Interface to the transport's reactor for scheduling timers.

Definition at line 32 of file TransportImpl.inl.

References reactor().

Referenced by OpenDDS::DCPS::DataLink::handle_exception(), and OpenDDS::DCPS::DataLink::transport_shutdown().

00033 {
00034   return reactor();
00035 }

Here is the call graph for this function:

Here is the caller graph for this function:

virtual OPENDDS_STRING OpenDDS::DCPS::TransportImpl::transport_type (  )  const [pure virtual]
int OpenDDS::DCPS::TransportImpl::tryacquire (  ) 
void OpenDDS::DCPS::TransportImpl::unbind_link ( DataLink link  )  [virtual]

Remove any pending_release mappings.

Reimplemented in OpenDDS::DCPS::TcpTransport.

Definition at line 123 of file TransportImpl.cpp.

References DBG_ENTRY_LVL.

Referenced by OpenDDS::DCPS::DataLink::handle_timeout().

00124 {
00125   // may be overridden by subclass
00126   DBG_ENTRY_LVL("TransportImpl", "unbind_link",6);
00127 }

Here is the caller graph for this function:

virtual void OpenDDS::DCPS::TransportImpl::unregister_for_reader ( const RepoId ,
const RepoId ,
const RepoId  
) [inline, virtual]

Reimplemented in OpenDDS::DCPS::RtpsUdpTransport.

Definition at line 91 of file TransportImpl.h.

00093                                                                  { }

virtual void OpenDDS::DCPS::TransportImpl::unregister_for_writer ( const RepoId ,
const RepoId ,
const RepoId  
) [inline, virtual]

Reimplemented in OpenDDS::DCPS::RtpsUdpTransport.

Definition at line 101 of file TransportImpl.h.

00103                                                                  { }


Friends And Related Function Documentation

friend class DataLink [friend]

Definition at line 213 of file TransportImpl.h.

friend class TransportClient [friend]

Definition at line 212 of file TransportImpl.h.

friend class TransportInst [friend]

We have a few friends in the transport framework so that they can access our private methods. We do this to avoid pollution of our public interface with internal framework methods.

Definition at line 211 of file TransportImpl.h.


Member Data Documentation

A reference to the TransportInst object that was supplied to us during our configure() method.

Definition at line 267 of file TransportImpl.h.

Referenced by config(), and dump_to_str().

smart ptr to the associated DL cleanup task

Definition at line 274 of file TransportImpl.h.

Referenced by open(), release_link_resources(), and shutdown().

Definition at line 282 of file TransportImpl.h.

Referenced by create_reactor_task(), is_shut_down(), and shutdown().

Id of the last link established.

Definition at line 281 of file TransportImpl.h.

Referenced by OpenDDS::DCPS::TcpTransport::connect_tcp_datalink().

Lock to protect the config_ and reactor_task_ data members.

Definition at line 263 of file TransportImpl.h.

Monitor object for this entity.

Definition at line 277 of file TransportImpl.h.

Referenced by open(), report(), and TransportImpl().

The reactor (task) object - may not even be used if the concrete subclass (of TransportImpl) doesn't require a reactor.

Definition at line 271 of file TransportImpl.h.

Referenced by create_reactor_task(), reactor(), reactor_owner(), reactor_task(), and shutdown().


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

Generated on 10 Aug 2018 for OpenDDS by  doxygen 1.6.1