IBR-DTNSuite  0.10
dtn::net::HTTPConvergenceLayer Class Reference

#include <HTTPConvergenceLayer.h>

Inheritance diagram for dtn::net::HTTPConvergenceLayer:
Inheritance graph
Collaboration diagram for dtn::net::HTTPConvergenceLayer:
Collaboration graph

Public Member Functions

 HTTPConvergenceLayer (const std::string &server)
 
virtual ~HTTPConvergenceLayer ()
 
dtn::core::Node::Protocol getDiscoveryProtocol () const
 
void queue (const dtn::core::Node &n, const dtn::net::BundleTransfer &job)
 
virtual const std::string getName () const
 
- Public Member Functions inherited from dtn::net::ConvergenceLayer
virtual ~ConvergenceLayer ()=0
 
virtual void open (const dtn::core::Node &)
 
virtual void resetStats ()
 
virtual const stats_mapgetStats ()
 
- Public Member Functions inherited from dtn::daemon::IndependentComponent
 IndependentComponent ()
 
virtual ~IndependentComponent ()
 
virtual void initialize () throw ()
 
virtual void startup () throw ()
 
virtual void terminate () throw ()
 
- Public Member Functions inherited from dtn::daemon::Component
virtual ~Component ()=0
 

Protected Member Functions

virtual void componentUp () throw ()
 
virtual void componentRun () throw ()
 
virtual void componentDown () throw ()
 
void __cancellation () throw ()
 
- Protected Member Functions inherited from dtn::net::ConvergenceLayer
virtual void addStats (const std::string &tag, const size_t value)
 
virtual void setStats (const std::string &tag, const size_t value)
 
- Protected Member Functions inherited from dtn::daemon::IndependentComponent
void run () throw ()
 
- Protected Member Functions inherited from ibrcommon::JoinableThread
virtual ~JoinableThread ()=0
 
void join (void) throw (ThreadException)
 
bool isRunning (void)
 
void start (int priority=0) throw (ThreadException)
 
void stop () throw ()
 
 JoinableThread (size_t size=DEFAULT_STACKSIZE)
 

Additional Inherited Members

- Public Types inherited from dtn::net::ConvergenceLayer
typedef std::map< std::string,
size_t > 
stats_map
 

Detailed Description

Definition at line 65 of file HTTPConvergenceLayer.h.

Constructor & Destructor Documentation

dtn::net::HTTPConvergenceLayer::HTTPConvergenceLayer ( const std::string &  server)

HTTPConvergenceLayer constructor calls the curl_global_init() method to initialize curl global. Furthermore the attributes _server _push_iob and _running will be set.

Parameters
serverThe server parameter contains the Tomcat-Server URL

Definition at line 102 of file HTTPConvergenceLayer.cpp.

dtn::net::HTTPConvergenceLayer::~HTTPConvergenceLayer ( )
virtual

HTTPConvergenceLayer destructor, when the destructor is calling it calls the curl_global_cleanup() method to clean curl sessions.

Definition at line 113 of file HTTPConvergenceLayer.cpp.

Member Function Documentation

void dtn::net::HTTPConvergenceLayer::__cancellation ( ) throw ()
protectedvirtual

This method is from IndependentComponent interface. It could abort the componentRun() thread on the hard way.

Implements dtn::daemon::IndependentComponent.

Definition at line 390 of file HTTPConvergenceLayer.cpp.

References ibrcommon::iobuffer::finalize().

Here is the call graph for this function:

void dtn::net::HTTPConvergenceLayer::componentDown ( ) throw ()
protectedvirtual

This method is from IndependentComponent interface and is called when the IBR-DTN is shutting down. This method trys to stop the DownloadThread and to finalize the iobuffer, for a clean shut down.

Implements dtn::daemon::IndependentComponent.

Definition at line 382 of file HTTPConvergenceLayer.cpp.

void dtn::net::HTTPConvergenceLayer::componentRun ( ) throw ()
protectedvirtual

This method is from IndependentComponent interface. It runs as independent thread. This method is for receving data vom HTTP server. For the receiving the long polling mechanism is used. Curl calls when receiving data the HTTPConvergenceLayer_callback_write() method. There the received data is written in the ibrcommon::iobuffer, where the DownloadThread::run() method evaluate the stream. If the connection aborted, it will wait the CONN_TIMEOUT value and retry to connect until it could connect. When the connection is set up the DownloadThread the iobuffer will be initialize, when disconnecting the iobuffer will finalize.

Implements dtn::daemon::IndependentComponent.

Definition at line 305 of file HTTPConvergenceLayer.cpp.

References dtn::net::CONN_TIMEOUT, ibrcommon::iobuffer::finalize(), dtn::data::EID::getString(), IBRCOMMON_LOGGER_DEBUG_TAG, IBRCOMMON_LOGGER_ENDL, ibrcommon::JoinableThread::join(), dtn::core::BundleCore::local, ibrcommon::Thread::sleep(), ibrcommon::JoinableThread::start(), and ibrcommon::Thread::yield().

Here is the call graph for this function:

void dtn::net::HTTPConvergenceLayer::componentUp ( ) throw ()
protectedvirtual

Method from IndependentComponent interface, this method is called before the componentRun() method is called. At time here is nothing to do.

Implements dtn::daemon::IndependentComponent.

Definition at line 289 of file HTTPConvergenceLayer.cpp.

dtn::core::Node::Protocol dtn::net::HTTPConvergenceLayer::getDiscoveryProtocol ( ) const
virtual

Method to return protocol type, in this case HTTP.

Implements dtn::net::ConvergenceLayer.

Definition at line 280 of file HTTPConvergenceLayer.cpp.

References dtn::core::Node::CONN_HTTP.

const std::string dtn::net::HTTPConvergenceLayer::getName ( ) const
virtual
See Also
Component::getName()

Get method, returns a string with the name of this class, in this case "HTTPConvergenceLayer"

Implements dtn::daemon::Component.

Definition at line 406 of file HTTPConvergenceLayer.cpp.

void dtn::net::HTTPConvergenceLayer::queue ( const dtn::core::Node node,
const dtn::net::BundleTransfer job 
)
virtual
See Also
ConvergenceLayer::queue()

Function to send data to Tomcat Server. This method is from the ConvergenceLayer interface. Everytime a bundle is queued, this method will be called to send the bundle over HTTP. The HTTP transfer is performed in classical request-response principle. For file upload the HTTP PUT method is used. Curl uses the HTTPConvergenceLayer_callback_read() method for reading the bundle content. After a bundle is successfully transfered this method will raise the events for TransferCompletedEvent and the BundleEvent for BUNDLE_FORWARDED.

Parameters
nodenode informations
jobparameter to get next bundle to send from storage

Implements dtn::net::ConvergenceLayer.

Definition at line 185 of file HTTPConvergenceLayer.cpp.

References dtn::net::BundleTransfer::abort(), dtn::net::BundleTransfer::complete(), ibrcommon::BLOB::create(), dtn::net::CURL_CONN_OK, dtn::storage::BundleStorage::get(), dtn::net::BundleTransfer::getBundle(), dtn::core::BundleCore::getInstance(), dtn::core::BundleCore::getStorage(), dtn::data::EID::getString(), dtn::net::HTTP_OK, ibrcommon::BLOB::Reference::iostream(), dtn::core::BundleCore::local, dtn::net::TransferAbortedEvent::REASON_BUNDLE_DELETED, and ibrcommon::BLOB::iostream::size().

Here is the call graph for this function:


The documentation for this class was generated from the following files: