#include <RegistrationTable.h>
All changes to the table are made persistent via the RegistrationStore.
Definition at line 32 of file RegistrationTable.h.
Public Member Functions | |
RegistrationTable () | |
Constructor. | |
virtual | ~RegistrationTable () |
Destructor. | |
bool | add (Registration *reg, bool add_to_store=true) |
Add a new registration to the database. | |
Registration * | get (u_int32_t regid) const |
Look up a matching registration. | |
Registration * | get (const EndpointIDPattern &eid) const |
Look up the first matching registration for the exact endpoint id pattern given. | |
bool | del (u_int32_t regid) |
Remove the registration from the database, returns true if successful, false if the registration didn't exist. | |
bool | update (Registration *reg) |
Update the registration in the database. | |
int | get_matching (const EndpointID &eid, RegistrationList *reg_list) const |
Populate the given reglist with all registrations with an endpoint id that matches the bundle demux string. | |
int | delete_expired (const time_t now) |
Delete any expired registrations. | |
void | dump (oasys::StringBuffer *buf) const |
Dump out the registration database. | |
const RegistrationList * | reg_list () const |
Return the routing table. | |
oasys::Lock * | lock () const |
Accessor for the RouteTable internal lock. | |
Protected Member Functions | |
bool | find (u_int32_t regid, RegistrationList::iterator *iter) |
Internal method to find the location of the given registration. | |
Protected Attributes | |
RegistrationList | reglist_ |
All registrations are tabled in-memory in a flat list. | |
oasys::SpinLock | lock_ |
Lock to protect internal data structures. |
dtn::RegistrationTable::RegistrationTable | ( | ) |
dtn::RegistrationTable::~RegistrationTable | ( | ) | [virtual] |
bool dtn::RegistrationTable::add | ( | Registration * | reg, | |
bool | add_to_store = true | |||
) |
Add a new registration to the database.
Returns true if the registration is successfully added, false if there's another registration with the same {endpoint,regid}.
The flag controls whether or not the registration is added to the persistent store, which is only done for registrations added from the RPC interface.
Definition at line 96 of file RegistrationTable.cc.
References dtn::EndpointID::c_str(), dtn::Registration::endpoint(), lock_, dtn::Registration::MAX_RESERVED_REGID, dtn::Registration::regid(), and reglist_.
Referenced by dtn::BundleDaemon::handle_registration_added().
Registration * dtn::RegistrationTable::get | ( | u_int32_t | regid | ) | const |
Look up a matching registration.
Definition at line 63 of file RegistrationTable.cc.
Referenced by dtn::RegistrationCommand::exec(), dtnsim::NodeCommand::exec(), dtn::BundleCommand::exec(), dtn::APIClient::handle_bind(), dtn::BundleDaemon::handle_bundle_inject(), dtn::BundleDaemon::handle_registration_expired(), dtn::APIClient::handle_send(), and dtn::APIClient::handle_unbind().
Registration * dtn::RegistrationTable::get | ( | const EndpointIDPattern & | eid | ) | const |
Look up the first matching registration for the exact endpoint id pattern given.
Definition at line 79 of file RegistrationTable.cc.
References dtn::Registration::endpoint(), dtn::EndpointID::equals(), and reglist_.
bool dtn::RegistrationTable::del | ( | u_int32_t | regid | ) |
Remove the registration from the database, returns true if successful, false if the registration didn't exist.
Definition at line 130 of file RegistrationTable.cc.
References find(), lock_, and reglist_.
Referenced by dtn::BundleDaemon::handle_registration_expired(), and dtn::BundleDaemon::handle_registration_removed().
bool dtn::RegistrationTable::update | ( | Registration * | reg | ) |
Update the registration in the database.
Returns true on success, false on error.
Definition at line 157 of file RegistrationTable.cc.
References dtn::EndpointID::c_str(), dtn::Registration::endpoint(), lock_, and dtn::Registration::regid().
int dtn::RegistrationTable::get_matching | ( | const EndpointID & | eid, | |
RegistrationList * | reg_list | |||
) | const |
Populate the given reglist with all registrations with an endpoint id that matches the bundle demux string.
Returns the count of matching registrations.
Definition at line 182 of file RegistrationTable.cc.
References dtn::EndpointID::c_str(), count, dtn::Registration::endpoint(), lock_, dtn::EndpointIDPattern::match(), dtn::Registration::regid(), and reglist_.
Referenced by dtn::BundleDaemon::check_and_deliver_to_registrations(), dtn::BundleDaemon::check_local_delivery(), and dtn::APIClient::handle_send().
int dtn::RegistrationTable::delete_expired | ( | const time_t | now | ) |
Delete any expired registrations.
(was sweepOldRegistrations)
void dtn::RegistrationTable::dump | ( | oasys::StringBuffer * | buf | ) | const |
Dump out the registration database.
Definition at line 211 of file RegistrationTable.cc.
References lock_, and reglist_.
Referenced by dtnsim::NodeCommand::exec().
const RegistrationList * dtn::RegistrationTable::reg_list | ( | ) | const |
Return the routing table.
Asserts that the RegistrationTable spin lock is held by the caller.
Definition at line 227 of file RegistrationTable.cc.
oasys::Lock* dtn::RegistrationTable::lock | ( | ) | const [inline] |
Accessor for the RouteTable internal lock.
Definition at line 107 of file RegistrationTable.h.
References lock_.
bool dtn::RegistrationTable::find | ( | u_int32_t | regid, | |
RegistrationList::iterator * | iter | |||
) | [protected] |
Internal method to find the location of the given registration.
Definition at line 46 of file RegistrationTable.cc.
References dtn::Registration::regid(), and reglist_.
RegistrationList dtn::RegistrationTable::reglist_ [protected] |
All registrations are tabled in-memory in a flat list.
It's non-obvious what else would be better since we need to do a prefix match on demux strings in matching_registrations.
Definition at line 120 of file RegistrationTable.h.
Referenced by add(), del(), dump(), find(), get(), get_matching(), reg_list(), and ~RegistrationTable().
oasys::SpinLock dtn::RegistrationTable::lock_ [mutable, protected] |
Lock to protect internal data structures.
Definition at line 125 of file RegistrationTable.h.
Referenced by add(), del(), dump(), get(), get_matching(), lock(), reg_list(), and update().