diff --git a/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs b/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs index 8fa0c96deb..6c311bca83 100644 --- a/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs +++ b/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs @@ -36,16 +36,12 @@ 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 GridRegion = OpenSim.Services.Interfaces.GridRegion; - namespace OpenSim.Server.Handlers.Grid { public class GridInfoHandlers @@ -59,7 +55,7 @@ namespace OpenSim.Server.Handlers.Grid private byte[] cachedStatAnswer = null; private bool stats_available = false; private int _lastrun; - protected IGridService m_GridService = null; + protected IRegionData m_Database_regions = null; protected IGridUserData m_Database_griduser = null; /// @@ -89,34 +85,30 @@ namespace OpenSim.Server.Handlers.Grid if (stats_available) { stats_available = false; - string gridService = m_Config.Configs["GridService"].GetString("LocalServiceModule", string.Empty); - if(!string.IsNullOrEmpty(gridService)) + IConfig dbConfig = configSource.Configs["DatabaseService"]; + if (dbConfig is not null) { - m_GridService = ServerUtils.LoadPlugin(gridService, [m_Config]); - if(m_GridService != null) - { - IConfig dbConfig = configSource.Configs["DatabaseService"]; - if (dbConfig is not null) - { - ServiceBase serviceBase = new(configSource); - string dllName = dbConfig.GetString("StorageProvider", String.Empty); - string connString = dbConfig.GetString("ConnectionString", String.Empty); + 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) + if (dllName.Length != 0 && connString.Length != 0) + { + m_Database_regions = serviceBase.LoadPlugin(dllName, [connString, "regions"]); + if(m_Database_regions != null) + { + m_Database_griduser = serviceBase.LoadPlugin(dllName, [connString, "GridUser"]); + if (m_Database_griduser != null) { - m_Database_griduser = serviceBase.LoadPlugin(dllName, [connString, "GridUser"]); - if (m_Database_griduser != null) - { - stats_available = true; - _log.Debug("[GRID INFO SERVICE]: Grid Stats enabled"); - } + stats_available = true; + _log.Debug("[GRID INFO SERVICE]: Grid Stats enabled"); } } } } if (!stats_available) { - _log.Warn("[GRID INFO SERVICE]: Could not initialize. Grid stats will be unavailable!"); + _log.Warn("[GRID INFO SERVICE]: Could not find or initialize Database Service config. Grid stats will be unavailable!"); } } @@ -282,16 +274,13 @@ namespace OpenSim.Server.Handlers.Grid try { // Fetch region data - if(m_GridService is not null) + List regions = m_Database_regions.GetOnlineRegions(UUID.Zero); + foreach (RegionData region in regions) { - List 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; + // Count individual region equivalent + region_count += (region.sizeX * region.sizeY) >> 16; } + regions = null; // Fetch all grid users, can't do a simple query unfortunately GridUserData[] gridusers = m_Database_griduser.GetAll(string.Empty);