Sirikata
|
PersistedObjectSet tracks the set of objects which want to be restored if the object host fails and is restored. More...
#include <CassandraPersistedObjectSet.hpp>
Public Types | |
typedef std::tr1::function < void(bool success)> | RequestCallback |
RequestCallbacks are invoked when a request to change a persisted objects properties (or remove it from persistence) completes. | |
Public Member Functions | |
CassandraPersistedObjectSet (ObjectHostContext *ctx, const String &host, int port, const String &oh_id) | |
virtual | ~CassandraPersistedObjectSet () |
virtual void | start () |
virtual void | stop () |
virtual void | requestPersistedObject (const UUID &internal_id, const String &script_type, const String &script_args, const String &script_contents, RequestCallback cb, const String ×tamp="current") |
Request that an object be marked for persistence / restoration. | |
Private Member Functions | |
void | initDB () |
void | performUpdate (const UUID &internal_id, const String &script_type, const String &script_args, const String &script_contents, RequestCallback cb, const String ×tamp="current") |
Private Attributes | |
ObjectHostContext * | mContext |
String | mDBHost |
int | mDBPort |
String | mOHostID |
CassandraDBPtr | mDB |
Network::IOService * | mIOService |
Network::IOWork * | mWork |
Thread * | mThread |
PersistedObjectSet tracks the set of objects which want to be restored if the object host fails and is restored.
It is the counterpart to an ObjectFactory which restores objects from object storage. It has a very simple interface because it assumes the object scripts (manually or via the ObjectScript implementation) tracks almost all data itself: each object can register to be restored and only the unique internal identifier (allowing access to storage), script type, and script (allowing the object to reconstruct itself) are stored.
typedef std::tr1::function<void(bool success)> Sirikata::OH::CassandraPersistedObjectSet::RequestCallback |
RequestCallbacks are invoked when a request to change a persisted objects properties (or remove it from persistence) completes.
Reimplemented from Sirikata::OH::PersistedObjectSet.
Sirikata::OH::CassandraPersistedObjectSet::CassandraPersistedObjectSet | ( | ObjectHostContext * | ctx, |
const String & | host, | ||
int | port, | ||
const String & | oh_id | ||
) |
Sirikata::OH::CassandraPersistedObjectSet::~CassandraPersistedObjectSet | ( | ) | [virtual] |
void Sirikata::OH::CassandraPersistedObjectSet::initDB | ( | ) | [private] |
void Sirikata::OH::CassandraPersistedObjectSet::performUpdate | ( | const UUID & | internal_id, |
const String & | script_type, | ||
const String & | script_args, | ||
const String & | script_contents, | ||
RequestCallback | cb, | ||
const String & | timestamp = "current" |
||
) | [private] |
References CF_NAME, Sirikata::Context::mainStrand, mContext, mDB, mOHostID, Sirikata::Network::IOStrand::post(), and Sirikata::UUID::rawHexData().
Referenced by requestPersistedObject().
void Sirikata::OH::CassandraPersistedObjectSet::requestPersistedObject | ( | const UUID & | internal_id, |
const String & | script_type, | ||
const String & | script_args, | ||
const String & | script_contents, | ||
RequestCallback | cb, | ||
const String & | timestamp = "current" |
||
) | [virtual] |
Request that an object be marked for persistence / restoration.
If script_type and script_args are left blank, the restoration of the object will be disabled (e.g. if the object is being destroyed).
internal_id | the internal identifier used by the HostedObject. This should always be read from the HostedObject as it will be used to restore access to the appropriate stored data. |
script_type | the type of script the object is running, e.g. 'js' or 'python' |
script_args | arguments to the script to ensure it is in the same state as it was originally loaded in |
script_contents | the actual script text to be executed, usually bootstrapping code which then loads data from storage |
cb | callback to invoke when the operation completes |
Implements Sirikata::OH::PersistedObjectSet.
References mIOService, performUpdate(), and Sirikata::Network::IOService::post().
void Sirikata::OH::CassandraPersistedObjectSet::start | ( | ) | [virtual] |
Reimplemented from Sirikata::OH::PersistedObjectSet.
References initDB(), mIOService, mThread, mWork, Sirikata::Network::IOService::post(), and Sirikata::Network::IOService::runNoReturn().
void Sirikata::OH::CassandraPersistedObjectSet::stop | ( | ) | [virtual] |
Reimplemented from Sirikata::OH::PersistedObjectSet.
References Sirikata::Thread::join(), mIOService, mThread, and mWork.
Referenced by performUpdate().
CassandraDBPtr Sirikata::OH::CassandraPersistedObjectSet::mDB [private] |
Referenced by initDB(), and performUpdate().
String Sirikata::OH::CassandraPersistedObjectSet::mDBHost [private] |
Referenced by initDB().
int Sirikata::OH::CassandraPersistedObjectSet::mDBPort [private] |
Referenced by initDB().
Referenced by requestPersistedObject(), start(), and stop().
String Sirikata::OH::CassandraPersistedObjectSet::mOHostID [private] |
Referenced by performUpdate().