Sirikata
Public Types | Public Member Functions | Private Member Functions | Private Attributes
Sirikata::OH::CassandraPersistedObjectSet Class Reference

PersistedObjectSet tracks the set of objects which want to be restored if the object host fails and is restored. More...

#include <CassandraPersistedObjectSet.hpp>

Inheritance diagram for Sirikata::OH::CassandraPersistedObjectSet:
Collaboration diagram for Sirikata::OH::CassandraPersistedObjectSet:

List of all members.

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 &timestamp="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 &timestamp="current")

Private Attributes

ObjectHostContextmContext
String mDBHost
int mDBPort
String mOHostID
CassandraDBPtr mDB
Network::IOServicemIOService
Network::IOWorkmWork
ThreadmThread

Detailed Description

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.


Member Typedef Documentation

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.


Constructor & Destructor Documentation

Sirikata::OH::CassandraPersistedObjectSet::CassandraPersistedObjectSet ( ObjectHostContext ctx,
const String &  host,
int  port,
const String &  oh_id 
)
Sirikata::OH::CassandraPersistedObjectSet::~CassandraPersistedObjectSet ( ) [virtual]

Member Function Documentation

void Sirikata::OH::CassandraPersistedObjectSet::initDB ( ) [private]

References mDB, mDBHost, and mDBPort.

Referenced by start().

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]
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).

Parameters:
internal_idthe 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_typethe type of script the object is running, e.g. 'js' or 'python'
script_argsarguments to the script to ensure it is in the same state as it was originally loaded in
script_contentsthe actual script text to be executed, usually bootstrapping code which then loads data from storage
cbcallback to invoke when the operation completes

Implements Sirikata::OH::PersistedObjectSet.

References mIOService, performUpdate(), and Sirikata::Network::IOService::post().

void Sirikata::OH::CassandraPersistedObjectSet::start ( ) [virtual]
void Sirikata::OH::CassandraPersistedObjectSet::stop ( ) [virtual]

Member Data Documentation

Referenced by performUpdate().

Referenced by initDB(), and performUpdate().

Referenced by initDB().

Referenced by initDB().

Referenced by requestPersistedObject(), start(), and stop().

Referenced by performUpdate().

Referenced by start(), and stop().

Referenced by start(), and stop().


The documentation for this class was generated from the following files: