diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/Communications/RestClient.cs | 18 | ||||
-rw-r--r-- | OpenSim/Framework/Servers/BaseHttpServer.cs | 5 | ||||
-rw-r--r-- | OpenSim/Grid/GridServer/GridManager.cs | 58 | ||||
-rw-r--r-- | OpenSim/Grid/GridServer/GridServerBase.cs | 10 | ||||
-rw-r--r-- | prebuild.xml | 1 |
5 files changed, 71 insertions, 21 deletions
diff --git a/OpenSim/Framework/Communications/RestClient.cs b/OpenSim/Framework/Communications/RestClient.cs index d0ac833..4ed62bf 100644 --- a/OpenSim/Framework/Communications/RestClient.cs +++ b/OpenSim/Framework/Communications/RestClient.cs | |||
@@ -15,17 +15,17 @@ namespace OpenSim.Framework.Communications | |||
15 | /// </summary> | 15 | /// </summary> |
16 | /// <remarks> | 16 | /// <remarks> |
17 | /// This class is a generic implementation of a REST (Representational State Transfer) web service. This | 17 | /// This class is a generic implementation of a REST (Representational State Transfer) web service. This |
18 | /// class is designed to execute both synchroneously and asynchroneously. | 18 | /// class is designed to execute both synchronously and asynchronously. |
19 | /// | 19 | /// |
20 | /// Internally the implementation works as a two stage asynchroneous web-client. | 20 | /// Internally the implementation works as a two stage asynchronous web-client. |
21 | /// When the request is initiated, RestClient will query asynchroneously for for a web-response, | 21 | /// When the request is initiated, RestClient will query asynchronously for for a web-response, |
22 | /// sleeping until the initial response is returned by the server. Once the initial response is retrieved | 22 | /// sleeping until the initial response is returned by the server. Once the initial response is retrieved |
23 | /// the second stage of asynchroneous requests will be triggered, in an attempt to read of the response | 23 | /// the second stage of asynchronous requests will be triggered, in an attempt to read of the response |
24 | /// object into a memorystream as a sequence of asynchroneous reads. | 24 | /// object into a memorystream as a sequence of asynchronous reads. |
25 | /// | 25 | /// |
26 | /// The asynchronisity of RestClient is designed to move as much processing into the back-ground, allowing | 26 | /// The asynchronisity of RestClient is designed to move as much processing into the back-ground, allowing |
27 | /// other threads to execute, while it waits for a response from the web-service. RestClient it self, can be | 27 | /// other threads to execute, while it waits for a response from the web-service. RestClient itself can be |
28 | /// invoked by the caller in either synchroneous mode or asynchroneous mode. | 28 | /// invoked by the caller in either synchronous mode or asynchronous modes. |
29 | /// </remarks> | 29 | /// </remarks> |
30 | public class RestClient | 30 | public class RestClient |
31 | { | 31 | { |
@@ -245,7 +245,7 @@ namespace OpenSim.Framework.Communications | |||
245 | #endregion Async communications with server | 245 | #endregion Async communications with server |
246 | 246 | ||
247 | /// <summary> | 247 | /// <summary> |
248 | /// Perform synchroneous request | 248 | /// Perform a synchronous request |
249 | /// </summary> | 249 | /// </summary> |
250 | public Stream Request() | 250 | public Stream Request() |
251 | { | 251 | { |
@@ -365,4 +365,4 @@ namespace OpenSim.Framework.Communications | |||
365 | 365 | ||
366 | #endregion Async Invocation | 366 | #endregion Async Invocation |
367 | } | 367 | } |
368 | } \ No newline at end of file | 368 | } |
diff --git a/OpenSim/Framework/Servers/BaseHttpServer.cs b/OpenSim/Framework/Servers/BaseHttpServer.cs index e198c2c..2f495a9 100644 --- a/OpenSim/Framework/Servers/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/BaseHttpServer.cs | |||
@@ -144,6 +144,8 @@ namespace OpenSim.Framework.Servers | |||
144 | 144 | ||
145 | string path = request.RawUrl; | 145 | string path = request.RawUrl; |
146 | string handlerKey = GetHandlerKey(request.HttpMethod, path); | 146 | string handlerKey = GetHandlerKey(request.HttpMethod, path); |
147 | |||
148 | //m_log.DebugFormat("[BASE HTTP SERVER]: Handling {0} request for {1}", request.HttpMethod, path); | ||
147 | 149 | ||
148 | IRequestHandler requestHandler; | 150 | IRequestHandler requestHandler; |
149 | 151 | ||
@@ -154,6 +156,7 @@ namespace OpenSim.Framework.Servers | |||
154 | if (requestHandler is IStreamedRequestHandler) | 156 | if (requestHandler is IStreamedRequestHandler) |
155 | { | 157 | { |
156 | IStreamedRequestHandler streamedRequestHandler = requestHandler as IStreamedRequestHandler; | 158 | IStreamedRequestHandler streamedRequestHandler = requestHandler as IStreamedRequestHandler; |
159 | |||
157 | buffer = streamedRequestHandler.Handle(path, request.InputStream); | 160 | buffer = streamedRequestHandler.Handle(path, request.InputStream); |
158 | } | 161 | } |
159 | else | 162 | else |
@@ -179,7 +182,7 @@ namespace OpenSim.Framework.Servers | |||
179 | } | 182 | } |
180 | catch (HttpListenerException) | 183 | catch (HttpListenerException) |
181 | { | 184 | { |
182 | m_log.InfoFormat("[BASE HTTP SERVER] Http request abnormally terminated."); | 185 | m_log.WarnFormat("[BASE HTTP SERVER]: HTTP request abnormally terminated."); |
183 | } | 186 | } |
184 | } | 187 | } |
185 | else | 188 | else |
diff --git a/OpenSim/Grid/GridServer/GridManager.cs b/OpenSim/Grid/GridServer/GridManager.cs index 2bb26cf..84a515c 100644 --- a/OpenSim/Grid/GridServer/GridManager.cs +++ b/OpenSim/Grid/GridServer/GridManager.cs | |||
@@ -28,6 +28,7 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.IO; | ||
31 | using System.Reflection; | 32 | using System.Reflection; |
32 | using System.Xml; | 33 | using System.Xml; |
33 | using libsecondlife; | 34 | using libsecondlife; |
@@ -36,6 +37,7 @@ using Nwc.XmlRpc; | |||
36 | using OpenSim.Data; | 37 | using OpenSim.Data; |
37 | using OpenSim.Data.MySQL; | 38 | using OpenSim.Data.MySQL; |
38 | using OpenSim.Framework; | 39 | using OpenSim.Framework; |
40 | using OpenSim.Framework.Communications; | ||
39 | using OpenSim.Framework.Servers; | 41 | using OpenSim.Framework.Servers; |
40 | 42 | ||
41 | namespace OpenSim.Grid.GridServer | 43 | namespace OpenSim.Grid.GridServer |
@@ -248,7 +250,7 @@ namespace OpenSim.Grid.GridServer | |||
248 | /// </summary> | 250 | /// </summary> |
249 | /// <param name="sim"></param> | 251 | /// <param name="sim"></param> |
250 | /// <returns></returns> | 252 | /// <returns></returns> |
251 | protected virtual void ValidateOverwrite(RegionProfileData sim, RegionProfileData existingSim) | 253 | protected virtual void ValidateOverwriteKeys(RegionProfileData sim, RegionProfileData existingSim) |
252 | { | 254 | { |
253 | if (!(existingSim.regionRecvKey == sim.regionRecvKey && existingSim.regionSendKey == sim.regionSendKey)) | 255 | if (!(existingSim.regionRecvKey == sim.regionRecvKey && existingSim.regionSendKey == sim.regionSendKey)) |
254 | { | 256 | { |
@@ -271,7 +273,7 @@ namespace OpenSim.Grid.GridServer | |||
271 | /// | 273 | /// |
272 | /// <param name="sim"></param> | 274 | /// <param name="sim"></param> |
273 | /// <exception cref="LoginException">Thrown if region login failed</exception> | 275 | /// <exception cref="LoginException">Thrown if region login failed</exception> |
274 | protected virtual void ValidateNewRegion(RegionProfileData sim) | 276 | protected virtual void ValidateNewRegionKeys(RegionProfileData sim) |
275 | { | 277 | { |
276 | if (!(sim.regionRecvKey == Config.SimSendKey && sim.regionSendKey == Config.SimRecvKey)) | 278 | if (!(sim.regionRecvKey == Config.SimSendKey && sim.regionSendKey == Config.SimRecvKey)) |
277 | { | 279 | { |
@@ -282,8 +284,51 @@ namespace OpenSim.Grid.GridServer | |||
282 | sim.regionName, sim.regionLocX, sim.regionLocY, | 284 | sim.regionName, sim.regionLocX, sim.regionLocY, |
283 | sim.regionSendKey, Config.SimRecvKey, sim.regionRecvKey, Config.SimSendKey), | 285 | sim.regionSendKey, Config.SimRecvKey, sim.regionRecvKey, Config.SimSendKey), |
284 | "The keys required to login your region did not match your existing region keys. Please check your grid send and receive keys."); | 286 | "The keys required to login your region did not match your existing region keys. Please check your grid send and receive keys."); |
287 | } | ||
288 | } | ||
289 | |||
290 | /// <summary> | ||
291 | /// Check that a region's http uri is externally contactable. | ||
292 | /// </summary> | ||
293 | /// <param name="sim"></param> | ||
294 | /// <exception cref="LoginException">Thrown if the region is not contactable</exception> | ||
295 | protected virtual void ValidateRegionContactable(RegionProfileData sim) | ||
296 | { | ||
297 | string regionStatusUrl = String.Format("{0}{1}", sim.httpServerURI, "simstatus/"); | ||
298 | string regionStatusResponse; | ||
299 | |||
300 | RestClient rc = new RestClient(regionStatusUrl); | ||
301 | rc.RequestMethod = "GET"; | ||
302 | |||
303 | m_log.DebugFormat("[LOGIN]: Contacting {0} for status of region {1}", regionStatusUrl, sim.regionName); | ||
304 | |||
305 | try | ||
306 | { | ||
307 | Stream rs = rc.Request(); | ||
308 | StreamReader sr = new StreamReader(rs); | ||
309 | regionStatusResponse = sr.ReadToEnd(); | ||
310 | sr.Close(); | ||
285 | } | 311 | } |
286 | 312 | catch (Exception e) | |
313 | { | ||
314 | throw new LoginException( | ||
315 | String.Format("Region status request to {0} failed", regionStatusUrl), | ||
316 | String.Format( | ||
317 | "The grid service could not contact the http url {0} at your region. Please make sure this url is reachable by the grid service", | ||
318 | regionStatusUrl), | ||
319 | e); | ||
320 | } | ||
321 | |||
322 | if (!regionStatusResponse.Equals("OK")) | ||
323 | { | ||
324 | throw new LoginException( | ||
325 | String.Format( | ||
326 | "Region {0} at {1} returned status response {2} rather than {3}", | ||
327 | sim.regionName, regionStatusUrl, regionStatusResponse, "OK"), | ||
328 | String.Format( | ||
329 | "When the grid service asked for the status of your region, it received the response {0} rather than {1}. Please check your status", | ||
330 | regionStatusResponse, "OK")); | ||
331 | } | ||
287 | } | 332 | } |
288 | 333 | ||
289 | /// <summary> | 334 | /// <summary> |
@@ -332,7 +377,6 @@ namespace OpenSim.Grid.GridServer | |||
332 | m_log.InfoFormat("[LOGIN BEGIN]: Received login request from simulator: {0}", sim.regionName); | 377 | m_log.InfoFormat("[LOGIN BEGIN]: Received login request from simulator: {0}", sim.regionName); |
333 | 378 | ||
334 | existingSim = GetRegion(sim.regionHandle); | 379 | existingSim = GetRegion(sim.regionHandle); |
335 | |||
336 | 380 | ||
337 | if (existingSim == null || existingSim.UUID == sim.UUID || sim.UUID != sim.originUUID) | 381 | if (existingSim == null || existingSim.UUID == sim.UUID || sim.UUID != sim.originUUID) |
338 | { | 382 | { |
@@ -340,12 +384,14 @@ namespace OpenSim.Grid.GridServer | |||
340 | { | 384 | { |
341 | if (existingSim == null) | 385 | if (existingSim == null) |
342 | { | 386 | { |
343 | ValidateNewRegion(sim); | 387 | ValidateNewRegionKeys(sim); |
344 | } | 388 | } |
345 | else | 389 | else |
346 | { | 390 | { |
347 | ValidateOverwrite(sim, existingSim); | 391 | ValidateOverwriteKeys(sim, existingSim); |
348 | } | 392 | } |
393 | |||
394 | ValidateRegionContactable(sim); | ||
349 | } | 395 | } |
350 | catch (LoginException e) | 396 | catch (LoginException e) |
351 | { | 397 | { |
diff --git a/OpenSim/Grid/GridServer/GridServerBase.cs b/OpenSim/Grid/GridServer/GridServerBase.cs index 8adab1a..aeaead5 100644 --- a/OpenSim/Grid/GridServer/GridServerBase.cs +++ b/OpenSim/Grid/GridServer/GridServerBase.cs | |||
@@ -91,11 +91,11 @@ namespace OpenSim.Grid.GridServer | |||
91 | 91 | ||
92 | m_httpServer.Start(); | 92 | m_httpServer.Start(); |
93 | 93 | ||
94 | m_log.Info("[GRID]: Starting sim status checker"); | 94 | // m_log.Info("[GRID]: Starting sim status checker"); |
95 | 95 | // | |
96 | Timer simCheckTimer = new Timer(3600000 * 3); // 3 Hours between updates. | 96 | // Timer simCheckTimer = new Timer(3600000 * 3); // 3 Hours between updates. |
97 | simCheckTimer.Elapsed += new ElapsedEventHandler(CheckSims); | 97 | // simCheckTimer.Elapsed += new ElapsedEventHandler(CheckSims); |
98 | simCheckTimer.Enabled = true; | 98 | // simCheckTimer.Enabled = true; |
99 | } | 99 | } |
100 | 100 | ||
101 | protected void AddHttpHandlers() | 101 | protected void AddHttpHandlers() |
diff --git a/prebuild.xml b/prebuild.xml index a2390fb..544f626 100644 --- a/prebuild.xml +++ b/prebuild.xml | |||
@@ -1273,6 +1273,7 @@ | |||
1273 | <Reference name="System.Xml" localCopy="false"/> | 1273 | <Reference name="System.Xml" localCopy="false"/> |
1274 | <Reference name="Mono.Addins.dll" /> | 1274 | <Reference name="Mono.Addins.dll" /> |
1275 | <Reference name="OpenSim.Framework"/> | 1275 | <Reference name="OpenSim.Framework"/> |
1276 | <Reference name="OpenSim.Framework.Communications"/> | ||
1276 | <Reference name="OpenSim.Framework.Console"/> | 1277 | <Reference name="OpenSim.Framework.Console"/> |
1277 | <Reference name="OpenSim.Framework.Servers"/> | 1278 | <Reference name="OpenSim.Framework.Servers"/> |
1278 | <Reference name="OpenSim.Data"/> | 1279 | <Reference name="OpenSim.Data"/> |