diff options
author | Kitto Flora | 2009-09-30 19:07:18 +0200 |
---|---|---|
committer | Kitto Flora | 2009-09-30 19:07:18 +0200 |
commit | 07df0e0ab0c69633a6afec8d05cccc117656d3d9 (patch) | |
tree | 3048cc38b313e255cbf03fa3e2900e28cadc47c9 /OpenSim/Services | |
parent | And another merge issue (diff) | |
parent | Fix loading modules with alternate configurations and ports into ROBUST. (diff) | |
download | opensim-SC_OLD-07df0e0ab0c69633a6afec8d05cccc117656d3d9.zip opensim-SC_OLD-07df0e0ab0c69633a6afec8d05cccc117656d3d9.tar.gz opensim-SC_OLD-07df0e0ab0c69633a6afec8d05cccc117656d3d9.tar.bz2 opensim-SC_OLD-07df0e0ab0c69633a6afec8d05cccc117656d3d9.tar.xz |
Merge branch '0.6.7-post-fixes' into vehicles
Diffstat (limited to 'OpenSim/Services')
8 files changed, 908 insertions, 179 deletions
diff --git a/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs b/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs index 8904461..dcf090e 100644 --- a/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs +++ b/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs | |||
@@ -43,9 +43,9 @@ namespace OpenSim.Services.AuthenticationService | |||
43 | // | 43 | // |
44 | public class AuthenticationServiceBase : ServiceBase | 44 | public class AuthenticationServiceBase : ServiceBase |
45 | { | 45 | { |
46 | private static readonly ILog m_log = | 46 | // private static readonly ILog m_log = |
47 | LogManager.GetLogger( | 47 | // LogManager.GetLogger( |
48 | MethodBase.GetCurrentMethod().DeclaringType); | 48 | // MethodBase.GetCurrentMethod().DeclaringType); |
49 | 49 | ||
50 | protected IAuthenticationData m_Database; | 50 | protected IAuthenticationData m_Database; |
51 | 51 | ||
diff --git a/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs b/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs index 6c99b66..d65665a 100644 --- a/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs +++ b/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs | |||
@@ -47,9 +47,9 @@ namespace OpenSim.Services.AuthenticationService | |||
47 | public class PasswordAuthenticationService : | 47 | public class PasswordAuthenticationService : |
48 | AuthenticationServiceBase, IAuthenticationService | 48 | AuthenticationServiceBase, IAuthenticationService |
49 | { | 49 | { |
50 | private static readonly ILog m_log = | 50 | // private static readonly ILog m_log = |
51 | LogManager.GetLogger( | 51 | // LogManager.GetLogger( |
52 | MethodBase.GetCurrentMethod().DeclaringType); | 52 | // MethodBase.GetCurrentMethod().DeclaringType); |
53 | 53 | ||
54 | public PasswordAuthenticationService(IConfigSource config) : | 54 | public PasswordAuthenticationService(IConfigSource config) : |
55 | base(config) | 55 | base(config) |
diff --git a/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs b/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs index 8831c8a..d1a5b0f 100644 --- a/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs +++ b/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs | |||
@@ -43,9 +43,9 @@ namespace OpenSim.Services.AuthenticationService | |||
43 | public class WebkeyAuthenticationService : | 43 | public class WebkeyAuthenticationService : |
44 | AuthenticationServiceBase, IAuthenticationService | 44 | AuthenticationServiceBase, IAuthenticationService |
45 | { | 45 | { |
46 | private static readonly ILog m_log = | 46 | // private static readonly ILog m_log = |
47 | LogManager.GetLogger( | 47 | // LogManager.GetLogger( |
48 | MethodBase.GetCurrentMethod().DeclaringType); | 48 | // MethodBase.GetCurrentMethod().DeclaringType); |
49 | 49 | ||
50 | public WebkeyAuthenticationService(IConfigSource config) : | 50 | public WebkeyAuthenticationService(IConfigSource config) : |
51 | base(config) | 51 | base(config) |
diff --git a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs new file mode 100644 index 0000000..748892a --- /dev/null +++ b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs | |||
@@ -0,0 +1,448 @@ | |||
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 System; | ||
30 | using System.Collections.Generic; | ||
31 | using System.IO; | ||
32 | using System.Reflection; | ||
33 | using Nini.Config; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Framework.Communications; | ||
36 | using OpenSim.Framework.Servers.HttpServer; | ||
37 | using OpenSim.Services.Interfaces; | ||
38 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
39 | using OpenSim.Server.Base; | ||
40 | using OpenMetaverse; | ||
41 | |||
42 | namespace OpenSim.Services.Connectors | ||
43 | { | ||
44 | public class GridServicesConnector : IGridService | ||
45 | { | ||
46 | private static readonly ILog m_log = | ||
47 | LogManager.GetLogger( | ||
48 | MethodBase.GetCurrentMethod().DeclaringType); | ||
49 | |||
50 | private string m_ServerURI = String.Empty; | ||
51 | |||
52 | public GridServicesConnector() | ||
53 | { | ||
54 | } | ||
55 | |||
56 | public GridServicesConnector(string serverURI) | ||
57 | { | ||
58 | m_ServerURI = serverURI.TrimEnd('/'); | ||
59 | } | ||
60 | |||
61 | public GridServicesConnector(IConfigSource source) | ||
62 | { | ||
63 | Initialise(source); | ||
64 | } | ||
65 | |||
66 | public virtual void Initialise(IConfigSource source) | ||
67 | { | ||
68 | IConfig gridConfig = source.Configs["GridService"]; | ||
69 | if (gridConfig == null) | ||
70 | { | ||
71 | m_log.Error("[GRID CONNECTOR]: GridService missing from OpenSim.ini"); | ||
72 | throw new Exception("Grid connector init error"); | ||
73 | } | ||
74 | |||
75 | string serviceURI = gridConfig.GetString("GridServerURI", | ||
76 | String.Empty); | ||
77 | |||
78 | if (serviceURI == String.Empty) | ||
79 | { | ||
80 | m_log.Error("[GRID CONNECTOR]: No Server URI named in section GridService"); | ||
81 | throw new Exception("Grid connector init error"); | ||
82 | } | ||
83 | m_ServerURI = serviceURI; | ||
84 | } | ||
85 | |||
86 | |||
87 | #region IGridService | ||
88 | |||
89 | public virtual bool RegisterRegion(UUID scopeID, GridRegion regionInfo) | ||
90 | { | ||
91 | Dictionary<string, object> rinfo = regionInfo.ToKeyValuePairs(); | ||
92 | Dictionary<string, string> sendData = new Dictionary<string,string>(); | ||
93 | foreach (KeyValuePair<string, object> kvp in rinfo) | ||
94 | sendData[kvp.Key] = (string)kvp.Value; | ||
95 | |||
96 | sendData["SCOPEID"] = scopeID.ToString(); | ||
97 | |||
98 | sendData["METHOD"] = "register"; | ||
99 | |||
100 | string reqString = ServerUtils.BuildQueryString(sendData); | ||
101 | //m_log.DebugFormat("[GRID CONNECTOR]: queryString = {0}", reqString); | ||
102 | try | ||
103 | { | ||
104 | string reply = SynchronousRestFormsRequester.MakeRequest("POST", | ||
105 | m_ServerURI + "/grid", | ||
106 | reqString); | ||
107 | if (reply != string.Empty) | ||
108 | { | ||
109 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | ||
110 | |||
111 | if ((replyData["Result"] != null) && (replyData["Result"].ToString().ToLower() == "success")) | ||
112 | return true; | ||
113 | } | ||
114 | else | ||
115 | m_log.DebugFormat("[GRID CONNECTOR]: RegisterRegion received null reply"); | ||
116 | } | ||
117 | catch (Exception e) | ||
118 | { | ||
119 | m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message); | ||
120 | } | ||
121 | |||
122 | return false; | ||
123 | } | ||
124 | |||
125 | public virtual bool DeregisterRegion(UUID regionID) | ||
126 | { | ||
127 | Dictionary<string, string> sendData = new Dictionary<string, string>(); | ||
128 | |||
129 | sendData["REGIONID"] = regionID.ToString(); | ||
130 | |||
131 | sendData["METHOD"] = "deregister"; | ||
132 | |||
133 | try | ||
134 | { | ||
135 | string reply = SynchronousRestFormsRequester.MakeRequest("POST", | ||
136 | m_ServerURI + "/grid", | ||
137 | ServerUtils.BuildQueryString(sendData)); | ||
138 | |||
139 | if (reply != string.Empty) | ||
140 | { | ||
141 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | ||
142 | |||
143 | if ((replyData["Result"] != null) && (replyData["Result"].ToString().ToLower() == "success")) | ||
144 | return true; | ||
145 | } | ||
146 | else | ||
147 | m_log.DebugFormat("[GRID CONNECTOR]: DeregisterRegion received null reply"); | ||
148 | } | ||
149 | catch (Exception e) | ||
150 | { | ||
151 | m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message); | ||
152 | } | ||
153 | |||
154 | return false; | ||
155 | } | ||
156 | |||
157 | public virtual List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID) | ||
158 | { | ||
159 | Dictionary<string, string> sendData = new Dictionary<string, string>(); | ||
160 | |||
161 | sendData["SCOPEID"] = scopeID.ToString(); | ||
162 | sendData["REGIONID"] = regionID.ToString(); | ||
163 | |||
164 | sendData["METHOD"] = "get_neighbours"; | ||
165 | |||
166 | List<GridRegion> rinfos = new List<GridRegion>(); | ||
167 | |||
168 | string reqString = ServerUtils.BuildQueryString(sendData); | ||
169 | string reply = string.Empty; | ||
170 | try | ||
171 | { | ||
172 | reply = SynchronousRestFormsRequester.MakeRequest("POST", | ||
173 | m_ServerURI + "/grid", | ||
174 | reqString); | ||
175 | } | ||
176 | catch (Exception e) | ||
177 | { | ||
178 | m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message); | ||
179 | return rinfos; | ||
180 | } | ||
181 | |||
182 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | ||
183 | |||
184 | if (replyData != null) | ||
185 | { | ||
186 | Dictionary<string, object>.ValueCollection rinfosList = replyData.Values; | ||
187 | //m_log.DebugFormat("[GRID CONNECTOR]: get neighbours returned {0} elements", rinfosList.Count); | ||
188 | foreach (object r in rinfosList) | ||
189 | { | ||
190 | if (r is Dictionary<string, object>) | ||
191 | { | ||
192 | GridRegion rinfo = new GridRegion((Dictionary<string, object>)r); | ||
193 | rinfos.Add(rinfo); | ||
194 | } | ||
195 | else | ||
196 | m_log.DebugFormat("[GRID CONNECTOR]: GetNeighbours {0}, {1} received invalid response type {2}", | ||
197 | scopeID, regionID, r.GetType()); | ||
198 | } | ||
199 | } | ||
200 | else | ||
201 | m_log.DebugFormat("[GRID CONNECTOR]: GetNeighbours {0}, {1} received null response", | ||
202 | scopeID, regionID); | ||
203 | |||
204 | return rinfos; | ||
205 | } | ||
206 | |||
207 | public virtual GridRegion GetRegionByUUID(UUID scopeID, UUID regionID) | ||
208 | { | ||
209 | Dictionary<string, string> sendData = new Dictionary<string, string>(); | ||
210 | |||
211 | sendData["SCOPEID"] = scopeID.ToString(); | ||
212 | sendData["REGIONID"] = regionID.ToString(); | ||
213 | |||
214 | sendData["METHOD"] = "get_region_by_uuid"; | ||
215 | |||
216 | string reply = string.Empty; | ||
217 | try | ||
218 | { | ||
219 | reply = SynchronousRestFormsRequester.MakeRequest("POST", | ||
220 | m_ServerURI + "/grid", | ||
221 | ServerUtils.BuildQueryString(sendData)); | ||
222 | } | ||
223 | catch (Exception e) | ||
224 | { | ||
225 | m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message); | ||
226 | return null; | ||
227 | } | ||
228 | |||
229 | GridRegion rinfo = null; | ||
230 | |||
231 | if (reply != string.Empty) | ||
232 | { | ||
233 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | ||
234 | |||
235 | if ((replyData != null) && (replyData["result"] != null)) | ||
236 | { | ||
237 | if (replyData["result"] is Dictionary<string, object>) | ||
238 | rinfo = new GridRegion((Dictionary<string, object>)replyData["result"]); | ||
239 | //else | ||
240 | // m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID {0}, {1} received null response", | ||
241 | // scopeID, regionID); | ||
242 | } | ||
243 | else | ||
244 | m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID {0}, {1} received null response", | ||
245 | scopeID, regionID); | ||
246 | } | ||
247 | else | ||
248 | m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID received null reply"); | ||
249 | |||
250 | return rinfo; | ||
251 | } | ||
252 | |||
253 | public virtual GridRegion GetRegionByPosition(UUID scopeID, int x, int y) | ||
254 | { | ||
255 | Dictionary<string, string> sendData = new Dictionary<string, string>(); | ||
256 | |||
257 | sendData["SCOPEID"] = scopeID.ToString(); | ||
258 | sendData["X"] = x.ToString(); | ||
259 | sendData["Y"] = y.ToString(); | ||
260 | |||
261 | sendData["METHOD"] = "get_region_by_position"; | ||
262 | string reply = string.Empty; | ||
263 | try | ||
264 | { | ||
265 | reply = SynchronousRestFormsRequester.MakeRequest("POST", | ||
266 | m_ServerURI + "/grid", | ||
267 | ServerUtils.BuildQueryString(sendData)); | ||
268 | } | ||
269 | catch (Exception e) | ||
270 | { | ||
271 | m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message); | ||
272 | return null; | ||
273 | } | ||
274 | |||
275 | GridRegion rinfo = null; | ||
276 | if (reply != string.Empty) | ||
277 | { | ||
278 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | ||
279 | |||
280 | if ((replyData != null) && (replyData["result"] != null)) | ||
281 | { | ||
282 | if (replyData["result"] is Dictionary<string, object>) | ||
283 | rinfo = new GridRegion((Dictionary<string, object>)replyData["result"]); | ||
284 | else | ||
285 | m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received invalid response", | ||
286 | scopeID, x, y); | ||
287 | } | ||
288 | else | ||
289 | m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received null response", | ||
290 | scopeID, x, y); | ||
291 | } | ||
292 | else | ||
293 | m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition received null reply"); | ||
294 | |||
295 | return rinfo; | ||
296 | } | ||
297 | |||
298 | public virtual GridRegion GetRegionByName(UUID scopeID, string regionName) | ||
299 | { | ||
300 | Dictionary<string, string> sendData = new Dictionary<string, string>(); | ||
301 | |||
302 | sendData["SCOPEID"] = scopeID.ToString(); | ||
303 | sendData["NAME"] = regionName; | ||
304 | |||
305 | sendData["METHOD"] = "get_region_by_name"; | ||
306 | string reply = string.Empty; | ||
307 | try | ||
308 | { | ||
309 | reply = SynchronousRestFormsRequester.MakeRequest("POST", | ||
310 | m_ServerURI + "/grid", | ||
311 | ServerUtils.BuildQueryString(sendData)); | ||
312 | } | ||
313 | catch (Exception e) | ||
314 | { | ||
315 | m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message); | ||
316 | return null; | ||
317 | } | ||
318 | |||
319 | GridRegion rinfo = null; | ||
320 | if (reply != string.Empty) | ||
321 | { | ||
322 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | ||
323 | |||
324 | if ((replyData != null) && (replyData["result"] != null)) | ||
325 | { | ||
326 | if (replyData["result"] is Dictionary<string, object>) | ||
327 | rinfo = new GridRegion((Dictionary<string, object>)replyData["result"]); | ||
328 | } | ||
329 | else | ||
330 | m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1} received null response", | ||
331 | scopeID, regionName); | ||
332 | } | ||
333 | else | ||
334 | m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByName received null reply"); | ||
335 | |||
336 | return rinfo; | ||
337 | } | ||
338 | |||
339 | public virtual List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber) | ||
340 | { | ||
341 | Dictionary<string, string> sendData = new Dictionary<string, string>(); | ||
342 | |||
343 | sendData["SCOPEID"] = scopeID.ToString(); | ||
344 | sendData["NAME"] = name; | ||
345 | sendData["MAX"] = maxNumber.ToString(); | ||
346 | |||
347 | sendData["METHOD"] = "get_regions_by_name"; | ||
348 | List<GridRegion> rinfos = new List<GridRegion>(); | ||
349 | string reply = string.Empty; | ||
350 | try | ||
351 | { | ||
352 | reply = SynchronousRestFormsRequester.MakeRequest("POST", | ||
353 | m_ServerURI + "/grid", | ||
354 | ServerUtils.BuildQueryString(sendData)); | ||
355 | } | ||
356 | catch (Exception e) | ||
357 | { | ||
358 | m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message); | ||
359 | return rinfos; | ||
360 | } | ||
361 | |||
362 | if (reply != string.Empty) | ||
363 | { | ||
364 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | ||
365 | |||
366 | if (replyData != null) | ||
367 | { | ||
368 | Dictionary<string, object>.ValueCollection rinfosList = replyData.Values; | ||
369 | foreach (object r in rinfosList) | ||
370 | { | ||
371 | if (r is Dictionary<string, object>) | ||
372 | { | ||
373 | GridRegion rinfo = new GridRegion((Dictionary<string, object>)r); | ||
374 | rinfos.Add(rinfo); | ||
375 | } | ||
376 | else | ||
377 | m_log.DebugFormat("[GRID CONNECTOR]: GetRegionsByName {0}, {1}, {2} received invalid response", | ||
378 | scopeID, name, maxNumber); | ||
379 | } | ||
380 | } | ||
381 | else | ||
382 | m_log.DebugFormat("[GRID CONNECTOR]: GetRegionsByName {0}, {1}, {2} received null response", | ||
383 | scopeID, name, maxNumber); | ||
384 | } | ||
385 | else | ||
386 | m_log.DebugFormat("[GRID CONNECTOR]: GetRegionsByName received null reply"); | ||
387 | |||
388 | return rinfos; | ||
389 | } | ||
390 | |||
391 | public virtual List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) | ||
392 | { | ||
393 | Dictionary<string, string> sendData = new Dictionary<string, string>(); | ||
394 | |||
395 | sendData["SCOPEID"] = scopeID.ToString(); | ||
396 | sendData["XMIN"] = xmin.ToString(); | ||
397 | sendData["XMAX"] = xmax.ToString(); | ||
398 | sendData["YMIN"] = ymin.ToString(); | ||
399 | sendData["YMAX"] = ymax.ToString(); | ||
400 | |||
401 | sendData["METHOD"] = "get_region_range"; | ||
402 | |||
403 | List<GridRegion> rinfos = new List<GridRegion>(); | ||
404 | string reply = string.Empty; | ||
405 | try | ||
406 | { | ||
407 | reply = SynchronousRestFormsRequester.MakeRequest("POST", | ||
408 | m_ServerURI + "/grid", | ||
409 | ServerUtils.BuildQueryString(sendData)); | ||
410 | |||
411 | //m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply); | ||
412 | } | ||
413 | catch (Exception e) | ||
414 | { | ||
415 | m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message); | ||
416 | return rinfos; | ||
417 | } | ||
418 | |||
419 | if (reply != string.Empty) | ||
420 | { | ||
421 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | ||
422 | |||
423 | if (replyData != null) | ||
424 | { | ||
425 | Dictionary<string, object>.ValueCollection rinfosList = replyData.Values; | ||
426 | foreach (object r in rinfosList) | ||
427 | { | ||
428 | if (r is Dictionary<string, object>) | ||
429 | { | ||
430 | GridRegion rinfo = new GridRegion((Dictionary<string, object>)r); | ||
431 | rinfos.Add(rinfo); | ||
432 | } | ||
433 | } | ||
434 | } | ||
435 | else | ||
436 | m_log.DebugFormat("[GRID CONNECTOR]: GetRegionRange {0}, {1}-{2} {3}-{4} received null response", | ||
437 | scopeID, xmin, xmax, ymin, ymax); | ||
438 | } | ||
439 | else | ||
440 | m_log.DebugFormat("[GRID CONNECTOR]: GetRegionRange received null reply"); | ||
441 | |||
442 | return rinfos; | ||
443 | } | ||
444 | |||
445 | #endregion | ||
446 | |||
447 | } | ||
448 | } | ||
diff --git a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs new file mode 100644 index 0000000..b5e8743 --- /dev/null +++ b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs | |||
@@ -0,0 +1,152 @@ | |||
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 System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Text; | ||
32 | using System.Drawing; | ||
33 | using System.Net; | ||
34 | using System.Reflection; | ||
35 | using OpenSim.Services.Interfaces; | ||
36 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
37 | |||
38 | using OpenSim.Framework; | ||
39 | |||
40 | using OpenMetaverse; | ||
41 | using OpenMetaverse.Imaging; | ||
42 | using log4net; | ||
43 | using Nwc.XmlRpc; | ||
44 | |||
45 | namespace OpenSim.Services.Connectors.Grid | ||
46 | { | ||
47 | public class HypergridServiceConnector | ||
48 | { | ||
49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
50 | |||
51 | private IAssetService m_AssetService; | ||
52 | |||
53 | public HypergridServiceConnector(IAssetService assService) | ||
54 | { | ||
55 | m_AssetService = assService; | ||
56 | } | ||
57 | |||
58 | public UUID LinkRegion(GridRegion info, out ulong realHandle) | ||
59 | { | ||
60 | UUID uuid = UUID.Zero; | ||
61 | realHandle = 0; | ||
62 | |||
63 | Hashtable hash = new Hashtable(); | ||
64 | hash["region_name"] = info.RegionName; | ||
65 | |||
66 | IList paramList = new ArrayList(); | ||
67 | paramList.Add(hash); | ||
68 | |||
69 | XmlRpcRequest request = new XmlRpcRequest("linkk_region", paramList); | ||
70 | string uri = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/"; | ||
71 | m_log.Debug("[HGrid]: Linking to " + uri); | ||
72 | XmlRpcResponse response = request.Send(uri, 10000); | ||
73 | if (response.IsFault) | ||
74 | { | ||
75 | m_log.ErrorFormat("[HGrid]: remote call returned an error: {0}", response.FaultString); | ||
76 | } | ||
77 | else | ||
78 | { | ||
79 | hash = (Hashtable)response.Value; | ||
80 | //foreach (Object o in hash) | ||
81 | // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); | ||
82 | try | ||
83 | { | ||
84 | UUID.TryParse((string)hash["uuid"], out uuid); | ||
85 | info.RegionID = uuid; | ||
86 | if ((string)hash["handle"] != null) | ||
87 | { | ||
88 | realHandle = Convert.ToUInt64((string)hash["handle"]); | ||
89 | m_log.Debug(">> HERE, realHandle: " + realHandle); | ||
90 | } | ||
91 | //if (hash["region_image"] != null) | ||
92 | //{ | ||
93 | // UUID img = UUID.Zero; | ||
94 | // UUID.TryParse((string)hash["region_image"], out img); | ||
95 | // info.RegionSettings.TerrainImageID = img; | ||
96 | //} | ||
97 | if (hash["region_name"] != null) | ||
98 | { | ||
99 | info.RegionName = (string)hash["region_name"]; | ||
100 | //m_log.Debug(">> " + info.RegionName); | ||
101 | } | ||
102 | if (hash["internal_port"] != null) | ||
103 | { | ||
104 | int port = Convert.ToInt32((string)hash["internal_port"]); | ||
105 | info.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), port); | ||
106 | //m_log.Debug(">> " + info.InternalEndPoint.ToString()); | ||
107 | } | ||
108 | |||
109 | } | ||
110 | catch (Exception e) | ||
111 | { | ||
112 | m_log.Error("[HGrid]: Got exception while parsing hyperlink response " + e.StackTrace); | ||
113 | } | ||
114 | } | ||
115 | return uuid; | ||
116 | } | ||
117 | |||
118 | public void GetMapImage(GridRegion info) | ||
119 | { | ||
120 | try | ||
121 | { | ||
122 | string regionimage = "regionImage" + info.RegionID.ToString(); | ||
123 | regionimage = regionimage.Replace("-", ""); | ||
124 | |||
125 | WebClient c = new WebClient(); | ||
126 | string uri = "http://" + info.ExternalHostName + ":" + info.HttpPort + "/index.php?method=" + regionimage; | ||
127 | //m_log.Debug("JPEG: " + uri); | ||
128 | c.DownloadFile(uri, info.RegionID.ToString() + ".jpg"); | ||
129 | Bitmap m = new Bitmap(info.RegionID.ToString() + ".jpg"); | ||
130 | //m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width); | ||
131 | byte[] imageData = OpenJPEG.EncodeFromImage(m, true); | ||
132 | AssetBase ass = new AssetBase(UUID.Random(), "region " + info.RegionID.ToString()); | ||
133 | |||
134 | // !!! for now | ||
135 | //info.RegionSettings.TerrainImageID = ass.FullID; | ||
136 | |||
137 | ass.Type = (int)AssetType.Texture; | ||
138 | ass.Temporary = true; | ||
139 | ass.Local = true; | ||
140 | ass.Data = imageData; | ||
141 | |||
142 | m_AssetService.Store(ass); | ||
143 | |||
144 | } | ||
145 | catch // LEGIT: Catching problems caused by OpenJPEG p/invoke | ||
146 | { | ||
147 | m_log.Warn("[HGrid]: Failed getting/storing map image, because it is probably already in the cache"); | ||
148 | } | ||
149 | } | ||
150 | |||
151 | } | ||
152 | } | ||
diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 6aa1c4f..991acf2 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs | |||
@@ -35,6 +35,7 @@ using OpenSim.Framework; | |||
35 | using OpenSim.Framework.Console; | 35 | using OpenSim.Framework.Console; |
36 | using OpenSim.Data; | 36 | using OpenSim.Data; |
37 | using OpenSim.Services.Interfaces; | 37 | using OpenSim.Services.Interfaces; |
38 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
38 | using OpenMetaverse; | 39 | using OpenMetaverse; |
39 | 40 | ||
40 | namespace OpenSim.Services.GridService | 41 | namespace OpenSim.Services.GridService |
@@ -48,33 +49,28 @@ namespace OpenSim.Services.GridService | |||
48 | public GridService(IConfigSource config) | 49 | public GridService(IConfigSource config) |
49 | : base(config) | 50 | : base(config) |
50 | { | 51 | { |
51 | MainConsole.Instance.Commands.AddCommand("kfs", false, | 52 | m_log.DebugFormat("[GRID SERVICE]: Starting..."); |
52 | "show digest", | ||
53 | "show digest <ID>", | ||
54 | "Show asset digest", HandleShowDigest); | ||
55 | |||
56 | MainConsole.Instance.Commands.AddCommand("kfs", false, | ||
57 | "delete asset", | ||
58 | "delete asset <ID>", | ||
59 | "Delete asset from database", HandleDeleteAsset); | ||
60 | |||
61 | } | 53 | } |
62 | 54 | ||
63 | #region IGridService | 55 | #region IGridService |
64 | 56 | ||
65 | public bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfos) | 57 | public bool RegisterRegion(UUID scopeID, GridRegion regionInfos) |
66 | { | 58 | { |
67 | if (m_Database.Get(regionInfos.RegionID, scopeID) != null) | 59 | // This needs better sanity testing. What if regionInfo is registering in |
68 | { | 60 | // overlapping coords? |
69 | m_log.WarnFormat("[GRID SERVICE]: Region {0} already registered in scope {1}.", regionInfos.RegionID, scopeID); | 61 | RegionData region = m_Database.Get(regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); |
70 | return false; | 62 | if ((region != null) && (region.RegionID != regionInfos.RegionID)) |
71 | } | ||
72 | if (m_Database.Get((int)regionInfos.RegionLocX, (int)regionInfos.RegionLocY, scopeID) != null) | ||
73 | { | 63 | { |
74 | m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register in coordinates {1}, {2} which are already in use in scope {3}.", | 64 | m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register in coordinates {1}, {2} which are already in use in scope {3}.", |
75 | regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); | 65 | regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); |
76 | return false; | 66 | return false; |
77 | } | 67 | } |
68 | if ((region != null) && (region.RegionID == regionInfos.RegionID) && | ||
69 | ((region.posX != regionInfos.RegionLocX) || (region.posY != regionInfos.RegionLocY))) | ||
70 | { | ||
71 | // Region reregistering in other coordinates. Delete the old entry | ||
72 | m_Database.Delete(regionInfos.RegionID); | ||
73 | } | ||
78 | 74 | ||
79 | // Everything is ok, let's register | 75 | // Everything is ok, let's register |
80 | RegionData rdata = RegionInfo2RegionData(regionInfos); | 76 | RegionData rdata = RegionInfo2RegionData(regionInfos); |
@@ -88,17 +84,25 @@ namespace OpenSim.Services.GridService | |||
88 | return m_Database.Delete(regionID); | 84 | return m_Database.Delete(regionID); |
89 | } | 85 | } |
90 | 86 | ||
91 | public List<SimpleRegionInfo> GetNeighbours(UUID scopeID, int x, int y) | 87 | public List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID) |
92 | { | 88 | { |
93 | List<RegionData> rdatas = m_Database.Get(x - 1, y - 1, x + 1, y + 1, scopeID); | 89 | List<GridRegion> rinfos = new List<GridRegion>(); |
94 | List<SimpleRegionInfo> rinfos = new List<SimpleRegionInfo>(); | 90 | RegionData region = m_Database.Get(regionID, scopeID); |
95 | foreach (RegionData rdata in rdatas) | 91 | if (region != null) |
96 | rinfos.Add(RegionData2RegionInfo(rdata)); | 92 | { |
93 | // Not really? Maybe? | ||
94 | List<RegionData> rdatas = m_Database.Get(region.posX - (int)Constants.RegionSize, region.posY - (int)Constants.RegionSize, | ||
95 | region.posX + (int)Constants.RegionSize, region.posY + (int)Constants.RegionSize, scopeID); | ||
96 | |||
97 | foreach (RegionData rdata in rdatas) | ||
98 | if (rdata.RegionID != regionID) | ||
99 | rinfos.Add(RegionData2RegionInfo(rdata)); | ||
97 | 100 | ||
101 | } | ||
98 | return rinfos; | 102 | return rinfos; |
99 | } | 103 | } |
100 | 104 | ||
101 | public SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID) | 105 | public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID) |
102 | { | 106 | { |
103 | RegionData rdata = m_Database.Get(regionID, scopeID); | 107 | RegionData rdata = m_Database.Get(regionID, scopeID); |
104 | if (rdata != null) | 108 | if (rdata != null) |
@@ -107,16 +111,18 @@ namespace OpenSim.Services.GridService | |||
107 | return null; | 111 | return null; |
108 | } | 112 | } |
109 | 113 | ||
110 | public SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y) | 114 | public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) |
111 | { | 115 | { |
112 | RegionData rdata = m_Database.Get(x, y, scopeID); | 116 | int snapX = (int)(x / Constants.RegionSize) * (int)Constants.RegionSize; |
117 | int snapY = (int)(y / Constants.RegionSize) * (int)Constants.RegionSize; | ||
118 | RegionData rdata = m_Database.Get(snapX, snapY, scopeID); | ||
113 | if (rdata != null) | 119 | if (rdata != null) |
114 | return RegionData2RegionInfo(rdata); | 120 | return RegionData2RegionInfo(rdata); |
115 | 121 | ||
116 | return null; | 122 | return null; |
117 | } | 123 | } |
118 | 124 | ||
119 | public SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName) | 125 | public GridRegion GetRegionByName(UUID scopeID, string regionName) |
120 | { | 126 | { |
121 | List<RegionData> rdatas = m_Database.Get(regionName + "%", scopeID); | 127 | List<RegionData> rdatas = m_Database.Get(regionName + "%", scopeID); |
122 | if ((rdatas != null) && (rdatas.Count > 0)) | 128 | if ((rdatas != null) && (rdatas.Count > 0)) |
@@ -125,12 +131,12 @@ namespace OpenSim.Services.GridService | |||
125 | return null; | 131 | return null; |
126 | } | 132 | } |
127 | 133 | ||
128 | public List<SimpleRegionInfo> GetRegionsByName(UUID scopeID, string name, int maxNumber) | 134 | public List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber) |
129 | { | 135 | { |
130 | List<RegionData> rdatas = m_Database.Get("%" + name + "%", scopeID); | 136 | List<RegionData> rdatas = m_Database.Get("%" + name + "%", scopeID); |
131 | 137 | ||
132 | int count = 0; | 138 | int count = 0; |
133 | List<SimpleRegionInfo> rinfos = new List<SimpleRegionInfo>(); | 139 | List<GridRegion> rinfos = new List<GridRegion>(); |
134 | 140 | ||
135 | if (rdatas != null) | 141 | if (rdatas != null) |
136 | { | 142 | { |
@@ -144,10 +150,15 @@ namespace OpenSim.Services.GridService | |||
144 | return rinfos; | 150 | return rinfos; |
145 | } | 151 | } |
146 | 152 | ||
147 | public List<SimpleRegionInfo> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) | 153 | public List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) |
148 | { | 154 | { |
149 | List<RegionData> rdatas = m_Database.Get(xmin, ymin, xmax, ymax, scopeID); | 155 | int xminSnap = (int)(xmin / Constants.RegionSize) * (int)Constants.RegionSize; |
150 | List<SimpleRegionInfo> rinfos = new List<SimpleRegionInfo>(); | 156 | int xmaxSnap = (int)(xmax / Constants.RegionSize) * (int)Constants.RegionSize; |
157 | int yminSnap = (int)(ymin / Constants.RegionSize) * (int)Constants.RegionSize; | ||
158 | int ymaxSnap = (int)(ymax / Constants.RegionSize) * (int)Constants.RegionSize; | ||
159 | |||
160 | List<RegionData> rdatas = m_Database.Get(xminSnap, yminSnap, xmaxSnap, ymaxSnap, scopeID); | ||
161 | List<GridRegion> rinfos = new List<GridRegion>(); | ||
151 | foreach (RegionData rdata in rdatas) | 162 | foreach (RegionData rdata in rdatas) |
152 | rinfos.Add(RegionData2RegionInfo(rdata)); | 163 | rinfos.Add(RegionData2RegionInfo(rdata)); |
153 | 164 | ||
@@ -158,140 +169,31 @@ namespace OpenSim.Services.GridService | |||
158 | 169 | ||
159 | #region Data structure conversions | 170 | #region Data structure conversions |
160 | 171 | ||
161 | protected RegionData RegionInfo2RegionData(SimpleRegionInfo rinfo) | 172 | protected RegionData RegionInfo2RegionData(GridRegion rinfo) |
162 | { | 173 | { |
163 | RegionData rdata = new RegionData(); | 174 | RegionData rdata = new RegionData(); |
164 | rdata.posX = (int)rinfo.RegionLocX; | 175 | rdata.posX = (int)rinfo.RegionLocX; |
165 | rdata.posY = (int)rinfo.RegionLocY; | 176 | rdata.posY = (int)rinfo.RegionLocY; |
166 | rdata.RegionID = rinfo.RegionID; | 177 | rdata.RegionID = rinfo.RegionID; |
167 | //rdata.RegionName = rinfo.RegionName; | 178 | rdata.RegionName = rinfo.RegionName; |
168 | rdata.Data["external_ip_address"] = rinfo.ExternalEndPoint.Address.ToString(); | 179 | rdata.Data = rinfo.ToKeyValuePairs(); |
169 | rdata.Data["external_port"] = rinfo.ExternalEndPoint.Port.ToString(); | 180 | rdata.Data["regionHandle"] = Utils.UIntsToLong((uint)rdata.posX, (uint)rdata.posY); |
170 | rdata.Data["external_host_name"] = rinfo.ExternalHostName; | ||
171 | rdata.Data["http_port"] = rinfo.HttpPort.ToString(); | ||
172 | rdata.Data["internal_ip_address"] = rinfo.InternalEndPoint.Address.ToString(); | ||
173 | rdata.Data["internal_port"] = rinfo.InternalEndPoint.Port.ToString(); | ||
174 | rdata.Data["alternate_ports"] = rinfo.m_allow_alternate_ports.ToString(); | ||
175 | rdata.Data["server_uri"] = rinfo.ServerURI; | ||
176 | |||
177 | return rdata; | 181 | return rdata; |
178 | } | 182 | } |
179 | 183 | ||
180 | protected SimpleRegionInfo RegionData2RegionInfo(RegionData rdata) | 184 | protected GridRegion RegionData2RegionInfo(RegionData rdata) |
181 | { | 185 | { |
182 | SimpleRegionInfo rinfo = new SimpleRegionInfo(); | 186 | GridRegion rinfo = new GridRegion(rdata.Data); |
183 | rinfo.RegionLocX = (uint)rdata.posX; | 187 | rinfo.RegionLocX = rdata.posX; |
184 | rinfo.RegionLocY = (uint)rdata.posY; | 188 | rinfo.RegionLocY = rdata.posY; |
185 | rinfo.RegionID = rdata.RegionID; | 189 | rinfo.RegionID = rdata.RegionID; |
186 | //rinfo.RegionName = rdata.RegionName; | 190 | rinfo.RegionName = rdata.RegionName; |
187 | 191 | rinfo.ScopeID = rdata.ScopeID; | |
188 | // Now for the variable data | ||
189 | if ((rdata.Data["external_ip_address"] != null) && (rdata.Data["external_port"] != null)) | ||
190 | { | ||
191 | int port = 0; | ||
192 | Int32.TryParse((string)rdata.Data["external_port"], out port); | ||
193 | IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)rdata.Data["external_ip_address"]), port); | ||
194 | rinfo.ExternalEndPoint = ep; | ||
195 | } | ||
196 | else | ||
197 | rinfo.ExternalEndPoint = new IPEndPoint(new IPAddress(0), 0); | ||
198 | |||
199 | if (rdata.Data["external_host_name"] != null) | ||
200 | rinfo.ExternalHostName = (string)rdata.Data["external_host_name"] ; | ||
201 | |||
202 | if (rdata.Data["http_port"] != null) | ||
203 | { | ||
204 | UInt32 port = 0; | ||
205 | UInt32.TryParse((string)rdata.Data["http_port"], out port); | ||
206 | rinfo.HttpPort = port; | ||
207 | } | ||
208 | |||
209 | if ((rdata.Data["internal_ip_address"] != null) && (rdata.Data["internal_port"] != null)) | ||
210 | { | ||
211 | int port = 0; | ||
212 | Int32.TryParse((string)rdata.Data["internal_port"], out port); | ||
213 | IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)rdata.Data["internal_ip_address"]), port); | ||
214 | rinfo.InternalEndPoint = ep; | ||
215 | } | ||
216 | else | ||
217 | rinfo.InternalEndPoint = new IPEndPoint(new IPAddress(0), 0); | ||
218 | |||
219 | if (rdata.Data["alternate_ports"] != null) | ||
220 | { | ||
221 | bool alts = false; | ||
222 | Boolean.TryParse((string)rdata.Data["alternate_ports"], out alts); | ||
223 | rinfo.m_allow_alternate_ports = alts; | ||
224 | } | ||
225 | |||
226 | if (rdata.Data["server_uri"] != null) | ||
227 | rinfo.ServerURI = (string)rdata.Data["server_uri"]; | ||
228 | 192 | ||
229 | return rinfo; | 193 | return rinfo; |
230 | } | 194 | } |
231 | 195 | ||
232 | #endregion | 196 | #endregion |
233 | 197 | ||
234 | void HandleShowDigest(string module, string[] args) | ||
235 | { | ||
236 | //if (args.Length < 3) | ||
237 | //{ | ||
238 | // MainConsole.Instance.Output("Syntax: show digest <ID>"); | ||
239 | // return; | ||
240 | //} | ||
241 | |||
242 | //AssetBase asset = Get(args[2]); | ||
243 | |||
244 | //if (asset == null || asset.Data.Length == 0) | ||
245 | //{ | ||
246 | // MainConsole.Instance.Output("Asset not found"); | ||
247 | // return; | ||
248 | //} | ||
249 | |||
250 | //int i; | ||
251 | |||
252 | //MainConsole.Instance.Output(String.Format("Name: {0}", asset.Name)); | ||
253 | //MainConsole.Instance.Output(String.Format("Description: {0}", asset.Description)); | ||
254 | //MainConsole.Instance.Output(String.Format("Type: {0}", asset.Type)); | ||
255 | //MainConsole.Instance.Output(String.Format("Content-type: {0}", asset.Metadata.ContentType)); | ||
256 | |||
257 | //for (i = 0 ; i < 5 ; i++) | ||
258 | //{ | ||
259 | // int off = i * 16; | ||
260 | // if (asset.Data.Length <= off) | ||
261 | // break; | ||
262 | // int len = 16; | ||
263 | // if (asset.Data.Length < off + len) | ||
264 | // len = asset.Data.Length - off; | ||
265 | |||
266 | // byte[] line = new byte[len]; | ||
267 | // Array.Copy(asset.Data, off, line, 0, len); | ||
268 | |||
269 | // string text = BitConverter.ToString(line); | ||
270 | // MainConsole.Instance.Output(String.Format("{0:x4}: {1}", off, text)); | ||
271 | //} | ||
272 | } | ||
273 | |||
274 | void HandleDeleteAsset(string module, string[] args) | ||
275 | { | ||
276 | //if (args.Length < 3) | ||
277 | //{ | ||
278 | // MainConsole.Instance.Output("Syntax: delete asset <ID>"); | ||
279 | // return; | ||
280 | //} | ||
281 | |||
282 | //AssetBase asset = Get(args[2]); | ||
283 | |||
284 | //if (asset == null || asset.Data.Length == 0) | ||
285 | // MainConsole.Instance.Output("Asset not found"); | ||
286 | // return; | ||
287 | //} | ||
288 | |||
289 | //Delete(args[2]); | ||
290 | |||
291 | ////MainConsole.Instance.Output("Asset deleted"); | ||
292 | //// TODO: Implement this | ||
293 | |||
294 | //MainConsole.Instance.Output("Asset deletion not supported by database"); | ||
295 | } | ||
296 | } | 198 | } |
297 | } | 199 | } |
diff --git a/OpenSim/Services/GridService/GridServiceBase.cs b/OpenSim/Services/GridService/GridServiceBase.cs index 7b69290..444f79b 100644 --- a/OpenSim/Services/GridService/GridServiceBase.cs +++ b/OpenSim/Services/GridService/GridServiceBase.cs | |||
@@ -47,17 +47,6 @@ namespace OpenSim.Services.GridService | |||
47 | string realm = "regions"; | 47 | string realm = "regions"; |
48 | 48 | ||
49 | // | 49 | // |
50 | // Try reading the [AssetService] section first, if it exists | ||
51 | // | ||
52 | IConfig gridConfig = config.Configs["GridService"]; | ||
53 | if (gridConfig != null) | ||
54 | { | ||
55 | dllName = gridConfig.GetString("StorageProvider", dllName); | ||
56 | connString = gridConfig.GetString("ConnectionString", connString); | ||
57 | realm = gridConfig.GetString("Realm", realm); | ||
58 | } | ||
59 | |||
60 | // | ||
61 | // Try reading the [DatabaseService] section, if it exists | 50 | // Try reading the [DatabaseService] section, if it exists |
62 | // | 51 | // |
63 | IConfig dbConfig = config.Configs["DatabaseService"]; | 52 | IConfig dbConfig = config.Configs["DatabaseService"]; |
@@ -70,6 +59,17 @@ namespace OpenSim.Services.GridService | |||
70 | } | 59 | } |
71 | 60 | ||
72 | // | 61 | // |
62 | // [GridService] section overrides [DatabaseService], if it exists | ||
63 | // | ||
64 | IConfig gridConfig = config.Configs["GridService"]; | ||
65 | if (gridConfig != null) | ||
66 | { | ||
67 | dllName = gridConfig.GetString("StorageProvider", dllName); | ||
68 | connString = gridConfig.GetString("ConnectionString", connString); | ||
69 | realm = gridConfig.GetString("Realm", realm); | ||
70 | } | ||
71 | |||
72 | // | ||
73 | // We tried, but this doesn't exist. We can't proceed. | 73 | // We tried, but this doesn't exist. We can't proceed. |
74 | // | 74 | // |
75 | if (dllName.Equals(String.Empty)) | 75 | if (dllName.Equals(String.Empty)) |
diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs index 83ab9c1..ce432ab 100644 --- a/OpenSim/Services/Interfaces/IGridService.cs +++ b/OpenSim/Services/Interfaces/IGridService.cs | |||
@@ -25,8 +25,11 @@ | |||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using OpenSim.Framework; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Net; | ||
31 | using System.Net.Sockets; | ||
32 | using OpenSim.Framework; | ||
30 | using OpenMetaverse; | 33 | using OpenMetaverse; |
31 | 34 | ||
32 | namespace OpenSim.Services.Interfaces | 35 | namespace OpenSim.Services.Interfaces |
@@ -39,7 +42,7 @@ namespace OpenSim.Services.Interfaces | |||
39 | /// <param name="regionInfos"> </param> | 42 | /// <param name="regionInfos"> </param> |
40 | /// <returns></returns> | 43 | /// <returns></returns> |
41 | /// <exception cref="System.Exception">Thrown if region registration failed</exception> | 44 | /// <exception cref="System.Exception">Thrown if region registration failed</exception> |
42 | bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfos); | 45 | bool RegisterRegion(UUID scopeID, GridRegion regionInfos); |
43 | 46 | ||
44 | /// <summary> | 47 | /// <summary> |
45 | /// Deregister a region with the grid service. | 48 | /// Deregister a region with the grid service. |
@@ -55,9 +58,9 @@ namespace OpenSim.Services.Interfaces | |||
55 | /// <param name="x"></param> | 58 | /// <param name="x"></param> |
56 | /// <param name="y"></param> | 59 | /// <param name="y"></param> |
57 | /// <returns></returns> | 60 | /// <returns></returns> |
58 | List<SimpleRegionInfo> GetNeighbours(UUID scopeID, int x, int y); | 61 | List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID); |
59 | 62 | ||
60 | SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID); | 63 | GridRegion GetRegionByUUID(UUID scopeID, UUID regionID); |
61 | 64 | ||
62 | /// <summary> | 65 | /// <summary> |
63 | /// Get the region at the given position (in meters) | 66 | /// Get the region at the given position (in meters) |
@@ -66,9 +69,9 @@ namespace OpenSim.Services.Interfaces | |||
66 | /// <param name="x"></param> | 69 | /// <param name="x"></param> |
67 | /// <param name="y"></param> | 70 | /// <param name="y"></param> |
68 | /// <returns></returns> | 71 | /// <returns></returns> |
69 | SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y); | 72 | GridRegion GetRegionByPosition(UUID scopeID, int x, int y); |
70 | 73 | ||
71 | SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName); | 74 | GridRegion GetRegionByName(UUID scopeID, string regionName); |
72 | 75 | ||
73 | /// <summary> | 76 | /// <summary> |
74 | /// Get information about regions starting with the provided name. | 77 | /// Get information about regions starting with the provided name. |
@@ -83,9 +86,233 @@ namespace OpenSim.Services.Interfaces | |||
83 | /// A list of <see cref="RegionInfo"/>s of regions with matching name. If the | 86 | /// A list of <see cref="RegionInfo"/>s of regions with matching name. If the |
84 | /// grid-server couldn't be contacted or returned an error, return null. | 87 | /// grid-server couldn't be contacted or returned an error, return null. |
85 | /// </returns> | 88 | /// </returns> |
86 | List<SimpleRegionInfo> GetRegionsByName(UUID scopeID, string name, int maxNumber); | 89 | List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber); |
87 | 90 | ||
88 | List<SimpleRegionInfo> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax); | 91 | List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax); |
89 | 92 | ||
90 | } | 93 | } |
94 | |||
95 | public class GridRegion | ||
96 | { | ||
97 | |||
98 | /// <summary> | ||
99 | /// The port by which http communication occurs with the region | ||
100 | /// </summary> | ||
101 | public uint HttpPort | ||
102 | { | ||
103 | get { return m_httpPort; } | ||
104 | set { m_httpPort = value; } | ||
105 | } | ||
106 | protected uint m_httpPort; | ||
107 | |||
108 | /// <summary> | ||
109 | /// A well-formed URI for the host region server (namely "http://" + ExternalHostName) | ||
110 | /// </summary> | ||
111 | public string ServerURI | ||
112 | { | ||
113 | get { return m_serverURI; } | ||
114 | set { m_serverURI = value; } | ||
115 | } | ||
116 | protected string m_serverURI; | ||
117 | |||
118 | public string RegionName | ||
119 | { | ||
120 | get { return m_regionName; } | ||
121 | set { m_regionName = value; } | ||
122 | } | ||
123 | protected string m_regionName = String.Empty; | ||
124 | |||
125 | protected bool Allow_Alternate_Ports; | ||
126 | public bool m_allow_alternate_ports; | ||
127 | |||
128 | protected string m_externalHostName; | ||
129 | |||
130 | protected IPEndPoint m_internalEndPoint; | ||
131 | |||
132 | public int RegionLocX | ||
133 | { | ||
134 | get { return m_regionLocX; } | ||
135 | set { m_regionLocX = value; } | ||
136 | } | ||
137 | protected int m_regionLocX; | ||
138 | |||
139 | public int RegionLocY | ||
140 | { | ||
141 | get { return m_regionLocY; } | ||
142 | set { m_regionLocY = value; } | ||
143 | } | ||
144 | protected int m_regionLocY; | ||
145 | |||
146 | public UUID RegionID = UUID.Zero; | ||
147 | public UUID ScopeID = UUID.Zero; | ||
148 | |||
149 | public GridRegion() | ||
150 | { | ||
151 | } | ||
152 | |||
153 | public GridRegion(int regionLocX, int regionLocY, IPEndPoint internalEndPoint, string externalUri) | ||
154 | { | ||
155 | m_regionLocX = regionLocX; | ||
156 | m_regionLocY = regionLocY; | ||
157 | |||
158 | m_internalEndPoint = internalEndPoint; | ||
159 | m_externalHostName = externalUri; | ||
160 | } | ||
161 | |||
162 | public GridRegion(int regionLocX, int regionLocY, string externalUri, uint port) | ||
163 | { | ||
164 | m_regionLocX = regionLocX; | ||
165 | m_regionLocY = regionLocY; | ||
166 | |||
167 | m_externalHostName = externalUri; | ||
168 | |||
169 | m_internalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)port); | ||
170 | } | ||
171 | |||
172 | public GridRegion(uint xcell, uint ycell) | ||
173 | { | ||
174 | m_regionLocX = (int)(xcell * Constants.RegionSize); | ||
175 | m_regionLocY = (int)(ycell * Constants.RegionSize); | ||
176 | } | ||
177 | |||
178 | public GridRegion(RegionInfo ConvertFrom) | ||
179 | { | ||
180 | m_regionName = ConvertFrom.RegionName; | ||
181 | m_regionLocX = (int)(ConvertFrom.RegionLocX * Constants.RegionSize); | ||
182 | m_regionLocY = (int)(ConvertFrom.RegionLocY * Constants.RegionSize); | ||
183 | m_internalEndPoint = ConvertFrom.InternalEndPoint; | ||
184 | m_externalHostName = ConvertFrom.ExternalHostName; | ||
185 | m_httpPort = ConvertFrom.HttpPort; | ||
186 | m_allow_alternate_ports = ConvertFrom.m_allow_alternate_ports; | ||
187 | RegionID = UUID.Zero; | ||
188 | ServerURI = ConvertFrom.ServerURI; | ||
189 | } | ||
190 | |||
191 | |||
192 | /// <value> | ||
193 | /// This accessor can throw all the exceptions that Dns.GetHostAddresses can throw. | ||
194 | /// | ||
195 | /// XXX Isn't this really doing too much to be a simple getter, rather than an explict method? | ||
196 | /// </value> | ||
197 | public IPEndPoint ExternalEndPoint | ||
198 | { | ||
199 | get | ||
200 | { | ||
201 | // Old one defaults to IPv6 | ||
202 | //return new IPEndPoint(Dns.GetHostAddresses(m_externalHostName)[0], m_internalEndPoint.Port); | ||
203 | |||
204 | IPAddress ia = null; | ||
205 | // If it is already an IP, don't resolve it - just return directly | ||
206 | if (IPAddress.TryParse(m_externalHostName, out ia)) | ||
207 | return new IPEndPoint(ia, m_internalEndPoint.Port); | ||
208 | |||
209 | // Reset for next check | ||
210 | ia = null; | ||
211 | try | ||
212 | { | ||
213 | foreach (IPAddress Adr in Dns.GetHostAddresses(m_externalHostName)) | ||
214 | { | ||
215 | if (ia == null) | ||
216 | ia = Adr; | ||
217 | |||
218 | if (Adr.AddressFamily == AddressFamily.InterNetwork) | ||
219 | { | ||
220 | ia = Adr; | ||
221 | break; | ||
222 | } | ||
223 | } | ||
224 | } | ||
225 | catch (SocketException e) | ||
226 | { | ||
227 | throw new Exception( | ||
228 | "Unable to resolve local hostname " + m_externalHostName + " innerException of type '" + | ||
229 | e + "' attached to this exception", e); | ||
230 | } | ||
231 | |||
232 | return new IPEndPoint(ia, m_internalEndPoint.Port); | ||
233 | } | ||
234 | |||
235 | set { m_externalHostName = value.ToString(); } | ||
236 | } | ||
237 | |||
238 | public string ExternalHostName | ||
239 | { | ||
240 | get { return m_externalHostName; } | ||
241 | set { m_externalHostName = value; } | ||
242 | } | ||
243 | |||
244 | public IPEndPoint InternalEndPoint | ||
245 | { | ||
246 | get { return m_internalEndPoint; } | ||
247 | set { m_internalEndPoint = value; } | ||
248 | } | ||
249 | |||
250 | public ulong RegionHandle | ||
251 | { | ||
252 | get { return Util.UIntsToLong((uint)RegionLocX, (uint)RegionLocY); } | ||
253 | } | ||
254 | |||
255 | public int getInternalEndPointPort() | ||
256 | { | ||
257 | return m_internalEndPoint.Port; | ||
258 | } | ||
259 | |||
260 | public Dictionary<string, object> ToKeyValuePairs() | ||
261 | { | ||
262 | Dictionary<string, object> kvp = new Dictionary<string, object>(); | ||
263 | kvp["uuid"] = RegionID.ToString(); | ||
264 | kvp["locX"] = RegionLocX.ToString(); | ||
265 | kvp["locY"] = RegionLocY.ToString(); | ||
266 | kvp["regionName"] = RegionName; | ||
267 | kvp["serverIP"] = ExternalHostName; //ExternalEndPoint.Address.ToString(); | ||
268 | kvp["serverHttpPort"] = HttpPort.ToString(); | ||
269 | kvp["serverURI"] = ServerURI; | ||
270 | kvp["serverPort"] = InternalEndPoint.Port.ToString(); | ||
271 | |||
272 | return kvp; | ||
273 | } | ||
274 | |||
275 | public GridRegion(Dictionary<string, object> kvp) | ||
276 | { | ||
277 | if (kvp.ContainsKey("uuid")) | ||
278 | RegionID = new UUID((string)kvp["uuid"]); | ||
279 | |||
280 | if (kvp.ContainsKey("locX")) | ||
281 | RegionLocX = Convert.ToInt32((string)kvp["locX"]); | ||
282 | |||
283 | if (kvp.ContainsKey("locY")) | ||
284 | RegionLocY = Convert.ToInt32((string)kvp["locY"]); | ||
285 | |||
286 | if (kvp.ContainsKey("regionName")) | ||
287 | RegionName = (string)kvp["regionName"]; | ||
288 | |||
289 | if (kvp.ContainsKey("serverIP")) | ||
290 | { | ||
291 | //int port = 0; | ||
292 | //Int32.TryParse((string)kvp["serverPort"], out port); | ||
293 | //IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)kvp["serverIP"]), port); | ||
294 | ExternalHostName = (string)kvp["serverIP"]; | ||
295 | } | ||
296 | else | ||
297 | ExternalHostName = "127.0.0.1"; | ||
298 | |||
299 | if (kvp.ContainsKey("serverPort")) | ||
300 | { | ||
301 | Int32 port = 0; | ||
302 | Int32.TryParse((string)kvp["serverPort"], out port); | ||
303 | InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), port); | ||
304 | } | ||
305 | |||
306 | if (kvp.ContainsKey("serverHttpPort")) | ||
307 | { | ||
308 | UInt32 port = 0; | ||
309 | UInt32.TryParse((string)kvp["serverHttpPort"], out port); | ||
310 | HttpPort = port; | ||
311 | } | ||
312 | |||
313 | if (kvp.ContainsKey("serverURI")) | ||
314 | ServerURI = (string)kvp["serverURI"]; | ||
315 | } | ||
316 | } | ||
317 | |||
91 | } | 318 | } |