let LocalGridServiceConnector also have a RegionInfoCache, use the remote one if this is active.
parent
3c4d908cda
commit
79b7787eff
|
@ -52,6 +52,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
|
|||
|
||||
private IGridService m_GridService;
|
||||
private Dictionary<UUID, RegionCache> m_LocalCache = new Dictionary<UUID, RegionCache>();
|
||||
private RegionInfoCache m_RegionInfoCache = null;
|
||||
|
||||
private bool m_Enabled;
|
||||
|
||||
|
@ -60,10 +61,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
|
|||
m_log.DebugFormat("{0} LocalGridServicesConnector no parms.", LogHeader);
|
||||
}
|
||||
|
||||
public LocalGridServicesConnector(IConfigSource source)
|
||||
public LocalGridServicesConnector(IConfigSource source, RegionInfoCache regionInfoCache)
|
||||
{
|
||||
m_log.DebugFormat("{0} LocalGridServicesConnector instantiated directly.", LogHeader);
|
||||
InitialiseService(source);
|
||||
InitialiseService(source, regionInfoCache);
|
||||
}
|
||||
|
||||
#region ISharedRegionModule
|
||||
|
@ -86,19 +87,25 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
|
|||
string name = moduleConfig.GetString("GridServices", "");
|
||||
if (name == Name)
|
||||
{
|
||||
InitialiseService(source);
|
||||
m_log.Info("[LOCAL GRID SERVICE CONNECTOR]: Local grid connector enabled");
|
||||
|
||||
if(InitialiseService(source,null))
|
||||
m_log.Info("[LOCAL GRID SERVICE CONNECTOR]: Local grid connector enabled");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void InitialiseService(IConfigSource source)
|
||||
private bool InitialiseService(IConfigSource source, RegionInfoCache ric)
|
||||
{
|
||||
if(ric == null)
|
||||
m_RegionInfoCache = new RegionInfoCache();
|
||||
else
|
||||
m_RegionInfoCache = ric;
|
||||
|
||||
IConfig config = source.Configs["GridService"];
|
||||
if (config == null)
|
||||
{
|
||||
m_log.Error("[LOCAL GRID SERVICE CONNECTOR]: GridService missing from OpenSim.ini");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
string serviceDll = config.GetString("LocalServiceModule", String.Empty);
|
||||
|
@ -106,7 +113,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
|
|||
if (serviceDll == String.Empty)
|
||||
{
|
||||
m_log.Error("[LOCAL GRID SERVICE CONNECTOR]: No LocalServiceModule named in section GridService");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
Object[] args = new Object[] { source };
|
||||
|
@ -117,10 +124,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
|
|||
if (m_GridService == null)
|
||||
{
|
||||
m_log.Error("[LOCAL GRID SERVICE CONNECTOR]: Can't load grid service");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
m_Enabled = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void PostInitialise()
|
||||
|
@ -189,7 +197,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
|
|||
|
||||
public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
|
||||
{
|
||||
return m_GridService.GetRegionByUUID(scopeID, regionID);
|
||||
bool inCache = false;
|
||||
GridRegion rinfo = m_RegionInfoCache.Get(scopeID,regionID,out inCache);
|
||||
if (inCache)
|
||||
return rinfo;
|
||||
|
||||
rinfo = m_GridService.GetRegionByUUID(scopeID, regionID);
|
||||
if(rinfo != null)
|
||||
m_RegionInfoCache.Cache(scopeID, rinfo);
|
||||
return rinfo;
|
||||
}
|
||||
|
||||
// Get a region given its base coordinates.
|
||||
|
@ -197,52 +213,37 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
|
|||
// be the base coordinate of the region.
|
||||
public GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
|
||||
{
|
||||
GridRegion region = null;
|
||||
uint regionX = Util.WorldToRegionLoc((uint)x);
|
||||
uint regionY = Util.WorldToRegionLoc((uint)y);
|
||||
// try in cache by handler first
|
||||
ulong regionHandle = Util.RegionWorldLocToHandle((uint)x, (uint)y);
|
||||
|
||||
// First see if it's a neighbour, even if it isn't on this sim.
|
||||
// Neighbour data is cached in memory, so this is fast
|
||||
bool inCache = false;
|
||||
GridRegion rinfo = m_RegionInfoCache.Get(scopeID, regionHandle, out inCache);
|
||||
if (inCache)
|
||||
return rinfo;
|
||||
|
||||
lock (m_LocalCache)
|
||||
{
|
||||
foreach (RegionCache rcache in m_LocalCache.Values)
|
||||
{
|
||||
region = rcache.GetRegionByPosition(x, y);
|
||||
if (region != null)
|
||||
{
|
||||
//m_log.DebugFormat("{0} GetRegionByPosition. Found region {1} in cache (of region {2}). Pos=<{3},{4}>",
|
||||
// LogHeader, region.RegionName, rcache.RegionName,
|
||||
// Util.WorldToRegionLoc((uint)region.RegionLocX), Util.WorldToRegionLoc((uint)region.RegionLocY));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// try in cache by slower position next
|
||||
rinfo = m_RegionInfoCache.Get(scopeID, x, y, out inCache);
|
||||
if (inCache)
|
||||
return rinfo;
|
||||
|
||||
// Then try on this sim (may be a lookup in DB if this is using MySql).
|
||||
if (region == null)
|
||||
{
|
||||
region = m_GridService.GetRegionByPosition(scopeID, x, y);
|
||||
|
||||
if (region == null)
|
||||
{
|
||||
m_log.DebugFormat("{0} GetRegionByPosition. Region not found by grid service. Pos=<{1},{2}>",
|
||||
LogHeader, regionX, regionY);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.DebugFormat("{0} GetRegionByPosition. Got region {1} from grid service. Pos=<{2},{3}>",
|
||||
LogHeader, region.RegionName,
|
||||
Util.WorldToRegionLoc((uint)region.RegionLocX), Util.WorldToRegionLoc((uint)region.RegionLocY));
|
||||
}
|
||||
}
|
||||
|
||||
return region;
|
||||
rinfo = m_GridService.GetRegionByPosition(scopeID, x, y);
|
||||
if(rinfo != null)
|
||||
m_RegionInfoCache.Cache(scopeID, rinfo);
|
||||
return rinfo;
|
||||
}
|
||||
|
||||
public GridRegion GetRegionByName(UUID scopeID, string regionName)
|
||||
{
|
||||
return m_GridService.GetRegionByName(scopeID, regionName);
|
||||
bool inCache = false;
|
||||
GridRegion rinfo = m_RegionInfoCache.Get(scopeID, regionName, out inCache);
|
||||
if (inCache)
|
||||
return rinfo;
|
||||
|
||||
rinfo = m_GridService.GetRegionByName(scopeID, regionName);
|
||||
if(rinfo != null)
|
||||
m_RegionInfoCache.Cache(scopeID, rinfo);
|
||||
return rinfo;
|
||||
}
|
||||
|
||||
public List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber)
|
||||
|
|
|
@ -87,39 +87,47 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
|
|||
string name = moduleConfig.GetString("GridServices", "");
|
||||
if (name == Name)
|
||||
{
|
||||
InitialiseServices(source);
|
||||
m_Enabled = true;
|
||||
m_log.Info("[REMOTE GRID CONNECTOR]: Remote grid enabled");
|
||||
if(InitialiseServices(source))
|
||||
{
|
||||
m_Enabled = true;
|
||||
m_log.Info("[REMOTE GRID CONNECTOR]: Remote grid enabled");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void InitialiseServices(IConfigSource source)
|
||||
private bool InitialiseServices(IConfigSource source)
|
||||
{
|
||||
IConfig gridConfig = source.Configs["GridService"];
|
||||
if (gridConfig == null)
|
||||
{
|
||||
m_log.Error("[REMOTE GRID CONNECTOR]: GridService missing from OpenSim.ini");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
string networkConnector = gridConfig.GetString("NetworkConnector", string.Empty);
|
||||
if (networkConnector == string.Empty)
|
||||
{
|
||||
m_log.Error("[REMOTE GRID CONNECTOR]: Please specify a network connector under [GridService]");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
Object[] args = new Object[] { source };
|
||||
m_RemoteGridService = ServerUtils.LoadPlugin<IGridService>(networkConnector, args);
|
||||
|
||||
m_LocalGridService = new LocalGridServicesConnector(source);
|
||||
m_LocalGridService = new LocalGridServicesConnector(source, m_RegionInfoCache);
|
||||
if (m_LocalGridService == null)
|
||||
{
|
||||
m_log.Error("[REMOTE GRID CONNECTOR]: failed to loar local connector");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void PostInitialise()
|
||||
{
|
||||
if (m_LocalGridService != null)
|
||||
((ISharedRegionModule)m_LocalGridService).PostInitialise();
|
||||
((ISharedRegionModule)m_LocalGridService).PostInitialise();
|
||||
}
|
||||
|
||||
public void Close()
|
||||
|
@ -131,14 +139,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
|
|||
if (m_Enabled)
|
||||
scene.RegisterModuleInterface<IGridService>(this);
|
||||
|
||||
if (m_LocalGridService != null)
|
||||
((ISharedRegionModule)m_LocalGridService).AddRegion(scene);
|
||||
((ISharedRegionModule)m_LocalGridService).AddRegion(scene);
|
||||
}
|
||||
|
||||
public void RemoveRegion(Scene scene)
|
||||
{
|
||||
if (m_LocalGridService != null)
|
||||
((ISharedRegionModule)m_LocalGridService).RemoveRegion(scene);
|
||||
((ISharedRegionModule)m_LocalGridService).RemoveRegion(scene);
|
||||
}
|
||||
|
||||
public void RegionLoaded(Scene scene)
|
||||
|
@ -174,15 +180,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
|
|||
|
||||
public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
|
||||
{
|
||||
bool inCache = false;
|
||||
GridRegion rinfo = m_RegionInfoCache.Get(scopeID,regionID,out inCache);
|
||||
if (inCache)
|
||||
GridRegion rinfo = m_LocalGridService.GetRegionByUUID(scopeID, regionID);
|
||||
if (rinfo != null)
|
||||
return rinfo;
|
||||
|
||||
rinfo = m_LocalGridService.GetRegionByUUID(scopeID, regionID);
|
||||
if (rinfo == null)
|
||||
rinfo = m_RemoteGridService.GetRegionByUUID(scopeID, regionID);
|
||||
|
||||
rinfo = m_RemoteGridService.GetRegionByUUID(scopeID, regionID);
|
||||
m_RegionInfoCache.Cache(scopeID, rinfo);
|
||||
return rinfo;
|
||||
}
|
||||
|
@ -193,24 +195,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
|
|||
// The coordinates are world coords (meters), NOT region units.
|
||||
public GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
|
||||
{
|
||||
// try in cache by handler first
|
||||
ulong regionHandle = Util.RegionWorldLocToHandle((uint)x, (uint)y);
|
||||
|
||||
bool inCache = false;
|
||||
GridRegion rinfo = m_RegionInfoCache.Get(scopeID, regionHandle, out inCache);
|
||||
if (inCache)
|
||||
GridRegion rinfo = m_LocalGridService.GetRegionByPosition(scopeID, x, y);
|
||||
if (rinfo != null)
|
||||
{
|
||||
m_log.DebugFormat("[REMOTE GRID CONNECTOR]: GetRegionByPosition. Added region {0} to the cache from local. Pos=<{1},{2}>, RegionHandle={3}",
|
||||
rinfo.RegionName, rinfo.RegionCoordX, rinfo.RegionCoordY, rinfo.RegionHandle);
|
||||
return rinfo;
|
||||
}
|
||||
|
||||
// try in cache by slower position next
|
||||
rinfo = m_RegionInfoCache.Get(scopeID, x, y, out inCache);
|
||||
if (inCache)
|
||||
return rinfo;
|
||||
|
||||
rinfo = m_LocalGridService.GetRegionByPosition(scopeID, x, y);
|
||||
if (rinfo == null)
|
||||
rinfo = m_RemoteGridService.GetRegionByPosition(scopeID, x, y);
|
||||
|
||||
|
||||
rinfo = m_RemoteGridService.GetRegionByPosition(scopeID, x, y);
|
||||
|
||||
if (rinfo == null)
|
||||
{
|
||||
|
@ -223,23 +216,18 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
|
|||
m_RegionInfoCache.Cache(scopeID, rinfo);
|
||||
|
||||
m_log.DebugFormat("[REMOTE GRID CONNECTOR]: GetRegionByPosition. Added region {0} to the cache. Pos=<{1},{2}>, RegionHandle={3}",
|
||||
rinfo.RegionName, rinfo.RegionCoordX, rinfo.RegionCoordY, (rinfo == null) ? regionHandle : rinfo.RegionHandle);
|
||||
rinfo.RegionName, rinfo.RegionCoordX, rinfo.RegionCoordY, rinfo.RegionHandle);
|
||||
}
|
||||
return rinfo;
|
||||
}
|
||||
|
||||
public GridRegion GetRegionByName(UUID scopeID, string regionName)
|
||||
{
|
||||
bool inCache = false;
|
||||
GridRegion rinfo = m_RegionInfoCache.Get(scopeID, regionName, out inCache);
|
||||
if (inCache)
|
||||
GridRegion rinfo = m_LocalGridService.GetRegionByName(scopeID, regionName);
|
||||
if (rinfo != null)
|
||||
return rinfo;
|
||||
|
||||
rinfo = m_LocalGridService.GetRegionByName(scopeID, regionName);
|
||||
if (rinfo == null)
|
||||
rinfo = m_RemoteGridService.GetRegionByName(scopeID, regionName);
|
||||
|
||||
// can't cache negative results for name lookups
|
||||
|
||||
rinfo = m_RemoteGridService.GetRegionByName(scopeID, regionName);
|
||||
m_RegionInfoCache.Cache(scopeID, rinfo);
|
||||
return rinfo;
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests
|
|||
config.Configs["GridService"].Set("Region_Test_Region_3", "FallbackRegion");
|
||||
config.Configs["GridService"].Set("Region_Other_Region_4", "FallbackRegion");
|
||||
|
||||
m_LocalConnector = new LocalGridServicesConnector(config);
|
||||
m_LocalConnector = new LocalGridServicesConnector(config, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
Loading…
Reference in New Issue