32 using System.Collections.Generic;
33 using System.Reflection;
34 using OpenSim.Framework;
35 using OpenSim.Framework.Console;
36 using OpenSim.Server.Base;
37 using OpenSim.Region.Framework.Interfaces;
38 using OpenSim.Region.Framework.Scenes;
39 using OpenSim.Services.Interfaces;
45 [Extension(Path =
"/OpenSim/RegionModules", NodeName =
"RegionModule", Id =
"LocalGridServicesConnector")]
48 private static readonly ILog m_log =
50 MethodBase.GetCurrentMethod().DeclaringType);
51 private static string LogHeader =
"[LOCAL GRID SERVICE CONNECTOR]";
54 private Dictionary<UUID, RegionCache> m_LocalCache =
new Dictionary<UUID, RegionCache>();
56 private bool m_Enabled;
60 m_log.DebugFormat(
"{0} LocalGridServicesConnector no parms.", LogHeader);
65 m_log.DebugFormat(
"{0} LocalGridServicesConnector instantiated directly.", LogHeader);
66 InitialiseService(source);
69 #region ISharedRegionModule
71 public Type ReplaceableInterface
78 get {
return "LocalGridServicesConnector"; }
83 IConfig moduleConfig = source.Configs[
"Modules"];
84 if (moduleConfig != null)
86 string name = moduleConfig.GetString(
"GridServices",
"");
89 InitialiseService(source);
90 m_log.Info(
"[LOCAL GRID SERVICE CONNECTOR]: Local grid connector enabled");
95 private void InitialiseService(IConfigSource source)
97 IConfig config = source.Configs[
"GridService"];
100 m_log.Error(
"[LOCAL GRID SERVICE CONNECTOR]: GridService missing from OpenSim.ini");
104 string serviceDll = config.GetString(
"LocalServiceModule", String.Empty);
106 if (serviceDll ==
String.Empty)
108 m_log.Error(
"[LOCAL GRID SERVICE CONNECTOR]: No LocalServiceModule named in section GridService");
117 if (m_GridService == null)
119 m_log.Error(
"[LOCAL GRID SERVICE CONNECTOR]: Can't load grid service");
130 MainConsole.Instance.Commands.AddCommand(
"Regions",
false,
"show neighbours",
132 "Shows the local regions' neighbours", HandleShowNeighboursCommand);
149 m_log.ErrorFormat(
"[LOCAL GRID SERVICE CONNECTOR]: simulator seems to have more than one region with the same UUID. Please correct this!");
151 m_LocalCache.Add(scene.RegionInfo.RegionID,
new RegionCache(scene));
162 m_LocalCache[scene.RegionInfo.RegionID].Clear();
163 m_LocalCache.Remove(scene.RegionInfo.RegionID);
177 return m_GridService.RegisterRegion(scopeID, regionInfo);
182 return m_GridService.DeregisterRegion(regionID);
187 return m_GridService.GetNeighbours(scopeID, regionID);
192 return m_GridService.GetRegionByUUID(scopeID, regionID);
201 uint regionX = Util.WorldToRegionLoc((uint)x);
202 uint regionY = Util.WorldToRegionLoc((uint)y);
209 foreach (
RegionCache rcache
in m_LocalCache.Values)
211 region = rcache.GetRegionByPosition(x, y);
225 region = m_GridService.GetRegionByPosition(scopeID, x, y);
229 m_log.DebugFormat(
"{0} GetRegionByPosition. Region not found by grid service. Pos=<{1},{2}>",
230 LogHeader, regionX, regionY);
234 m_log.DebugFormat(
"{0} GetRegionByPosition. Got region {1} from grid service. Pos=<{2},{3}>",
235 LogHeader, region.RegionName,
236 Util.WorldToRegionLoc((uint)region.
RegionLocX), Util.WorldToRegionLoc((uint)region.
RegionLocY));
245 return m_GridService.GetRegionByName(scopeID, regionName);
250 return m_GridService.GetRegionsByName(scopeID, name, maxNumber);
253 public List<GridRegion>
GetRegionRange(UUID scopeID,
int xmin,
int xmax,
int ymin,
int ymax)
255 return m_GridService.GetRegionRange(scopeID, xmin, xmax, ymin, ymax);
260 return m_GridService.GetDefaultRegions(scopeID);
265 return m_GridService.GetDefaultHypergridRegions(scopeID);
270 return m_GridService.GetFallbackRegions(scopeID, x, y);
275 return m_GridService.GetHyperlinks(scopeID);
280 return m_GridService.GetRegionFlags(scopeID, regionID);
285 return m_GridService.GetExtraFeatures();
292 System.Text.StringBuilder caps =
new System.Text.StringBuilder();
296 foreach (KeyValuePair<UUID, RegionCache> kvp
in m_LocalCache)
298 caps.AppendFormat(
"*** Neighbours of {0} ({1}) ***\n", kvp.Value.RegionName, kvp.Key);
299 List<GridRegion> regions = kvp.Value.GetNeighbours();
301 caps.AppendFormat(
" {0} @ {1}-{2}\n", r.RegionName, Util.WorldToRegionLoc((uint)r.
RegionLocX), Util.WorldToRegionLoc((uint)r.
RegionLocY));
305 MainConsole.Instance.Output(caps.ToString());
GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
Get the region at the given position (in meters)
List< GridRegion > GetDefaultRegions(UUID scopeID)
List< GridRegion > GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax)
void Initialise(IConfigSource source)
This is called to initialize the region module. For shared modules, this is called exactly once...
List< GridRegion > GetDefaultHypergridRegions(UUID scopeID)
int GetRegionFlags(UUID scopeID, UUID regionID)
Get internal OpenSimulator region flags.
Dictionary< string, object > GetExtraFeatures()
string RegisterRegion(UUID scopeID, GridRegion regionInfo)
Register a region with the grid service.
void Close()
This is the inverse to Initialise. After a Close(), this instance won't be usable anymore...
LocalGridServicesConnector(IConfigSource source)
void HandleShowNeighboursCommand(string module, string[] cmdparams)
GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
int RegionLocX
The location of this region in meters. DANGER DANGER! Note that this name means something different i...
List< GridRegion > GetHyperlinks(UUID scopeID)
int RegionLocY
The location of this region in meters. DANGER DANGER! Note that this name means something different i...
LocalGridServicesConnector()
OpenSim.Services.Interfaces.GridRegion GridRegion
Interactive OpenSim region server
void PostInitialise()
This is called exactly once after all the shared region-modules have been instanciated and IRegionMod...
bool DeregisterRegion(UUID regionID)
Deregister a region with the grid service.
List< GridRegion > GetRegionsByName(UUID scopeID, string name, int maxNumber)
Get information about regions starting with the provided name.
void AddRegion(Scene scene)
This is called whenever a Scene is added. For shared modules, this can happen several times...
void RegionLoaded(Scene scene)
This will be called once for every scene loaded. In a shared module this will be multiple times in on...
List< GridRegion > GetNeighbours(UUID scopeID, UUID regionID)
Get information about the regions neighbouring the given co-ordinates (in meters).
virtual RegionInfo RegionInfo
GridRegion GetRegionByName(UUID scopeID, string regionName)
Get information about a region which exactly matches the name given.
List< GridRegion > GetFallbackRegions(UUID scopeID, int x, int y)
void RemoveRegion(Scene scene)
This is called whenever a Scene is removed. For shared modules, this can happen several times...