Sirikata
Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes
Sirikata::AggregateManager Class Reference

#include <AggregateManager.hpp>

Inheritance diagram for Sirikata::AggregateManager:
Collaboration diagram for Sirikata::AggregateManager:

List of all members.

Classes

struct  AggregateObject
struct  LocationInfo
class  LocationServiceCache

Public Member Functions

 AggregateManager (LocationService *loc, Transfer::OAuthParamsPtr oauth, const String &username, const String &local_path, const String &local_url_prefix, uint16 n_gen_threads, uint16 n_upload_threads, bool skip_gen, bool skip_upload)
 Create an AggregateManager.
 ~AggregateManager ()
void addAggregate (const UUID &uuid)
void removeAggregate (const UUID &uuid)
void addChild (const UUID &uuid, const UUID &child_uuid)
void removeChild (const UUID &uuid, const UUID &child_uuid)
void aggregateObserved (const UUID &objid, uint32 nobservers, uint32 nchildren)
void generateAggregateMesh (const UUID &uuid, const Duration &delayFor=Duration::milliseconds(1.0f))
void generateAggregateMesh (const UUID &uuid, AggregateObjectPtr aggObject, const Duration &delayFor=Duration::milliseconds(1.0f))
void metadataFinished (Time t, const UUID uuid, const UUID child_uuid, std::string meshName, uint8 attemptNo, std::tr1::shared_ptr< Transfer::MetadataRequest > request, std::tr1::shared_ptr< Transfer::RemoteFileMetadata > response)
void chunkFinished (Time t, const UUID uuid, const UUID child_uuid, std::string meshName, std::tr1::shared_ptr< Transfer::ChunkRequest > request, std::tr1::shared_ptr< const Transfer::DenseData > response)

Private Types

enum  { MAX_NUM_GENERATION_THREADS = 16 }
enum  { MAX_NUM_UPLOAD_THREADS = 16 }
enum  {
  GEN_SUCCESS = 1, CHILDREN_NOT_YET_GEN = 2, NEWER_REQUEST = 3, MISSING_LOC_INFO = 4,
  MISSING_CHILD_LOC_INFO = 5, MISSING_CHILD_MESHES = 6
}
typedef struct
Sirikata::AggregateManager::LocationInfo 
LocationInfo
typedef std::tr1::shared_ptr
< AggregateObject
AggregateObjectPtr
typedef
std::tr1::unordered_map< UUID,
AggregateObjectPtr,
UUID::Hasher
AggregateObjectsMap

Private Member Functions

std::tr1::shared_ptr
< LocationInfo
getCachedLocInfo (const UUID &uuid)
virtual void localObjectAdded (const UUID &uuid, bool agg, const TimedMotionVector3f &loc, const TimedMotionQuaternion &orient, const AggregateBoundingInfo &bounds, const String &mesh, const String &physics, const String &zernike)
virtual void localObjectRemoved (const UUID &uuid, bool agg)
virtual void localLocationUpdated (const UUID &uuid, bool agg, const TimedMotionVector3f &newval)
virtual void localOrientationUpdated (const UUID &uuid, bool agg, const TimedMotionQuaternion &newval)
virtual void localBoundsUpdated (const UUID &uuid, bool agg, const AggregateBoundingInfo &newval)
virtual void localMeshUpdated (const UUID &uuid, bool agg, const String &newval)
virtual void replicaObjectAdded (const UUID &uuid, const TimedMotionVector3f &loc, const TimedMotionQuaternion &orient, const AggregateBoundingInfo &bounds, const String &mesh, const String &physics, const String &zernike)
virtual void replicaObjectRemoved (const UUID &uuid)
virtual void replicaLocationUpdated (const UUID &uuid, const TimedMotionVector3f &newval)
virtual void replicaOrientationUpdated (const UUID &uuid, const TimedMotionQuaternion &newval)
virtual void replicaBoundsUpdated (const UUID &uuid, const AggregateBoundingInfo &newval)
virtual void replicaMeshUpdated (const UUID &uuid, const String &newval)
void addToInMemoryCache (const String &meshName, const Mesh::MeshdataPtr mdptr)
void uploadThreadMain (uint8 i)
bool findChild (std::vector< AggregateObjectPtr > &v, const UUID &uuid)
void removeChild (std::vector< AggregateObjectPtr > &v, const UUID &uuid)
void iRemoveChild (const UUID &uuid, const UUID &child_uuid)
void getLeaves (const std::vector< UUID > &mIndividualObjects)
void addLeavesUpTree (UUID leaf_uuid, UUID uuid)
bool isAggregate (const UUID &uuid)
void updateChildrenTreeLevel (const UUID &uuid, uint16 treeLevel)
void addDirtyAggregates (UUID uuid)
void queueDirtyAggregates (Time postTime)
void generateMeshesFromQueue (uint8 i)
uint32 generateAggregateMeshAsync (const UUID uuid, Time postTime, bool generateSiblings=true)
void aggregationThreadMain (uint8 i)
void updateAggregateLocMesh (UUID uuid, String mesh)
void uploadAggregateMesh (Mesh::MeshdataPtr agg_mesh, AggregateObjectPtr aggObject, std::tr1::unordered_map< String, String > textureSet, uint32 retryAttempt, Time uploadStartTime)
void handleUploadFinished (Transfer::UploadRequestPtr request, const Transfer::URI &path, Mesh::MeshdataPtr agg_mesh, AggregateObjectPtr aggObject, std::tr1::unordered_map< String, String > textureSet, uint32 retryAttempt, const Time &uploadStartTime)
void sendKeepAlives ()
void handleKeepAliveResponse (const UUID &objid, std::tr1::shared_ptr< Transfer::HttpManager::HttpResponse > response, Transfer::HttpManager::ERR_TYPE error, const boost::system::error_code &boost_error)
bool cleanUpChild (const UUID &parent_uuid, const UUID &child_id)
void removeStaleLeaves ()
void commandStats (const Command::Command &cmd, Command::Commander *cmdr, Command::CommandID cmdid)

Private Attributes

uint16 mNumGenerationThreads
ThreadmAggregationThreads [MAX_NUM_GENERATION_THREADS]
Network::IOServicemAggregationServices [MAX_NUM_GENERATION_THREADS]
Network::IOStrandmAggregationStrands [MAX_NUM_GENERATION_THREADS]
Network::IOWorkmIOWorks [MAX_NUM_GENERATION_THREADS]
LocationServiceCache mLocationServiceCache
boost::mutex mLocCacheMutex
LocationServicemLoc
boost::mutex mModelsSystemMutex
ModelsSystemmModelsSystem
Sirikata::Mesh::MeshSimplifier mMeshSimplifier
Sirikata::Mesh::FiltermCenteringFilter
boost::mutex mAggregateObjectsMutex
AggregateObjectsMap mAggregateObjects
Time mAggregateGenerationStartTime
std::tr1::unordered_map< UUID,
AggregateObjectPtr,
UUID::Hasher
mDirtyAggregateObjects
boost::mutex mObjectsByPriorityLocks [MAX_NUM_GENERATION_THREADS]
std::map< float, std::deque
< AggregateObjectPtr > > 
mObjectsByPriority [MAX_NUM_GENERATION_THREADS]
boost::mutex mMeshStoreMutex
std::tr1::unordered_map
< String, Mesh::MeshdataPtr
mMeshStore
std::tr1::shared_ptr
< Transfer::TransferPool
mTransferPool
Transfer::TransferMediatormTransferMediator
Transfer::OAuthParamsPtr mOAuth
const String mCDNUsername
Duration mModelTTL
PollermCDNKeepAlivePoller
const String mLocalPath
const String mLocalURLPrefix
bool mSkipGenerate
bool mSkipUpload
uint16 mNumUploadThreads
ThreadmUploadThreads [MAX_NUM_UPLOAD_THREADS]
Network::IOServicemUploadServices [MAX_NUM_UPLOAD_THREADS]
Network::IOStrandmUploadStrands [MAX_NUM_UPLOAD_THREADS]
Network::IOWorkmUploadWorks [MAX_NUM_UPLOAD_THREADS]
AtomicValue< uint32 > mRawAggregateUpdates
AtomicValue< uint32 > mAggregatesQueued
AtomicValue< uint32 > mAggregatesGenerated
AtomicValue< uint32 > mAggregatesFailedToGenerate
AtomicValue< uint32 > mAggregatesUploaded
AtomicValue< uint32 > mAggregatesFailedToUpload
boost::mutex mStatsMutex
Duration mAggregateCumulativeGenerationTime
Duration mAggregateCumulativeUploadTime
uint64 mAggregateCumulativeDataSize

Member Typedef Documentation

typedef std::tr1::shared_ptr<AggregateObject> Sirikata::AggregateManager::AggregateObjectPtr [private]

Member Enumeration Documentation

anonymous enum [private]
Enumerator:
MAX_NUM_GENERATION_THREADS 
anonymous enum [private]
Enumerator:
MAX_NUM_UPLOAD_THREADS 
anonymous enum [private]
Enumerator:
GEN_SUCCESS 
CHILDREN_NOT_YET_GEN 
NEWER_REQUEST 
MISSING_LOC_INFO 
MISSING_CHILD_LOC_INFO 
MISSING_CHILD_MESHES 

Constructor & Destructor Documentation

Sirikata::AggregateManager::AggregateManager ( LocationService loc,
Transfer::OAuthParamsPtr  oauth,
const String &  username,
const String &  local_path,
const String &  local_url_prefix,
uint16  n_gen_threads,
uint16  n_upload_threads,
bool  skip_gen,
bool  skip_upload 
)

Create an AggregateManager.

OAuth upload parameters for the CDN. If omitted, uploads will not be attempted User name for account your OAuth params let you upload to on the the CDN

Parameters:
local_pathif non-empty and OAuth values are not specified, generate local meshes that create file:/// URLs. Useful to avoid uploading to the CDN, but in distributed systems will obviously cause failures to download meshes on other nodes.
local_url_prefixused in conjunction with local_path. If provided, specifies the URL prefix to prepend to the filename to get the full mesh URL, allowing you to publicize the meshes by using something other than a file:// URL, e.g. if you run a web server on your host.
n_gen_threadsnumber of threads to use for creating aggregate meshes
n_upload_threadsnumber of threads to use for uploading
skip_genif true, skip the generation phase, but pretend it was successful. Useful for testing without spending CPU on generating meshes. Forces skip_upload to be true
skip_uploadif true, skip the upload phase, but pretend it was successful. Useful for testing, but since the mesh cache is limited, this will eventually cause later aggregates to fail to be generated

References Sirikata::LocationService::addListener(), aggregationThreadMain(), Sirikata::Context::commander(), commandStats(), Sirikata::LocationService::context(), Sirikata::Network::IOService::createStrand(), Sirikata::FactoryImpl< T, Ftype >::getConstructor(), Sirikata::Transfer::TransferMediator::getSingleton(), Sirikata::ModelsSystemFactory::getSingleton(), mAggregationServices, mAggregationStrands, mAggregationThreads, mCDNKeepAlivePoller, mCenteringFilter, mIOWorks, mLoc, mModelsSystem, mNumGenerationThreads, mNumUploadThreads, mTransferMediator, mTransferPool, mUploadServices, mUploadStrands, mUploadThreads, mUploadWorks, Sirikata::Transfer::TransferMediator::registerClient(), Sirikata::Command::Commander::registerCommand(), removeStaleLeaves(), sendKeepAlives(), Sirikata::Poller::start(), and uploadThreadMain().

Sirikata::AggregateManager::~AggregateManager ( )

Member Function Documentation

void Sirikata::AggregateManager::addAggregate ( const UUID uuid)
void Sirikata::AggregateManager::addChild ( const UUID uuid,
const UUID child_uuid 
)
void Sirikata::AggregateManager::addDirtyAggregates ( UUID  uuid) [private]
void Sirikata::AggregateManager::addLeavesUpTree ( UUID  leaf_uuid,
UUID  uuid 
) [private]
void Sirikata::AggregateManager::addToInMemoryCache ( const String &  meshName,
const Mesh::MeshdataPtr  mdptr 
) [private]
void Sirikata::AggregateManager::aggregateObserved ( const UUID objid,
uint32  nobservers,
uint32  nchildren 
)
void Sirikata::AggregateManager::aggregationThreadMain ( uint8  i) [private]
void Sirikata::AggregateManager::chunkFinished ( Time  t,
const UUID  uuid,
const UUID  child_uuid,
std::string  meshName,
std::tr1::shared_ptr< Transfer::ChunkRequest request,
std::tr1::shared_ptr< const Transfer::DenseData response 
)
bool Sirikata::AggregateManager::cleanUpChild ( const UUID parent_uuid,
const UUID child_id 
) [private]

References mAggregateObjects.

Referenced by iRemoveChild(), and removeAggregate().

void Sirikata::AggregateManager::commandStats ( const Command::Command cmd,
Command::Commander cmdr,
Command::CommandID  cmdid 
) [private]
bool Sirikata::AggregateManager::findChild ( std::vector< AggregateObjectPtr > &  v,
const UUID uuid 
) [private]
void Sirikata::AggregateManager::generateAggregateMesh ( const UUID uuid,
const Duration delayFor = Duration::milliseconds(1.0f) 
)
void Sirikata::AggregateManager::generateAggregateMesh ( const UUID uuid,
AggregateObjectPtr  aggObject,
const Duration delayFor = Duration::milliseconds(1.0f) 
)
uint32 Sirikata::AggregateManager::generateAggregateMeshAsync ( const UUID  uuid,
Time  postTime,
bool  generateSiblings = true 
) [private]

References AGG_LOG, CHILDREN_NOT_YET_GEN, Sirikata::Mesh::ComputeBounds(), Sirikata::LocationService::context(), Sirikata::Transfer::URL::context(), Sirikata::Logging::detailed, Sirikata::Transfer::URI::empty(), Sirikata::Transfer::URL::empty(), GEN_SUCCESS, Sirikata::Mesh::GeometryInstance::geometryIndex, getCachedLocInfo(), Sirikata::Matrix4x4< float32 >::identity(), Sirikata::Logging::info, Sirikata::Logging::insane, isAggregate(), Sirikata::Mesh::LightInstance::lightIndex, mAggregateCumulativeGenerationTime, mAggregateGenerationStartTime, mAggregateObjects, mAggregateObjectsMutex, mAggregatesGenerated, Sirikata::Context::mainStrand, Sirikata::Mesh::GeometryInstance::materialBindingMap, metadataFinished(), MISSING_CHILD_LOC_INFO, MISSING_CHILD_MESHES, MISSING_LOC_INFO, mLoc, mMeshSimplifier, mMeshStore, mMeshStoreMutex, mNumUploadThreads, mSkipGenerate, mStatsMutex, mTransferPool, mUploadStrands, NEWER_REQUEST, Sirikata::Mesh::Meshdata::GeometryInstanceIterator::next(), Sirikata::Quaternion::normal(), Sirikata::Timer::now(), Sirikata::Time::null(), Sirikata::Mesh::GeometryInstance::parentNode, Sirikata::Network::IOStrand::post(), Sirikata::Matrix4x4< float32 >::scale(), Sirikata::Mesh::MeshSimplifier::simplify(), Sirikata::texfilename(), Sirikata::Transfer::URI::toString(), Sirikata::UUID::toString(), updateAggregateLocMesh(), uploadAggregateMesh(), url, Sirikata::Vector4< scalar >::w, Sirikata::Vector4< scalar >::x, Sirikata::Vector4< scalar >::y, and Sirikata::Vector4< scalar >::z.

Referenced by generateMeshesFromQueue().

void Sirikata::AggregateManager::generateMeshesFromQueue ( uint8  i) [private]
std::tr1::shared_ptr< AggregateManager::LocationInfo > Sirikata::AggregateManager::getCachedLocInfo ( const UUID uuid) [private]
void Sirikata::AggregateManager::getLeaves ( const std::vector< UUID > &  mIndividualObjects) [private]

References addLeavesUpTree().

Referenced by queueDirtyAggregates().

void Sirikata::AggregateManager::handleKeepAliveResponse ( const UUID objid,
std::tr1::shared_ptr< Transfer::HttpManager::HttpResponse response,
Transfer::HttpManager::ERR_TYPE  error,
const boost::system::error_code &  boost_error 
) [private]
void Sirikata::AggregateManager::handleUploadFinished ( Transfer::UploadRequestPtr  request,
const Transfer::URI path,
Mesh::MeshdataPtr  agg_mesh,
AggregateObjectPtr  aggObject,
std::tr1::unordered_map< String, String >  textureSet,
uint32  retryAttempt,
const Time uploadStartTime 
) [private]
void Sirikata::AggregateManager::iRemoveChild ( const UUID uuid,
const UUID child_uuid 
) [private]
bool Sirikata::AggregateManager::isAggregate ( const UUID uuid) [private]
void Sirikata::AggregateManager::localBoundsUpdated ( const UUID uuid,
bool  agg,
const AggregateBoundingInfo newval 
) [private, virtual]
void Sirikata::AggregateManager::localLocationUpdated ( const UUID uuid,
bool  agg,
const TimedMotionVector3f newval 
) [private, virtual]
void Sirikata::AggregateManager::localMeshUpdated ( const UUID uuid,
bool  agg,
const String &  newval 
) [private, virtual]
void Sirikata::AggregateManager::localObjectAdded ( const UUID uuid,
bool  agg,
const TimedMotionVector3f loc,
const TimedMotionQuaternion orient,
const AggregateBoundingInfo bounds,
const String &  mesh,
const String &  physics,
const String &  zernike 
) [private, virtual]
void Sirikata::AggregateManager::localObjectRemoved ( const UUID uuid,
bool  agg 
) [private, virtual]
void Sirikata::AggregateManager::localOrientationUpdated ( const UUID uuid,
bool  agg,
const TimedMotionQuaternion newval 
) [private, virtual]
void Sirikata::AggregateManager::metadataFinished ( Time  t,
const UUID  uuid,
const UUID  child_uuid,
std::string  meshName,
uint8  attemptNo,
std::tr1::shared_ptr< Transfer::MetadataRequest request,
std::tr1::shared_ptr< Transfer::RemoteFileMetadata response 
)
void Sirikata::AggregateManager::queueDirtyAggregates ( Time  postTime) [private]
void Sirikata::AggregateManager::removeAggregate ( const UUID uuid)
void Sirikata::AggregateManager::removeChild ( std::vector< AggregateObjectPtr > &  v,
const UUID uuid 
) [private]
void Sirikata::AggregateManager::removeChild ( const UUID uuid,
const UUID child_uuid 
)
void Sirikata::AggregateManager::removeStaleLeaves ( ) [private]
void Sirikata::AggregateManager::replicaBoundsUpdated ( const UUID uuid,
const AggregateBoundingInfo newval 
) [private, virtual]
void Sirikata::AggregateManager::replicaLocationUpdated ( const UUID uuid,
const TimedMotionVector3f newval 
) [private, virtual]
void Sirikata::AggregateManager::replicaMeshUpdated ( const UUID uuid,
const String &  newval 
) [private, virtual]
void Sirikata::AggregateManager::replicaObjectAdded ( const UUID uuid,
const TimedMotionVector3f loc,
const TimedMotionQuaternion orient,
const AggregateBoundingInfo bounds,
const String &  mesh,
const String &  physics,
const String &  zernike 
) [private, virtual]
void Sirikata::AggregateManager::replicaObjectRemoved ( const UUID uuid) [private, virtual]
void Sirikata::AggregateManager::replicaOrientationUpdated ( const UUID uuid,
const TimedMotionQuaternion newval 
) [private, virtual]
void Sirikata::AggregateManager::sendKeepAlives ( ) [private]
void Sirikata::AggregateManager::updateAggregateLocMesh ( UUID  uuid,
String  mesh 
) [private]
void Sirikata::AggregateManager::updateChildrenTreeLevel ( const UUID uuid,
uint16  treeLevel 
) [private]

References mAggregateObjects.

Referenced by addChild().

void Sirikata::AggregateManager::uploadAggregateMesh ( Mesh::MeshdataPtr  agg_mesh,
AggregateObjectPtr  aggObject,
std::tr1::unordered_map< String, String >  textureSet,
uint32  retryAttempt,
Time  uploadStartTime 
) [private]
void Sirikata::AggregateManager::uploadThreadMain ( uint8  i) [private]

Member Data Documentation

Thread* Sirikata::AggregateManager::mAggregationThreads[MAX_NUM_GENERATION_THREADS] [private]
Network::IOWork* Sirikata::AggregateManager::mIOWorks[MAX_NUM_GENERATION_THREADS] [private]

Referenced by uploadAggregateMesh().

Referenced by uploadAggregateMesh().

std::tr1::unordered_map<String, Mesh::MeshdataPtr> Sirikata::AggregateManager::mMeshStore [private]

Referenced by uploadAggregateMesh().

std::map<float, std::deque<AggregateObjectPtr > > Sirikata::AggregateManager::mObjectsByPriority[MAX_NUM_GENERATION_THREADS] [private]
boost::mutex Sirikata::AggregateManager::mObjectsByPriorityLocks[MAX_NUM_GENERATION_THREADS] [private]

Referenced by uploadAggregateMesh().

Referenced by AggregateManager().

Thread* Sirikata::AggregateManager::mUploadThreads[MAX_NUM_UPLOAD_THREADS] [private]
Network::IOWork* Sirikata::AggregateManager::mUploadWorks[MAX_NUM_UPLOAD_THREADS] [private]

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