Partial revert commit aed3df84a7
Can't assume GridService runs within same instance as GridInfoService
This commit is contained in:
@@ -36,16 +36,12 @@ using Nini.Config;
|
|||||||
using Nwc.XmlRpc;
|
using Nwc.XmlRpc;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
using OpenSim.Framework.Servers.HttpServer;
|
using OpenSim.Framework.Servers.HttpServer;
|
||||||
using OpenSim.Services.Interfaces;
|
|
||||||
using OpenSim.Services.Base;
|
using OpenSim.Services.Base;
|
||||||
using OpenSim.Server.Base;
|
|
||||||
|
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
using OpenMetaverse.StructuredData;
|
using OpenMetaverse.StructuredData;
|
||||||
using OpenSim.Data;
|
using OpenSim.Data;
|
||||||
|
|
||||||
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
|
|
||||||
|
|
||||||
namespace OpenSim.Server.Handlers.Grid
|
namespace OpenSim.Server.Handlers.Grid
|
||||||
{
|
{
|
||||||
public class GridInfoHandlers
|
public class GridInfoHandlers
|
||||||
@@ -59,7 +55,7 @@ namespace OpenSim.Server.Handlers.Grid
|
|||||||
private byte[] cachedStatAnswer = null;
|
private byte[] cachedStatAnswer = null;
|
||||||
private bool stats_available = false;
|
private bool stats_available = false;
|
||||||
private int _lastrun;
|
private int _lastrun;
|
||||||
protected IGridService m_GridService = null;
|
protected IRegionData m_Database_regions = null;
|
||||||
protected IGridUserData m_Database_griduser = null;
|
protected IGridUserData m_Database_griduser = null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -89,34 +85,30 @@ namespace OpenSim.Server.Handlers.Grid
|
|||||||
if (stats_available)
|
if (stats_available)
|
||||||
{
|
{
|
||||||
stats_available = false;
|
stats_available = false;
|
||||||
string gridService = m_Config.Configs["GridService"].GetString("LocalServiceModule", string.Empty);
|
IConfig dbConfig = configSource.Configs["DatabaseService"];
|
||||||
if(!string.IsNullOrEmpty(gridService))
|
if (dbConfig is not null)
|
||||||
{
|
{
|
||||||
m_GridService = ServerUtils.LoadPlugin<IGridService>(gridService, [m_Config]);
|
ServiceBase serviceBase = new(configSource);
|
||||||
if(m_GridService != null)
|
string dllName = dbConfig.GetString("StorageProvider", String.Empty);
|
||||||
{
|
string connString = dbConfig.GetString("ConnectionString", String.Empty);
|
||||||
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);
|
|
||||||
|
|
||||||
if (dllName.Length != 0 && connString.Length != 0)
|
if (dllName.Length != 0 && connString.Length != 0)
|
||||||
|
{
|
||||||
|
m_Database_regions = serviceBase.LoadPlugin<IRegionData>(dllName, [connString, "regions"]);
|
||||||
|
if(m_Database_regions != null)
|
||||||
|
{
|
||||||
|
m_Database_griduser = serviceBase.LoadPlugin<IGridUserData>(dllName, [connString, "GridUser"]);
|
||||||
|
if (m_Database_griduser != null)
|
||||||
{
|
{
|
||||||
m_Database_griduser = serviceBase.LoadPlugin<IGridUserData>(dllName, [connString, "GridUser"]);
|
stats_available = true;
|
||||||
if (m_Database_griduser != null)
|
_log.Debug("[GRID INFO SERVICE]: Grid Stats enabled");
|
||||||
{
|
|
||||||
stats_available = true;
|
|
||||||
_log.Debug("[GRID INFO SERVICE]: Grid Stats enabled");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!stats_available)
|
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
|
try
|
||||||
{
|
{
|
||||||
// Fetch region data
|
// Fetch region data
|
||||||
if(m_GridService is not null)
|
List<RegionData> regions = m_Database_regions.GetOnlineRegions(UUID.Zero);
|
||||||
|
foreach (RegionData region in regions)
|
||||||
{
|
{
|
||||||
List<GridRegion> regions = m_GridService.GetOnlineRegions(UUID.Zero, 0, 0, int.MaxValue);
|
// Count individual region equivalent
|
||||||
foreach (GridRegion region in regions)
|
region_count += (region.sizeX * region.sizeY) >> 16;
|
||||||
{
|
|
||||||
// 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
|
// Fetch all grid users, can't do a simple query unfortunately
|
||||||
GridUserData[] gridusers = m_Database_griduser.GetAll(string.Empty);
|
GridUserData[] gridusers = m_Database_griduser.GetAll(string.Empty);
|
||||||
|
|||||||
Reference in New Issue
Block a user