IBR-DTNSuite
0.12
|
#include <SQLiteDatabase.h>
Classes | |
class | DatabaseListener |
class | SQLBundleQuery |
class | SQLiteQueryException |
class | Statement |
Public Types | |
enum | UPDATE_VALUES { UPDATE_CUSTODIAN } |
typedef std::list< std::pair < int, const ibrcommon::File > > | blocklist |
typedef std::pair< int, const ibrcommon::File > | blocklist_entry |
Public Types inherited from dtn::storage::BundleSeeker | |
typedef std::set< dtn::data::EID > | eid_set |
Public Member Functions | |
SQLiteDatabase (const ibrcommon::File &file, DatabaseListener &listener) | |
virtual | ~SQLiteDatabase () |
void | open () throw (SQLiteQueryException) |
void | close () |
void | expire (const dtn::data::Timestamp ×tamp) throw () |
void | vacuum () throw (SQLiteQueryException) |
void | update (UPDATE_VALUES, const dtn::data::BundleID &id, const dtn::data::EID &) throw (SQLiteQueryException) |
dtn::data::Length | remove (const dtn::data::BundleID &id) throw (SQLiteQueryException) |
virtual void | get (const BundleSelector &cb, BundleResult &result) throw (NoBundleFoundException, BundleSelectorException) |
void | get (const dtn::data::BundleID &id, dtn::data::MetaBundle &meta) const throw (SQLiteQueryException, NoBundleFoundException) |
void | get (const dtn::data::BundleID &id, dtn::data::Bundle &bundle, blocklist &blocks) const throw (SQLiteQueryException, NoBundleFoundException) |
void | store (const dtn::data::Bundle &bundle, const dtn::data::Length &size) throw (SQLiteQueryException) |
void | store (const dtn::data::BundleID &id, int index, const dtn::data::Block &block, const ibrcommon::File &file) throw (SQLiteQueryException) |
void | transaction () throw (SQLiteQueryException) |
void | rollback () throw (SQLiteQueryException) |
void | commit () throw (SQLiteQueryException) |
bool | empty () const throw (SQLiteQueryException) |
dtn::data::Size | count () const throw (SQLiteQueryException) |
void | clear () throw (SQLiteQueryException) |
bool | contains (const dtn::data::BundleID &id) throw (SQLiteDatabase::SQLiteQueryException) |
virtual const eid_set | getDistinctDestinations () throw (SQLiteQueryException) |
void | iterateAll () throw (SQLiteQueryException) |
void | setFaulty (bool mode) |
Public Member Functions inherited from dtn::storage::BundleSeeker | |
virtual | ~BundleSeeker () |
Friends | |
class | SQLiteBundleSet |
Definition at line 40 of file SQLiteDatabase.h.
typedef std::list<std::pair<int, const ibrcommon::File> > dtn::storage::SQLiteDatabase::blocklist |
Definition at line 187 of file SQLiteDatabase.h.
typedef std::pair<int, const ibrcommon::File> dtn::storage::SQLiteDatabase::blocklist_entry |
Definition at line 188 of file SQLiteDatabase.h.
Enumerator | |
---|---|
UPDATE_CUSTODIAN |
Definition at line 125 of file SQLiteDatabase.h.
dtn::storage::SQLiteDatabase::SQLiteDatabase | ( | const ibrcommon::File & | file, |
DatabaseListener & | listener | ||
) |
Definition at line 204 of file SQLiteDatabase.cpp.
|
virtual |
Definition at line 209 of file SQLiteDatabase.cpp.
void dtn::storage::SQLiteDatabase::clear | ( | ) | ||
throw | ( | SQLiteQueryException | ||
) |
Definition at line 827 of file SQLiteDatabase.cpp.
References dtn::storage::SQLiteDatabase::Statement::step(), and vacuum().
Referenced by dtn::storage::SQLiteBundleStorage::clear().
void dtn::storage::SQLiteDatabase::close | ( | ) |
close the database
Definition at line 352 of file SQLiteDatabase.cpp.
References ibrcommon::LogLevel::error, IBRCOMMON_LOGGER_ENDL, IBRCOMMON_LOGGER_TAG, and dtn::storage::SQLiteConfigure::shutdown().
Referenced by dtn::storage::SQLiteBundleStorage::~SQLiteBundleStorage().
void dtn::storage::SQLiteDatabase::commit | ( | ) | ||
throw | ( | SQLiteQueryException | ||
) |
Definition at line 754 of file SQLiteDatabase.cpp.
Referenced by dtn::storage::SQLiteBundleStorage::store().
bool dtn::storage::SQLiteDatabase::contains | ( | const dtn::data::BundleID & | id) | ||
throw | ( | SQLiteDatabase::SQLiteQueryException | |||
) |
Returns true, if the bundle ID is stored in the database
Definition at line 844 of file SQLiteDatabase.cpp.
References dtn::storage::SQLiteDatabase::Statement::step().
Referenced by dtn::storage::SQLiteBundleStorage::contains().
size_t dtn::storage::SQLiteDatabase::count | ( | ) | const | |
throw | ( | SQLiteQueryException | ||
) |
Definition at line 870 of file SQLiteDatabase.cpp.
References ibrcommon::LogLevel::error, and dtn::storage::SQLiteDatabase::Statement::step().
Referenced by dtn::storage::SQLiteBundleStorage::count().
bool dtn::storage::SQLiteDatabase::empty | ( | ) | const | |
throw | ( | SQLiteQueryException | ||
) |
Definition at line 856 of file SQLiteDatabase.cpp.
References dtn::storage::SQLiteDatabase::Statement::step().
Referenced by dtn::storage::SQLiteBundleStorage::empty().
void dtn::storage::SQLiteDatabase::expire | ( | const dtn::data::Timestamp & | timestamp) | ||
throw | ( | ||||
) |
Expire all bundles with a lifetime lower than the given timestamp.
timestamp |
Definition at line 924 of file SQLiteDatabase.cpp.
References ibrcommon::LogLevel::error, IBRCOMMON_LOGGER_ENDL, IBRCOMMON_LOGGER_TAG, dtn::core::BundleExpiredEvent::raise(), ibrcommon::File::remove(), dtn::storage::SQLiteDatabase::Statement::step(), and ibrcommon::Exception::what().
|
virtual |
Implements dtn::storage::BundleSeeker.
Definition at line 475 of file SQLiteDatabase.cpp.
References dtn::storage::SQLiteDatabase::SQLBundleQuery::bind(), ibrcommon::LogLevel::critical, dtn::storage::SQLiteDatabase::SQLBundleQuery::getWhere(), IBRCOMMON_LOGGER_ENDL, IBRCOMMON_LOGGER_TAG, and ibrcommon::Exception::what().
Referenced by dtn::storage::SQLiteBundleStorage::get(), and dtn::storage::SQLiteBundleStorage::info().
void dtn::storage::SQLiteDatabase::get | ( | const dtn::data::BundleID & | id, |
dtn::data::MetaBundle & | meta | ||
) | const | ||
throw | ( | SQLiteQueryException, | |
NoBundleFoundException | |||
) |
Retrieve the meta data of a given bundle
id |
Definition at line 364 of file SQLiteDatabase.cpp.
References ibrcommon::LogLevel::error, IBRCOMMON_LOGGER_DEBUG_TAG, IBRCOMMON_LOGGER_ENDL, and dtn::storage::SQLiteDatabase::Statement::step().
void dtn::storage::SQLiteDatabase::get | ( | const dtn::data::BundleID & | id, |
dtn::data::Bundle & | bundle, | ||
blocklist & | blocks | ||
) | const | ||
throw | ( | SQLiteQueryException, | |
NoBundleFoundException | |||
) |
Retrieve the data of a given bundle
id |
Definition at line 566 of file SQLiteDatabase.cpp.
References ibrcommon::LogLevel::error, IBRCOMMON_LOGGER_DEBUG_TAG, IBRCOMMON_LOGGER_ENDL, IBRCOMMON_LOGGER_TAG, dtn::storage::SQLiteDatabase::Statement::step(), and ibrcommon::Exception::what().
|
virtual |
Implements dtn::storage::BundleSeeker.
Definition at line 891 of file SQLiteDatabase.cpp.
References dtn::storage::SQLiteDatabase::Statement::step().
Referenced by dtn::storage::SQLiteBundleStorage::getDistinctDestinations().
void dtn::storage::SQLiteDatabase::iterateAll | ( | ) | ||
throw | ( | SQLiteQueryException | ||
) |
iterate through all the bundles and call the iterateDatabase() on each bundle
Definition at line 457 of file SQLiteDatabase.cpp.
References dtn::storage::SQLiteDatabase::DatabaseListener::iterateDatabase(), dtn::storage::SQLiteDatabase::Statement::reset(), and dtn::storage::SQLiteDatabase::Statement::step().
Referenced by dtn::storage::SQLiteBundleStorage::componentUp().
void dtn::storage::SQLiteDatabase::open | ( | ) | ||
throw | ( | SQLiteQueryException | ||
) |
open the database
Definition at line 305 of file SQLiteDatabase.cpp.
References dtn::storage::SQLiteConfigure::configure(), ibrcommon::LogLevel::critical, ibrcommon::LogLevel::error, ibrcommon::File::getPath(), IBRCOMMON_LOGGER_ENDL, IBRCOMMON_LOGGER_LEVEL, IBRCOMMON_LOGGER_TAG, ibrcommon::LogLevel::info, dtn::storage::sql_tracer(), and ibrcommon::LogLevel::warning.
Referenced by dtn::storage::SQLiteBundleStorage::SQLiteBundleStorage().
dtn::data::Length dtn::storage::SQLiteDatabase::remove | ( | const dtn::data::BundleID & | id) | ||
throw | ( | SQLiteQueryException | |||
) |
Delete an entry in the database.
id |
Definition at line 769 of file SQLiteDatabase.cpp.
References IBRCOMMON_LOGGER_DEBUG_TAG, IBRCOMMON_LOGGER_ENDL, ibrcommon::File::remove(), and dtn::storage::SQLiteDatabase::Statement::step().
Referenced by dtn::storage::SQLiteBundleStorage::remove().
void dtn::storage::SQLiteDatabase::rollback | ( | ) | ||
throw | ( | SQLiteQueryException | ||
) |
Definition at line 739 of file SQLiteDatabase.cpp.
Referenced by dtn::storage::SQLiteBundleStorage::store().
void dtn::storage::SQLiteDatabase::setFaulty | ( | bool | mode) |
Set the storage to faulty. If set to true, each try to store a bundle will fail.
Definition at line 1066 of file SQLiteDatabase.cpp.
Referenced by dtn::storage::SQLiteBundleStorage::setFaulty().
void dtn::storage::SQLiteDatabase::store | ( | const dtn::data::Bundle & | bundle, |
const dtn::data::Length & | size | ||
) | |||
throw | ( | SQLiteQueryException | |
) |
bundle |
Definition at line 627 of file SQLiteDatabase.cpp.
References ibrcommon::LogLevel::error, dtn::data::PrimaryBlock::FRAGMENT, dtn::data::SDNV< E >::get(), dtn::utils::Clock::getExpireTime(), dtn::data::ScopeControlHopLimitBlock::getHopsToLive(), dtn::data::SchedulingBlock::getPriority(), IBRCOMMON_LOGGER_ENDL, IBRCOMMON_LOGGER_TAG, dtn::storage::SQLiteDatabase::Statement::step(), and ibrcommon::LogLevel::warning.
Referenced by dtn::storage::SQLiteBundleStorage::store().
void dtn::storage::SQLiteDatabase::store | ( | const dtn::data::BundleID & | id, |
int | index, | ||
const dtn::data::Block & | block, | ||
const ibrcommon::File & | file | ||
) | |||
throw | ( | SQLiteQueryException | |
) |
Definition at line 698 of file SQLiteDatabase.cpp.
References dtn::storage::SQLiteDatabase::Statement::step().
void dtn::storage::SQLiteDatabase::transaction | ( | ) | ||
throw | ( | SQLiteQueryException | ||
) |
Definition at line 724 of file SQLiteDatabase.cpp.
Referenced by dtn::storage::SQLiteBundleStorage::store().
void dtn::storage::SQLiteDatabase::update | ( | UPDATE_VALUES | mode, |
const dtn::data::BundleID & | id, | ||
const dtn::data::EID & | eid | ||
) | |||
throw | ( | SQLiteQueryException | |
) |
Update
id | |
Definition at line 1008 of file SQLiteDatabase.cpp.
References ibrcommon::LogLevel::error, and dtn::storage::SQLiteDatabase::Statement::step().
Referenced by dtn::storage::SQLiteBundleStorage::releaseCustody(), and dtn::storage::SQLiteBundleStorage::store().
void dtn::storage::SQLiteDatabase::vacuum | ( | ) | ||
throw | ( | SQLiteQueryException | ||
) |
Shrink down the database.
Definition at line 1002 of file SQLiteDatabase.cpp.
References dtn::storage::SQLiteDatabase::Statement::step().
Referenced by clear().
|
friend |
Definition at line 42 of file SQLiteDatabase.h.