diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs | 54 |
1 files changed, 50 insertions, 4 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs index 743d3b9..6c2928a 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs | |||
@@ -31,6 +31,7 @@ using System; | |||
31 | using System.Collections.Generic; | 31 | using System.Collections.Generic; |
32 | using System.Reflection; | 32 | using System.Reflection; |
33 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
34 | using OpenSim.Framework.Console; | ||
34 | using OpenSim.Server.Base; | 35 | using OpenSim.Server.Base; |
35 | using OpenSim.Region.Framework.Interfaces; | 36 | using OpenSim.Region.Framework.Interfaces; |
36 | using OpenSim.Region.Framework.Scenes; | 37 | using OpenSim.Region.Framework.Scenes; |
@@ -47,7 +48,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
47 | LogManager.GetLogger( | 48 | LogManager.GetLogger( |
48 | MethodBase.GetCurrentMethod().DeclaringType); | 49 | MethodBase.GetCurrentMethod().DeclaringType); |
49 | 50 | ||
51 | private static LocalGridServicesConnector m_MainInstance; | ||
52 | |||
50 | private IGridService m_GridService; | 53 | private IGridService m_GridService; |
54 | private Dictionary<UUID, RegionCache> m_LocalCache = new Dictionary<UUID, RegionCache>(); | ||
51 | 55 | ||
52 | private bool m_Enabled = false; | 56 | private bool m_Enabled = false; |
53 | 57 | ||
@@ -58,6 +62,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
58 | public LocalGridServicesConnector(IConfigSource source) | 62 | public LocalGridServicesConnector(IConfigSource source) |
59 | { | 63 | { |
60 | m_log.Debug("[LOCAL GRID CONNECTOR]: LocalGridServicesConnector instantiated"); | 64 | m_log.Debug("[LOCAL GRID CONNECTOR]: LocalGridServicesConnector instantiated"); |
65 | m_MainInstance = this; | ||
61 | InitialiseService(source); | 66 | InitialiseService(source); |
62 | } | 67 | } |
63 | 68 | ||
@@ -82,6 +87,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
82 | if (name == Name) | 87 | if (name == Name) |
83 | { | 88 | { |
84 | InitialiseService(source); | 89 | InitialiseService(source); |
90 | m_MainInstance = this; | ||
85 | m_Enabled = true; | 91 | m_Enabled = true; |
86 | m_log.Info("[LOCAL GRID CONNECTOR]: Local grid connector enabled"); | 92 | m_log.Info("[LOCAL GRID CONNECTOR]: Local grid connector enabled"); |
87 | } | 93 | } |
@@ -120,6 +126,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
120 | 126 | ||
121 | public void PostInitialise() | 127 | public void PostInitialise() |
122 | { | 128 | { |
129 | if (m_MainInstance == this) | ||
130 | { | ||
131 | MainConsole.Instance.Commands.AddCommand("LocalGridConnector", false, "show neighbours", | ||
132 | "show neighbours", | ||
133 | "Shows the local regions' neighbours", NeighboursCommand); | ||
134 | } | ||
123 | } | 135 | } |
124 | 136 | ||
125 | public void Close() | 137 | public void Close() |
@@ -128,14 +140,26 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
128 | 140 | ||
129 | public void AddRegion(Scene scene) | 141 | public void AddRegion(Scene scene) |
130 | { | 142 | { |
131 | if (!m_Enabled) | 143 | if (m_Enabled) |
132 | return; | 144 | scene.RegisterModuleInterface<IGridService>(this); |
145 | |||
146 | if (m_MainInstance == this) | ||
147 | { | ||
148 | if (m_LocalCache.ContainsKey(scene.RegionInfo.RegionID)) | ||
149 | m_log.ErrorFormat("[LOCAL GRID 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)); | ||
133 | 152 | ||
134 | scene.RegisterModuleInterface<IGridService>(this); | 153 | } |
135 | } | 154 | } |
136 | 155 | ||
137 | public void RemoveRegion(Scene scene) | 156 | public void RemoveRegion(Scene scene) |
138 | { | 157 | { |
158 | if (m_MainInstance == this) | ||
159 | { | ||
160 | m_LocalCache[scene.RegionInfo.RegionID].Clear(); | ||
161 | m_LocalCache.Remove(scene.RegionInfo.RegionID); | ||
162 | } | ||
139 | } | 163 | } |
140 | 164 | ||
141 | public void RegionLoaded(Scene scene) | 165 | public void RegionLoaded(Scene scene) |
@@ -158,7 +182,18 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
158 | 182 | ||
159 | public List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID) | 183 | public List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID) |
160 | { | 184 | { |
161 | return m_GridService.GetNeighbours(scopeID, regionID); | 185 | if (m_LocalCache.ContainsKey(regionID)) |
186 | { | ||
187 | return m_LocalCache[regionID].GetNeighbours(); | ||
188 | } | ||
189 | else | ||
190 | { | ||
191 | m_log.WarnFormat("[LOCAL GRID CONNECTOR]: GetNeighbours: Requested region {0} is not on this sim", regionID); | ||
192 | return new List<GridRegion>(); | ||
193 | } | ||
194 | |||
195 | // Don't go to the DB | ||
196 | //return m_GridService.GetNeighbours(scopeID, regionID); | ||
162 | } | 197 | } |
163 | 198 | ||
164 | public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID) | 199 | public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID) |
@@ -187,5 +222,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
187 | } | 222 | } |
188 | 223 | ||
189 | #endregion | 224 | #endregion |
225 | |||
226 | public void NeighboursCommand(string module, string[] cmdparams) | ||
227 | { | ||
228 | foreach (KeyValuePair<UUID, RegionCache> kvp in m_LocalCache) | ||
229 | { | ||
230 | m_log.InfoFormat("*** Neighbours of {0} {1} ***", kvp.Key, kvp.Value.RegionName); | ||
231 | List<GridRegion> regions = kvp.Value.GetNeighbours(); | ||
232 | foreach (GridRegion r in regions) | ||
233 | m_log.InfoFormat(" {0} @ {1}={2}", r.RegionName, r.RegionLocX / Constants.RegionSize, r.RegionLocY / Constants.RegionSize); | ||
234 | } | ||
235 | } | ||
190 | } | 236 | } |
191 | } | 237 | } |