aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs100
1 files changed, 78 insertions, 22 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs
index c0c2ca7..1f782f5 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs
@@ -48,6 +48,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
48 private static readonly ILog m_log = 48 private static readonly ILog m_log =
49 LogManager.GetLogger( 49 LogManager.GetLogger(
50 MethodBase.GetCurrentMethod().DeclaringType); 50 MethodBase.GetCurrentMethod().DeclaringType);
51 private static string LogHeader = "[LOCAL GRID SERVICE CONNECTOR]";
51 52
52 private IGridService m_GridService; 53 private IGridService m_GridService;
53 private Dictionary<UUID, RegionCache> m_LocalCache = new Dictionary<UUID, RegionCache>(); 54 private Dictionary<UUID, RegionCache> m_LocalCache = new Dictionary<UUID, RegionCache>();
@@ -56,11 +57,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
56 57
57 public LocalGridServicesConnector() 58 public LocalGridServicesConnector()
58 { 59 {
60 m_log.DebugFormat("{0} LocalGridServicesConnector no parms.", LogHeader);
59 } 61 }
60 62
61 public LocalGridServicesConnector(IConfigSource source) 63 public LocalGridServicesConnector(IConfigSource source)
62 { 64 {
63 m_log.Debug("[LOCAL GRID SERVICE CONNECTOR]: LocalGridServicesConnector instantiated directly."); 65 m_log.DebugFormat("{0} LocalGridServicesConnector instantiated directly.", LogHeader);
64 InitialiseService(source); 66 InitialiseService(source);
65 } 67 }
66 68
@@ -92,15 +94,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
92 94
93 private void InitialiseService(IConfigSource source) 95 private void InitialiseService(IConfigSource source)
94 { 96 {
95 IConfig assetConfig = source.Configs["GridService"]; 97 IConfig config = source.Configs["GridService"];
96 if (assetConfig == null) 98 if (config == null)
97 { 99 {
98 m_log.Error("[LOCAL GRID SERVICE CONNECTOR]: GridService missing from OpenSim.ini"); 100 m_log.Error("[LOCAL GRID SERVICE CONNECTOR]: GridService missing from OpenSim.ini");
99 return; 101 return;
100 } 102 }
101 103
102 string serviceDll = assetConfig.GetString("LocalServiceModule", 104 string serviceDll = config.GetString("LocalServiceModule", String.Empty);
103 String.Empty);
104 105
105 if (serviceDll == String.Empty) 106 if (serviceDll == String.Empty)
106 { 107 {
@@ -142,10 +143,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
142 143
143 scene.RegisterModuleInterface<IGridService>(this); 144 scene.RegisterModuleInterface<IGridService>(this);
144 145
145 if (m_LocalCache.ContainsKey(scene.RegionInfo.RegionID)) 146 lock (m_LocalCache)
146 m_log.ErrorFormat("[LOCAL GRID SERVICE CONNECTOR]: simulator seems to have more than one region with the same UUID. Please correct this!"); 147 {
147 else 148 if (m_LocalCache.ContainsKey(scene.RegionInfo.RegionID))
148 m_LocalCache.Add(scene.RegionInfo.RegionID, new RegionCache(scene)); 149 m_log.ErrorFormat("[LOCAL GRID SERVICE CONNECTOR]: simulator seems to have more than one region with the same UUID. Please correct this!");
150 else
151 m_LocalCache.Add(scene.RegionInfo.RegionID, new RegionCache(scene));
152 }
149 } 153 }
150 154
151 public void RemoveRegion(Scene scene) 155 public void RemoveRegion(Scene scene)
@@ -153,8 +157,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
153 if (!m_Enabled) 157 if (!m_Enabled)
154 return; 158 return;
155 159
156 m_LocalCache[scene.RegionInfo.RegionID].Clear(); 160 lock (m_LocalCache)
157 m_LocalCache.Remove(scene.RegionInfo.RegionID); 161 {
162 m_LocalCache[scene.RegionInfo.RegionID].Clear();
163 m_LocalCache.Remove(scene.RegionInfo.RegionID);
164 }
158 } 165 }
159 166
160 public void RegionLoaded(Scene scene) 167 public void RegionLoaded(Scene scene)
@@ -185,23 +192,59 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
185 return m_GridService.GetRegionByUUID(scopeID, regionID); 192 return m_GridService.GetRegionByUUID(scopeID, regionID);
186 } 193 }
187 194
195 // Get a region given its base coordinates.
196 // NOTE: this is NOT 'get a region by some point in the region'. The coordinate MUST
197 // be the base coordinate of the region.
188 public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) 198 public GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
189 { 199 {
190 GridRegion region = null; 200 GridRegion region = null;
201 uint regionX = Util.WorldToRegionLoc((uint)x);
202 uint regionY = Util.WorldToRegionLoc((uint)y);
203
204 // Sanity check
205 if ((Util.RegionToWorldLoc(regionX) != (uint)x) || (Util.RegionToWorldLoc(regionY) != (uint)y))
206 {
207 m_log.WarnFormat("{0} GetRegionByPosition. Bad position requested: not the base of the region. Requested Pos=<{1},{2}>, Should Be=<{3},{4}>",
208 LogHeader, x, y, Util.RegionToWorldLoc(regionX), Util.RegionToWorldLoc(regionY));
209 }
191 210
192 // First see if it's a neighbour, even if it isn't on this sim. 211 // First see if it's a neighbour, even if it isn't on this sim.
193 // Neighbour data is cached in memory, so this is fast 212 // Neighbour data is cached in memory, so this is fast
194 foreach (RegionCache rcache in m_LocalCache.Values) 213
214 lock (m_LocalCache)
195 { 215 {
196 region = rcache.GetRegionByPosition(x, y); 216 foreach (RegionCache rcache in m_LocalCache.Values)
197 if (region != null)
198 { 217 {
199 return region; 218 region = rcache.GetRegionByPosition(x, y);
219 if (region != null)
220 {
221 m_log.DebugFormat("{0} GetRegionByPosition. Found region {1} in cache (of region {2}). Pos=<{3},{4}>",
222 LogHeader, region.RegionName, rcache.RegionName,
223 Util.WorldToRegionLoc((uint)region.RegionLocX), Util.WorldToRegionLoc((uint)region.RegionLocY));
224 break;
225 }
200 } 226 }
201 } 227 }
202 228
203 // Then try on this sim (may be a lookup in DB if this is using MySql). 229 // Then try on this sim (may be a lookup in DB if this is using MySql).
204 return m_GridService.GetRegionByPosition(scopeID, x, y); 230 if (region == null)
231 {
232 region = m_GridService.GetRegionByPosition(scopeID, x, y);
233
234 if (region == null)
235 {
236 m_log.DebugFormat("{0} GetRegionByPosition. Region not found by grid service. Pos=<{1},{2}>",
237 LogHeader, regionX, regionY);
238 }
239 else
240 {
241 m_log.DebugFormat("{0} GetRegionByPosition. Got region {1} from grid service. Pos=<{2},{3}>",
242 LogHeader, region.RegionName,
243 Util.WorldToRegionLoc((uint)region.RegionLocX), Util.WorldToRegionLoc((uint)region.RegionLocY));
244 }
245 }
246
247 return region;
205 } 248 }
206 249
207 public GridRegion GetRegionByName(UUID scopeID, string regionName) 250 public GridRegion GetRegionByName(UUID scopeID, string regionName)
@@ -224,6 +267,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
224 return m_GridService.GetDefaultRegions(scopeID); 267 return m_GridService.GetDefaultRegions(scopeID);
225 } 268 }
226 269
270 public List<GridRegion> GetDefaultHypergridRegions(UUID scopeID)
271 {
272 return m_GridService.GetDefaultHypergridRegions(scopeID);
273 }
274
227 public List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y) 275 public List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y)
228 { 276 {
229 return m_GridService.GetFallbackRegions(scopeID, x, y); 277 return m_GridService.GetFallbackRegions(scopeID, x, y);
@@ -239,21 +287,29 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
239 return m_GridService.GetRegionFlags(scopeID, regionID); 287 return m_GridService.GetRegionFlags(scopeID, regionID);
240 } 288 }
241 289
290 public Dictionary<string, object> GetExtraFeatures()
291 {
292 return m_GridService.GetExtraFeatures();
293 }
294
242 #endregion 295 #endregion
243 296
244 public void HandleShowNeighboursCommand(string module, string[] cmdparams) 297 public void HandleShowNeighboursCommand(string module, string[] cmdparams)
245 { 298 {
246 System.Text.StringBuilder caps = new System.Text.StringBuilder(); 299 System.Text.StringBuilder caps = new System.Text.StringBuilder();
247 300
248 foreach (KeyValuePair<UUID, RegionCache> kvp in m_LocalCache) 301 lock (m_LocalCache)
249 { 302 {
250 caps.AppendFormat("*** Neighbours of {0} ({1}) ***\n", kvp.Value.RegionName, kvp.Key); 303 foreach (KeyValuePair<UUID, RegionCache> kvp in m_LocalCache)
251 List<GridRegion> regions = kvp.Value.GetNeighbours(); 304 {
252 foreach (GridRegion r in regions) 305 caps.AppendFormat("*** Neighbours of {0} ({1}) ***\n", kvp.Value.RegionName, kvp.Key);
253 caps.AppendFormat(" {0} @ {1}-{2}\n", r.RegionName, r.RegionLocX / Constants.RegionSize, r.RegionLocY / Constants.RegionSize); 306 List<GridRegion> regions = kvp.Value.GetNeighbours();
307 foreach (GridRegion r in regions)
308 caps.AppendFormat(" {0} @ {1}-{2}\n", r.RegionName, Util.WorldToRegionLoc((uint)r.RegionLocX), Util.WorldToRegionLoc((uint)r.RegionLocY));
309 }
254 } 310 }
255 311
256 MainConsole.Instance.Output(caps.ToString()); 312 MainConsole.Instance.Output(caps.ToString());
257 } 313 }
258 } 314 }
259} \ No newline at end of file 315}