Refactor only: serve stats objects directly through StatsManager singleton

ThreadPoolClientBranch
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

@ -48,8 +48,6 @@ namespace OpenSim.Framework.UserManagement
protected UserManagerBase m_userManager = null;
protected Mutex m_loginMutex = new Mutex(false);
protected UserStatsReporter m_statsCollector;
/// <summary>
/// Used during login to send the skeleton of the OpenSim Library to the client.
/// </summary>
@ -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 StartCollecting()
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 StartCollectingSimExtraStats()
{
simExtraStats = new SimExtraStatsReporter();
}

View File

@ -54,8 +54,6 @@ namespace OpenSim.Grid.AssetServer
private IAssetProvider m_assetProvider;
protected AssetStatsReporter m_stats;
[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":

View File

@ -43,22 +43,18 @@ namespace OpenSim.Grid.AssetServer
{
private OpenAsset_Main m_assetManager;
private IAssetProvider m_assetProvider;
private AssetStatsReporter m_stats;
/// <summary>
/// Constructor.
/// </summary>
/// <param name="assetManager"></param>
/// <param name="assetProvider"></param>
/// <param name="stats">Can be null if stats collection isn't required</param>
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);
}

View File

@ -48,8 +48,6 @@ namespace OpenSim.Grid.UserServer
public UserLoginService m_loginService;
public MessageServersConnector m_messagesService;
protected UserStatsReporter m_stats;
private LogBase m_console;
private LLUUID m_lastCreatedUser = LLUUID.Random();
@ -89,15 +87,15 @@ namespace OpenSim.Grid.UserServer
{
Cfg = new UserConfig("USER SERVER", (Path.Combine(Util.configDir(), "UserServer_Config.xml")));
m_stats = new UserStatsReporter();
StatsManager.StartCollectingUserStats();
MainLog.Instance.Verbose("REGION", "Establishing data connection");
m_userManager = new UserManager(m_stats);
m_userManager = new UserManager();
m_userManager._config = Cfg;
m_userManager.AddPlugin(Cfg.DatabaseProvider);
m_loginService = new UserLoginService(
m_userManager, new LibraryRootFolder(), m_stats, Cfg, Cfg.DefaultStartupMsg);
m_userManager, new LibraryRootFolder(), Cfg, Cfg.DefaultStartupMsg);
m_messagesService = new MessageServersConnector(MainLog.Instance);
@ -199,7 +197,7 @@ namespace OpenSim.Grid.UserServer
break;
case "stats":
MainLog.Instance.Notice("STATS", Environment.NewLine + m_stats.Report());
MainLog.Instance.Notice("STATS", Environment.NewLine + StatsManager.UserStats.Report());
break;
case "test-inventory":

View File

@ -55,8 +55,8 @@ namespace OpenSim.Grid.UserServer
public UserLoginService(
UserManagerBase userManager, LibraryRootFolder libraryRootFolder,
UserStatsReporter statsCollector, UserConfig config, string welcomeMess)
: base(userManager, libraryRootFolder, statsCollector, welcomeMess)
UserConfig config, string welcomeMess)
: base(userManager, libraryRootFolder, welcomeMess)
{
m_config = config;
}

View File

@ -39,15 +39,6 @@ namespace OpenSim.Grid.UserServer
{
public class UserManager : UserManagerBase
{
/// <summary>
/// Constructor.
/// </summary>
/// <param name="statsCollector">Can be null if stats collection is not required.
/// </param>
public UserManager(UserStatsReporter statsCollector) : base(statsCollector)
{
}
/// <summary>
/// Deletes an active agent session
/// </summary>

View File

@ -304,7 +304,7 @@ namespace OpenSim
m_log = CreateLog();
MainLog.Instance = m_log;
StatsManager.StartCollecting();
StatsManager.StartCollectingSimExtraStats();
// Do baseclass startup sequence: OpenSim.Region.ClientStack.RegionApplicationBase.StartUp
// TerrainManager, StorageManager, HTTP Server
@ -320,7 +320,7 @@ namespace OpenSim
LocalUserServices userService =
new LocalUserServices(m_networkServersInfo, m_networkServersInfo.DefaultHomeLocX,
m_networkServersInfo.DefaultHomeLocY, inventoryService, null);
m_networkServersInfo.DefaultHomeLocY, inventoryService);
userService.AddPlugin(m_standaloneUserPlugin);
LocalBackEndServices backendService = new LocalBackEndServices();
@ -333,7 +333,7 @@ namespace OpenSim
// TODO No user stats collection yet for standalone
m_loginService =
new LocalLoginService(userService, m_standaloneWelcomeMessage, localComms, m_networkServersInfo,
null, m_standaloneAuthenticate);
m_standaloneAuthenticate);
m_loginService.OnLoginToRegion += backendService.AddNewSession;
// XMLRPC action

View File

@ -55,8 +55,8 @@ namespace OpenSim.Region.Communications.Local
public LocalLoginService(UserManagerBase userManager, string welcomeMess,
CommunicationsLocal parent, NetworkServersInfo serversInfo,
UserStatsReporter statsCollector, bool authenticate)
: base(userManager, parent.UserProfileCacheService.libraryRoot, statsCollector, welcomeMess)
bool authenticate)
: base(userManager, parent.UserProfileCacheService.libraryRoot, welcomeMess)
{
m_Parent = parent;
this.serversInfo = serversInfo;

View File

@ -52,8 +52,7 @@ namespace OpenSim.Region.Communications.Local
/// <param name="inventoryService"></param>
/// <param name="statsCollector">Can be null if stats collection is not required.</param>
public LocalUserServices(NetworkServersInfo serversInfo, uint defaultHomeLocX, uint defaultHomeLocY,
IInventoryServices inventoryService, UserStatsReporter statsCollector)
: base(statsCollector)
IInventoryServices inventoryService)
{
m_serversInfo = serversInfo;

View File

@ -77,7 +77,7 @@ namespace SimpleApp
LocalUserServices userService =
new LocalUserServices(m_networkServersInfo, m_networkServersInfo.DefaultHomeLocX,
m_networkServersInfo.DefaultHomeLocY, inventoryService, null);
m_networkServersInfo.DefaultHomeLocY, inventoryService);
userService.AddPlugin(m_userPlugin);
LocalBackEndServices backendService = new LocalBackEndServices();
@ -89,7 +89,7 @@ namespace SimpleApp
LocalLoginService loginService =
new LocalLoginService(
userService, String.Empty, localComms, m_networkServersInfo, null, false);
userService, String.Empty, localComms, m_networkServersInfo, false);
loginService.OnLoginToRegion += backendService.AddNewSession;
m_httpServer.AddXmlRPCHandler("login_to_simulator", loginService.XmlRpcLoginMethod);