try to improve wquivalent regions count for standalones case on grid stats. Thx Tampa
This commit is contained in:
@@ -36,10 +36,15 @@ using Nini.Config;
|
||||
using Nwc.XmlRpc;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Servers.HttpServer;
|
||||
using OpenSim.Services.Interfaces;
|
||||
using OpenSim.Services.Base;
|
||||
using OpenSim.Server.Base;
|
||||
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.StructuredData;
|
||||
using OpenSim.Data;
|
||||
using OpenSim.Services.Base;
|
||||
|
||||
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
|
||||
|
||||
namespace OpenSim.Server.Handlers.Grid
|
||||
{
|
||||
@@ -54,7 +59,7 @@ namespace OpenSim.Server.Handlers.Grid
|
||||
private byte[] cachedStatAnswer = null;
|
||||
private bool stats_available = false;
|
||||
private int _lastrun;
|
||||
protected IRegionData m_Database_regions = null;
|
||||
protected IGridService m_GridService = null;
|
||||
protected IGridUserData m_Database_griduser = null;
|
||||
|
||||
/// <summary>
|
||||
@@ -83,31 +88,36 @@ namespace OpenSim.Server.Handlers.Grid
|
||||
|
||||
if (stats_available)
|
||||
{
|
||||
|
||||
stats_available = false;
|
||||
IConfig dbConfig = configSource.Configs["DatabaseService"];
|
||||
if (dbConfig is not null)
|
||||
string gridService = m_Config.Configs["GridService"].GetString("LocalServiceModule", string.Empty);
|
||||
if(!string.IsNullOrEmpty(gridService))
|
||||
{
|
||||
ServiceBase serviceBase = new(configSource);
|
||||
string dllName = dbConfig.GetString("StorageProvider", String.Empty);
|
||||
string connString = dbConfig.GetString("ConnectionString", String.Empty);
|
||||
|
||||
if (dllName.Length != 0 && connString.Length != 0)
|
||||
{
|
||||
m_Database_regions = serviceBase.LoadPlugin<IRegionData>(dllName, [connString, "regions"]);
|
||||
if(m_Database_regions != null)
|
||||
m_GridService = ServerUtils.LoadPlugin<IGridService>(gridService, [m_Config]);
|
||||
if(m_GridService != null)
|
||||
{
|
||||
IConfig dbConfig = configSource.Configs["DatabaseService"];
|
||||
if (dbConfig is not null)
|
||||
{
|
||||
m_Database_griduser = serviceBase.LoadPlugin<IGridUserData>(dllName, [connString, "GridUser"]);
|
||||
if (m_Database_griduser != null)
|
||||
ServiceBase serviceBase = new(configSource);
|
||||
string dllName = dbConfig.GetString("StorageProvider", String.Empty);
|
||||
string connString = dbConfig.GetString("ConnectionString", String.Empty);
|
||||
|
||||
if (dllName.Length != 0 && connString.Length != 0)
|
||||
{
|
||||
stats_available = true;
|
||||
_log.Debug("[GRID INFO SERVICE]: Grid Stats enabled");
|
||||
m_Database_griduser = serviceBase.LoadPlugin<IGridUserData>(dllName, [connString, "GridUser"]);
|
||||
if (m_Database_griduser != null)
|
||||
{
|
||||
stats_available = true;
|
||||
_log.Debug("[GRID INFO SERVICE]: Grid Stats enabled");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!stats_available)
|
||||
{
|
||||
_log.Warn("[GRID INFO SERVICE]: Could not find or initialize Database Service config, grid stats will be unavailable!");
|
||||
_log.Warn("[GRID INFO SERVICE]: Could not initialize. Grid stats will be unavailable!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -273,17 +283,23 @@ namespace OpenSim.Server.Handlers.Grid
|
||||
try
|
||||
{
|
||||
// Fetch region data
|
||||
List<RegionData> regions = m_Database_regions.GetOnlineRegions(UUID.Zero);
|
||||
foreach (RegionData region in regions)
|
||||
if(m_GridService is not null)
|
||||
{
|
||||
// Count individual region equivalent
|
||||
region_count += (region.sizeX * region.sizeY) >> 16;
|
||||
List<GridRegion> regions = m_GridService.GetOnlineRegions(UUID.Zero, 0, 0, int.MaxValue);
|
||||
foreach (GridRegion region in regions)
|
||||
{
|
||||
// Count individual region equivalent
|
||||
region_count += (region.RegionSizeX * region.RegionSizeY) >> 16;
|
||||
}
|
||||
regions = null;
|
||||
}
|
||||
regions = null;
|
||||
|
||||
// Fetch all grid users, can't do a simple query unfortunately
|
||||
GridUserData[] gridusers = m_Database_griduser.GetAll(string.Empty);
|
||||
|
||||
// Count if last login was within the last 30 days
|
||||
int oldestTime = now - 2592000;
|
||||
|
||||
// Go through grid user data
|
||||
foreach (GridUserData griduser in gridusers)
|
||||
{
|
||||
@@ -297,8 +313,7 @@ namespace OpenSim.Server.Handlers.Grid
|
||||
if (last_login == 0)
|
||||
continue;
|
||||
|
||||
// Count if last login was within the last 30 days
|
||||
if (last_login > (now - 2592000))
|
||||
if (last_login > oldestTime)
|
||||
active_users++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1069,29 +1069,32 @@ namespace OpenSim.Services.GridService
|
||||
|
||||
private int ParseFlags(int prev, string flags)
|
||||
{
|
||||
if(string.IsNullOrEmpty(flags))
|
||||
return prev;
|
||||
|
||||
OpenSim.Framework.RegionFlags f = (OpenSim.Framework.RegionFlags)prev;
|
||||
|
||||
string[] parts = flags.Split(new char[] {',', ' '}, StringSplitOptions.RemoveEmptyEntries);
|
||||
string[] parts = flags.Split([',', ' '], StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
foreach (string p in parts)
|
||||
{
|
||||
int val;
|
||||
|
||||
try
|
||||
{
|
||||
if (p.StartsWith("+"))
|
||||
int val;
|
||||
|
||||
if (p.StartsWith('+'))
|
||||
{
|
||||
val = (int)Enum.Parse(typeof(OpenSim.Framework.RegionFlags), p.Substring(1));
|
||||
val = (int)Enum.Parse(typeof(OpenSim.Framework.RegionFlags), p.AsSpan(1), true);
|
||||
f |= (OpenSim.Framework.RegionFlags)val;
|
||||
}
|
||||
else if (p.StartsWith("-"))
|
||||
else if (p.StartsWith('-'))
|
||||
{
|
||||
val = (int)Enum.Parse(typeof(OpenSim.Framework.RegionFlags), p.Substring(1));
|
||||
val = (int)Enum.Parse(typeof(OpenSim.Framework.RegionFlags), p.AsSpan(1), true);
|
||||
f &= ~(OpenSim.Framework.RegionFlags)val;
|
||||
}
|
||||
else
|
||||
{
|
||||
val = (int)Enum.Parse(typeof(OpenSim.Framework.RegionFlags), p);
|
||||
val = (int)Enum.Parse(typeof(OpenSim.Framework.RegionFlags), p.AsSpan());
|
||||
f |= (OpenSim.Framework.RegionFlags)val;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user