From 931754a1ab86867fb3fd388cb403938351a8da99 Mon Sep 17 00:00:00 2001 From: MW Date: Mon, 23 Feb 2009 20:01:03 +0000 Subject: Renamed IGridMessagingModule to IGridMessagingMapper. Plus some general cleanup of the GridMessagingModule. --- OpenSim/Grid/GridServer/GridMessagingModule.cs | 43 ++++++++++++++++++------- OpenSim/Grid/GridServer/GridXmlRpcModule.cs | 8 ++--- OpenSim/Grid/GridServer/IGridMessagingMapper.cs | 40 +++++++++++++++++++++++ OpenSim/Grid/GridServer/IGridMessagingModule.cs | 38 ---------------------- 4 files changed, 75 insertions(+), 54 deletions(-) create mode 100644 OpenSim/Grid/GridServer/IGridMessagingMapper.cs delete mode 100644 OpenSim/Grid/GridServer/IGridMessagingModule.cs (limited to 'OpenSim/Grid') diff --git a/OpenSim/Grid/GridServer/GridMessagingModule.cs b/OpenSim/Grid/GridServer/GridMessagingModule.cs index 16623e7..14ce727 100644 --- a/OpenSim/Grid/GridServer/GridMessagingModule.cs +++ b/OpenSim/Grid/GridServer/GridMessagingModule.cs @@ -37,7 +37,7 @@ using OpenSim.Framework; namespace OpenSim.Grid.GridServer { - public class GridMessagingModule : IGridMessagingModule + public class GridMessagingModule : IGridMessagingMapper { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -54,12 +54,7 @@ namespace OpenSim.Grid.GridServer protected BaseHttpServer m_httpServer; // This is here so that the grid server can hand out MessageServer settings to regions on registration - private List _MessageServers = new List(); - - public List MessageServers - { - get { return _MessageServers; } - } + private List m_messageServers = new List(); public GridMessagingModule() { @@ -72,7 +67,7 @@ namespace OpenSim.Grid.GridServer m_gridCore = gridCore; m_config = config; - m_gridCore.RegisterInterface(this); + m_gridCore.RegisterInterface(this); RegisterHandlers(); } @@ -92,6 +87,14 @@ namespace OpenSim.Grid.GridServer m_httpServer.AddXmlRPCHandler("deregister_messageserver", XmlRPCDeRegisterMessageServer); } + public List GetMessageServersList() + { + lock (m_messageServers) + { + return new List(m_messageServers); + } + } + public XmlRpcResponse XmlRPCRegisterMessageServer(XmlRpcRequest request) { XmlRpcResponse response = new XmlRpcResponse(); @@ -107,8 +110,7 @@ namespace OpenSim.Grid.GridServer m.URI = URI; m.sendkey = sendkey; m.recvkey = recvkey; - if (!_MessageServers.Contains(m)) - _MessageServers.Add(m); + RegisterMessageServer(m); responseData["responsestring"] = "TRUE"; response.Value = responseData; } @@ -130,12 +132,29 @@ namespace OpenSim.Grid.GridServer m.URI = URI; m.sendkey = sendkey; m.recvkey = recvkey; - if (_MessageServers.Contains(m)) - _MessageServers.Remove(m); + DeRegisterMessageServer(m); responseData["responsestring"] = "TRUE"; response.Value = responseData; } 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); + } + } } } diff --git a/OpenSim/Grid/GridServer/GridXmlRpcModule.cs b/OpenSim/Grid/GridServer/GridXmlRpcModule.cs index 874b57f..e0e16b5 100644 --- a/OpenSim/Grid/GridServer/GridXmlRpcModule.cs +++ b/OpenSim/Grid/GridServer/GridXmlRpcModule.cs @@ -50,7 +50,7 @@ namespace OpenSim.Grid.GridServer protected GridConfig m_config; - protected IGridMessagingModule m_messagingServerMapper; + protected IGridMessagingMapper m_messagingServerMapper; /// /// Used to notify old regions as to which OpenSim version to upgrade to /// @@ -79,8 +79,8 @@ namespace OpenSim.Grid.GridServer public void PostInitialise() { - IGridMessagingModule messagingModule; - if (m_gridCore.TryGet(out messagingModule)) + IGridMessagingMapper messagingModule; + if (m_gridCore.TryGet(out messagingModule)) { m_messagingServerMapper = messagingModule; } @@ -401,7 +401,7 @@ namespace OpenSim.Grid.GridServer //{ if(m_messagingServerMapper != null) { - List messageServers = m_messagingServerMapper.MessageServers; + List messageServers = m_messagingServerMapper.GetMessageServersList(); responseData["messageserver_count"] = messageServers.Count; for (int i = 0; i < messageServers.Count; i++) diff --git a/OpenSim/Grid/GridServer/IGridMessagingMapper.cs b/OpenSim/Grid/GridServer/IGridMessagingMapper.cs new file mode 100644 index 0000000..0183ad5 --- /dev/null +++ b/OpenSim/Grid/GridServer/IGridMessagingMapper.cs @@ -0,0 +1,40 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * 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 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using OpenSim.Framework.Servers; + +namespace OpenSim.Grid.GridServer +{ + public interface IGridMessagingMapper + { + List GetMessageServersList(); + void RegisterMessageServer(MessageServerInfo m); + void DeRegisterMessageServer(MessageServerInfo m); + } +} diff --git a/OpenSim/Grid/GridServer/IGridMessagingModule.cs b/OpenSim/Grid/GridServer/IGridMessagingModule.cs deleted file mode 100644 index 7e37f586..0000000 --- a/OpenSim/Grid/GridServer/IGridMessagingModule.cs +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * 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 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections.Generic; -using OpenSim.Framework.Servers; - -namespace OpenSim.Grid.GridServer -{ - public interface IGridMessagingModule - { - List MessageServers { get; } - } -} -- cgit v1.1