#include <RegistrationTable.h>
Inheritance diagram for dtn::RegistrationTable:
All changes to the table are made persistent via the RegistrationStore.
Definition at line 53 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. | |
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. |
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 107 of file RegistrationTable.cc.
References dtn::EndpointID::c_str(), dtn::Registration::endpoint(), dtn::RegistrationStore::instance(), log_err, log_info, 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 76 of file RegistrationTable.cc.
References find().
Referenced by dtn::RegistrationCommand::exec(), dtn::APIClient::handle_bind(), dtn::APIClient::handle_find_registration(), dtn::BundleDaemon::handle_registration_expired(), dtn::APIClient::handle_unbind(), and dtn::APIClient::handle_unregister().
Registration * dtn::RegistrationTable::get | ( | const EndpointIDPattern & | eid | ) | const |
Look up the first matching registration for the exact endpoint id pattern given.
Definition at line 90 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 139 of file RegistrationTable.cc.
References find(), dtn::RegistrationStore::instance(), log_err, log_info, 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 164 of file RegistrationTable.cc.
References dtn::EndpointID::c_str(), dtn::Registration::endpoint(), dtn::RegistrationStore::instance(), log_err, log_info, 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 187 of file RegistrationTable.cc.
References dtn::EndpointID::c_str(), count, dtn::Registration::endpoint(), log_debug, dtn::EndpointIDPattern::match(), dtn::Registration::regid(), and reglist_.
Referenced by dtn::BundleDaemon::check_registrations().
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 214 of file RegistrationTable.cc.
References oasys::StringBuffer::appendf(), dtn::Registration::EXEC, dtn::Registration::failure_action_toa(), and reglist_.
Referenced by dtn::RegistrationCommand::exec().
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 59 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 130 of file RegistrationTable.h.
Referenced by add(), del(), dump(), find(), get(), and get_matching().