Sirikata
|
Public Types | |
enum | Type { Read, ReadRange, Compare, Write, Erase, EraseRange, Error } |
Public Member Functions | |
StorageAction () | |
Implementation Notes. | |
StorageAction (const StorageAction &rhs) | |
~StorageAction () | |
StorageAction & | operator= (const StorageAction &rhs) |
Result | execute (SQLiteDBPtr db, const Bucket &bucket, ReadSet *rs) |
Result | executeWithRetry (SQLiteDBPtr db, const Bucket &bucket, ReadSet *rs, int32 retries, const Duration &retry_wait) |
Public Attributes | |
Type | type |
Key | key |
Key | keyEnd |
String * | value |
Sirikata::OH::SQLiteStorage::StorageAction::StorageAction | ( | ) |
Implementation Notes.
--------------------
This implementation is fairly straightforward since SQLite takes care of almost everything for us. A single table 'persistence' holds all data in rows of (object, key, value). All operations except leases are trivially handled through normal SQLite transactions.
Leases require a little more work since they span transactions. We use a special key to keep track of the lessee and expiration. When transactions are initiated we make sure we have the lease, and also setup renewals. Checking at the beginning of the transaction is sufficient because as soon as we read the data, we have a reader lock and the transaction won't complete if someone else tried to write to it.
Sirikata::OH::SQLiteStorage::StorageAction::StorageAction | ( | const StorageAction & | rhs | ) |
Sirikata::OH::SQLiteStorage::StorageAction::~StorageAction | ( | ) |
Storage::Result Sirikata::OH::SQLiteStorage::StorageAction::execute | ( | SQLiteDBPtr | db, |
const Bucket & | bucket, | ||
ReadSet * | rs | ||
) |
References Sirikata::OH::SQLiteStorage::checkSQLiteError(), Sirikata::Logging::error, Sirikata::Logging::fatal, Sirikata::OH::Storage::LOCK_ERROR, Sirikata::UUID::rawHexData(), Sirikata::SQLite::resultAsString(), SILOG, Sirikata::OH::Storage::SUCCESS, TABLE_NAME, and Sirikata::OH::Storage::TRANSACTION_ERROR.
Storage::Result Sirikata::OH::SQLiteStorage::StorageAction::executeWithRetry | ( | SQLiteDBPtr | db, |
const Bucket & | bucket, | ||
ReadSet * | rs, | ||
int32 | retries, | ||
const Duration & | retry_wait | ||
) |
SQLiteStorage::StorageAction & Sirikata::OH::SQLiteStorage::StorageAction::operator= | ( | const StorageAction & | rhs | ) |
Referenced by Sirikata::OH::SQLiteStorage::acquireLease(), Sirikata::OH::SQLiteStorage::compare(), Sirikata::OH::SQLiteStorage::erase(), operator=(), Sirikata::OH::SQLiteStorage::rangeErase(), Sirikata::OH::SQLiteStorage::rangeRead(), Sirikata::OH::SQLiteStorage::read(), Sirikata::OH::SQLiteStorage::releaseLease(), Sirikata::OH::SQLiteStorage::renewLease(), and Sirikata::OH::SQLiteStorage::write().
Referenced by operator=(), Sirikata::OH::SQLiteStorage::rangeErase(), and Sirikata::OH::SQLiteStorage::rangeRead().
Referenced by Sirikata::OH::SQLiteStorage::acquireLease(), Sirikata::OH::SQLiteStorage::compare(), Sirikata::OH::SQLiteStorage::erase(), operator=(), Sirikata::OH::SQLiteStorage::rangeErase(), Sirikata::OH::SQLiteStorage::rangeRead(), Sirikata::OH::SQLiteStorage::read(), Sirikata::OH::SQLiteStorage::releaseLease(), Sirikata::OH::SQLiteStorage::renewLease(), and Sirikata::OH::SQLiteStorage::write().