Refactor only: serve stats objects directly through StatsManager singleton

This commit is contained in:
Justin Clarke Casey
2008-02-04 16:22:58 +00:00
parent ffaf160362
commit a1c9349d47
13 changed files with 59 additions and 74 deletions

View File

@@ -46,9 +46,7 @@ namespace OpenSim.Framework.UserManagement
{
protected string m_welcomeMessage = "Welcome to OpenSim";
protected UserManagerBase m_userManager = null;
protected Mutex m_loginMutex = new Mutex(false);
protected UserStatsReporter m_statsCollector;
protected Mutex m_loginMutex = new Mutex(false);
/// <summary>
/// Used during login to send the skeleton of the OpenSim Library to the client.
@@ -60,16 +58,12 @@ namespace OpenSim.Framework.UserManagement
/// </summary>
/// <param name="userManager"></param>
/// <param name="libraryRootFolder"></param>
/// <param name="statsCollector">
/// An object for collecting statistical information.
/// Can be null if statistics are not required</param>
/// <param name="welcomeMess"></param>
public LoginService(UserManagerBase userManager, LibraryRootFolder libraryRootFolder,
UserStatsReporter statsCollector, string welcomeMess)
string welcomeMess)
{
m_userManager = userManager;
m_libraryRootFolder = libraryRootFolder;
m_statsCollector = statsCollector;
if (welcomeMess != String.Empty)
{
@@ -226,8 +220,8 @@ namespace OpenSim.Framework.UserManagement
CommitAgent(ref userProfile);
// If we reach this point, then the login has successfully logged onto the grid
if (m_statsCollector != null)
m_statsCollector.AddSuccessfulLogin();
if (StatsManager.UserStats != null)
StatsManager.UserStats.AddSuccessfulLogin();
return logResponse.ToXmlRpcResponse();
}
@@ -358,8 +352,8 @@ namespace OpenSim.Framework.UserManagement
CommitAgent(ref userProfile);
// If we reach this point, then the login has successfully logged onto the grid
if (m_statsCollector != null)
m_statsCollector.AddSuccessfulLogin();
if (StatsManager.UserStats != null)
StatsManager.UserStats.AddSuccessfulLogin();
return logResponse.ToLLSDResponse();
}

View File

@@ -45,17 +45,6 @@ namespace OpenSim.Framework.UserManagement
{
public UserConfig _config;
private Dictionary<string, IUserData> _plugins = new Dictionary<string, IUserData>();
protected UserStatsReporter _stats;
/// <summary>
/// Constructor.
/// </summary>
/// <param name="statsCollector">Can be null if stats collection is not required.
/// </param>
public UserManagerBase(UserStatsReporter statsCollector)
{
_stats = statsCollector;
}
/// <summary>
/// Adds a new user server plugin - user servers will be requested in the order they were loaded.
@@ -435,8 +424,8 @@ namespace OpenSim.Framework.UserManagement
/// <param name="posz"></param>
public void LogOffUser(LLUUID userid, LLUUID regionid, ulong regionhandle, float posx, float posy, float posz)
{
if (_stats != null)
_stats.AddLogout();
if (StatsManager.UserStats != null)
StatsManager.UserStats.AddLogout();
UserProfileData userProfile;
UserAgentData userAgent;

View File

@@ -30,7 +30,7 @@ using System;
using System.Text;
using System.Timers;
namespace OpenSim.Grid.AssetServer
namespace OpenSim.Framework.Statistics
{
/// <summary>
/// Collects and reports information on the requests made to the asset server

View File

@@ -33,19 +33,39 @@ namespace OpenSim.Framework.Statistics
/// </summary>
public class StatsManager
{
private static AssetStatsReporter assetStats;
private static UserStatsReporter userStats;
private static SimExtraStatsReporter simExtraStats;
public static AssetStatsReporter AssetStats { get { return assetStats; } }
public static UserStatsReporter UserStats { get { return userStats; } }
public static SimExtraStatsReporter SimExtraStats { get { return simExtraStats; } }
private StatsManager()
private StatsManager() {}
/// <summary>
/// Start collecting statistics related to assets.
/// Should only be called once.
/// </summary>
public static void StartCollectingAssetStats()
{
assetStats = new AssetStatsReporter();
}
/// <summary>
/// Start recording statistics. Should only be called once - calling again will reset statistic
/// counts.
/// Start collecting statistics related to users.
/// Should only be called once.
/// </summary>
public static void StartCollectingUserStats()
{
userStats = new UserStatsReporter();
}
/// <summary>
/// Start collecting extra sim statistics apart from those collected for the client.
/// Should only be called once.
/// </summary>
public static void StartCollecting()
public static void StartCollectingSimExtraStats()
{
simExtraStats = new SimExtraStatsReporter();
}