Renamed IGridMessagingModule to IGridMessagingMapper.

Plus some general cleanup of the GridMessagingModule.
GenericGridServerConcept
MW 2009-02-23 20:01:03 +00:00
parent 03ff84426f
commit 931754a1ab
3 changed files with 75 additions and 54 deletions

View File

@ -37,7 +37,7 @@ using OpenSim.Framework;
namespace OpenSim.Grid.GridServer namespace OpenSim.Grid.GridServer
{ {
public class GridMessagingModule : IGridMessagingModule public class GridMessagingModule : IGridMessagingMapper
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@ -54,12 +54,7 @@ namespace OpenSim.Grid.GridServer
protected BaseHttpServer m_httpServer; protected BaseHttpServer m_httpServer;
// This is here so that the grid server can hand out MessageServer settings to regions on registration // This is here so that the grid server can hand out MessageServer settings to regions on registration
private List<MessageServerInfo> _MessageServers = new List<MessageServerInfo>(); private List<MessageServerInfo> m_messageServers = new List<MessageServerInfo>();
public List<MessageServerInfo> MessageServers
{
get { return _MessageServers; }
}
public GridMessagingModule() public GridMessagingModule()
{ {
@ -72,7 +67,7 @@ namespace OpenSim.Grid.GridServer
m_gridCore = gridCore; m_gridCore = gridCore;
m_config = config; m_config = config;
m_gridCore.RegisterInterface<IGridMessagingModule>(this); m_gridCore.RegisterInterface<IGridMessagingMapper>(this);
RegisterHandlers(); RegisterHandlers();
} }
@ -92,6 +87,14 @@ namespace OpenSim.Grid.GridServer
m_httpServer.AddXmlRPCHandler("deregister_messageserver", XmlRPCDeRegisterMessageServer); m_httpServer.AddXmlRPCHandler("deregister_messageserver", XmlRPCDeRegisterMessageServer);
} }
public List<MessageServerInfo> GetMessageServersList()
{
lock (m_messageServers)
{
return new List<MessageServerInfo>(m_messageServers);
}
}
public XmlRpcResponse XmlRPCRegisterMessageServer(XmlRpcRequest request) public XmlRpcResponse XmlRPCRegisterMessageServer(XmlRpcRequest request)
{ {
XmlRpcResponse response = new XmlRpcResponse(); XmlRpcResponse response = new XmlRpcResponse();
@ -107,8 +110,7 @@ namespace OpenSim.Grid.GridServer
m.URI = URI; m.URI = URI;
m.sendkey = sendkey; m.sendkey = sendkey;
m.recvkey = recvkey; m.recvkey = recvkey;
if (!_MessageServers.Contains(m)) RegisterMessageServer(m);
_MessageServers.Add(m);
responseData["responsestring"] = "TRUE"; responseData["responsestring"] = "TRUE";
response.Value = responseData; response.Value = responseData;
} }
@ -130,12 +132,29 @@ namespace OpenSim.Grid.GridServer
m.URI = URI; m.URI = URI;
m.sendkey = sendkey; m.sendkey = sendkey;
m.recvkey = recvkey; m.recvkey = recvkey;
if (_MessageServers.Contains(m)) DeRegisterMessageServer(m);
_MessageServers.Remove(m);
responseData["responsestring"] = "TRUE"; responseData["responsestring"] = "TRUE";
response.Value = responseData; response.Value = responseData;
} }
return response; return response;
} }
public void RegisterMessageServer(MessageServerInfo m)
{
lock (m_messageServers)
{
if (!m_messageServers.Contains(m))
m_messageServers.Add(m);
}
}
public void DeRegisterMessageServer(MessageServerInfo m)
{
lock (m_messageServers)
{
if (m_messageServers.Contains(m))
m_messageServers.Remove(m);
}
}
} }
} }

View File

@ -50,7 +50,7 @@ namespace OpenSim.Grid.GridServer
protected GridConfig m_config; protected GridConfig m_config;
protected IGridMessagingModule m_messagingServerMapper; protected IGridMessagingMapper m_messagingServerMapper;
/// <value> /// <value>
/// Used to notify old regions as to which OpenSim version to upgrade to /// Used to notify old regions as to which OpenSim version to upgrade to
/// </value> /// </value>
@ -79,8 +79,8 @@ namespace OpenSim.Grid.GridServer
public void PostInitialise() public void PostInitialise()
{ {
IGridMessagingModule messagingModule; IGridMessagingMapper messagingModule;
if (m_gridCore.TryGet<IGridMessagingModule>(out messagingModule)) if (m_gridCore.TryGet<IGridMessagingMapper>(out messagingModule))
{ {
m_messagingServerMapper = messagingModule; m_messagingServerMapper = messagingModule;
} }
@ -401,7 +401,7 @@ namespace OpenSim.Grid.GridServer
//{ //{
if(m_messagingServerMapper != null) if(m_messagingServerMapper != null)
{ {
List<MessageServerInfo> messageServers = m_messagingServerMapper.MessageServers; List<MessageServerInfo> messageServers = m_messagingServerMapper.GetMessageServersList();
responseData["messageserver_count"] = messageServers.Count; responseData["messageserver_count"] = messageServers.Count;
for (int i = 0; i < messageServers.Count; i++) for (int i = 0; i < messageServers.Count; i++)

View File

@ -1,38 +1,40 @@
/* /*
* Copyright (c) Contributors, http://opensimulator.org/ * Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders. * See CONTRIBUTORS.TXT for a full list of copyright holders.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright * * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright * * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the * * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products * names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission. * derived from this software without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using OpenSim.Framework.Servers; using OpenSim.Framework.Servers;
namespace OpenSim.Grid.GridServer namespace OpenSim.Grid.GridServer
{ {
public interface IGridMessagingModule public interface IGridMessagingMapper
{ {
List<MessageServerInfo> MessageServers { get; } List<MessageServerInfo> GetMessageServersList();
} void RegisterMessageServer(MessageServerInfo m);
} void DeRegisterMessageServer(MessageServerInfo m);
}
}