IBR-DTNSuite
0.12
|
#include <DataStorage.h>
Classes | |
class | Callback |
class | Container |
class | DataNotAvailableException |
class | Hash |
class | istream |
Public Member Functions | |
DataStorage (Callback &callback, const ibrcommon::File &path, unsigned int write_buffer=0, bool initialize=false) | |
virtual | ~DataStorage () |
const Hash | store (Container *data) |
void | store (const Hash &hash, Container *data) |
DataStorage::istream | retrieve (const Hash &hash) throw (DataNotAvailableException) |
void | remove (const Hash &hash) |
void | wait () |
void | iterateAll () |
void | reset () |
void | setFaulty (bool mode) |
Public Member Functions inherited from ibrcommon::JoinableThread | |
virtual | ~JoinableThread ()=0 |
void | join (void) throw (ThreadException) |
bool | isRunning (void) |
void | start (int priority=0) throw (ThreadException) |
void | stop () throw () |
Protected Member Functions | |
void | run () throw () |
void | __cancellation () throw () |
Protected Member Functions inherited from ibrcommon::JoinableThread | |
JoinableThread (size_t size=DEFAULT_STACKSIZE) | |
Protected Member Functions inherited from ibrcommon::Thread | |
virtual | ~Thread ()=0 |
void | reset () throw (ThreadException) |
virtual void | setup (void) throw () |
virtual void | finally (void) throw () |
bool | isFinalized () throw () |
bool | operator== (const ibrcommon::Thread &other) |
Thread (size_t stack=DEFAULT_STACKSIZE) | |
int | kill (int sig) |
void | cancel () throw () |
Additional Inherited Members | |
Static Protected Member Functions inherited from ibrcommon::Thread | |
static size_t | getNumberOfProcessors () |
static void | yield (void) |
static void | sleep (time_t timeout) |
static void | concurrency (int level) |
static bool | equal (pthread_t thread1, pthread_t thread2) |
static void * | __execute__ (void *obj) throw () |
Definition at line 41 of file DataStorage.h.
dtn::storage::DataStorage::DataStorage | ( | Callback & | callback, |
const ibrcommon::File & | path, | ||
unsigned int | write_buffer = 0 , |
||
bool | initialize = false |
||
) |
Definition at line 89 of file DataStorage.cpp.
References ibrcommon::File::createDirectory(), ibrcommon::File::exists(), and ibrcommon::File::getFiles().
|
virtual |
Definition at line 115 of file DataStorage.cpp.
References ibrcommon::Queue< T >::abort(), ibrcommon::Queue< T >::getnpop(), and ibrcommon::JoinableThread::join().
|
protectedvirtual |
Implements ibrcommon::Thread.
Definition at line 198 of file DataStorage.cpp.
References ibrcommon::Queue< T >::abort().
void dtn::storage::DataStorage::iterateAll | ( | ) |
iterate through all the data and call the iterateDataStorage() on each dataset
Definition at line 142 of file DataStorage.cpp.
References ibrcommon::File::getFiles(), and dtn::storage::DataStorage::Callback::iterateDataStorage().
Referenced by dtn::storage::SimpleBundleStorage::componentUp().
void dtn::storage::DataStorage::remove | ( | const Hash & | hash) |
Definition at line 188 of file DataStorage.cpp.
References ibrcommon::Queue< T >::push().
Referenced by dtn::storage::SimpleBundleStorage::clear(), dtn::storage::SimpleBundleStorage::iterateDataStorage(), and dtn::storage::SimpleBundleStorage::remove().
void dtn::storage::DataStorage::reset | ( | ) |
reset the data storage
Definition at line 132 of file DataStorage.cpp.
Referenced by dtn::storage::SimpleBundleStorage::componentDown().
DataStorage::istream dtn::storage::DataStorage::retrieve | ( | const Hash & | hash) | ||
throw | ( | DataNotAvailableException | |||
) |
Definition at line 176 of file DataStorage.cpp.
References ibrcommon::File::exists(), ibrcommon::File::get(), and ibrcommon::File::getPath().
Referenced by dtn::storage::SimpleBundleStorage::get().
|
protectedvirtual |
Abstract interface for thread context run method.
Implements ibrcommon::Thread.
Definition at line 203 of file DataStorage.cpp.
References dtn::storage::DataStorage::Callback::eventDataStorageRemoved(), dtn::storage::DataStorage::Callback::eventDataStorageRemoveFailed(), dtn::storage::DataStorage::Callback::eventDataStorageStored(), dtn::storage::DataStorage::Callback::eventDataStorageStoreFailed(), ibrcommon::File::exists(), ibrcommon::File::get(), ibrcommon::Queue< T >::get(), ibrcommon::File::getPath(), ibrcommon::Queue< T >::pop(), ibrcommon::Semaphore::post(), ibrcommon::File::remove(), and store().
void dtn::storage::DataStorage::setFaulty | ( | bool | mode) |
Set the storage to faulty. If set to true, each try to store a bundle will fail.
Definition at line 137 of file DataStorage.cpp.
Referenced by dtn::storage::SimpleBundleStorage::setFaulty().
const DataStorage::Hash dtn::storage::DataStorage::store | ( | DataStorage::Container * | data) |
Definition at line 168 of file DataStorage.cpp.
Referenced by run().
void dtn::storage::DataStorage::store | ( | const Hash & | hash, |
DataStorage::Container * | data | ||
) |
Definition at line 159 of file DataStorage.cpp.
References ibrcommon::Queue< T >::push(), and ibrcommon::Semaphore::wait().
void dtn::storage::DataStorage::wait | ( | ) |
wait until all tasks are completed
Definition at line 193 of file DataStorage.cpp.
References ibrcommon::Queue< T >::wait().
Referenced by dtn::storage::SimpleBundleStorage::componentDown(), and dtn::storage::SimpleBundleStorage::wait().