IBR-DTNSuite
0.12
|
#include <Registration.h>
Classes | |
class | AlreadyAttachedException |
class | NotFoundException |
class | NotPersistentException |
class | RegistrationException |
Public Types | |
enum | NOTIFY_CALL { NOTIFY_BUNDLE_AVAILABLE = 0, NOTIFY_NEIGHBOR_AVAILABLE = 1, NOTIFY_NEIGHBOR_UNAVAILABLE = 2, NOTIFY_SHUTDOWN = 3 } |
Public Member Functions | |
Registration () | |
Registration (const std::string &handle) | |
virtual | ~Registration () |
void | notify (const NOTIFY_CALL) |
NOTIFY_CALL | wait () |
void | wait_for_bundle (size_t timeout=0) |
void | subscribe (const dtn::data::EID &endpoint) |
void | unsubscribe (const dtn::data::EID &endpoint) |
bool | hasSubscribed (const dtn::data::EID &endpoint) |
const std::set< dtn::data::EID > | getSubscriptions () |
bool | operator== (const std::string &) const |
bool | operator== (const Registration &) const |
bool | operator< (const Registration &) const |
dtn::data::Bundle | receive () throw (dtn::storage::NoBundleFoundException) |
dtn::data::MetaBundle | receiveMetaBundle () throw (dtn::storage::NoBundleFoundException) |
void | delivered (const dtn::data::MetaBundle &m) const |
const dtn::data::EID & | getDefaultEID () const |
const std::string & | getHandle () const |
void | abort () |
void | reset () |
void | setPersistent (ibrcommon::Timer::time_t lifetime) |
void | unsetPersistent () |
bool | isPersistent () |
bool | isPersistent () const |
void | setFilterFragments (bool val) |
ibrcommon::Timer::time_t | getExpireTime () const |
void | attach () |
void | detach () |
Static Public Member Functions | |
static void | processIncomingBundle (const dtn::data::EID &source, dtn::data::Bundle &bundle) |
Protected Member Functions | |
void | underflow () |
Definition at line 39 of file Registration.h.
Enumerator | |
---|---|
NOTIFY_BUNDLE_AVAILABLE | |
NOTIFY_NEIGHBOR_AVAILABLE | |
NOTIFY_NEIGHBOR_UNAVAILABLE | |
NOTIFY_SHUTDOWN |
Definition at line 44 of file Registration.h.
dtn::api::Registration::Registration | ( | ) |
constructor of the registration
Definition at line 111 of file Registration.cpp.
References dtn::data::EID::setApplication().
dtn::api::Registration::Registration | ( | const std::string & | handle) |
create a registration with a pre-defined handle (used to resume a session with an external manager)
Definition at line 103 of file Registration.cpp.
References dtn::data::EID::setApplication().
|
virtual |
destructor of the registration
Definition at line 119 of file Registration.cpp.
void dtn::api::Registration::abort | ( | ) |
abort all blocking operations on this registration
Definition at line 426 of file Registration.cpp.
References ibrcommon::Conditional::abort(), and ibrcommon::Queue< T >::abort().
Referenced by dtn::api::NativeSession::destroy(), dtn::api::OrderedStreamHandler::finally(), dtn::api::BinaryStreamClient::finally(), dtn::api::ExtendedApiHandler::finally(), dtn::api::ClientHandler::finally(), dtn::api::ExtendedApiHandler::run(), dtn::api::ClientHandler::switchRegistration(), dtn::api::BinaryStreamClient::~BinaryStreamClient(), and dtn::api::ExtendedApiHandler::~ExtendedApiHandler().
void dtn::api::Registration::attach | ( | ) |
attaches a client to this registration
AlreadyAttachedException | a client is already attached |
Definition at line 489 of file Registration.cpp.
Referenced by dtn::api::ApiServer::getRegistration(), and dtn::api::ApiServer::timeout().
void dtn::api::Registration::delivered | ( | const dtn::data::MetaBundle & | m) | const |
notify a bundle as delivered (and delete it if singleton destination)
id |
Definition at line 172 of file Registration.cpp.
References dtn::core::BUNDLE_DELIVERED, dtn::data::PrimaryBlock::DESTINATION_IS_SINGLETON, dtn::data::MetaBundle::get(), dtn::core::BundlePurgeEvent::raise(), and dtn::core::BundleEvent::raise().
Referenced by dtn::api::OrderedStreamHandler::delivered(), dtn::api::BinaryStreamClient::eventBundleForwarded(), dtn::api::NativeSession::receive(), and dtn::api::ExtendedApiHandler::run().
void dtn::api::Registration::detach | ( | ) |
detaches a client from this registration
Definition at line 497 of file Registration.cpp.
References ibrcommon::Conditional::reset(), and ibrcommon::Queue< T >::reset().
Referenced by dtn::api::ApiServer::freeRegistration(), and dtn::api::ApiServer::timeout().
const dtn::data::EID & dtn::api::Registration::getDefaultEID | ( | ) | const |
returns a default EID based on the registration handle
Definition at line 435 of file Registration.cpp.
Referenced by dtn::api::BinaryStreamClient::eventConnectionUp(), dtn::api::NativeSession::NativeSession(), dtn::api::OrderedStreamHandler::OrderedStreamHandler(), dtn::api::OrderedStreamHandler::put(), dtn::api::NativeSession::resetEndpoint(), and dtn::api::ExtendedApiHandler::run().
ibrcommon::Timer::time_t dtn::api::Registration::getExpireTime | ( | ) | const |
gets the expire time of this registration if it is persistent
NotPersistentException | the registration is not persistent |
Definition at line 481 of file Registration.cpp.
References isPersistent().
const std::string & dtn::api::Registration::getHandle | ( | ) | const |
returns the handle of this registration
Definition at line 440 of file Registration.cpp.
Referenced by dtn::api::ApiServer::componentRun(), dtn::api::BinaryStreamClient::eventConnectionUp(), dtn::api::ApiServer::freeRegistration(), dtn::api::NativeSession::getHandle(), dtn::api::ExtendedApiHandler::run(), and dtn::api::ApiServer::timeout().
const std::set< dtn::data::EID > dtn::api::Registration::getSubscriptions | ( | ) |
Definition at line 166 of file Registration.cpp.
Referenced by dtn::api::NativeSession::clearRegistration(), dtn::api::NativeSession::getSubscriptions(), and dtn::api::ExtendedApiHandler::run().
bool dtn::api::Registration::hasSubscribed | ( | const dtn::data::EID & | endpoint) |
check if this registration has subscribed to a specific endpoint
endpoint |
Definition at line 160 of file Registration.cpp.
Referenced by dtn::api::ApiServer::raiseEvent().
bool dtn::api::Registration::isPersistent | ( | ) |
returns the persistent state of this registration and also sets the persistent state to false, if the timer is expired
Definition at line 456 of file Registration.cpp.
References ibrcommon::Timer::get_current_time().
Referenced by dtn::api::ApiServer::freeRegistration(), getExpireTime(), dtn::api::ApiServer::getRegistration(), and dtn::api::ApiServer::timeout().
bool dtn::api::Registration::isPersistent | ( | ) | const |
returns the persistent state of this registration
Definition at line 466 of file Registration.cpp.
References ibrcommon::Timer::get_current_time().
void dtn::api::Registration::notify | ( | const NOTIFY_CALL | call) |
notify the corresponding client about something happen
Definition at line 124 of file Registration.cpp.
References NOTIFY_BUNDLE_AVAILABLE, ibrcommon::Queue< T >::push(), and ibrcommon::Conditional::signal().
Referenced by dtn::api::ApiServer::raiseEvent(), and subscribe().
bool dtn::api::Registration::operator< | ( | const Registration & | other) | const |
compares and order a registration (using the handle)
Definition at line 421 of file Registration.cpp.
bool dtn::api::Registration::operator== | ( | const std::string & | other) | const |
compares the local handle with the given one
Definition at line 405 of file Registration.cpp.
bool dtn::api::Registration::operator== | ( | const Registration & | other) | const |
compares another registration with this one
Definition at line 413 of file Registration.cpp.
|
static |
Definition at line 510 of file Registration.cpp.
References dtn::data::TrackingBlock::append(), dtn::data::CompressedPayloadBlock::compress(), dtn::data::CompressedPayloadBlock::COMPRESSION_ZLIB, dtn::data::PrimaryBlock::custodian, dtn::data::PrimaryBlock::destination, dtn::data::PrimaryBlock::DTNSEC_REQUEST_ENCRYPT, dtn::data::PrimaryBlock::DTNSEC_REQUEST_SIGN, dtn::security::SecurityManager::encrypt(), dtn::data::Bundle::find(), dtn::data::PrimaryBlock::get(), dtn::security::SecurityManager::getInstance(), dtn::daemon::Configuration::getInstance(), dtn::daemon::Configuration::getLimit(), IBRCOMMON_LOGGER_ENDL, IBRCOMMON_LOGGER_TAG, dtn::data::PrimaryBlock::IBRDTN_REQUEST_COMPRESSION, dtn::core::BundleCore::local, dtn::data::Bundle::push_front(), dtn::net::BundleReceivedEvent::raise(), dtn::data::PrimaryBlock::relabel(), dtn::data::PrimaryBlock::reportto, dtn::data::PrimaryBlock::set(), dtn::security::SecurityManager::sign(), dtn::data::BundleID::source, dtn::core::FragmentManager::split(), dtn::data::BundleID::timestamp, ibrcommon::LogLevel::warning, and ibrcommon::Exception::what().
Referenced by dtn::api::BinaryStreamClient::run(), dtn::api::ExtendedApiHandler::run(), and dtn::api::NativeSession::send().
dtn::data::Bundle dtn::api::Registration::receive | ( | ) | ||
throw | ( | dtn::storage::NoBundleFoundException | ||
) |
Receive a bundle from the queue. If the queue is empty, it will query the storage for more bundles (up to 10). If no bundle is found and the queue is empty an exception is thrown.
Definition at line 183 of file Registration.cpp.
References dtn::storage::BundleStorage::get(), dtn::core::BundleCore::getInstance(), dtn::core::BundleCore::getStorage(), and receiveMetaBundle().
dtn::data::MetaBundle dtn::api::Registration::receiveMetaBundle | ( | ) | ||
throw | ( | dtn::storage::NoBundleFoundException | ||
) |
Definition at line 195 of file Registration.cpp.
References IBRCOMMON_LOGGER_DEBUG_TAG, IBRCOMMON_LOGGER_ENDL, ibrcommon::QueueUnblockedException::QUEUE_ABORT, ibrcommon::QueueUnblockedException::reason, and underflow().
Referenced by dtn::api::OrderedStreamHandler::get(), receive(), and dtn::api::NativeSession::receive().
void dtn::api::Registration::reset | ( | ) |
resets the underlying queues (if you want to continue using the registration after an abort call
void dtn::api::Registration::setFilterFragments | ( | bool | val) |
Allows to disable the re-assemble of fragments
Definition at line 476 of file Registration.cpp.
void dtn::api::Registration::setPersistent | ( | ibrcommon::Timer::time_t | lifetime) |
make this registration persistent
lifetime | the lifetime of the registration in seconds |
Definition at line 445 of file Registration.cpp.
References ibrcommon::Timer::get_current_time().
Referenced by dtn::api::ExtendedApiHandler::run().
void dtn::api::Registration::subscribe | ( | const dtn::data::EID & | endpoint) |
subscribe to a end-point
Definition at line 383 of file Registration.cpp.
References notify(), and NOTIFY_BUNDLE_AVAILABLE.
Referenced by dtn::api::BinaryStreamClient::eventConnectionUp(), dtn::api::ExtendedApiHandler::ExtendedApiHandler(), dtn::api::NativeSession::resetEndpoint(), dtn::api::OrderedStreamHandler::run(), and dtn::api::ExtendedApiHandler::run().
|
protected |
search for bundles in the storage
Definition at line 221 of file Registration.cpp.
References dtn::data::MetaBundle::destination, dtn::daemon::Configuration::Network::doFragmentation(), dtn::storage::BundleSeeker::get(), dtn::core::BundleCore::getInstance(), dtn::daemon::Configuration::getInstance(), dtn::daemon::Configuration::getNetwork(), dtn::core::BundleCore::getSeeker(), dtn::utils::Clock::getTime(), IBRCOMMON_LOGGER_DEBUG_TAG, IBRCOMMON_LOGGER_ENDL, dtn::data::MetaBundle::isFragment(), dtn::core::BundleCore::max_bundles_in_transit, dtn::data::BundleID::source, and dtn::data::BundleID::toString().
Referenced by receiveMetaBundle().
void dtn::api::Registration::unsetPersistent | ( | ) |
remove the persistent flag of this registration
Definition at line 451 of file Registration.cpp.
void dtn::api::Registration::unsubscribe | ( | const dtn::data::EID & | endpoint) |
unsubscribe to a end-point
Definition at line 396 of file Registration.cpp.
Referenced by dtn::api::NativeSession::clearRegistration(), dtn::api::BinaryStreamClient::eventConnectionDown(), dtn::api::NativeSession::resetEndpoint(), dtn::api::OrderedStreamHandler::run(), and dtn::api::ExtendedApiHandler::run().
Registration::NOTIFY_CALL dtn::api::Registration::wait | ( | ) |
wait for the next notify event
Definition at line 155 of file Registration.cpp.
References ibrcommon::Queue< T >::getnpop().
void dtn::api::Registration::wait_for_bundle | ( | size_t | timeout = 0 ) |
wait for available bundle
Definition at line 138 of file Registration.cpp.
References ibrcommon::Conditional::wait().
Referenced by dtn::api::OrderedStreamHandler::get(), and dtn::api::NativeSession::receive().