IBR-DTNSuite
0.8
|
#include <HTTPConvergenceLayer.h>
Public Member Functions | |
HTTPConvergenceLayer (const std::string &server) | |
virtual | ~HTTPConvergenceLayer () |
dtn::core::Node::Protocol | getDiscoveryProtocol () const |
void | queue (const dtn::core::Node &n, const ConvergenceLayer::Job &job) |
virtual const std::string | getName () const |
Protected Member Functions | |
virtual void | componentUp () |
virtual void | componentRun () |
virtual void | componentDown () |
void | __cancellation () |
Definition at line 50 of file HTTPConvergenceLayer.h.
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.
server | The server parameter contains the Tomcat-Server URL |
Definition at line 204 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 215 of file HTTPConvergenceLayer.cpp.
void dtn::net::HTTPConvergenceLayer::__cancellation | ( | ) | [protected, virtual] |
This method is from IndependentComponent interface. It could abort the componentRun() thread on the hard way.
Implements dtn::daemon::IndependentComponent.
Definition at line 517 of file HTTPConvergenceLayer.cpp.
References _running, and ibrcommon::iobuffer::finalize().
void dtn::net::HTTPConvergenceLayer::componentDown | ( | ) | [protected, virtual] |
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 509 of file HTTPConvergenceLayer.cpp.
void dtn::net::HTTPConvergenceLayer::componentRun | ( | ) | [protected, virtual] |
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 414 of file HTTPConvergenceLayer.cpp.
References _running, dtn::net::CONN_TIMEOUT, ibrcommon::iobuffer::finalize(), dtn::data::EID::getString(), IBRCOMMON_LOGGER_DEBUG, IBRCOMMON_LOGGER_ENDL, ibrcommon::JoinableThread::join(), dtn::core::BundleCore::local, ibrcommon::Thread::sleep(), ibrcommon::JoinableThread::start(), and ibrcommon::Thread::yield().
void dtn::net::HTTPConvergenceLayer::componentUp | ( | ) | [protected, virtual] |
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 399 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 390 of file HTTPConvergenceLayer.cpp.
References dtn::core::Node::CONN_HTTP.
const std::string dtn::net::HTTPConvergenceLayer::getName | ( | ) | const [virtual] |
Get method, returns a string with the name of this class, in this case "HTTPConvergenceLayer"
Implements dtn::daemon::Component.
Definition at line 533 of file HTTPConvergenceLayer.cpp.
void dtn::net::HTTPConvergenceLayer::queue | ( | const dtn::core::Node & | node, |
const ConvergenceLayer::Job & | job | ||
) | [virtual] |
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.
node | node informations |
job | parameter to get next bundle to send from storage |
Implements dtn::net::ConvergenceLayer.
Definition at line 296 of file HTTPConvergenceLayer.cpp.
References dtn::net::ConvergenceLayer::Job::_bundle, dtn::net::ConvergenceLayer::Job::_destination, dtn::core::BUNDLE_FORWARDED, ibrcommon::BLOB::create(), dtn::net::CURL_CONN_OK, dtn::storage::BundleStorage::get(), dtn::core::Node::getEID(), 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::TransferCompletedEvent::raise(), dtn::net::TransferAbortedEvent::raise(), dtn::core::BundleEvent::raise(), dtn::net::TransferAbortedEvent::REASON_BUNDLE_DELETED, and ibrcommon::BLOB::iostream::size().