* As part of the region registration process, the grid service now requests the status of the region using the region http uri just passed in

* If the status cannot be retrieved, then the region startup will terminate.
* The aim of this is for earlier detection of situations where the region can send messages out but cannot accept incoming requests (often due to firewall issues)
* This is currently an extremely simplistic check which completely trusts whatever http uri is given by the region
* This contact may be problematic, though since the user service needs to be able to contact the region http uri, it doesn't seem unreasonable for the grid to have to be able to do so too at this stage
* This change will require a prebuild
0.6.0-stable
Justin Clarke Casey 2008-05-13 13:36:21 +00:00
parent bfce23dcf4
commit 550018f02d
5 changed files with 71 additions and 21 deletions

View File

@ -15,17 +15,17 @@ namespace OpenSim.Framework.Communications
/// </summary>
/// <remarks>
/// This class is a generic implementation of a REST (Representational State Transfer) web service. This
/// class is designed to execute both synchroneously and asynchroneously.
/// class is designed to execute both synchronously and asynchronously.
///
/// Internally the implementation works as a two stage asynchroneous web-client.
/// When the request is initiated, RestClient will query asynchroneously for for a web-response,
/// Internally the implementation works as a two stage asynchronous web-client.
/// When the request is initiated, RestClient will query asynchronously for for a web-response,
/// sleeping until the initial response is returned by the server. Once the initial response is retrieved
/// the second stage of asynchroneous requests will be triggered, in an attempt to read of the response
/// object into a memorystream as a sequence of asynchroneous reads.
/// the second stage of asynchronous requests will be triggered, in an attempt to read of the response
/// object into a memorystream as a sequence of asynchronous reads.
///
/// The asynchronisity of RestClient is designed to move as much processing into the back-ground, allowing
/// other threads to execute, while it waits for a response from the web-service. RestClient it self, can be
/// invoked by the caller in either synchroneous mode or asynchroneous mode.
/// other threads to execute, while it waits for a response from the web-service. RestClient itself can be
/// invoked by the caller in either synchronous mode or asynchronous modes.
/// </remarks>
public class RestClient
{
@ -245,7 +245,7 @@ namespace OpenSim.Framework.Communications
#endregion Async communications with server
/// <summary>
/// Perform synchroneous request
/// Perform a synchronous request
/// </summary>
public Stream Request()
{
@ -365,4 +365,4 @@ namespace OpenSim.Framework.Communications
#endregion Async Invocation
}
}
}

View File

@ -144,6 +144,8 @@ namespace OpenSim.Framework.Servers
string path = request.RawUrl;
string handlerKey = GetHandlerKey(request.HttpMethod, path);
//m_log.DebugFormat("[BASE HTTP SERVER]: Handling {0} request for {1}", request.HttpMethod, path);
IRequestHandler requestHandler;
@ -154,6 +156,7 @@ namespace OpenSim.Framework.Servers
if (requestHandler is IStreamedRequestHandler)
{
IStreamedRequestHandler streamedRequestHandler = requestHandler as IStreamedRequestHandler;
buffer = streamedRequestHandler.Handle(path, request.InputStream);
}
else
@ -179,7 +182,7 @@ namespace OpenSim.Framework.Servers
}
catch (HttpListenerException)
{
m_log.InfoFormat("[BASE HTTP SERVER] Http request abnormally terminated.");
m_log.WarnFormat("[BASE HTTP SERVER]: HTTP request abnormally terminated.");
}
}
else

View File

@ -28,6 +28,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Xml;
using libsecondlife;
@ -36,6 +37,7 @@ using Nwc.XmlRpc;
using OpenSim.Data;
using OpenSim.Data.MySQL;
using OpenSim.Framework;
using OpenSim.Framework.Communications;
using OpenSim.Framework.Servers;
namespace OpenSim.Grid.GridServer
@ -248,7 +250,7 @@ namespace OpenSim.Grid.GridServer
/// </summary>
/// <param name="sim"></param>
/// <returns></returns>
protected virtual void ValidateOverwrite(RegionProfileData sim, RegionProfileData existingSim)
protected virtual void ValidateOverwriteKeys(RegionProfileData sim, RegionProfileData existingSim)
{
if (!(existingSim.regionRecvKey == sim.regionRecvKey && existingSim.regionSendKey == sim.regionSendKey))
{
@ -271,7 +273,7 @@ namespace OpenSim.Grid.GridServer
///
/// <param name="sim"></param>
/// <exception cref="LoginException">Thrown if region login failed</exception>
protected virtual void ValidateNewRegion(RegionProfileData sim)
protected virtual void ValidateNewRegionKeys(RegionProfileData sim)
{
if (!(sim.regionRecvKey == Config.SimSendKey && sim.regionSendKey == Config.SimRecvKey))
{
@ -282,8 +284,51 @@ namespace OpenSim.Grid.GridServer
sim.regionName, sim.regionLocX, sim.regionLocY,
sim.regionSendKey, Config.SimRecvKey, sim.regionRecvKey, Config.SimSendKey),
"The keys required to login your region did not match your existing region keys. Please check your grid send and receive keys.");
}
}
/// <summary>
/// Check that a region's http uri is externally contactable.
/// </summary>
/// <param name="sim"></param>
/// <exception cref="LoginException">Thrown if the region is not contactable</exception>
protected virtual void ValidateRegionContactable(RegionProfileData sim)
{
string regionStatusUrl = String.Format("{0}{1}", sim.httpServerURI, "simstatus/");
string regionStatusResponse;
RestClient rc = new RestClient(regionStatusUrl);
rc.RequestMethod = "GET";
m_log.DebugFormat("[LOGIN]: Contacting {0} for status of region {1}", regionStatusUrl, sim.regionName);
try
{
Stream rs = rc.Request();
StreamReader sr = new StreamReader(rs);
regionStatusResponse = sr.ReadToEnd();
sr.Close();
}
catch (Exception e)
{
throw new LoginException(
String.Format("Region status request to {0} failed", regionStatusUrl),
String.Format(
"The grid service could not contact the http url {0} at your region. Please make sure this url is reachable by the grid service",
regionStatusUrl),
e);
}
if (!regionStatusResponse.Equals("OK"))
{
throw new LoginException(
String.Format(
"Region {0} at {1} returned status response {2} rather than {3}",
sim.regionName, regionStatusUrl, regionStatusResponse, "OK"),
String.Format(
"When the grid service asked for the status of your region, it received the response {0} rather than {1}. Please check your status",
regionStatusResponse, "OK"));
}
}
/// <summary>
@ -332,7 +377,6 @@ namespace OpenSim.Grid.GridServer
m_log.InfoFormat("[LOGIN BEGIN]: Received login request from simulator: {0}", sim.regionName);
existingSim = GetRegion(sim.regionHandle);
if (existingSim == null || existingSim.UUID == sim.UUID || sim.UUID != sim.originUUID)
{
@ -340,12 +384,14 @@ namespace OpenSim.Grid.GridServer
{
if (existingSim == null)
{
ValidateNewRegion(sim);
ValidateNewRegionKeys(sim);
}
else
{
ValidateOverwrite(sim, existingSim);
ValidateOverwriteKeys(sim, existingSim);
}
ValidateRegionContactable(sim);
}
catch (LoginException e)
{

View File

@ -91,11 +91,11 @@ namespace OpenSim.Grid.GridServer
m_httpServer.Start();
m_log.Info("[GRID]: Starting sim status checker");
Timer simCheckTimer = new Timer(3600000 * 3); // 3 Hours between updates.
simCheckTimer.Elapsed += new ElapsedEventHandler(CheckSims);
simCheckTimer.Enabled = true;
// m_log.Info("[GRID]: Starting sim status checker");
//
// Timer simCheckTimer = new Timer(3600000 * 3); // 3 Hours between updates.
// simCheckTimer.Elapsed += new ElapsedEventHandler(CheckSims);
// simCheckTimer.Enabled = true;
}
protected void AddHttpHandlers()

View File

@ -1273,6 +1273,7 @@
<Reference name="System.Xml" localCopy="false"/>
<Reference name="Mono.Addins.dll" />
<Reference name="OpenSim.Framework"/>
<Reference name="OpenSim.Framework.Communications"/>
<Reference name="OpenSim.Framework.Console"/>
<Reference name="OpenSim.Framework.Servers"/>
<Reference name="OpenSim.Data"/>