OpenSim::Framework::Communications::Cache::AssetCache Class Reference

Manages local cache of assets and their sending to viewers. More...

Inheritance diagram for OpenSim::Framework::Communications::Cache::AssetCache:

OpenSim::Framework::IAssetReceiver List of all members.

Public Member Functions

void ShowState ()
 Report statistical data.
void Clear ()
 Clear the asset cache.
 AssetCache (IAssetServer assetServer)
 Constructor. Initialize will need to be called separately.
void RunAssetManager ()
 Process the asset queue which holds data which is packeted up and sent directly back to the client.
bool TryGetCachedAsset (UUID assetId, out AssetBase asset)
 Only get an asset if we already have it in the cache.
void GetAsset (UUID assetId, AssetRequestCallback callback, bool isTexture)
 Asynchronously retrieve an asset.
AssetBase GetAsset (UUID assetID, bool isTexture)
 Synchronously retreive an asset. If the asset isn't in the cache, a request will be made to the persistent store to load it into the cache.
void AddAsset (AssetBase asset)
 Add an asset to both the persistent store and the cache.
void ExpireAsset (UUID uuid)
 Allows you to clear a specific asset by uuid out of the asset cache. This is needed because the osdynamic texture code grows the asset cache without bounds. The real solution here is a much better cache archicture, but this is a stop gap measure until we have such a thing.
void AssetReceived (AssetBase asset, bool IsTexture)
 Call back made when a requested asset has been retrieved by an asset server.
void AssetNotFound (UUID assetID, bool IsTexture)
 Call back made when an asset server could not retrieve a requested asset.
void AddAssetRequest (IClientAPI userInfo, TransferRequestPacket transferRequest)
 Handle an asset request from the client. The result will be sent back asynchronously.

Protected Attributes

ICache m_memcache = new SimpleMemoryCache()

Properties

IAssetServer AssetServer [get]

Classes

class  AssetInfo
class  AssetRequest
class  AssetRequestsList
 A list of requests for a particular asset. More...
class  NewAssetRequest
 Represent a request for an asset that has yet to be fulfilled. More...
class  TextureImage

Detailed Description

Manages local cache of assets and their sending to viewers.

This class actually encapsulates two largely separate mechanisms. One mechanism fetches assets either synchronously or async and passes the data back to the requester. The second mechanism fetches assets and sends packetised data directly back to the client. The only point where they meet is AssetReceived() and AssetNotFound(), which means they do share the same asset and texture caches.

TODO: Assets in this cache are effectively immortal (they are never disposed of through old age). This is not a huge problem at the moment since other memory use usually dwarfs that used by assets but it's something to bear in mind.


Constructor & Destructor Documentation

OpenSim::Framework::Communications::Cache::AssetCache::AssetCache ( IAssetServer  assetServer  )  [inline]

Constructor. Initialize will need to be called separately.

Parameters:
assetServer 


Member Function Documentation

void OpenSim::Framework::Communications::Cache::AssetCache::ShowState (  )  [inline]

Report statistical data.

void OpenSim::Framework::Communications::Cache::AssetCache::Clear (  )  [inline]

Clear the asset cache.

void OpenSim::Framework::Communications::Cache::AssetCache::RunAssetManager (  )  [inline]

Process the asset queue which holds data which is packeted up and sent directly back to the client.

bool OpenSim::Framework::Communications::Cache::AssetCache::TryGetCachedAsset ( UUID  assetId,
out AssetBase  asset 
) [inline]

Only get an asset if we already have it in the cache.

Parameters:
assetId 
asset 
Returns:
true if the asset was in the cache, false if it was not

void OpenSim::Framework::Communications::Cache::AssetCache::GetAsset ( UUID  assetId,
AssetRequestCallback  callback,
bool  isTexture 
) [inline]

Asynchronously retrieve an asset.

Parameters:
assetId 
callback 
Parameters:
isTexture 
A callback invoked when the asset has either been found or not found. If the asset was found this is called with the asset UUID and the asset data If the asset was not found this is still called with the asset UUID but with a null asset data reference

AssetBase OpenSim::Framework::Communications::Cache::AssetCache::GetAsset ( UUID  assetID,
bool  isTexture 
) [inline]

Synchronously retreive an asset. If the asset isn't in the cache, a request will be made to the persistent store to load it into the cache.

XXX We'll keep polling the cache until we get the asset or we exceed the allowed number of polls. This isn't a very good way of doing things since a single thread is processing inbound packets, so if the asset server is slow, we could block this for up to the timeout period. Whereever possible we want to use the asynchronous callback GetAsset()

Parameters:
assetID 
isTexture 
Returns:
null if the asset could not be retrieved

void OpenSim::Framework::Communications::Cache::AssetCache::AddAsset ( AssetBase  asset  )  [inline]

Add an asset to both the persistent store and the cache.

Parameters:
asset 

void OpenSim::Framework::Communications::Cache::AssetCache::ExpireAsset ( UUID  uuid  )  [inline]

Allows you to clear a specific asset by uuid out of the asset cache. This is needed because the osdynamic texture code grows the asset cache without bounds. The real solution here is a much better cache archicture, but this is a stop gap measure until we have such a thing.

void OpenSim::Framework::Communications::Cache::AssetCache::AssetReceived ( AssetBase  asset,
bool  IsTexture 
) [inline]

Call back made when a requested asset has been retrieved by an asset server.

Parameters:
asset 
IsTexture 

Implements OpenSim::Framework::IAssetReceiver.

void OpenSim::Framework::Communications::Cache::AssetCache::AssetNotFound ( UUID  assetID,
bool  IsTexture 
) [inline]

Call back made when an asset server could not retrieve a requested asset.

Parameters:
assetID 
IsTexture 

Implements OpenSim::Framework::IAssetReceiver.

void OpenSim::Framework::Communications::Cache::AssetCache::AddAssetRequest ( IClientAPI  userInfo,
TransferRequestPacket  transferRequest 
) [inline]

Handle an asset request from the client. The result will be sent back asynchronously.

Parameters:
userInfo 
transferRequest 


Member Data Documentation

ICache OpenSim::Framework::Communications::Cache::AssetCache::m_memcache = new SimpleMemoryCache() [protected]


Property Documentation

IAssetServer OpenSim::Framework::Communications::Cache::AssetCache::AssetServer [get]


The documentation for this class was generated from the following file:
Generated on Thu Nov 20 01:00:39 2008 for OpenSim by  doxygen 1.5.1