#include <GlobalStore.h>
Examples include the running sequence number for bundles and registrations, as well as any other persistent configuration settings.
Definition at line 42 of file GlobalStore.h.
Public Member Functions | |
GlobalStore () | |
Constructor. | |
int | do_init (const oasys::StorageConfig &cfg, oasys::DurableStore *store) |
Real initialization method. | |
~GlobalStore () | |
Destructor. | |
u_int32_t | next_bundleid () |
Get a new bundle id, updating the value in the store. | |
u_int32_t | next_regid () |
Get a new unique registration id, updating the running value in the persistent table. | |
bool | load () |
Load in the globals. | |
void | close () |
Close (and flush) the data store. | |
Static Public Member Functions | |
static GlobalStore * | instance () |
Singleton instance accessor. | |
static int | init (const oasys::StorageConfig &cfg, oasys::DurableStore *store) |
Boot time initializer. | |
static bool | initialized () |
Return true if initialization has completed. | |
Static Public Attributes | |
static const u_int32_t | CURRENT_VERSION = 3 |
Protected Member Functions | |
void | update () |
Update the globals in the store. | |
void | calc_digest (u_char *digest) |
Calculate a digest of on-disk serialized objects. | |
Protected Attributes | |
bool | loaded_ |
Globals * | globals_ |
oasys::SingleTypeDurableTable < Globals > * | store_ |
oasys::Mutex * | lock_ |
Static Protected Attributes | |
static GlobalStore * | instance_ |
singleton instance |
dtn::GlobalStore::GlobalStore | ( | ) |
Constructor.
Definition at line 67 of file GlobalStore.cc.
References lock_, oasys::Logger::logpath_, and oasys::Mutex::TYPE_RECURSIVE.
Referenced by init().
dtn::GlobalStore::~GlobalStore | ( | ) |
static GlobalStore* dtn::GlobalStore::instance | ( | ) | [inline, static] |
Singleton instance accessor.
Definition at line 49 of file GlobalStore.h.
References instance_.
Referenced by dtn::Bundle::Bundle(), dtn::DTNServer::close_datastore(), dtn::APIClient::handle_register(), and dtn::DTNServer::init_datastore().
int dtn::GlobalStore::init | ( | const oasys::StorageConfig & | cfg, | |
oasys::DurableStore * | store | |||
) | [static] |
Boot time initializer.
Definition at line 78 of file GlobalStore.cc.
References do_init(), GlobalStore(), and instance_.
Referenced by dtn::DTNServer::init_datastore().
int dtn::GlobalStore::do_init | ( | const oasys::StorageConfig & | cfg, | |
oasys::DurableStore * | store | |||
) |
Real initialization method.
Definition at line 92 of file GlobalStore.cc.
References calc_digest(), CURRENT_VERSION, dtn::Globals::digest_, oasys::DS_CREATE, oasys::DS_EXCL, oasys::DS_EXISTS, oasys::DS_NOTFOUND, oasys::DurableStore::get_table(), dtn::GLOBAL_KEY, dtn::GLOBAL_TABLE, globals_, oasys::StorageConfig::init_, loaded_, log_err, log_err_p, log_info, dtn::Registration::MAX_RESERVED_REGID, dtn::Globals::next_bundleid_, dtn::Globals::next_regid_, store_, and dtn::Globals::version_.
Referenced by init().
static bool dtn::GlobalStore::initialized | ( | ) | [inline, static] |
Return true if initialization has completed.
Definition at line 77 of file GlobalStore.h.
References instance_.
u_int32_t dtn::GlobalStore::next_bundleid | ( | ) |
Get a new bundle id, updating the value in the store.
(was db_update_bundle_id, db_restore_bundle_id)
Definition at line 157 of file GlobalStore.cc.
References ASSERT, globals_, ExamineDump::l, lock_, log_debug, dtn::Globals::next_bundleid_, and update().
Referenced by dtn::Bundle::Bundle().
u_int32_t dtn::GlobalStore::next_regid | ( | ) |
Get a new unique registration id, updating the running value in the persistent table.
(was db_new_regID, db_update_registration_id, db_retable_registration_id)
Definition at line 175 of file GlobalStore.cc.
References ASSERT, globals_, ExamineDump::l, lock_, log_debug, dtn::Globals::next_regid_, and update().
Referenced by dtn::APIClient::handle_register().
bool dtn::GlobalStore::load | ( | ) |
Load in the globals.
Reimplemented in dtn::SQLGlobalStore.
Definition at line 221 of file GlobalStore.cc.
References ASSERT, calc_digest(), CURRENT_VERSION, dtn::Globals::digest_, dtn::GLOBAL_KEY, globals_, oasys::hex2str(), loaded_, log_crit, log_debug, oasys::MD5::MD5LEN, store_, and dtn::Globals::version_.
void dtn::GlobalStore::close | ( | ) |
Close (and flush) the data store.
Definition at line 283 of file GlobalStore.cc.
References instance_, oasys::Mutex::lock(), lock_, and store_.
Referenced by dtn::DTNServer::close_datastore().
void dtn::GlobalStore::update | ( | ) | [protected] |
Update the globals in the store.
Reimplemented in dtn::SQLGlobalStore.
Definition at line 263 of file GlobalStore.cc.
References ASSERT, oasys::durable_strerror(), dtn::GLOBAL_KEY, globals_, oasys::Lock::is_locked_by_me(), loaded_, lock_, log_debug, and store_.
Referenced by next_bundleid(), and next_regid().
void dtn::GlobalStore::calc_digest | ( | u_char * | digest | ) | [protected] |
Calculate a digest of on-disk serialized objects.
Definition at line 193 of file GlobalStore.cc.
References oasys::StringSerialize::action(), oasys::StringSerialize::buf(), oasys::Builder::builder(), oasys::Serialize::CONTEXT_LOCAL, oasys::MD5::digest(), oasys::MD5::digest_ascii(), oasys::MD5::finalize(), oasys::StringSerialize::INCLUDE_NAME, oasys::StringSerialize::INCLUDE_TYPE, log_debug, oasys::MD5::MD5LEN, oasys::StringSerialize::SCHEMA_ONLY, and oasys::MD5::update().
const u_int32_t dtn::GlobalStore::CURRENT_VERSION = 3 [static] |
bool dtn::GlobalStore::loaded_ [protected] |
Globals* dtn::GlobalStore::globals_ [protected] |
Definition at line 122 of file GlobalStore.h.
Referenced by do_init(), load(), next_bundleid(), next_regid(), update(), and ~GlobalStore().
oasys::SingleTypeDurableTable<Globals>* dtn::GlobalStore::store_ [protected] |
Reimplemented in dtn::SQLGlobalStore.
Definition at line 123 of file GlobalStore.h.
Referenced by close(), do_init(), load(), update(), and ~GlobalStore().
oasys::Mutex* dtn::GlobalStore::lock_ [protected] |
Definition at line 125 of file GlobalStore.h.
Referenced by close(), GlobalStore(), next_bundleid(), next_regid(), update(), and ~GlobalStore().
GlobalStore * dtn::GlobalStore::instance_ [static, protected] |
singleton instance
Definition at line 127 of file GlobalStore.h.
Referenced by close(), init(), initialized(), and instance().