31 using System.Collections;
32 using System.Collections.Generic;
33 using System.Reflection;
37 using OpenSim.Framework;
38 using OpenSim.Services.Connectors;
39 using OpenSim.Region.Framework.Interfaces;
40 using OpenSim.Region.Framework.Scenes;
41 using OpenSim.Server.Base;
42 using OpenSim.Services.Interfaces;
45 namespace OpenSim.
Region.CoreModules.ServiceConnectorsOut.Grid
47 [Extension(Path =
"/OpenSim/RegionModules", NodeName =
"RegionModule", Id =
"RemoteGridServicesConnector")]
50 private static readonly ILog m_log =
52 MethodBase.GetCurrentMethod().DeclaringType);
54 private bool m_Enabled =
false;
67 InitialiseServices(source);
70 #region ISharedRegionmodule
72 public Type ReplaceableInterface
79 get {
return "RemoteGridServicesConnector"; }
84 IConfig moduleConfig = source.Configs[
"Modules"];
85 if (moduleConfig != null)
87 string name = moduleConfig.GetString(
"GridServices",
"");
90 InitialiseServices(source);
92 m_log.Info(
"[REMOTE GRID CONNECTOR]: Remote grid enabled");
97 private void InitialiseServices(IConfigSource source)
99 IConfig gridConfig = source.Configs[
"GridService"];
100 if (gridConfig == null)
102 m_log.Error(
"[REMOTE GRID CONNECTOR]: GridService missing from OpenSim.ini");
106 string networkConnector = gridConfig.GetString(
"NetworkConnector", string.Empty);
107 if (networkConnector ==
string.Empty)
109 m_log.Error(
"[REMOTE GRID CONNECTOR]: Please specify a network connector under [GridService]");
114 m_RemoteGridService = ServerUtils.LoadPlugin<
IGridService>(networkConnector, args);
116 m_LocalGridService =
new LocalGridServicesConnector(source);
121 if (m_LocalGridService != null)
134 if (m_LocalGridService != null)
140 if (m_LocalGridService != null)
154 string msg = m_LocalGridService.RegisterRegion(scopeID, regionInfo);
157 return m_RemoteGridService.RegisterRegion(scopeID, regionInfo);
164 if (m_LocalGridService.DeregisterRegion(regionID))
165 return m_RemoteGridService.DeregisterRegion(regionID);
172 return m_RemoteGridService.GetNeighbours(scopeID, regionID);
177 bool inCache =
false;
178 GridRegion rinfo = m_RegionInfoCache.Get(scopeID,regionID,out inCache);
182 rinfo = m_LocalGridService.GetRegionByUUID(scopeID, regionID);
184 rinfo = m_RemoteGridService.GetRegionByUUID(scopeID, regionID);
186 m_RegionInfoCache.Cache(scopeID,regionID,rinfo);
196 ulong regionHandle = Util.RegionWorldLocToHandle((uint)x, (uint)y);
197 uint regionX = Util.WorldToRegionLoc((uint)x);
198 uint regionY = Util.WorldToRegionLoc((uint)y);
208 bool inCache =
false;
209 GridRegion rinfo = m_RegionInfoCache.Get(scopeID, regionHandle, out inCache);
217 rinfo = m_LocalGridService.GetRegionByPosition(scopeID, x, y);
219 rinfo = m_RemoteGridService.GetRegionByPosition(scopeID, x, y);
221 m_RegionInfoCache.Cache(rinfo);
223 m_log.DebugFormat(
"[REMOTE GRID CONNECTOR]: GetRegionByPosition. Added region {0} to the cache. Pos=<{1},{2}>, RegionHandle={3}",
224 (rinfo == null) ?
"<missing>" : rinfo.RegionName, regionX, regionY, (rinfo == null) ? regionHandle : rinfo.RegionHandle);
231 bool inCache =
false;
232 GridRegion rinfo = m_RegionInfoCache.Get(scopeID,regionName, out inCache);
236 rinfo = m_LocalGridService.GetRegionByName(scopeID, regionName);
238 rinfo = m_RemoteGridService.GetRegionByName(scopeID, regionName);
241 m_RegionInfoCache.Cache(rinfo);
247 List<GridRegion> rinfo = m_LocalGridService.GetRegionsByName(scopeID, name, maxNumber);
249 List<GridRegion> grinfo = m_RemoteGridService.GetRegionsByName(scopeID, name, maxNumber);
256 m_RegionInfoCache.Cache(r);
257 if (rinfo.Find(delegate(
GridRegion gr) {
return gr.RegionID == r.RegionID; }) == null)
265 public virtual List<GridRegion>
GetRegionRange(UUID scopeID,
int xmin,
int xmax,
int ymin,
int ymax)
267 List<GridRegion> rinfo = m_LocalGridService.GetRegionRange(scopeID, xmin, xmax, ymin, ymax);
269 List<GridRegion> grinfo = m_RemoteGridService.GetRegionRange(scopeID, xmin, xmax, ymin, ymax);
276 m_RegionInfoCache.Cache(r);
277 if (rinfo.Find(delegate(
GridRegion gr) {
return gr.RegionID == r.RegionID; }) == null)
287 List<GridRegion> rinfo = m_LocalGridService.GetDefaultRegions(scopeID);
289 List<GridRegion> grinfo = m_RemoteGridService.GetDefaultRegions(scopeID);
296 m_RegionInfoCache.Cache(r);
297 if (rinfo.Find(delegate(
GridRegion gr) {
return gr.RegionID == r.RegionID; }) == null)
307 List<GridRegion> rinfo = m_LocalGridService.GetDefaultHypergridRegions(scopeID);
309 List<GridRegion> grinfo = m_RemoteGridService.GetDefaultHypergridRegions(scopeID);
316 m_RegionInfoCache.Cache(r);
317 if (rinfo.Find(delegate(
GridRegion gr) {
return gr.RegionID == r.RegionID; }) == null)
327 List<GridRegion> rinfo = m_LocalGridService.GetFallbackRegions(scopeID, x, y);
329 List<GridRegion> grinfo = m_RemoteGridService.GetFallbackRegions(scopeID, x, y);
336 m_RegionInfoCache.Cache(r);
337 if (rinfo.Find(delegate(
GridRegion gr) {
return gr.RegionID == r.RegionID; }) == null)
347 List<GridRegion> rinfo = m_LocalGridService.GetHyperlinks(scopeID);
349 List<GridRegion> grinfo = m_RemoteGridService.GetHyperlinks(scopeID);
356 m_RegionInfoCache.Cache(r);
357 if (rinfo.Find(delegate(
GridRegion gr) {
return gr.RegionID == r.RegionID; }) == null)
367 int flags = m_LocalGridService.GetRegionFlags(scopeID, regionID);
369 flags = m_RemoteGridService.GetRegionFlags(scopeID, regionID);
376 Dictionary<string, object> extraFeatures;
377 extraFeatures = m_LocalGridService.GetExtraFeatures();
379 if (extraFeatures.Count == 0)
380 extraFeatures = m_RemoteGridService.GetExtraFeatures();
382 return extraFeatures;
virtual List< GridRegion > GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax)
List< GridRegion > GetHyperlinks(UUID scopeID)
void AddRegion(Scene scene)
This is called whenever a Scene is added. For shared modules, this can happen several times...
List< GridRegion > GetFallbackRegions(UUID scopeID, int x, int y)
RemoteGridServicesConnector()
void RegionLoaded(Scene scene)
This will be called once for every scene loaded. In a shared module this will be multiple times in on...
void PostInitialise()
This is called exactly once after all the shared region-modules have been instanciated and IRegionMod...
Dictionary< string, object > GetExtraFeatures()
List< GridRegion > GetNeighbours(UUID scopeID, UUID regionID)
Get information about the regions neighbouring the given co-ordinates (in meters).
GridRegion GetRegionByName(UUID scopeID, string regionName)
Get information about a region which exactly matches the name given.
List< GridRegion > GetDefaultHypergridRegions(UUID scopeID)
List< GridRegion > GetRegionsByName(UUID scopeID, string name, int maxNumber)
Get information about regions starting with the provided name.
bool DeregisterRegion(UUID regionID)
Deregister a region with the grid service.
RemoteGridServicesConnector(IConfigSource source)
OpenSim.Services.Interfaces.GridRegion GridRegion
string RegisterRegion(UUID scopeID, GridRegion regionInfo)
Register a region with the grid service.
void RemoveRegion(Scene scene)
This is called whenever a Scene is removed. For shared modules, this can happen several times...
GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
Get the region at the given position (in meters)
GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
int GetRegionFlags(UUID scopeID, UUID regionID)
Get internal OpenSimulator region flags.
void Close()
This is the inverse to Initialise. After a Close(), this instance won't be usable anymore...
List< GridRegion > GetDefaultRegions(UUID scopeID)
void Initialise(IConfigSource source)
This is called to initialize the region module. For shared modules, this is called exactly once...