clockwerk-opensim-stable – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | vero | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ |
||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
||
4 | * |
||
5 | * Redistribution and use in source and binary forms, with or without |
||
6 | * modification, are permitted provided that the following conditions are met: |
||
7 | * * Redistributions of source code must retain the above copyright |
||
8 | * notice, this list of conditions and the following disclaimer. |
||
9 | * * Redistributions in binary form must reproduce the above copyright |
||
10 | * notice, this list of conditions and the following disclaimer in the |
||
11 | * documentation and/or other materials provided with the distribution. |
||
12 | * * Neither the name of the OpenSimulator Project nor the |
||
13 | * names of its contributors may be used to endorse or promote products |
||
14 | * derived from this software without specific prior written permission. |
||
15 | * |
||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||
26 | */ |
||
27 | |||
28 | using log4net; |
||
29 | using Mono.Addins; |
||
30 | using System; |
||
31 | using System.Collections.Generic; |
||
32 | using System.Reflection; |
||
33 | using Nini.Config; |
||
34 | using OpenMetaverse; |
||
35 | |||
36 | using OpenSim.Framework; |
||
37 | using OpenSim.Services.Connectors; |
||
38 | using OpenSim.Region.Framework.Interfaces; |
||
39 | using OpenSim.Region.Framework.Scenes; |
||
40 | using OpenSim.Server.Base; |
||
41 | using OpenSim.Services.Interfaces; |
||
42 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; |
||
43 | |||
44 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid |
||
45 | { |
||
46 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "RemoteGridServicesConnector")] |
||
47 | public class RemoteGridServicesConnector : ISharedRegionModule, IGridService |
||
48 | { |
||
49 | private static readonly ILog m_log = |
||
50 | LogManager.GetLogger( |
||
51 | MethodBase.GetCurrentMethod().DeclaringType); |
||
52 | |||
53 | private bool m_Enabled = false; |
||
54 | |||
55 | private IGridService m_LocalGridService; |
||
56 | private IGridService m_RemoteGridService; |
||
57 | |||
58 | private RegionInfoCache m_RegionInfoCache = new RegionInfoCache(); |
||
59 | |||
60 | public RemoteGridServicesConnector() |
||
61 | { |
||
62 | } |
||
63 | |||
64 | public RemoteGridServicesConnector(IConfigSource source) |
||
65 | { |
||
66 | InitialiseServices(source); |
||
67 | } |
||
68 | |||
69 | #region ISharedRegionmodule |
||
70 | |||
71 | public Type ReplaceableInterface |
||
72 | { |
||
73 | get { return null; } |
||
74 | } |
||
75 | |||
76 | public string Name |
||
77 | { |
||
78 | get { return "RemoteGridServicesConnector"; } |
||
79 | } |
||
80 | |||
81 | public void Initialise(IConfigSource source) |
||
82 | { |
||
83 | IConfig moduleConfig = source.Configs["Modules"]; |
||
84 | if (moduleConfig != null) |
||
85 | { |
||
86 | string name = moduleConfig.GetString("GridServices", ""); |
||
87 | if (name == Name) |
||
88 | { |
||
89 | InitialiseServices(source); |
||
90 | m_Enabled = true; |
||
91 | m_log.Info("[REMOTE GRID CONNECTOR]: Remote grid enabled"); |
||
92 | } |
||
93 | } |
||
94 | } |
||
95 | |||
96 | private void InitialiseServices(IConfigSource source) |
||
97 | { |
||
98 | IConfig gridConfig = source.Configs["GridService"]; |
||
99 | if (gridConfig == null) |
||
100 | { |
||
101 | m_log.Error("[REMOTE GRID CONNECTOR]: GridService missing from OpenSim.ini"); |
||
102 | return; |
||
103 | } |
||
104 | |||
105 | string networkConnector = gridConfig.GetString("NetworkConnector", string.Empty); |
||
106 | if (networkConnector == string.Empty) |
||
107 | { |
||
108 | m_log.Error("[REMOTE GRID CONNECTOR]: Please specify a network connector under [GridService]"); |
||
109 | return; |
||
110 | } |
||
111 | |||
112 | Object[] args = new Object[] { source }; |
||
113 | m_RemoteGridService = ServerUtils.LoadPlugin<IGridService>(networkConnector, args); |
||
114 | |||
115 | m_LocalGridService = new LocalGridServicesConnector(source); |
||
116 | } |
||
117 | |||
118 | public void PostInitialise() |
||
119 | { |
||
120 | if (m_LocalGridService != null) |
||
121 | ((ISharedRegionModule)m_LocalGridService).PostInitialise(); |
||
122 | } |
||
123 | |||
124 | public void Close() |
||
125 | { |
||
126 | } |
||
127 | |||
128 | public void AddRegion(Scene scene) |
||
129 | { |
||
130 | if (m_Enabled) |
||
131 | scene.RegisterModuleInterface<IGridService>(this); |
||
132 | |||
133 | if (m_LocalGridService != null) |
||
134 | ((ISharedRegionModule)m_LocalGridService).AddRegion(scene); |
||
135 | } |
||
136 | |||
137 | public void RemoveRegion(Scene scene) |
||
138 | { |
||
139 | if (m_LocalGridService != null) |
||
140 | ((ISharedRegionModule)m_LocalGridService).RemoveRegion(scene); |
||
141 | } |
||
142 | |||
143 | public void RegionLoaded(Scene scene) |
||
144 | { |
||
145 | } |
||
146 | |||
147 | #endregion |
||
148 | |||
149 | #region IGridService |
||
150 | |||
151 | public string RegisterRegion(UUID scopeID, GridRegion regionInfo) |
||
152 | { |
||
153 | string msg = m_LocalGridService.RegisterRegion(scopeID, regionInfo); |
||
154 | |||
155 | if (msg == String.Empty) |
||
156 | return m_RemoteGridService.RegisterRegion(scopeID, regionInfo); |
||
157 | |||
158 | return msg; |
||
159 | } |
||
160 | |||
161 | public bool DeregisterRegion(UUID regionID) |
||
162 | { |
||
163 | if (m_LocalGridService.DeregisterRegion(regionID)) |
||
164 | return m_RemoteGridService.DeregisterRegion(regionID); |
||
165 | |||
166 | return false; |
||
167 | } |
||
168 | |||
169 | public List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID) |
||
170 | { |
||
171 | return m_RemoteGridService.GetNeighbours(scopeID, regionID); |
||
172 | } |
||
173 | |||
174 | public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID) |
||
175 | { |
||
176 | bool inCache = false; |
||
177 | GridRegion rinfo = m_RegionInfoCache.Get(scopeID,regionID,out inCache); |
||
178 | if (inCache) |
||
179 | return rinfo; |
||
180 | |||
181 | rinfo = m_LocalGridService.GetRegionByUUID(scopeID, regionID); |
||
182 | if (rinfo == null) |
||
183 | rinfo = m_RemoteGridService.GetRegionByUUID(scopeID, regionID); |
||
184 | |||
185 | m_RegionInfoCache.Cache(scopeID,regionID,rinfo); |
||
186 | return rinfo; |
||
187 | } |
||
188 | |||
189 | public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) |
||
190 | { |
||
191 | bool inCache = false; |
||
192 | GridRegion rinfo = m_RegionInfoCache.Get(scopeID, Util.UIntsToLong((uint)x, (uint)y), out inCache); |
||
193 | if (inCache) |
||
194 | return rinfo; |
||
195 | |||
196 | rinfo = m_LocalGridService.GetRegionByPosition(scopeID, x, y); |
||
197 | if (rinfo == null) |
||
198 | rinfo = m_RemoteGridService.GetRegionByPosition(scopeID, x, y); |
||
199 | |||
200 | m_RegionInfoCache.Cache(rinfo); |
||
201 | return rinfo; |
||
202 | } |
||
203 | |||
204 | public GridRegion GetRegionByName(UUID scopeID, string regionName) |
||
205 | { |
||
206 | bool inCache = false; |
||
207 | GridRegion rinfo = m_RegionInfoCache.Get(scopeID,regionName, out inCache); |
||
208 | if (inCache) |
||
209 | return rinfo; |
||
210 | |||
211 | rinfo = m_LocalGridService.GetRegionByName(scopeID, regionName); |
||
212 | if (rinfo == null) |
||
213 | rinfo = m_RemoteGridService.GetRegionByName(scopeID, regionName); |
||
214 | |||
215 | // can't cache negative results for name lookups |
||
216 | m_RegionInfoCache.Cache(rinfo); |
||
217 | return rinfo; |
||
218 | } |
||
219 | |||
220 | public List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber) |
||
221 | { |
||
222 | List<GridRegion> rinfo = m_LocalGridService.GetRegionsByName(scopeID, name, maxNumber); |
||
223 | //m_log.DebugFormat("[REMOTE GRID CONNECTOR]: Local GetRegionsByName {0} found {1} regions", name, rinfo.Count); |
||
224 | List<GridRegion> grinfo = m_RemoteGridService.GetRegionsByName(scopeID, name, maxNumber); |
||
225 | |||
226 | if (grinfo != null) |
||
227 | { |
||
228 | //m_log.DebugFormat("[REMOTE GRID CONNECTOR]: Remote GetRegionsByName {0} found {1} regions", name, grinfo.Count); |
||
229 | foreach (GridRegion r in grinfo) |
||
230 | { |
||
231 | m_RegionInfoCache.Cache(r); |
||
232 | if (rinfo.Find(delegate(GridRegion gr) { return gr.RegionID == r.RegionID; }) == null) |
||
233 | rinfo.Add(r); |
||
234 | } |
||
235 | } |
||
236 | |||
237 | return rinfo; |
||
238 | } |
||
239 | |||
240 | public virtual List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) |
||
241 | { |
||
242 | List<GridRegion> rinfo = m_LocalGridService.GetRegionRange(scopeID, xmin, xmax, ymin, ymax); |
||
243 | //m_log.DebugFormat("[REMOTE GRID CONNECTOR]: Local GetRegionRange {0} found {1} regions", name, rinfo.Count); |
||
244 | List<GridRegion> grinfo = m_RemoteGridService.GetRegionRange(scopeID, xmin, xmax, ymin, ymax); |
||
245 | |||
246 | if (grinfo != null) |
||
247 | { |
||
248 | //m_log.DebugFormat("[REMOTE GRID CONNECTOR]: Remote GetRegionRange {0} found {1} regions", name, grinfo.Count); |
||
249 | foreach (GridRegion r in grinfo) |
||
250 | { |
||
251 | m_RegionInfoCache.Cache(r); |
||
252 | if (rinfo.Find(delegate(GridRegion gr) { return gr.RegionID == r.RegionID; }) == null) |
||
253 | rinfo.Add(r); |
||
254 | } |
||
255 | } |
||
256 | |||
257 | return rinfo; |
||
258 | } |
||
259 | |||
260 | public List<GridRegion> GetDefaultRegions(UUID scopeID) |
||
261 | { |
||
262 | List<GridRegion> rinfo = m_LocalGridService.GetDefaultRegions(scopeID); |
||
263 | //m_log.DebugFormat("[REMOTE GRID CONNECTOR]: Local GetDefaultRegions {0} found {1} regions", name, rinfo.Count); |
||
264 | List<GridRegion> grinfo = m_RemoteGridService.GetDefaultRegions(scopeID); |
||
265 | |||
266 | if (grinfo != null) |
||
267 | { |
||
268 | //m_log.DebugFormat("[REMOTE GRID CONNECTOR]: Remote GetDefaultRegions {0} found {1} regions", name, grinfo.Count); |
||
269 | foreach (GridRegion r in grinfo) |
||
270 | { |
||
271 | m_RegionInfoCache.Cache(r); |
||
272 | if (rinfo.Find(delegate(GridRegion gr) { return gr.RegionID == r.RegionID; }) == null) |
||
273 | rinfo.Add(r); |
||
274 | } |
||
275 | } |
||
276 | |||
277 | return rinfo; |
||
278 | } |
||
279 | |||
280 | public List<GridRegion> GetDefaultHypergridRegions(UUID scopeID) |
||
281 | { |
||
282 | List<GridRegion> rinfo = m_LocalGridService.GetDefaultHypergridRegions(scopeID); |
||
283 | //m_log.DebugFormat("[REMOTE GRID CONNECTOR]: Local GetDefaultHypergridRegions {0} found {1} regions", name, rinfo.Count); |
||
284 | List<GridRegion> grinfo = m_RemoteGridService.GetDefaultHypergridRegions(scopeID); |
||
285 | |||
286 | if (grinfo != null) |
||
287 | { |
||
288 | //m_log.DebugFormat("[REMOTE GRID CONNECTOR]: Remote GetDefaultHypergridRegions {0} found {1} regions", name, grinfo.Count); |
||
289 | foreach (GridRegion r in grinfo) |
||
290 | { |
||
291 | m_RegionInfoCache.Cache(r); |
||
292 | if (rinfo.Find(delegate(GridRegion gr) { return gr.RegionID == r.RegionID; }) == null) |
||
293 | rinfo.Add(r); |
||
294 | } |
||
295 | } |
||
296 | |||
297 | return rinfo; |
||
298 | } |
||
299 | |||
300 | public List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y) |
||
301 | { |
||
302 | List<GridRegion> rinfo = m_LocalGridService.GetFallbackRegions(scopeID, x, y); |
||
303 | //m_log.DebugFormat("[REMOTE GRID CONNECTOR]: Local GetFallbackRegions {0} found {1} regions", name, rinfo.Count); |
||
304 | List<GridRegion> grinfo = m_RemoteGridService.GetFallbackRegions(scopeID, x, y); |
||
305 | |||
306 | if (grinfo != null) |
||
307 | { |
||
308 | //m_log.DebugFormat("[REMOTE GRID CONNECTOR]: Remote GetFallbackRegions {0} found {1} regions", name, grinfo.Count); |
||
309 | foreach (GridRegion r in grinfo) |
||
310 | { |
||
311 | m_RegionInfoCache.Cache(r); |
||
312 | if (rinfo.Find(delegate(GridRegion gr) { return gr.RegionID == r.RegionID; }) == null) |
||
313 | rinfo.Add(r); |
||
314 | } |
||
315 | } |
||
316 | |||
317 | return rinfo; |
||
318 | } |
||
319 | |||
320 | public List<GridRegion> GetHyperlinks(UUID scopeID) |
||
321 | { |
||
322 | List<GridRegion> rinfo = m_LocalGridService.GetHyperlinks(scopeID); |
||
323 | //m_log.DebugFormat("[REMOTE GRID CONNECTOR]: Local GetHyperlinks {0} found {1} regions", name, rinfo.Count); |
||
324 | List<GridRegion> grinfo = m_RemoteGridService.GetHyperlinks(scopeID); |
||
325 | |||
326 | if (grinfo != null) |
||
327 | { |
||
328 | //m_log.DebugFormat("[REMOTE GRID CONNECTOR]: Remote GetHyperlinks {0} found {1} regions", name, grinfo.Count); |
||
329 | foreach (GridRegion r in grinfo) |
||
330 | { |
||
331 | m_RegionInfoCache.Cache(r); |
||
332 | if (rinfo.Find(delegate(GridRegion gr) { return gr.RegionID == r.RegionID; }) == null) |
||
333 | rinfo.Add(r); |
||
334 | } |
||
335 | } |
||
336 | |||
337 | return rinfo; |
||
338 | } |
||
339 | |||
340 | public int GetRegionFlags(UUID scopeID, UUID regionID) |
||
341 | { |
||
342 | int flags = m_LocalGridService.GetRegionFlags(scopeID, regionID); |
||
343 | if (flags == -1) |
||
344 | flags = m_RemoteGridService.GetRegionFlags(scopeID, regionID); |
||
345 | |||
346 | return flags; |
||
347 | } |
||
348 | #endregion |
||
349 | } |
||
350 | } |