* refactor: rename AssetCache.Initialize() to AssetCache.Reset() to avoid having Initialise() and Initialize() in the same class - very difficult to read.

0.6.5-rc1
Justin Clarke Casey 2009-04-14 16:36:32 +00:00
parent 762703852e
commit ad2bd74057
3 changed files with 48 additions and 51 deletions

View File

@ -49,6 +49,26 @@ namespace OpenSim.Framework.Communications.Cache
/// AssetNotFound(), which means they do share the same asset and texture caches.
public class AssetCache : IAssetCache
{
private static readonly ILog m_log
= LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
protected ICache m_memcache = new SimpleMemoryCache();
/// <value>
/// Assets requests which are waiting for asset server data. This includes texture requests
/// </value>
private Dictionary<UUID, AssetRequest> RequestedAssets;
/// <value>
/// Asset requests with data which are ready to be sent back to requesters. This includes textures.
/// </value>
private List<AssetRequest> AssetRequests;
/// <value>
/// Until the asset request is fulfilled, each asset request is associated with a list of requesters
/// </value>
private Dictionary<UUID, AssetRequestsList> RequestLists;
#region IPlugin
/// <summary>
@ -77,7 +97,7 @@ namespace OpenSim.Framework.Communications.Cache
m_log.Debug("[ASSET CACHE]: Asset cache server-specified initialisation");
m_log.InfoFormat("[ASSET CACHE]: Asset cache initialisation [{0}/{1}]", Name, Version);
Initialize();
Reset();
m_assetServer = assetServer;
m_assetServer.SetReceiver(this);
@ -95,43 +115,32 @@ namespace OpenSim.Framework.Communications.Cache
Initialise(assetServer);
}
public AssetCache()
{
m_log.Debug("[ASSET CACHE]: Asset cache (plugin constructor)");
}
public void Dispose()
{
}
#endregion
protected ICache m_memcache = new SimpleMemoryCache();
private static readonly ILog m_log
= LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
/// <value>
/// Assets requests which are waiting for asset server data. This includes texture requests
/// </value>
private Dictionary<UUID, AssetRequest> RequestedAssets;
/// <value>
/// Asset requests with data which are ready to be sent back to requesters. This includes textures.
/// </value>
private List<AssetRequest> AssetRequests;
/// <value>
/// Until the asset request is fulfilled, each asset request is associated with a list of requesters
/// </value>
private Dictionary<UUID, AssetRequestsList> RequestLists;
public IAssetServer AssetServer
{
get { return m_assetServer; }
}
private IAssetServer m_assetServer;
public AssetCache()
{
m_log.Debug("[ASSET CACHE]: Asset cache (plugin constructor)");
}
/// <summary>
/// Constructor.
/// </summary>
/// <param name="assetServer"></param>
public AssetCache(IAssetServer assetServer)
{
Initialise(assetServer);
}
public void ShowState()
{
m_log.InfoFormat("Memcache:{0} RequestLists:{1}",
@ -148,30 +157,19 @@ namespace OpenSim.Framework.Communications.Cache
if (StatsManager.SimExtraStats != null)
StatsManager.SimExtraStats.ClearAssetCacheStatistics();
Initialize();
Reset();
}
/// <summary>
/// Initialize the cache.
/// Reset the cache.
/// </summary>
private void Initialize()
private void Reset()
{
AssetRequests = new List<AssetRequest>();
RequestedAssets = new Dictionary<UUID, AssetRequest>();
RequestLists = new Dictionary<UUID, AssetRequestsList>();
}
/// <summary>
/// Constructor. Initialize will need to be called separately.
/// </summary>
/// <param name="assetServer"></param>
public AssetCache(IAssetServer assetServer)
{
m_log.Info("[ASSET CACHE]: Asset cache direct constructor");
Initialise(assetServer);
}
/// <summary>
/// Process the asset queue which holds data which is packeted up and sent
/// directly back to the client.
@ -550,7 +548,6 @@ namespace OpenSim.Framework.Communications.Cache
req2.RequestAssetID = req.RequestAssetID;
req2.TransferRequestID = req.TransferRequestID;
req.RequestUser.SendAsset(req2);
}
}

View File

@ -365,7 +365,7 @@ namespace OpenSim
catch
{
}
m_log.Info("[OPENSIMBASE] Default assetserver will be used");
m_log.Info("[OPENSIMBASE]: Default assetserver will be used");
break;
}
@ -428,6 +428,7 @@ namespace OpenSim
if (m_configSettings.AssetCache != null && m_configSettings.AssetCache != String.Empty)
{
m_log.DebugFormat("[OPENSIMBASE]: Attempting to load asset cache id = {0}", m_configSettings.AssetCache);
try
{
PluginInitialiserBase init = new AssetCachePluginInitialiser(m_configSettings, assetServer);
@ -440,8 +441,8 @@ namespace OpenSim
}
catch (Exception e)
{
m_log.Debug("[OPENSIMBASE]: ResolveAssetCache completed");
m_log.Debug(e);
m_log.Error("[OPENSIMBASE]: ResolveAssetCache failed");
m_log.Error(e);
}
}
@ -453,12 +454,12 @@ namespace OpenSim
{
if (LoginEnabled)
{
m_log.Info("[Login]: Login is now enabled ");
m_log.Info("[LOGIN]: Login is now enabled.");
m_commsManager.GridService.RegionLoginsEnabled = true;
}
else
{
m_log.Info("[Login]: Login is now disabled ");
m_log.Info("[LOGIN]: Login is now disabled.");
m_commsManager.GridService.RegionLoginsEnabled = false;
}
}

View File

@ -60,8 +60,7 @@ namespace OpenSim.Tests.Common.Mock
m_inventoryDataPlugin = new TestInventoryDataPlugin();
SQLAssetServer assetService = new SQLAssetServer(new TestAssetDataPlugin());
IAssetCache ac = new AssetCache(assetService);
m_assetCache = ac;
m_assetCache = new AssetCache(assetService);
LocalInventoryService lis = new LocalInventoryService();
lis.AddPlugin(m_inventoryDataPlugin);