From ad2bd740574b7695a74bb65a63c4bb884cafdf7d Mon Sep 17 00:00:00 2001
From: Justin Clarke Casey
Date: Tue, 14 Apr 2009 16:36:32 +0000
Subject: * refactor: rename AssetCache.Initialize() to AssetCache.Reset() to
avoid having Initialise() and Initialize() in the same class - very difficult
to read.
---
.../Framework/Communications/Cache/AssetCache.cs | 83 +++++++++++-----------
OpenSim/Region/Application/OpenSimBase.cs | 11 +--
.../Tests/Common/Mock/TestCommunicationsManager.cs | 5 +-
3 files changed, 48 insertions(+), 51 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs
index f8b5757..8c451b0 100644
--- a/OpenSim/Framework/Communications/Cache/AssetCache.cs
+++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs
@@ -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();
+
+ ///
+ /// Assets requests which are waiting for asset server data. This includes texture requests
+ ///
+ private Dictionary RequestedAssets;
+
+ ///
+ /// Asset requests with data which are ready to be sent back to requesters. This includes textures.
+ ///
+ private List AssetRequests;
+
+ ///
+ /// Until the asset request is fulfilled, each asset request is associated with a list of requesters
+ ///
+ private Dictionary RequestLists;
+
#region IPlugin
///
@@ -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,42 +115,31 @@ 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);
-
- ///
- /// Assets requests which are waiting for asset server data. This includes texture requests
- ///
- private Dictionary RequestedAssets;
-
- ///
- /// Asset requests with data which are ready to be sent back to requesters. This includes textures.
- ///
- private List AssetRequests;
-
- ///
- /// Until the asset request is fulfilled, each asset request is associated with a list of requesters
- ///
- private Dictionary RequestLists;
+ #endregion
public IAssetServer AssetServer
{
get { return m_assetServer; }
}
- private IAssetServer m_assetServer;
+ private IAssetServer m_assetServer;
+
+ public AssetCache()
+ {
+ m_log.Debug("[ASSET CACHE]: Asset cache (plugin constructor)");
+ }
+
+ ///
+ /// Constructor.
+ ///
+ ///
+ public AssetCache(IAssetServer assetServer)
+ {
+ Initialise(assetServer);
+ }
public void ShowState()
{
@@ -148,31 +157,20 @@ namespace OpenSim.Framework.Communications.Cache
if (StatsManager.SimExtraStats != null)
StatsManager.SimExtraStats.ClearAssetCacheStatistics();
- Initialize();
+ Reset();
}
///
- /// Initialize the cache.
+ /// Reset the cache.
///
- private void Initialize()
+ private void Reset()
{
AssetRequests = new List();
-
RequestedAssets = new Dictionary();
RequestLists = new Dictionary();
}
///
- /// Constructor. Initialize will need to be called separately.
- ///
- ///
- public AssetCache(IAssetServer assetServer)
- {
- m_log.Info("[ASSET CACHE]: Asset cache direct constructor");
- Initialise(assetServer);
- }
-
- ///
/// 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);
-
}
}
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs
index fd3549e..3840240 100644
--- a/OpenSim/Region/Application/OpenSimBase.cs
+++ b/OpenSim/Region/Application/OpenSimBase.cs
@@ -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;
}
}
diff --git a/OpenSim/Tests/Common/Mock/TestCommunicationsManager.cs b/OpenSim/Tests/Common/Mock/TestCommunicationsManager.cs
index 38a3033..8416fb6 100644
--- a/OpenSim/Tests/Common/Mock/TestCommunicationsManager.cs
+++ b/OpenSim/Tests/Common/Mock/TestCommunicationsManager.cs
@@ -59,9 +59,8 @@ namespace OpenSim.Tests.Common.Mock
m_userDataPlugin = new TestUserDataPlugin();
m_inventoryDataPlugin = new TestInventoryDataPlugin();
- SQLAssetServer assetService = new SQLAssetServer(new TestAssetDataPlugin());
- IAssetCache ac = new AssetCache(assetService);
- m_assetCache = ac;
+ SQLAssetServer assetService = new SQLAssetServer(new TestAssetDataPlugin());
+ m_assetCache = new AssetCache(assetService);
LocalInventoryService lis = new LocalInventoryService();
lis.AddPlugin(m_inventoryDataPlugin);
--
cgit v1.1