diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/ServiceConnectorsOut')
6 files changed, 101 insertions, 31 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs index 31ef79b..3b38c71 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,12 +57,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
56 | 57 | ||
57 | public LocalGridServicesConnector() | 58 | public LocalGridServicesConnector() |
58 | { | 59 | { |
59 | m_log.Debug("[LOCAL GRID SERVICE CONNECTOR]: LocalGridServicesConnector no parms."); | 60 | m_log.DebugFormat("{0} LocalGridServicesConnector no parms.", LogHeader); |
60 | } | 61 | } |
61 | 62 | ||
62 | public LocalGridServicesConnector(IConfigSource source) | 63 | public LocalGridServicesConnector(IConfigSource source) |
63 | { | 64 | { |
64 | m_log.Debug("[LOCAL GRID SERVICE CONNECTOR]: LocalGridServicesConnector instantiated directly."); | 65 | m_log.DebugFormat("{0} LocalGridServicesConnector instantiated directly.", LogHeader); |
65 | InitialiseService(source); | 66 | InitialiseService(source); |
66 | } | 67 | } |
67 | 68 | ||
@@ -192,6 +193,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
192 | return m_GridService.GetRegionByUUID(scopeID, regionID); | 193 | return m_GridService.GetRegionByUUID(scopeID, regionID); |
193 | } | 194 | } |
194 | 195 | ||
196 | // Get a region given its base coordinates. | ||
197 | // NOTE: this is NOT 'get a region by some point in the region'. The coordinate MUST | ||
198 | // be the base coordinate of the region. | ||
195 | public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) | 199 | public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) |
196 | { | 200 | { |
197 | GridRegion region = null; | 201 | GridRegion region = null; |
@@ -206,13 +210,25 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
206 | region = rcache.GetRegionByPosition(x, y); | 210 | region = rcache.GetRegionByPosition(x, y); |
207 | if (region != null) | 211 | if (region != null) |
208 | { | 212 | { |
209 | return region; | 213 | // m_log.DebugFormat("{0} GetRegionByPosition. Found region {1} in cache. Pos=<{2},{3}>", |
214 | // LogHeader, region.RegionName, x, y); | ||
215 | break; | ||
210 | } | 216 | } |
211 | } | 217 | } |
212 | } | 218 | } |
213 | 219 | ||
214 | // Then try on this sim (may be a lookup in DB if this is using MySql). | 220 | // Then try on this sim (may be a lookup in DB if this is using MySql). |
215 | return m_GridService.GetRegionByPosition(scopeID, x, y); | 221 | if (region == null) |
222 | { | ||
223 | region = m_GridService.GetRegionByPosition(scopeID, x, y); | ||
224 | if (region == null) | ||
225 | m_log.DebugFormat("{0} GetRegionByPosition. Region not found by grid service. Pos=<{1},{2}>", | ||
226 | LogHeader, x, y); | ||
227 | else | ||
228 | m_log.DebugFormat("{0} GetRegionByPosition. Requested region {1} from grid service. Pos=<{2},{3}>", | ||
229 | LogHeader, region.RegionName, x, y); | ||
230 | } | ||
231 | return region; | ||
216 | } | 232 | } |
217 | 233 | ||
218 | public GridRegion GetRegionByName(UUID scopeID, string regionName) | 234 | public GridRegion GetRegionByName(UUID scopeID, string regionName) |
@@ -268,7 +284,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
268 | caps.AppendFormat("*** Neighbours of {0} ({1}) ***\n", kvp.Value.RegionName, kvp.Key); | 284 | caps.AppendFormat("*** Neighbours of {0} ({1}) ***\n", kvp.Value.RegionName, kvp.Key); |
269 | List<GridRegion> regions = kvp.Value.GetNeighbours(); | 285 | List<GridRegion> regions = kvp.Value.GetNeighbours(); |
270 | foreach (GridRegion r in regions) | 286 | foreach (GridRegion r in regions) |
271 | caps.AppendFormat(" {0} @ {1}-{2}\n", r.RegionName, r.RegionLocX / Constants.RegionSize, r.RegionLocY / Constants.RegionSize); | 287 | caps.AppendFormat(" {0} @ {1}-{2}\n", r.RegionName, Util.WorldToRegionLoc((uint)r.RegionLocX), Util.WorldToRegionLoc((uint)r.RegionLocY)); |
272 | } | 288 | } |
273 | } | 289 | } |
274 | 290 | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs index 9172536..ae76288 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs | |||
@@ -66,7 +66,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
66 | return; | 66 | return; |
67 | 67 | ||
68 | m_log.DebugFormat("[REGION CACHE]: (on region {0}) Region {1} is up @ {2}-{3}", | 68 | m_log.DebugFormat("[REGION CACHE]: (on region {0}) Region {1} is up @ {2}-{3}", |
69 | m_scene.RegionInfo.RegionName, otherRegion.RegionName, otherRegion.RegionLocX / Constants.RegionSize, otherRegion.RegionLocY / Constants.RegionSize); | 69 | m_scene.RegionInfo.RegionName, otherRegion.RegionName, Util.WorldToRegionLoc((uint)otherRegion.RegionLocX), Util.WorldToRegionLoc((uint)otherRegion.RegionLocY)); |
70 | 70 | ||
71 | m_neighbours[otherRegion.RegionHandle] = otherRegion; | 71 | m_neighbours[otherRegion.RegionHandle] = otherRegion; |
72 | } | 72 | } |
@@ -82,11 +82,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
82 | return new List<GridRegion>(m_neighbours.Values); | 82 | return new List<GridRegion>(m_neighbours.Values); |
83 | } | 83 | } |
84 | 84 | ||
85 | // Get a region given its base coordinates (in meters). | ||
86 | // NOTE: this is NOT 'get a region by some point in the region'. The coordinate MUST | ||
87 | // be the base coordinate of the region. | ||
88 | // The snapping is technically unnecessary but is harmless because regions are always | ||
89 | // multiples of the legacy region size (256). | ||
85 | public GridRegion GetRegionByPosition(int x, int y) | 90 | public GridRegion GetRegionByPosition(int x, int y) |
86 | { | 91 | { |
87 | uint xsnap = (uint)(x / Constants.RegionSize) * Constants.RegionSize; | 92 | uint xsnap = (uint)(x / Constants.RegionSize) * Constants.RegionSize; |
88 | uint ysnap = (uint)(y / Constants.RegionSize) * Constants.RegionSize; | 93 | uint ysnap = (uint)(y / Constants.RegionSize) * Constants.RegionSize; |
89 | ulong handle = Utils.UIntsToLong(xsnap, ysnap); | 94 | ulong handle = Util.RegionWorldLocToHandle(xsnap, ysnap); |
90 | 95 | ||
91 | if (m_neighbours.ContainsKey(handle)) | 96 | if (m_neighbours.ContainsKey(handle)) |
92 | return m_neighbours[handle]; | 97 | return m_neighbours[handle]; |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs index 6a57d1f..ae5081c 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs | |||
@@ -186,10 +186,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
186 | return rinfo; | 186 | return rinfo; |
187 | } | 187 | } |
188 | 188 | ||
189 | // Get a region given its base world coordinates (in meters). | ||
190 | // NOTE: this is NOT 'get a region by some point in the region'. The coordinate MUST | ||
191 | // be the base coordinate of the region. | ||
192 | // The coordinates are world coords (meters), NOT region units. | ||
189 | public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) | 193 | public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) |
190 | { | 194 | { |
191 | bool inCache = false; | 195 | bool inCache = false; |
192 | GridRegion rinfo = m_RegionInfoCache.Get(scopeID, Util.UIntsToLong((uint)x, (uint)y), out inCache); | 196 | GridRegion rinfo = m_RegionInfoCache.Get(scopeID, Util.RegionWorldLocToHandle((uint)x, (uint)y), out inCache); |
193 | if (inCache) | 197 | if (inCache) |
194 | return rinfo; | 198 | return rinfo; |
195 | 199 | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs index 4338133..25ae689 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs | |||
@@ -34,6 +34,7 @@ using log4net.Config; | |||
34 | using Nini.Config; | 34 | using Nini.Config; |
35 | using NUnit.Framework; | 35 | using NUnit.Framework; |
36 | using OpenMetaverse; | 36 | using OpenMetaverse; |
37 | |||
37 | using OpenSim.Framework; | 38 | using OpenSim.Framework; |
38 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid; | 39 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid; |
39 | using OpenSim.Region.Framework.Scenes; | 40 | using OpenSim.Region.Framework.Scenes; |
@@ -141,7 +142,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests | |||
141 | Assert.IsNotNull(result, "Retrieved GetRegionByUUID is null"); | 142 | Assert.IsNotNull(result, "Retrieved GetRegionByUUID is null"); |
142 | Assert.That(result.RegionID, Is.EqualTo(new UUID(1)), "Retrieved region's UUID does not match"); | 143 | Assert.That(result.RegionID, Is.EqualTo(new UUID(1)), "Retrieved region's UUID does not match"); |
143 | 144 | ||
144 | result = m_LocalConnector.GetRegionByPosition(UUID.Zero, 1000 * (int)Constants.RegionSize, 1000 * (int)Constants.RegionSize); | 145 | result = m_LocalConnector.GetRegionByPosition(UUID.Zero, (int)Util.RegionToWorldLoc(1000), (int)Util.RegionToWorldLoc(1000)); |
145 | Assert.IsNotNull(result, "Retrieved GetRegionByPosition is null"); | 146 | Assert.IsNotNull(result, "Retrieved GetRegionByPosition is null"); |
146 | Assert.That(result.RegionLocX, Is.EqualTo(1000 * (int)Constants.RegionSize), "Retrieved region's position does not match"); | 147 | Assert.That(result.RegionLocX, Is.EqualTo(1000 * (int)Constants.RegionSize), "Retrieved region's position does not match"); |
147 | 148 | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs index 26d22b8..4d7538c 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs | |||
@@ -57,6 +57,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage | |||
57 | { | 57 | { |
58 | private static readonly ILog m_log = | 58 | private static readonly ILog m_log = |
59 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 59 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
60 | private static string LogHeader = "[MAP IMAGE SERVICE MODULE]"; | ||
60 | 61 | ||
61 | private bool m_enabled = false; | 62 | private bool m_enabled = false; |
62 | private IMapImageService m_MapService; | 63 | private IMapImageService m_MapService; |
@@ -192,42 +193,85 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage | |||
192 | ///</summary> | 193 | ///</summary> |
193 | private void UploadMapTile(IScene scene) | 194 | private void UploadMapTile(IScene scene) |
194 | { | 195 | { |
195 | m_log.DebugFormat("[MAP IMAGE SERVICE MODULE]: upload maptile for {0}", scene.RegionInfo.RegionName); | 196 | m_log.DebugFormat("{0} Upload maptile for {1}", LogHeader, scene.RegionInfo.RegionName); |
197 | string regionName = scene.RegionInfo.RegionName; | ||
196 | 198 | ||
197 | // Create a JPG map tile and upload it to the AddMapTile API | 199 | // Create a JPG map tile and upload it to the AddMapTile API |
198 | byte[] jpgData = Utils.EmptyBytes; | ||
199 | IMapImageGenerator tileGenerator = scene.RequestModuleInterface<IMapImageGenerator>(); | 200 | IMapImageGenerator tileGenerator = scene.RequestModuleInterface<IMapImageGenerator>(); |
200 | if (tileGenerator == null) | 201 | if (tileGenerator == null) |
201 | { | 202 | { |
202 | m_log.Warn("[MAP IMAGE SERVICE MODULE]: Cannot upload PNG map tile without an ImageGenerator"); | 203 | m_log.WarnFormat("{0} Cannot upload map tile without an ImageGenerator", LogHeader); |
203 | return; | 204 | return; |
204 | } | 205 | } |
205 | 206 | using (Bitmap mapTile = tileGenerator.CreateMapTile()) | |
206 | using (Image mapTile = tileGenerator.CreateMapTile()) | ||
207 | { | 207 | { |
208 | // XXX: The MapImageModule will return a null if the user has chosen not to create map tiles and there | 208 | if (mapTile != null) |
209 | // is no static map tile. | 209 | { |
210 | if (mapTile == null) | 210 | // mapTile.Save( // DEBUG DEBUG |
211 | return; | 211 | // String.Format("maptiles/raw-{0}-{1}-{2}.jpg", regionName, scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY), |
212 | 212 | // ImageFormat.Jpeg); | |
213 | using (MemoryStream stream = new MemoryStream()) | 213 | // If the region/maptile is legacy sized, just upload the one tile like it has always been done |
214 | if (mapTile.Width == Constants.RegionSize && mapTile.Height == Constants.RegionSize) | ||
215 | { | ||
216 | ConvertAndUploadMaptile(mapTile, | ||
217 | scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY, | ||
218 | scene.RegionInfo.RegionName); | ||
219 | } | ||
220 | else | ||
221 | { | ||
222 | // For larger regions (varregion) we must cut the region image into legacy sized | ||
223 | // pieces since that is how the maptile system works. | ||
224 | // Note the assumption that varregions are always a multiple of legacy size. | ||
225 | for (uint xx = 0; xx < mapTile.Width; xx += Constants.RegionSize) | ||
226 | { | ||
227 | for (uint yy = 0; yy < mapTile.Height; yy += Constants.RegionSize) | ||
228 | { | ||
229 | // Images are addressed from the upper left corner so have to do funny | ||
230 | // math to pick out the sub-tile since regions are numbered from | ||
231 | // the lower left. | ||
232 | Rectangle rect = new Rectangle( | ||
233 | (int)xx, | ||
234 | mapTile.Height - (int)yy - (int)Constants.RegionSize, | ||
235 | (int)Constants.RegionSize, (int)Constants.RegionSize); | ||
236 | using (Bitmap subMapTile = mapTile.Clone(rect, mapTile.PixelFormat)) | ||
237 | { | ||
238 | ConvertAndUploadMaptile(subMapTile, | ||
239 | scene.RegionInfo.RegionLocX + (xx / Constants.RegionSize), | ||
240 | scene.RegionInfo.RegionLocY + (yy / Constants.RegionSize), | ||
241 | regionName); | ||
242 | } | ||
243 | } | ||
244 | } | ||
245 | } | ||
246 | } | ||
247 | else | ||
214 | { | 248 | { |
215 | mapTile.Save(stream, ImageFormat.Jpeg); | 249 | m_log.WarnFormat("{0} Tile image generation failed", LogHeader); |
216 | jpgData = stream.ToArray(); | ||
217 | } | 250 | } |
218 | } | 251 | } |
252 | } | ||
219 | 253 | ||
220 | if (jpgData == Utils.EmptyBytes) | 254 | private void ConvertAndUploadMaptile(Image tileImage, uint locX, uint locY, string regionName) |
255 | { | ||
256 | byte[] jpgData = Utils.EmptyBytes; | ||
257 | |||
258 | using (MemoryStream stream = new MemoryStream()) | ||
221 | { | 259 | { |
222 | m_log.WarnFormat("[MAP IMAGE SERVICE MODULE]: Tile image generation failed"); | 260 | tileImage.Save(stream, ImageFormat.Jpeg); |
223 | return; | 261 | jpgData = stream.ToArray(); |
224 | } | 262 | } |
225 | 263 | if (jpgData != Utils.EmptyBytes) | |
226 | string reason = string.Empty; | 264 | { |
227 | if (!m_MapService.AddMapTile((int)scene.RegionInfo.RegionLocX, (int)scene.RegionInfo.RegionLocY, jpgData, out reason)) | 265 | string reason = string.Empty; |
266 | if (!m_MapService.AddMapTile((int)locX, (int)locY, jpgData, out reason)) | ||
267 | { | ||
268 | m_log.DebugFormat("{0} Unable to upload tile image for {1} at {2}-{3}: {4}", LogHeader, | ||
269 | regionName, locX, locY, reason); | ||
270 | } | ||
271 | } | ||
272 | else | ||
228 | { | 273 | { |
229 | m_log.DebugFormat("[MAP IMAGE SERVICE MODULE]: Unable to upload tile image for {0} at {1}-{2}: {3}", | 274 | m_log.WarnFormat("{0} Tile image generation failed for region {1}", LogHeader, regionName); |
230 | scene.RegionInfo.RegionName, scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY, reason); | ||
231 | } | 275 | } |
232 | } | 276 | } |
233 | } | 277 | } |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/LocalNeighbourServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/LocalNeighbourServiceConnector.cs index fd89428..56d9937 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/LocalNeighbourServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/LocalNeighbourServiceConnector.cs | |||
@@ -132,7 +132,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Neighbour | |||
132 | if (s.RegionInfo.RegionHandle == regionHandle) | 132 | if (s.RegionInfo.RegionHandle == regionHandle) |
133 | { | 133 | { |
134 | m_log.DebugFormat("[LOCAL NEIGHBOUR SERVICE CONNECTOR]: HelloNeighbour from region {0} to neighbour {1} at {2}-{3}", | 134 | m_log.DebugFormat("[LOCAL NEIGHBOUR SERVICE CONNECTOR]: HelloNeighbour from region {0} to neighbour {1} at {2}-{3}", |
135 | thisRegion.RegionName, s.Name, x / Constants.RegionSize, y / Constants.RegionSize); | 135 | thisRegion.RegionName, s.Name, Util.WorldToRegionLoc(x), Util.WorldToRegionLoc(y) ); |
136 | 136 | ||
137 | //m_log.Debug("[NEIGHBOUR CONNECTOR]: Found region to SendHelloNeighbour"); | 137 | //m_log.Debug("[NEIGHBOUR CONNECTOR]: Found region to SendHelloNeighbour"); |
138 | return s.IncomingHelloNeighbour(thisRegion); | 138 | return s.IncomingHelloNeighbour(thisRegion); |