From a1c9349d4765833691e7816d7f4df7bd37b9ee36 Mon Sep 17 00:00:00 2001
From: Justin Clarke Casey
Date: Mon, 4 Feb 2008 16:22:58 +0000
Subject: Refactor only: serve stats objects directly through StatsManager
singleton
---
OpenSim/Grid/AssetServer/Main.cs | 10 ++++------
OpenSim/Grid/AssetServer/RestService.cs | 14 +++++---------
2 files changed, 9 insertions(+), 15 deletions(-)
(limited to 'OpenSim/Grid/AssetServer')
diff --git a/OpenSim/Grid/AssetServer/Main.cs b/OpenSim/Grid/AssetServer/Main.cs
index c9f7e8e..23b0afa 100644
--- a/OpenSim/Grid/AssetServer/Main.cs
+++ b/OpenSim/Grid/AssetServer/Main.cs
@@ -52,9 +52,7 @@ namespace OpenSim.Grid.AssetServer
// Temporarily hardcoded - should be a plugin
protected IAssetLoader assetLoader = new AssetLoaderFileSystem();
- private IAssetProvider m_assetProvider;
-
- protected AssetStatsReporter m_stats;
+ private IAssetProvider m_assetProvider;
[STAThread]
public static void Main(string[] args)
@@ -101,9 +99,9 @@ namespace OpenSim.Grid.AssetServer
m_console.Verbose("ASSET", "Starting HTTP process");
BaseHttpServer httpServer = new BaseHttpServer(m_config.HttpPort);
- m_stats = new AssetStatsReporter();
+ StatsManager.StartCollectingAssetStats();
- httpServer.AddStreamHandler(new GetAssetStreamHandler(this, m_assetProvider, m_stats));
+ httpServer.AddStreamHandler(new GetAssetStreamHandler(this, m_assetProvider));
httpServer.AddStreamHandler(new PostAssetStreamHandler(this, m_assetProvider));
httpServer.Start();
@@ -184,7 +182,7 @@ namespace OpenSim.Grid.AssetServer
break;
case "stats":
- m_console.Notice("STATS", Environment.NewLine + m_stats.Report());
+ m_console.Notice("STATS", Environment.NewLine + StatsManager.AssetStats.Report());
break;
case "shutdown":
diff --git a/OpenSim/Grid/AssetServer/RestService.cs b/OpenSim/Grid/AssetServer/RestService.cs
index 9b288a7..5c497b6 100644
--- a/OpenSim/Grid/AssetServer/RestService.cs
+++ b/OpenSim/Grid/AssetServer/RestService.cs
@@ -43,22 +43,18 @@ namespace OpenSim.Grid.AssetServer
{
private OpenAsset_Main m_assetManager;
private IAssetProvider m_assetProvider;
- private AssetStatsReporter m_stats;
///
/// Constructor.
///
///
///
- /// Can be null if stats collection isn't required
- public GetAssetStreamHandler(OpenAsset_Main assetManager, IAssetProvider assetProvider,
- AssetStatsReporter stats)
+ public GetAssetStreamHandler(OpenAsset_Main assetManager, IAssetProvider assetProvider)
: base("GET", "/assets")
{
MainLog.Instance.Verbose("REST", "In Get Request");
m_assetManager = assetManager;
m_assetProvider = assetProvider;
- m_stats = stats;
}
public override byte[] Handle(string path, Stream request)
@@ -80,8 +76,8 @@ namespace OpenSim.Grid.AssetServer
return result;
}
- if (m_stats != null)
- m_stats.AddRequest();
+ if (StatsManager.AssetStats != null)
+ StatsManager.AssetStats.AddRequest();
AssetBase asset = m_assetProvider.FetchAsset(assetID);
if (asset != null)
@@ -107,8 +103,8 @@ namespace OpenSim.Grid.AssetServer
}
else
{
- if (m_stats != null)
- m_stats.AddNotFoundRequest();
+ if (StatsManager.AssetStats != null)
+ StatsManager.AssetStats.AddNotFoundRequest();
MainLog.Instance.Verbose("REST", "GET:/asset failed to find {0}", assetID);
}
--
cgit v1.1