More Grid server refactoring

GenericGridServerConcept
MW 2009-02-21 18:41:28 +00:00
parent cdbd52e55b
commit e77b5d990d
6 changed files with 61 additions and 23 deletions

View File

@ -197,7 +197,7 @@ namespace OpenSim.Grid.GridServer
return regions; return regions;
} }
public DataResponse LoginRegion(RegionProfileData sim, RegionProfileData existingSim) public DataResponse AddUpdateRegion(RegionProfileData sim, RegionProfileData existingSim)
{ {
DataResponse insertResponse = DataResponse.RESPONSE_ERROR; DataResponse insertResponse = DataResponse.RESPONSE_ERROR;
foreach (IGridDataPlugin plugin in _plugins) foreach (IGridDataPlugin plugin in _plugins)

View File

@ -42,7 +42,7 @@ namespace OpenSim.Grid.GridServer
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
protected GridDBService m_gridDBService; protected GridDBService m_gridDBService;
protected IGridCore m_gridCore; protected IUGAIMCore m_gridCore;
protected GridConfig m_config; protected GridConfig m_config;
@ -65,19 +65,29 @@ namespace OpenSim.Grid.GridServer
{ {
} }
public void Initialise(string opensimVersion, GridDBService gridDBService, IGridCore gridCore, GridConfig config) public void Initialise(string opensimVersion, GridDBService gridDBService, IUGAIMCore gridCore, GridConfig config)
{ {
m_opensimVersion = opensimVersion; m_opensimVersion = opensimVersion;
m_gridDBService = gridDBService; m_gridDBService = gridDBService;
m_gridCore = gridCore; m_gridCore = gridCore;
m_config = config; m_config = config;
RegisterHandlers();
}
public void PostInitialise()
{
}
public void RegisterHandlers()
{
//have these in separate method as some servers restart the http server and reregister all the handlers.
m_httpServer = m_gridCore.GetHttpServer(); m_httpServer = m_gridCore.GetHttpServer();
m_gridCore.RegisterInterface<IGridMessagingModule>(this); m_gridCore.RegisterInterface<IGridMessagingModule>(this);
// Message Server ---> Grid Server // Message Server ---> Grid Server
m_httpServer.AddXmlRPCHandler("register_messageserver", XmlRPCRegisterMessageServer); m_httpServer.AddXmlRPCHandler("register_messageserver", XmlRPCRegisterMessageServer);
m_httpServer.AddXmlRPCHandler("deregister_messageserver", XmlRPCDeRegisterMessageServer); m_httpServer.AddXmlRPCHandler("deregister_messageserver", XmlRPCDeRegisterMessageServer);
} }
public XmlRpcResponse XmlRPCRegisterMessageServer(XmlRpcRequest request) public XmlRpcResponse XmlRPCRegisterMessageServer(XmlRpcRequest request)

View File

@ -45,7 +45,7 @@ namespace OpenSim.Grid.GridServer
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private GridDBService m_gridDBService; private GridDBService m_gridDBService;
private IGridCore m_gridCore; private IUGAIMCore m_gridCore;
protected GridConfig m_config; protected GridConfig m_config;
@ -66,12 +66,23 @@ namespace OpenSim.Grid.GridServer
{ {
} }
public void Initialise(string opensimVersion, GridDBService gridDBService, IGridCore gridCore, GridConfig config) public void Initialise(string opensimVersion, GridDBService gridDBService, IUGAIMCore gridCore, GridConfig config)
{ {
m_opensimVersion = opensimVersion; m_opensimVersion = opensimVersion;
m_gridDBService = gridDBService; m_gridDBService = gridDBService;
m_gridCore = gridCore; m_gridCore = gridCore;
m_config = config; m_config = config;
RegisterHandlers();
}
public void PostInitialise()
{
}
public void RegisterHandlers()
{
//have these in separate method as some servers restart the http server and reregister all the handlers.
m_httpServer = m_gridCore.GetHttpServer(); m_httpServer = m_gridCore.GetHttpServer();
m_httpServer.AddStreamHandler(new RestStreamHandler("GET", "/sims/", RestGetSimMethod)); m_httpServer.AddStreamHandler(new RestStreamHandler("GET", "/sims/", RestGetSimMethod));

View File

@ -39,7 +39,7 @@ namespace OpenSim.Grid.GridServer
{ {
/// <summary> /// <summary>
/// </summary> /// </summary>
public class GridServerBase : BaseOpenSimServer, IGridCore public class GridServerBase : BaseOpenSimServer, IUGAIMCore
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@ -163,6 +163,10 @@ namespace OpenSim.Grid.GridServer
m_gridRestModule = new GridRestModule(); m_gridRestModule = new GridRestModule();
m_gridRestModule.Initialise(m_version, m_gridDBService, this, m_config); m_gridRestModule.Initialise(m_version, m_gridDBService, this, m_config);
m_gridMessageModule.PostInitialise();
m_gridXmlRpcModule.PostInitialise();
m_gridRestModule.PostInitialise();
} }
public void CheckSims(object sender, ElapsedEventArgs e) public void CheckSims(object sender, ElapsedEventArgs e)
@ -207,8 +211,8 @@ namespace OpenSim.Grid.GridServer
foreach (IGridPlugin plugin in m_plugins) plugin.Dispose(); foreach (IGridPlugin plugin in m_plugins) plugin.Dispose();
} }
#region IGridCore #region IUGAIMCore
private readonly Dictionary<Type, object> m_gridInterfaces = new Dictionary<Type, object>(); private readonly Dictionary<Type, object> m_moduleInterfaces = new Dictionary<Type, object>();
/// <summary> /// <summary>
/// Register an Module interface. /// Register an Module interface.
@ -217,20 +221,20 @@ namespace OpenSim.Grid.GridServer
/// <param name="iface"></param> /// <param name="iface"></param>
public void RegisterInterface<T>(T iface) public void RegisterInterface<T>(T iface)
{ {
lock (m_gridInterfaces) lock (m_moduleInterfaces)
{ {
if (!m_gridInterfaces.ContainsKey(typeof(T))) if (!m_moduleInterfaces.ContainsKey(typeof(T)))
{ {
m_gridInterfaces.Add(typeof(T), iface); m_moduleInterfaces.Add(typeof(T), iface);
} }
} }
} }
public bool TryGet<T>(out T iface) public bool TryGet<T>(out T iface)
{ {
if (m_gridInterfaces.ContainsKey(typeof(T))) if (m_moduleInterfaces.ContainsKey(typeof(T)))
{ {
iface = (T)m_gridInterfaces[typeof(T)]; iface = (T)m_moduleInterfaces[typeof(T)];
return true; return true;
} }
iface = default(T); iface = default(T);
@ -239,7 +243,7 @@ namespace OpenSim.Grid.GridServer
public T Get<T>() public T Get<T>()
{ {
return (T)m_gridInterfaces[typeof(T)]; return (T)m_moduleInterfaces[typeof(T)];
} }
public BaseHttpServer GetHttpServer() public BaseHttpServer GetHttpServer()

View File

@ -46,7 +46,7 @@ namespace OpenSim.Grid.GridServer
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private GridDBService m_gridDBService; private GridDBService m_gridDBService;
private IGridCore m_gridCore; private IUGAIMCore m_gridCore;
protected GridConfig m_config; protected GridConfig m_config;
@ -67,12 +67,23 @@ namespace OpenSim.Grid.GridServer
{ {
} }
public void Initialise(string opensimVersion, GridDBService gridDBService, IGridCore gridCore, GridConfig config) public void Initialise(string opensimVersion, GridDBService gridDBService, IUGAIMCore gridCore, GridConfig config)
{ {
m_opensimVersion = opensimVersion; m_opensimVersion = opensimVersion;
m_gridDBService = gridDBService; m_gridDBService = gridDBService;
m_gridCore = gridCore; m_gridCore = gridCore;
m_config = config; m_config = config;
RegisterHandlers();
}
public void PostInitialise()
{
}
public void RegisterHandlers()
{
//have these in separate method as some servers restart the http server and reregister all the handlers.
m_httpServer = m_gridCore.GetHttpServer(); m_httpServer = m_gridCore.GetHttpServer();
m_httpServer.AddXmlRPCHandler("simulator_login", XmlRpcSimulatorLoginMethod); m_httpServer.AddXmlRPCHandler("simulator_login", XmlRpcSimulatorLoginMethod);
@ -305,7 +316,7 @@ namespace OpenSim.Grid.GridServer
return e.XmlRpcErrorResponse; return e.XmlRpcErrorResponse;
} }
DataResponse insertResponse = m_gridDBService.LoginRegion(sim, existingSim); DataResponse insertResponse = m_gridDBService.AddUpdateRegion(sim, existingSim);
switch (insertResponse) switch (insertResponse)
{ {
@ -557,7 +568,7 @@ namespace OpenSim.Grid.GridServer
//TheSim = GetRegion(new UUID((string) requestData["UUID"])); //TheSim = GetRegion(new UUID((string) requestData["UUID"]));
uuid = requestData["UUID"].ToString(); uuid = requestData["UUID"].ToString();
m_log.InfoFormat("[LOGOUT]: Logging out region: {0}", uuid); m_log.InfoFormat("[LOGOUT]: Logging out region: {0}", uuid);
// logToDB((new LLUUID((string)requestData["UUID"])).ToString(),"XmlRpcDeleteRegionMethod","", 5,"Attempting delete with UUID."); // logToDB((new LLUUID((string)requestData["UUID"])).ToString(),"XmlRpcDeleteRegionMethod","", 5,"Attempting delete with UUID.");
} }
else else
{ {
@ -849,13 +860,15 @@ namespace OpenSim.Grid.GridServer
} }
private XmlRpcResponse m_xmlRpcErrorResponse; private XmlRpcResponse m_xmlRpcErrorResponse;
public LoginException(string message, string xmlRpcMessage) : base(message) public LoginException(string message, string xmlRpcMessage)
: base(message)
{ {
// FIXME: Might be neater to refactor and put the method inside here // FIXME: Might be neater to refactor and put the method inside here
m_xmlRpcErrorResponse = GridXmlRpcModule.ErrorResponse(xmlRpcMessage); m_xmlRpcErrorResponse = GridXmlRpcModule.ErrorResponse(xmlRpcMessage);
} }
public LoginException(string message, string xmlRpcMessage, Exception e) : base(message, e) public LoginException(string message, string xmlRpcMessage, Exception e)
: base(message, e)
{ {
// FIXME: Might be neater to refactor and put the method inside here // FIXME: Might be neater to refactor and put the method inside here
m_xmlRpcErrorResponse = GridXmlRpcModule.ErrorResponse(xmlRpcMessage); m_xmlRpcErrorResponse = GridXmlRpcModule.ErrorResponse(xmlRpcMessage);

View File

@ -3,7 +3,7 @@ using OpenSim.Framework.Servers;
namespace OpenSim.Grid.GridServer namespace OpenSim.Grid.GridServer
{ {
public interface IGridCore public interface IUGAIMCore
{ {
T Get<T>(); T Get<T>();
void RegisterInterface<T>(T iface); void RegisterInterface<T>(T iface);