From 6461243e7c780d79244184a8d4b100303f4cda27 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 17 Sep 2009 23:55:06 +0100 Subject: Remove the methods for full inventory fetch from the connector. Remove tests for the old, removed asset handlers --- .../Inventory/InventoryServiceConnector.cs | 36 +--------------------- 1 file changed, 1 insertion(+), 35 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs b/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs index cef678d..5443891 100644 --- a/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs +++ b/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs @@ -236,42 +236,8 @@ namespace OpenSim.Services.Connectors } catch (Exception e) { - // Maybe we're talking to an old inventory server. Try this other thing. - m_log.ErrorFormat("[INVENTORY CONNECTOR]: GetFolderContent operation failed, {0} {1} (old server?). Trying GetInventory.", + m_log.ErrorFormat("[INVENTORY CONNECTOR]: GetFolderContent operation failed, {0} {1} (old server?).", e.Source, e.Message); - - InventoryCollection inventory; - List folders = null; - try - { - inventory = SynchronousRestSessionObjectPoster.BeginPostObject( - "POST", m_ServerURI + "/GetInventory/", new Guid(userID), sessionID.ToString(), userID.ToString()); - if (inventory != null) - folders = inventory.Folders; - } - catch (Exception ex) - { - m_log.ErrorFormat("[INVENTORY CONNECTOR]: GetInventory operation also failed, {0} {1}. Giving up.", - e.Source, ex.Message); - return new InventoryCollection(); - } - - if ((folders != null) && (folders.Count > 0)) - { - m_log.DebugFormat("[INVENTORY CONNECTOR]: Received entire inventory ({0} folders) for user {1}", - folders.Count, userID); - - folders = folders.FindAll(delegate(InventoryFolderBase f) { return f.ParentID == folderID; }); - List items = inventory.Items; - if (items != null) - { - items = items.FindAll(delegate(InventoryItemBase i) { return i.Folder == folderID; }); - } - - inventory.Items = items; - inventory.Folders = folders; - return inventory; - } } InventoryCollection nullCollection = new InventoryCollection(); -- cgit v1.1 From e7362738155c0a0a5c9ef8b867eb14b18bb31a44 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 18 Sep 2009 19:16:30 -0700 Subject: First pass at the grid service. --- OpenSim/Services/Grid/GridService.cs | 79 ------- OpenSim/Services/GridService/GridService.cs | 297 ++++++++++++++++++++++++ OpenSim/Services/GridService/GridServiceBase.cs | 84 +++++++ OpenSim/Services/Interfaces/IGridService.cs | 17 +- 4 files changed, 392 insertions(+), 85 deletions(-) delete mode 100644 OpenSim/Services/Grid/GridService.cs create mode 100644 OpenSim/Services/GridService/GridService.cs create mode 100644 OpenSim/Services/GridService/GridServiceBase.cs (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/Grid/GridService.cs b/OpenSim/Services/Grid/GridService.cs deleted file mode 100644 index 47710d8..0000000 --- a/OpenSim/Services/Grid/GridService.cs +++ /dev/null @@ -1,79 +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.Collections.Generic; -using OpenMetaverse; -using OpenSim.Services.Interfaces; - -namespace OpenSim.Services.Interfaces -{ - public class GridService : IGridService - { - bool RegisterRegion(UUID scopeID, RegionInfo regionInfos); - { - return false; - } - - bool DeregisterRegion(UUID regionID); - { - return false; - } - - List RequestNeighbours(UUID scopeID, uint x, uint y) - { - return new List() - } - - RegionInfo RequestNeighbourInfo(UUID regionID) - { - return null; - } - - RegionInfo RequestClosestRegion(UUID scopeID, string regionName) - { - return null; - } - - List RequestNeighbourMapBlocks(UUID scopeID, int minX, - int minY, int maxX, int maxY) - { - return new List(); - } - - LandData RequestLandData(UUID scopeID, ulong regionHandle, - uint x, uint y) - { - return null; - } - - List RequestNamedRegions(UUID scopeID, string name, - int maxNumber) - { - return new List(); - } - } -} diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs new file mode 100644 index 0000000..6aa1c4f --- /dev/null +++ b/OpenSim/Services/GridService/GridService.cs @@ -0,0 +1,297 @@ +/* + * 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 System.Net; +using System.Reflection; +using Nini.Config; +using log4net; +using OpenSim.Framework; +using OpenSim.Framework.Console; +using OpenSim.Data; +using OpenSim.Services.Interfaces; +using OpenMetaverse; + +namespace OpenSim.Services.GridService +{ + public class GridService : GridServiceBase, IGridService + { + private static readonly ILog m_log = + LogManager.GetLogger( + MethodBase.GetCurrentMethod().DeclaringType); + + public GridService(IConfigSource config) + : base(config) + { + MainConsole.Instance.Commands.AddCommand("kfs", false, + "show digest", + "show digest ", + "Show asset digest", HandleShowDigest); + + MainConsole.Instance.Commands.AddCommand("kfs", false, + "delete asset", + "delete asset ", + "Delete asset from database", HandleDeleteAsset); + + } + + #region IGridService + + public bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfos) + { + if (m_Database.Get(regionInfos.RegionID, scopeID) != null) + { + m_log.WarnFormat("[GRID SERVICE]: Region {0} already registered in scope {1}.", regionInfos.RegionID, scopeID); + return false; + } + if (m_Database.Get((int)regionInfos.RegionLocX, (int)regionInfos.RegionLocY, scopeID) != null) + { + m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register in coordinates {1}, {2} which are already in use in scope {3}.", + regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); + return false; + } + + // Everything is ok, let's register + RegionData rdata = RegionInfo2RegionData(regionInfos); + rdata.ScopeID = scopeID; + m_Database.Store(rdata); + return true; + } + + public bool DeregisterRegion(UUID regionID) + { + return m_Database.Delete(regionID); + } + + public List GetNeighbours(UUID scopeID, int x, int y) + { + List rdatas = m_Database.Get(x - 1, y - 1, x + 1, y + 1, scopeID); + List rinfos = new List(); + foreach (RegionData rdata in rdatas) + rinfos.Add(RegionData2RegionInfo(rdata)); + + return rinfos; + } + + public SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID) + { + RegionData rdata = m_Database.Get(regionID, scopeID); + if (rdata != null) + return RegionData2RegionInfo(rdata); + + return null; + } + + public SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y) + { + RegionData rdata = m_Database.Get(x, y, scopeID); + if (rdata != null) + return RegionData2RegionInfo(rdata); + + return null; + } + + public SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName) + { + List rdatas = m_Database.Get(regionName + "%", scopeID); + if ((rdatas != null) && (rdatas.Count > 0)) + return RegionData2RegionInfo(rdatas[0]); // get the first + + return null; + } + + public List GetRegionsByName(UUID scopeID, string name, int maxNumber) + { + List rdatas = m_Database.Get("%" + name + "%", scopeID); + + int count = 0; + List rinfos = new List(); + + if (rdatas != null) + { + foreach (RegionData rdata in rdatas) + { + if (count++ < maxNumber) + rinfos.Add(RegionData2RegionInfo(rdata)); + } + } + + return rinfos; + } + + public List GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) + { + List rdatas = m_Database.Get(xmin, ymin, xmax, ymax, scopeID); + List rinfos = new List(); + foreach (RegionData rdata in rdatas) + rinfos.Add(RegionData2RegionInfo(rdata)); + + return rinfos; + } + + #endregion + + #region Data structure conversions + + protected RegionData RegionInfo2RegionData(SimpleRegionInfo rinfo) + { + RegionData rdata = new RegionData(); + rdata.posX = (int)rinfo.RegionLocX; + rdata.posY = (int)rinfo.RegionLocY; + rdata.RegionID = rinfo.RegionID; + //rdata.RegionName = rinfo.RegionName; + rdata.Data["external_ip_address"] = rinfo.ExternalEndPoint.Address.ToString(); + rdata.Data["external_port"] = rinfo.ExternalEndPoint.Port.ToString(); + rdata.Data["external_host_name"] = rinfo.ExternalHostName; + rdata.Data["http_port"] = rinfo.HttpPort.ToString(); + rdata.Data["internal_ip_address"] = rinfo.InternalEndPoint.Address.ToString(); + rdata.Data["internal_port"] = rinfo.InternalEndPoint.Port.ToString(); + rdata.Data["alternate_ports"] = rinfo.m_allow_alternate_ports.ToString(); + rdata.Data["server_uri"] = rinfo.ServerURI; + + return rdata; + } + + protected SimpleRegionInfo RegionData2RegionInfo(RegionData rdata) + { + SimpleRegionInfo rinfo = new SimpleRegionInfo(); + rinfo.RegionLocX = (uint)rdata.posX; + rinfo.RegionLocY = (uint)rdata.posY; + rinfo.RegionID = rdata.RegionID; + //rinfo.RegionName = rdata.RegionName; + + // Now for the variable data + if ((rdata.Data["external_ip_address"] != null) && (rdata.Data["external_port"] != null)) + { + int port = 0; + Int32.TryParse((string)rdata.Data["external_port"], out port); + IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)rdata.Data["external_ip_address"]), port); + rinfo.ExternalEndPoint = ep; + } + else + rinfo.ExternalEndPoint = new IPEndPoint(new IPAddress(0), 0); + + if (rdata.Data["external_host_name"] != null) + rinfo.ExternalHostName = (string)rdata.Data["external_host_name"] ; + + if (rdata.Data["http_port"] != null) + { + UInt32 port = 0; + UInt32.TryParse((string)rdata.Data["http_port"], out port); + rinfo.HttpPort = port; + } + + if ((rdata.Data["internal_ip_address"] != null) && (rdata.Data["internal_port"] != null)) + { + int port = 0; + Int32.TryParse((string)rdata.Data["internal_port"], out port); + IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)rdata.Data["internal_ip_address"]), port); + rinfo.InternalEndPoint = ep; + } + else + rinfo.InternalEndPoint = new IPEndPoint(new IPAddress(0), 0); + + if (rdata.Data["alternate_ports"] != null) + { + bool alts = false; + Boolean.TryParse((string)rdata.Data["alternate_ports"], out alts); + rinfo.m_allow_alternate_ports = alts; + } + + if (rdata.Data["server_uri"] != null) + rinfo.ServerURI = (string)rdata.Data["server_uri"]; + + return rinfo; + } + + #endregion + + void HandleShowDigest(string module, string[] args) + { + //if (args.Length < 3) + //{ + // MainConsole.Instance.Output("Syntax: show digest "); + // return; + //} + + //AssetBase asset = Get(args[2]); + + //if (asset == null || asset.Data.Length == 0) + //{ + // MainConsole.Instance.Output("Asset not found"); + // return; + //} + + //int i; + + //MainConsole.Instance.Output(String.Format("Name: {0}", asset.Name)); + //MainConsole.Instance.Output(String.Format("Description: {0}", asset.Description)); + //MainConsole.Instance.Output(String.Format("Type: {0}", asset.Type)); + //MainConsole.Instance.Output(String.Format("Content-type: {0}", asset.Metadata.ContentType)); + + //for (i = 0 ; i < 5 ; i++) + //{ + // int off = i * 16; + // if (asset.Data.Length <= off) + // break; + // int len = 16; + // if (asset.Data.Length < off + len) + // len = asset.Data.Length - off; + + // byte[] line = new byte[len]; + // Array.Copy(asset.Data, off, line, 0, len); + + // string text = BitConverter.ToString(line); + // MainConsole.Instance.Output(String.Format("{0:x4}: {1}", off, text)); + //} + } + + void HandleDeleteAsset(string module, string[] args) + { + //if (args.Length < 3) + //{ + // MainConsole.Instance.Output("Syntax: delete asset "); + // return; + //} + + //AssetBase asset = Get(args[2]); + + //if (asset == null || asset.Data.Length == 0) + // MainConsole.Instance.Output("Asset not found"); + // return; + //} + + //Delete(args[2]); + + ////MainConsole.Instance.Output("Asset deleted"); + //// TODO: Implement this + + //MainConsole.Instance.Output("Asset deletion not supported by database"); + } + } +} diff --git a/OpenSim/Services/GridService/GridServiceBase.cs b/OpenSim/Services/GridService/GridServiceBase.cs new file mode 100644 index 0000000..7b69290 --- /dev/null +++ b/OpenSim/Services/GridService/GridServiceBase.cs @@ -0,0 +1,84 @@ +/* + * 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.Reflection; +using Nini.Config; +using OpenSim.Framework; +using OpenSim.Data; +using OpenSim.Services.Interfaces; +using OpenSim.Services.Base; + +namespace OpenSim.Services.GridService +{ + public class GridServiceBase : ServiceBase + { + protected IRegionData m_Database = null; + + public GridServiceBase(IConfigSource config) + : base(config) + { + string dllName = String.Empty; + string connString = String.Empty; + string realm = "regions"; + + // + // Try reading the [AssetService] section first, if it exists + // + IConfig gridConfig = config.Configs["GridService"]; + if (gridConfig != null) + { + dllName = gridConfig.GetString("StorageProvider", dllName); + connString = gridConfig.GetString("ConnectionString", connString); + realm = gridConfig.GetString("Realm", realm); + } + + // + // Try reading the [DatabaseService] section, if it exists + // + IConfig dbConfig = config.Configs["DatabaseService"]; + if (dbConfig != null) + { + if (dllName == String.Empty) + dllName = dbConfig.GetString("StorageProvider", String.Empty); + if (connString == String.Empty) + connString = dbConfig.GetString("ConnectionString", String.Empty); + } + + // + // We tried, but this doesn't exist. We can't proceed. + // + if (dllName.Equals(String.Empty)) + throw new Exception("No StorageProvider configured"); + + m_Database = LoadPlugin(dllName, new Object[] { connString, realm }); + if (m_Database == null) + throw new Exception("Could not find a storage interface in the given module"); + + } + } +} diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs index ac4539a..83ab9c1 100644 --- a/OpenSim/Services/Interfaces/IGridService.cs +++ b/OpenSim/Services/Interfaces/IGridService.cs @@ -39,7 +39,7 @@ namespace OpenSim.Services.Interfaces /// /// /// Thrown if region registration failed - bool RegisterRegion(UUID scopeID, RegionInfo regionInfos); + bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfos); /// /// Deregister a region with the grid service. @@ -50,15 +50,22 @@ namespace OpenSim.Services.Interfaces bool DeregisterRegion(UUID regionID); /// - /// Get information about the regions neighbouring the given co-ordinates. + /// Get information about the regions neighbouring the given co-ordinates (in meters). /// /// /// /// - List GetNeighbours(UUID scopeID, uint x, uint y); + List GetNeighbours(UUID scopeID, int x, int y); SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID); + /// + /// Get the region at the given position (in meters) + /// + /// + /// + /// + /// SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y); SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName); @@ -78,9 +85,7 @@ namespace OpenSim.Services.Interfaces /// List GetRegionsByName(UUID scopeID, string name, int maxNumber); - - // Not sure about these two (diva) - + List GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax); } } -- cgit v1.1 From 15d6bb4ce55092d2ee0a27bbb3ec5e7760a05dcc Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 18 Sep 2009 20:09:43 -0700 Subject: Reverted the order of reading configs in GridServiceBase. --- OpenSim/Services/GridService/GridServiceBase.cs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/GridService/GridServiceBase.cs b/OpenSim/Services/GridService/GridServiceBase.cs index 7b69290..7522e64 100644 --- a/OpenSim/Services/GridService/GridServiceBase.cs +++ b/OpenSim/Services/GridService/GridServiceBase.cs @@ -47,17 +47,6 @@ namespace OpenSim.Services.GridService string realm = "regions"; // - // Try reading the [AssetService] section first, if it exists - // - IConfig gridConfig = config.Configs["GridService"]; - if (gridConfig != null) - { - dllName = gridConfig.GetString("StorageProvider", dllName); - connString = gridConfig.GetString("ConnectionString", connString); - realm = gridConfig.GetString("Realm", realm); - } - - // // Try reading the [DatabaseService] section, if it exists // IConfig dbConfig = config.Configs["DatabaseService"]; @@ -70,6 +59,17 @@ namespace OpenSim.Services.GridService } // + // [GridService] section overrides [DatabaseService], if it exists + // + IConfig gridConfig = config.Configs["GridService"]; + if (gridConfig != null) + { + dllName = gridConfig.GetString("StorageProvider", dllName); + connString = gridConfig.GetString("ConnectionString", connString); + realm = gridConfig.GetString("Realm", realm); + } + + // // We tried, but this doesn't exist. We can't proceed. // if (dllName.Equals(String.Empty)) -- cgit v1.1 From 2d9d25b367cd6a33747d2b647abfe57ede97e805 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 19 Sep 2009 17:33:57 +0100 Subject: Add the skeleton of the authentication connector and the forms data requester --- .../AuthenticationServiceConnector.cs | 99 ++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs b/OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs new file mode 100644 index 0000000..053d27c --- /dev/null +++ b/OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs @@ -0,0 +1,99 @@ +/* + * 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 log4net; +using System; +using System.Collections.Generic; +using System.IO; +using System.Reflection; +using Nini.Config; +using OpenSim.Framework; +using OpenSim.Framework.Communications; +using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Services.Interfaces; +using OpenMetaverse; + +namespace OpenSim.Services.Connectors +{ + public class AuthenticationServicesConnector : IAuthenticationService + { + private static readonly ILog m_log = + LogManager.GetLogger( + MethodBase.GetCurrentMethod().DeclaringType); + + private string m_ServerURI = String.Empty; + + public AuthenticationServicesConnector() + { + } + + public AuthenticationServicesConnector(string serverURI) + { + m_ServerURI = serverURI.TrimEnd('/'); + } + + public AuthenticationServicesConnector(IConfigSource source) + { + Initialise(source); + } + + public virtual void Initialise(IConfigSource source) + { + IConfig assetConfig = source.Configs["AuthenticationService"]; + if (assetConfig == null) + { + m_log.Error("[USER CONNECTOR]: AuthenticationService missing from OpanSim.ini"); + throw new Exception("Authentication connector init error"); + } + + string serviceURI = assetConfig.GetString("AuthenticationServerURI", + String.Empty); + + if (serviceURI == String.Empty) + { + m_log.Error("[USER CONNECTOR]: No Server URI named in section AuthenticationService"); + throw new Exception("Authentication connector init error"); + } + m_ServerURI = serviceURI; + } + + public string Authenticate(UUID principalID, string password, int lifetime) + { + return String.Empty; + } + + public bool Verify(UUID principalID, string token, int lifetime) + { + return false; + } + + public bool Release(UUID principalID, string token) + { + return false; + } + } +} -- cgit v1.1 From 2f624800d37bae36cecf1bff191b646d59d86746 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 19 Sep 2009 18:06:25 +0100 Subject: Adding the deserializer for server form/xml replies --- .../Authentication/AuthenticationServiceConnector.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs b/OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs index 053d27c..35f96a1 100644 --- a/OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs +++ b/OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs @@ -35,6 +35,7 @@ using OpenSim.Framework; using OpenSim.Framework.Communications; using OpenSim.Framework.Servers.HttpServer; using OpenSim.Services.Interfaces; +using OpenSim.Server.Base; using OpenMetaverse; namespace OpenSim.Services.Connectors @@ -83,6 +84,17 @@ namespace OpenSim.Services.Connectors public string Authenticate(UUID principalID, string password, int lifetime) { + Dictionary sendData = new Dictionary(); + sendData["LIFETIME"] = lifetime.ToString(); + sendData["PRINCIPAL"] = principalID.ToString(); + sendData["PASSWORD"] = password; + + sendData["METHOD"] = "authenticate"; + + string reply = SynchronousRestFormsRequester.MakeRequest("POST", + m_ServerURI + "/auth/plain", + ServerUtils.BuildQueryString(sendData)); + return String.Empty; } -- cgit v1.1 From 0c364ee2853f5d33df67e4a340734dfe7c6c2398 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 19 Sep 2009 18:14:22 +0100 Subject: Complete the first authenticator method --- .../Connectors/Authentication/AuthenticationServiceConnector.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs b/OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs index 35f96a1..258b9b1 100644 --- a/OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs +++ b/OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs @@ -95,7 +95,13 @@ namespace OpenSim.Services.Connectors m_ServerURI + "/auth/plain", ServerUtils.BuildQueryString(sendData)); - return String.Empty; + Dictionary replyData = ServerUtils.ParseXmlResponse( + reply); + + if (replyData["Result"].ToString() != "Success") + return String.Empty; + + return replyData["Token"].ToString(); } public bool Verify(UUID principalID, string token, int lifetime) -- cgit v1.1 From f6410882a5bb3ac53e7a0434c3dcc4ecd1de8457 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 19 Sep 2009 18:18:47 +0100 Subject: Finish the (untested) authentication connector --- .../AuthenticationServiceConnector.cs | 37 ++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs b/OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs index 258b9b1..50e817e 100644 --- a/OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs +++ b/OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs @@ -106,12 +106,45 @@ namespace OpenSim.Services.Connectors public bool Verify(UUID principalID, string token, int lifetime) { - return false; + Dictionary sendData = new Dictionary(); + sendData["LIFETIME"] = lifetime.ToString(); + sendData["PRINCIPAL"] = principalID.ToString(); + sendData["TOKEN"] = token; + + sendData["METHOD"] = "verify"; + + string reply = SynchronousRestFormsRequester.MakeRequest("POST", + m_ServerURI + "/auth/plain", + ServerUtils.BuildQueryString(sendData)); + + Dictionary replyData = ServerUtils.ParseXmlResponse( + reply); + + if (replyData["Result"].ToString() != "Success") + return false; + + return true; } public bool Release(UUID principalID, string token) { - return false; + Dictionary sendData = new Dictionary(); + sendData["PRINCIPAL"] = principalID.ToString(); + sendData["TOKEN"] = token; + + sendData["METHOD"] = "release"; + + string reply = SynchronousRestFormsRequester.MakeRequest("POST", + m_ServerURI + "/auth/plain", + ServerUtils.BuildQueryString(sendData)); + + Dictionary replyData = ServerUtils.ParseXmlResponse( + reply); + + if (replyData["Result"].ToString() != "Success") + return false; + + return true; } } } -- cgit v1.1 From 390137d540b9ae39eba3ba9136bd49d5e992bc5f Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 21 Sep 2009 11:05:01 -0700 Subject: Added grid handler and grid remote connector. --- .../Connectors/Grid/GridServiceConnector.cs | 346 +++++++++++++++++++++ OpenSim/Services/GridService/GridService.cs | 65 +--- OpenSim/Services/Interfaces/IGridService.cs | 2 +- 3 files changed, 358 insertions(+), 55 deletions(-) create mode 100644 OpenSim/Services/Connectors/Grid/GridServiceConnector.cs (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs new file mode 100644 index 0000000..ae7db7e --- /dev/null +++ b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs @@ -0,0 +1,346 @@ +/* + * 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 log4net; +using System; +using System.Collections.Generic; +using System.IO; +using System.Reflection; +using Nini.Config; +using OpenSim.Framework; +using OpenSim.Framework.Communications; +using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Services.Interfaces; +using OpenSim.Server.Base; +using OpenMetaverse; + +namespace OpenSim.Services.Connectors +{ + public class GridServicesConnector : IGridService + { + private static readonly ILog m_log = + LogManager.GetLogger( + MethodBase.GetCurrentMethod().DeclaringType); + + private string m_ServerURI = String.Empty; + + public GridServicesConnector() + { + } + + public GridServicesConnector(string serverURI) + { + m_ServerURI = serverURI.TrimEnd('/'); + } + + public GridServicesConnector(IConfigSource source) + { + Initialise(source); + } + + public virtual void Initialise(IConfigSource source) + { + IConfig gridConfig = source.Configs["GridService"]; + if (gridConfig == null) + { + m_log.Error("[GRID CONNECTOR]: GridService missing from OpenSim.ini"); + throw new Exception("Grid connector init error"); + } + + string serviceURI = gridConfig.GetString("GridServerURI", + String.Empty); + + if (serviceURI == String.Empty) + { + m_log.Error("[GRID CONNECTOR]: No Server URI named in section GridService"); + throw new Exception("Grid connector init error"); + } + m_ServerURI = serviceURI; + } + + + #region IGridService + + public bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfo) + { + Dictionary rinfo = regionInfo.ToKeyValuePairs(); + Dictionary sendData = new Dictionary(); + foreach (KeyValuePair kvp in rinfo) + sendData[kvp.Key] = (string)kvp.Value; + + sendData["SCOPEID"] = scopeID.ToString(); + + sendData["METHOD"] = "register"; + + string reply = SynchronousRestFormsRequester.MakeRequest("POST", + m_ServerURI + "/grid", + ServerUtils.BuildQueryString(sendData)); + + Dictionary replyData = ServerUtils.ParseXmlResponse(reply); + + if ((replyData["Result"] != null) && (replyData["Result"].ToString().ToLower() == "success")) + return true; + + return false; + } + + public bool DeregisterRegion(UUID regionID) + { + Dictionary sendData = new Dictionary(); + + sendData["REGIONID"] = regionID.ToString(); + + sendData["METHOD"] = "deregister"; + + string reply = SynchronousRestFormsRequester.MakeRequest("POST", + m_ServerURI + "/grid", + ServerUtils.BuildQueryString(sendData)); + + Dictionary replyData = ServerUtils.ParseXmlResponse(reply); + + if ((replyData["Result"] != null) && (replyData["Result"].ToString().ToLower() == "success")) + return true; + + return false; + } + + public List GetNeighbours(UUID scopeID, UUID regionID) + { + Dictionary sendData = new Dictionary(); + + sendData["SCOPEID"] = scopeID.ToString(); + sendData["REGIONID"] = regionID.ToString(); + + sendData["METHOD"] = "get_neighbours"; + + string reply = SynchronousRestFormsRequester.MakeRequest("POST", + m_ServerURI + "/grid", + ServerUtils.BuildQueryString(sendData)); + + Dictionary replyData = ServerUtils.ParseXmlResponse(reply); + + List rinfos = new List(); + if (replyData != null) + { + Dictionary.ValueCollection rinfosList = replyData.Values; + foreach (object r in rinfosList) + { + if (r is Dictionary) + { + SimpleRegionInfo rinfo = new SimpleRegionInfo((Dictionary)r); + rinfos.Add(rinfo); + } + else + m_log.DebugFormat("[GRID CONNECTOR]: GetNeighbours {0}, {1} received invalid response", + scopeID, regionID); + } + } + else + m_log.DebugFormat("[GRID CONNECTOR]: GetNeighbours {0}, {1} received null response", + scopeID, regionID); + + return rinfos; + } + + public SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID) + { + Dictionary sendData = new Dictionary(); + + sendData["SCOPEID"] = scopeID.ToString(); + sendData["REGIONID"] = regionID.ToString(); + + sendData["METHOD"] = "get_region_by_uuid"; + + string reply = SynchronousRestFormsRequester.MakeRequest("POST", + m_ServerURI + "/grid", + ServerUtils.BuildQueryString(sendData)); + + Dictionary replyData = ServerUtils.ParseXmlResponse(reply); + + SimpleRegionInfo rinfo = null; + if ((replyData != null) && (replyData["result"] != null)) + { + if (replyData["result"] is Dictionary) + rinfo = new SimpleRegionInfo((Dictionary)replyData["result"]); + else + m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID {0}, {1} received invalid response", + scopeID, regionID); + } + else + m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID {0}, {1} received null response", + scopeID, regionID); + + return rinfo; + } + + public SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y) + { + Dictionary sendData = new Dictionary(); + + sendData["SCOPEID"] = scopeID.ToString(); + sendData["X"] = x.ToString(); + sendData["Y"] = y.ToString(); + + sendData["METHOD"] = "get_region_by_position"; + + string reply = SynchronousRestFormsRequester.MakeRequest("POST", + m_ServerURI + "/grid", + ServerUtils.BuildQueryString(sendData)); + + Dictionary replyData = ServerUtils.ParseXmlResponse(reply); + + SimpleRegionInfo rinfo = null; + if ((replyData != null) && (replyData["result"] != null)) + { + if (replyData["result"] is Dictionary) + rinfo = new SimpleRegionInfo((Dictionary)replyData["result"]); + else + m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received invalid response", + scopeID, x, y); + } + else + m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received null response", + scopeID, x, y); + + return rinfo; + } + + public SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName) + { + Dictionary sendData = new Dictionary(); + + sendData["SCOPEID"] = scopeID.ToString(); + sendData["NAME"] = regionName; + + sendData["METHOD"] = "get_region_by_name"; + + string reply = SynchronousRestFormsRequester.MakeRequest("POST", + m_ServerURI + "/grid", + ServerUtils.BuildQueryString(sendData)); + + Dictionary replyData = ServerUtils.ParseXmlResponse(reply); + + SimpleRegionInfo rinfo = null; + if ((replyData != null) && (replyData["result"] != null)) + { + if (replyData["result"] is Dictionary) + rinfo = new SimpleRegionInfo((Dictionary)replyData["result"]); + else + m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1} received invalid response", + scopeID, regionName); + } + else + m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1} received null response", + scopeID, regionName); + + return rinfo; + } + + public List GetRegionsByName(UUID scopeID, string name, int maxNumber) + { + Dictionary sendData = new Dictionary(); + + sendData["SCOPEID"] = scopeID.ToString(); + sendData["NAME"] = name; + sendData["MAX"] = maxNumber.ToString(); + + sendData["METHOD"] = "get_regions_by_name"; + + string reply = SynchronousRestFormsRequester.MakeRequest("POST", + m_ServerURI + "/grid", + ServerUtils.BuildQueryString(sendData)); + + Dictionary replyData = ServerUtils.ParseXmlResponse(reply); + + List rinfos = new List(); + if (replyData != null) + { + Dictionary.ValueCollection rinfosList = replyData.Values; + foreach (object r in rinfosList) + { + if (r is Dictionary) + { + SimpleRegionInfo rinfo = new SimpleRegionInfo((Dictionary)r); + rinfos.Add(rinfo); + } + else + m_log.DebugFormat("[GRID CONNECTOR]: GetRegionsByName {0}, {1}, {2} received invalid response", + scopeID, name, maxNumber); + } + } + else + m_log.DebugFormat("[GRID CONNECTOR]: GetRegionsByName {0}, {1}, {2} received null response", + scopeID, name, maxNumber); + + return rinfos; + } + + public List GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) + { + Dictionary sendData = new Dictionary(); + + sendData["SCOPEID"] = scopeID.ToString(); + sendData["XMIN"] = xmin.ToString(); + sendData["XMAX"] = xmax.ToString(); + sendData["YMIN"] = ymin.ToString(); + sendData["YMAX"] = ymax.ToString(); + + sendData["METHOD"] = "get_region_range"; + + string reply = SynchronousRestFormsRequester.MakeRequest("POST", + m_ServerURI + "/grid", + ServerUtils.BuildQueryString(sendData)); + + Dictionary replyData = ServerUtils.ParseXmlResponse(reply); + + List rinfos = new List(); + if (replyData != null) + { + Dictionary.ValueCollection rinfosList = replyData.Values; + foreach (object r in rinfosList) + { + if (r is Dictionary) + { + SimpleRegionInfo rinfo = new SimpleRegionInfo((Dictionary)r); + rinfos.Add(rinfo); + } + else + m_log.DebugFormat("[GRID CONNECTOR]: GetRegionRange {0}, {1}-{2} {3}-{4} received invalid response", + scopeID, xmin, xmax, ymin, ymax); + } + } + else + m_log.DebugFormat("[GRID CONNECTOR]: GetRegionRange {0}, {1}-{2} {3}-{4} received null response", + scopeID, xmin, xmax, ymin, ymax); + + return rinfos; + } + + #endregion + + } +} diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 6aa1c4f..2229421 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -88,13 +88,18 @@ namespace OpenSim.Services.GridService return m_Database.Delete(regionID); } - public List GetNeighbours(UUID scopeID, int x, int y) + public List GetNeighbours(UUID scopeID, UUID regionID) { - List rdatas = m_Database.Get(x - 1, y - 1, x + 1, y + 1, scopeID); List rinfos = new List(); - foreach (RegionData rdata in rdatas) - rinfos.Add(RegionData2RegionInfo(rdata)); + RegionData region = m_Database.Get(regionID, scopeID); + if (region != null) + { + // Not really? Maybe? + List rdatas = m_Database.Get(region.posX - 1, region.posY - 1, region.posX + 1, region.posY + 1, scopeID); + foreach (RegionData rdata in rdatas) + rinfos.Add(RegionData2RegionInfo(rdata)); + } return rinfos; } @@ -164,68 +169,20 @@ namespace OpenSim.Services.GridService rdata.posX = (int)rinfo.RegionLocX; rdata.posY = (int)rinfo.RegionLocY; rdata.RegionID = rinfo.RegionID; + rdata.Data = rinfo.ToKeyValuePairs(); //rdata.RegionName = rinfo.RegionName; - rdata.Data["external_ip_address"] = rinfo.ExternalEndPoint.Address.ToString(); - rdata.Data["external_port"] = rinfo.ExternalEndPoint.Port.ToString(); - rdata.Data["external_host_name"] = rinfo.ExternalHostName; - rdata.Data["http_port"] = rinfo.HttpPort.ToString(); - rdata.Data["internal_ip_address"] = rinfo.InternalEndPoint.Address.ToString(); - rdata.Data["internal_port"] = rinfo.InternalEndPoint.Port.ToString(); - rdata.Data["alternate_ports"] = rinfo.m_allow_alternate_ports.ToString(); - rdata.Data["server_uri"] = rinfo.ServerURI; return rdata; } protected SimpleRegionInfo RegionData2RegionInfo(RegionData rdata) { - SimpleRegionInfo rinfo = new SimpleRegionInfo(); + SimpleRegionInfo rinfo = new SimpleRegionInfo(rdata.Data); rinfo.RegionLocX = (uint)rdata.posX; rinfo.RegionLocY = (uint)rdata.posY; rinfo.RegionID = rdata.RegionID; //rinfo.RegionName = rdata.RegionName; - // Now for the variable data - if ((rdata.Data["external_ip_address"] != null) && (rdata.Data["external_port"] != null)) - { - int port = 0; - Int32.TryParse((string)rdata.Data["external_port"], out port); - IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)rdata.Data["external_ip_address"]), port); - rinfo.ExternalEndPoint = ep; - } - else - rinfo.ExternalEndPoint = new IPEndPoint(new IPAddress(0), 0); - - if (rdata.Data["external_host_name"] != null) - rinfo.ExternalHostName = (string)rdata.Data["external_host_name"] ; - - if (rdata.Data["http_port"] != null) - { - UInt32 port = 0; - UInt32.TryParse((string)rdata.Data["http_port"], out port); - rinfo.HttpPort = port; - } - - if ((rdata.Data["internal_ip_address"] != null) && (rdata.Data["internal_port"] != null)) - { - int port = 0; - Int32.TryParse((string)rdata.Data["internal_port"], out port); - IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)rdata.Data["internal_ip_address"]), port); - rinfo.InternalEndPoint = ep; - } - else - rinfo.InternalEndPoint = new IPEndPoint(new IPAddress(0), 0); - - if (rdata.Data["alternate_ports"] != null) - { - bool alts = false; - Boolean.TryParse((string)rdata.Data["alternate_ports"], out alts); - rinfo.m_allow_alternate_ports = alts; - } - - if (rdata.Data["server_uri"] != null) - rinfo.ServerURI = (string)rdata.Data["server_uri"]; - return rinfo; } diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs index 83ab9c1..8f6c524 100644 --- a/OpenSim/Services/Interfaces/IGridService.cs +++ b/OpenSim/Services/Interfaces/IGridService.cs @@ -55,7 +55,7 @@ namespace OpenSim.Services.Interfaces /// /// /// - List GetNeighbours(UUID scopeID, int x, int y); + List GetNeighbours(UUID scopeID, UUID regionID); SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID); -- cgit v1.1 From ae07b220c61cc92453c67e602907f0b3c8fcc707 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 21 Sep 2009 17:16:30 -0700 Subject: Changed position methods so that they assume the input params are in meters. --- OpenSim/Services/GridService/GridService.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 2229421..dd529f5 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -95,7 +95,9 @@ namespace OpenSim.Services.GridService if (region != null) { // Not really? Maybe? - List rdatas = m_Database.Get(region.posX - 1, region.posY - 1, region.posX + 1, region.posY + 1, scopeID); + List rdatas = m_Database.Get(region.posX - (int)Constants.RegionSize, region.posY - (int)Constants.RegionSize, + region.posX + (int)Constants.RegionSize, region.posY + (int)Constants.RegionSize, scopeID); + foreach (RegionData rdata in rdatas) rinfos.Add(RegionData2RegionInfo(rdata)); @@ -114,7 +116,9 @@ namespace OpenSim.Services.GridService public SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y) { - RegionData rdata = m_Database.Get(x, y, scopeID); + int snapX = (int)(x / Constants.RegionSize) * (int)Constants.RegionSize; + int snapY = (int)(y / Constants.RegionSize) * (int)Constants.RegionSize; + RegionData rdata = m_Database.Get(snapX, snapY, scopeID); if (rdata != null) return RegionData2RegionInfo(rdata); @@ -151,7 +155,12 @@ namespace OpenSim.Services.GridService public List GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) { - List rdatas = m_Database.Get(xmin, ymin, xmax, ymax, scopeID); + int xminSnap = (int)(xmin / Constants.RegionSize) * (int)Constants.RegionSize; + int xmaxSnap = (int)(xmax / Constants.RegionSize) * (int)Constants.RegionSize; + int yminSnap = (int)(ymin / Constants.RegionSize) * (int)Constants.RegionSize; + int ymaxSnap = (int)(ymax / Constants.RegionSize) * (int)Constants.RegionSize; + + List rdatas = m_Database.Get(xminSnap, yminSnap, xmaxSnap, ymaxSnap, scopeID); List rinfos = new List(); foreach (RegionData rdata in rdatas) rinfos.Add(RegionData2RegionInfo(rdata)); -- cgit v1.1 From 34f4738159300ab6370e3db47df5187b6cea8771 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 22 Sep 2009 11:58:40 -0700 Subject: Added HGGridConnector and related code. --- .../Connectors/Grid/HypergridServiceConnector.cs | 155 +++++++++++++++++++++ 1 file changed, 155 insertions(+) create mode 100644 OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs new file mode 100644 index 0000000..f68c10a --- /dev/null +++ b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs @@ -0,0 +1,155 @@ +/* + * 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; +using System.Collections.Generic; +using System.Text; +using System.Drawing; +using System.Net; +using System.Reflection; +using OpenSim.Services.Interfaces; + +using OpenSim.Framework; + +using OpenMetaverse; +using OpenMetaverse.Imaging; +using log4net; +using Nwc.XmlRpc; + +namespace OpenSim.Services.Connectors.Grid +{ + public class HypergridServiceConnector + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private IAssetService m_AssetService; + + public HypergridServiceConnector(IAssetService assService) + { + m_AssetService = assService; + } + + public UUID LinkRegion(SimpleRegionInfo info) + { + UUID uuid = UUID.Zero; + + //Hashtable hash = new Hashtable(); + //hash["region_name"] = info.RegionName; + + //IList paramList = new ArrayList(); + //paramList.Add(hash); + + //XmlRpcRequest request = new XmlRpcRequest("link_region", paramList); + //string uri = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/"; + //m_log.Debug("[HGrid]: Linking to " + uri); + //XmlRpcResponse response = request.Send(uri, 10000); + //if (response.IsFault) + //{ + // m_log.ErrorFormat("[HGrid]: remote call returned an error: {0}", response.FaultString); + //} + //else + //{ + // hash = (Hashtable)response.Value; + // //foreach (Object o in hash) + // // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); + // try + // { + // UUID.TryParse((string)hash["uuid"], out uuid); + // info.RegionID = uuid; + // if ((string)hash["handle"] != null) + // { + // info.regionSecret = (string)hash["handle"]; + // //m_log.Debug(">> HERE: " + info.regionSecret); + // } + // if (hash["region_image"] != null) + // { + // UUID img = UUID.Zero; + // UUID.TryParse((string)hash["region_image"], out img); + // info.RegionSettings.TerrainImageID = img; + // } + // if (hash["region_name"] != null) + // { + // info.RegionName = (string)hash["region_name"]; + // //m_log.Debug(">> " + info.RegionName); + // } + // if (hash["internal_port"] != null) + // { + // int port = Convert.ToInt32((string)hash["internal_port"]); + // info.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), port); + // //m_log.Debug(">> " + info.InternalEndPoint.ToString()); + // } + // if (hash["remoting_port"] != null) + // { + // info.RemotingPort = Convert.ToUInt32(hash["remoting_port"]); + // //m_log.Debug(">> " + info.RemotingPort); + // } + + // } + // catch (Exception e) + // { + // m_log.Error("[HGrid]: Got exception while parsing hyperlink response " + e.StackTrace); + // } + //} + return uuid; + } + + public void GetMapImage(SimpleRegionInfo info) + { + try + { + string regionimage = "regionImage" + info.RegionID.ToString(); + regionimage = regionimage.Replace("-", ""); + + WebClient c = new WebClient(); + string uri = "http://" + info.ExternalHostName + ":" + info.HttpPort + "/index.php?method=" + regionimage; + //m_log.Debug("JPEG: " + uri); + c.DownloadFile(uri, info.RegionID.ToString() + ".jpg"); + Bitmap m = new Bitmap(info.RegionID.ToString() + ".jpg"); + //m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width); + byte[] imageData = OpenJPEG.EncodeFromImage(m, true); + AssetBase ass = new AssetBase(UUID.Random(), "region " + info.RegionID.ToString()); + + // !!! for now + //info.RegionSettings.TerrainImageID = ass.FullID; + + ass.Type = (int)AssetType.Texture; + ass.Temporary = true; + ass.Local = true; + ass.Data = imageData; + + m_AssetService.Store(ass); + + } + catch // LEGIT: Catching problems caused by OpenJPEG p/invoke + { + m_log.Warn("[HGrid]: Failed getting/storing map image, because it is probably already in the cache"); + } + } + + } +} -- cgit v1.1 From ffd30b8ac31bc408316079ba86076bf9e984a8be Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 22 Sep 2009 14:46:05 -0700 Subject: Moved RegionName from RegionInfo to SimpleRegionInfo. --- .../Connectors/Grid/HypergridServiceConnector.cs | 112 ++++++++++----------- OpenSim/Services/GridService/GridService.cs | 4 +- 2 files changed, 56 insertions(+), 60 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs index f68c10a..6b0518c 100644 --- a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs +++ b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs @@ -54,67 +54,63 @@ namespace OpenSim.Services.Connectors.Grid m_AssetService = assService; } - public UUID LinkRegion(SimpleRegionInfo info) + public UUID LinkRegion(SimpleRegionInfo info, out ulong realHandle) { UUID uuid = UUID.Zero; + realHandle = 0; - //Hashtable hash = new Hashtable(); - //hash["region_name"] = info.RegionName; - - //IList paramList = new ArrayList(); - //paramList.Add(hash); - - //XmlRpcRequest request = new XmlRpcRequest("link_region", paramList); - //string uri = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/"; - //m_log.Debug("[HGrid]: Linking to " + uri); - //XmlRpcResponse response = request.Send(uri, 10000); - //if (response.IsFault) - //{ - // m_log.ErrorFormat("[HGrid]: remote call returned an error: {0}", response.FaultString); - //} - //else - //{ - // hash = (Hashtable)response.Value; - // //foreach (Object o in hash) - // // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); - // try - // { - // UUID.TryParse((string)hash["uuid"], out uuid); - // info.RegionID = uuid; - // if ((string)hash["handle"] != null) - // { - // info.regionSecret = (string)hash["handle"]; - // //m_log.Debug(">> HERE: " + info.regionSecret); - // } - // if (hash["region_image"] != null) - // { - // UUID img = UUID.Zero; - // UUID.TryParse((string)hash["region_image"], out img); - // info.RegionSettings.TerrainImageID = img; - // } - // if (hash["region_name"] != null) - // { - // info.RegionName = (string)hash["region_name"]; - // //m_log.Debug(">> " + info.RegionName); - // } - // if (hash["internal_port"] != null) - // { - // int port = Convert.ToInt32((string)hash["internal_port"]); - // info.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), port); - // //m_log.Debug(">> " + info.InternalEndPoint.ToString()); - // } - // if (hash["remoting_port"] != null) - // { - // info.RemotingPort = Convert.ToUInt32(hash["remoting_port"]); - // //m_log.Debug(">> " + info.RemotingPort); - // } - - // } - // catch (Exception e) - // { - // m_log.Error("[HGrid]: Got exception while parsing hyperlink response " + e.StackTrace); - // } - //} + Hashtable hash = new Hashtable(); + hash["region_name"] = info.RegionName; + + IList paramList = new ArrayList(); + paramList.Add(hash); + + XmlRpcRequest request = new XmlRpcRequest("link_region", paramList); + string uri = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/"; + m_log.Debug("[HGrid]: Linking to " + uri); + XmlRpcResponse response = request.Send(uri, 10000); + if (response.IsFault) + { + m_log.ErrorFormat("[HGrid]: remote call returned an error: {0}", response.FaultString); + } + else + { + hash = (Hashtable)response.Value; + //foreach (Object o in hash) + // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); + try + { + UUID.TryParse((string)hash["uuid"], out uuid); + info.RegionID = uuid; + if ((string)hash["handle"] != null) + { + realHandle = Convert.ToUInt64((string)hash["handle"]); + m_log.Debug(">> HERE, realHandle: " + realHandle); + } + //if (hash["region_image"] != null) + //{ + // UUID img = UUID.Zero; + // UUID.TryParse((string)hash["region_image"], out img); + // info.RegionSettings.TerrainImageID = img; + //} + if (hash["region_name"] != null) + { + info.RegionName = (string)hash["region_name"]; + //m_log.Debug(">> " + info.RegionName); + } + if (hash["internal_port"] != null) + { + int port = Convert.ToInt32((string)hash["internal_port"]); + info.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), port); + //m_log.Debug(">> " + info.InternalEndPoint.ToString()); + } + + } + catch (Exception e) + { + m_log.Error("[HGrid]: Got exception while parsing hyperlink response " + e.StackTrace); + } + } return uuid; } diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index dd529f5..b37a51b 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -179,7 +179,7 @@ namespace OpenSim.Services.GridService rdata.posY = (int)rinfo.RegionLocY; rdata.RegionID = rinfo.RegionID; rdata.Data = rinfo.ToKeyValuePairs(); - //rdata.RegionName = rinfo.RegionName; + rdata.RegionName = rinfo.RegionName; return rdata; } @@ -190,7 +190,7 @@ namespace OpenSim.Services.GridService rinfo.RegionLocX = (uint)rdata.posX; rinfo.RegionLocY = (uint)rdata.posY; rinfo.RegionID = rdata.RegionID; - //rinfo.RegionName = rdata.RegionName; + rinfo.RegionName = rdata.RegionName; return rinfo; } -- cgit v1.1 From 882d2c9cc399c4c7d1809702104ce94c9c2c7b17 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 22 Sep 2009 20:25:00 -0700 Subject: Added hg console commands to the module. Added the IN connector module for link-region and corresponding handler to be used in the regions only. No service as such is needed. This will replace the current link-region machinery. Compiles but not tested. --- OpenSim/Services/Connectors/Grid/GridServiceConnector.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs index ae7db7e..1962bcf 100644 --- a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs +++ b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs @@ -85,7 +85,7 @@ namespace OpenSim.Services.Connectors #region IGridService - public bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfo) + public virtual bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfo) { Dictionary rinfo = regionInfo.ToKeyValuePairs(); Dictionary sendData = new Dictionary(); @@ -108,7 +108,7 @@ namespace OpenSim.Services.Connectors return false; } - public bool DeregisterRegion(UUID regionID) + public virtual bool DeregisterRegion(UUID regionID) { Dictionary sendData = new Dictionary(); @@ -128,7 +128,7 @@ namespace OpenSim.Services.Connectors return false; } - public List GetNeighbours(UUID scopeID, UUID regionID) + public virtual List GetNeighbours(UUID scopeID, UUID regionID) { Dictionary sendData = new Dictionary(); @@ -166,7 +166,7 @@ namespace OpenSim.Services.Connectors return rinfos; } - public SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID) + public virtual SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID) { Dictionary sendData = new Dictionary(); @@ -197,7 +197,7 @@ namespace OpenSim.Services.Connectors return rinfo; } - public SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y) + public virtual SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y) { Dictionary sendData = new Dictionary(); @@ -229,7 +229,7 @@ namespace OpenSim.Services.Connectors return rinfo; } - public SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName) + public virtual SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName) { Dictionary sendData = new Dictionary(); @@ -260,7 +260,7 @@ namespace OpenSim.Services.Connectors return rinfo; } - public List GetRegionsByName(UUID scopeID, string name, int maxNumber) + public virtual List GetRegionsByName(UUID scopeID, string name, int maxNumber) { Dictionary sendData = new Dictionary(); @@ -299,7 +299,7 @@ namespace OpenSim.Services.Connectors return rinfos; } - public List GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) + public virtual List GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) { Dictionary sendData = new Dictionary(); -- cgit v1.1 From 67276589c883fe1a74d8d52057db1431d637dade Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 23 Sep 2009 17:20:07 -0700 Subject: Changed IGridService to use the new GridRegion data structure instead of old SimpleRegionInfo. Added grid configs to standalones. --- .../Connectors/Grid/GridServiceConnector.cs | 39 ++-- .../Connectors/Grid/HypergridServiceConnector.cs | 5 +- OpenSim/Services/GridService/GridService.cs | 32 +-- OpenSim/Services/GridService/GridServiceBase.cs | 2 +- OpenSim/Services/Interfaces/IGridService.cs | 249 ++++++++++++++++++++- 5 files changed, 281 insertions(+), 46 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs index 1962bcf..0a867db 100644 --- a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs +++ b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs @@ -35,6 +35,7 @@ using OpenSim.Framework; using OpenSim.Framework.Communications; using OpenSim.Framework.Servers.HttpServer; using OpenSim.Services.Interfaces; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; using OpenSim.Server.Base; using OpenMetaverse; @@ -85,7 +86,7 @@ namespace OpenSim.Services.Connectors #region IGridService - public virtual bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfo) + public virtual bool RegisterRegion(UUID scopeID, GridRegion regionInfo) { Dictionary rinfo = regionInfo.ToKeyValuePairs(); Dictionary sendData = new Dictionary(); @@ -128,7 +129,7 @@ namespace OpenSim.Services.Connectors return false; } - public virtual List GetNeighbours(UUID scopeID, UUID regionID) + public virtual List GetNeighbours(UUID scopeID, UUID regionID) { Dictionary sendData = new Dictionary(); @@ -143,7 +144,7 @@ namespace OpenSim.Services.Connectors Dictionary replyData = ServerUtils.ParseXmlResponse(reply); - List rinfos = new List(); + List rinfos = new List(); if (replyData != null) { Dictionary.ValueCollection rinfosList = replyData.Values; @@ -151,7 +152,7 @@ namespace OpenSim.Services.Connectors { if (r is Dictionary) { - SimpleRegionInfo rinfo = new SimpleRegionInfo((Dictionary)r); + GridRegion rinfo = new GridRegion((Dictionary)r); rinfos.Add(rinfo); } else @@ -166,7 +167,7 @@ namespace OpenSim.Services.Connectors return rinfos; } - public virtual SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID) + public virtual GridRegion GetRegionByUUID(UUID scopeID, UUID regionID) { Dictionary sendData = new Dictionary(); @@ -181,11 +182,11 @@ namespace OpenSim.Services.Connectors Dictionary replyData = ServerUtils.ParseXmlResponse(reply); - SimpleRegionInfo rinfo = null; + GridRegion rinfo = null; if ((replyData != null) && (replyData["result"] != null)) { if (replyData["result"] is Dictionary) - rinfo = new SimpleRegionInfo((Dictionary)replyData["result"]); + rinfo = new GridRegion((Dictionary)replyData["result"]); else m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID {0}, {1} received invalid response", scopeID, regionID); @@ -197,7 +198,7 @@ namespace OpenSim.Services.Connectors return rinfo; } - public virtual SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y) + public virtual GridRegion GetRegionByPosition(UUID scopeID, int x, int y) { Dictionary sendData = new Dictionary(); @@ -213,11 +214,11 @@ namespace OpenSim.Services.Connectors Dictionary replyData = ServerUtils.ParseXmlResponse(reply); - SimpleRegionInfo rinfo = null; + GridRegion rinfo = null; if ((replyData != null) && (replyData["result"] != null)) { if (replyData["result"] is Dictionary) - rinfo = new SimpleRegionInfo((Dictionary)replyData["result"]); + rinfo = new GridRegion((Dictionary)replyData["result"]); else m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received invalid response", scopeID, x, y); @@ -229,7 +230,7 @@ namespace OpenSim.Services.Connectors return rinfo; } - public virtual SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName) + public virtual GridRegion GetRegionByName(UUID scopeID, string regionName) { Dictionary sendData = new Dictionary(); @@ -244,11 +245,11 @@ namespace OpenSim.Services.Connectors Dictionary replyData = ServerUtils.ParseXmlResponse(reply); - SimpleRegionInfo rinfo = null; + GridRegion rinfo = null; if ((replyData != null) && (replyData["result"] != null)) { if (replyData["result"] is Dictionary) - rinfo = new SimpleRegionInfo((Dictionary)replyData["result"]); + rinfo = new GridRegion((Dictionary)replyData["result"]); else m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1} received invalid response", scopeID, regionName); @@ -260,7 +261,7 @@ namespace OpenSim.Services.Connectors return rinfo; } - public virtual List GetRegionsByName(UUID scopeID, string name, int maxNumber) + public virtual List GetRegionsByName(UUID scopeID, string name, int maxNumber) { Dictionary sendData = new Dictionary(); @@ -276,7 +277,7 @@ namespace OpenSim.Services.Connectors Dictionary replyData = ServerUtils.ParseXmlResponse(reply); - List rinfos = new List(); + List rinfos = new List(); if (replyData != null) { Dictionary.ValueCollection rinfosList = replyData.Values; @@ -284,7 +285,7 @@ namespace OpenSim.Services.Connectors { if (r is Dictionary) { - SimpleRegionInfo rinfo = new SimpleRegionInfo((Dictionary)r); + GridRegion rinfo = new GridRegion((Dictionary)r); rinfos.Add(rinfo); } else @@ -299,7 +300,7 @@ namespace OpenSim.Services.Connectors return rinfos; } - public virtual List GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) + public virtual List GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) { Dictionary sendData = new Dictionary(); @@ -317,7 +318,7 @@ namespace OpenSim.Services.Connectors Dictionary replyData = ServerUtils.ParseXmlResponse(reply); - List rinfos = new List(); + List rinfos = new List(); if (replyData != null) { Dictionary.ValueCollection rinfosList = replyData.Values; @@ -325,7 +326,7 @@ namespace OpenSim.Services.Connectors { if (r is Dictionary) { - SimpleRegionInfo rinfo = new SimpleRegionInfo((Dictionary)r); + GridRegion rinfo = new GridRegion((Dictionary)r); rinfos.Add(rinfo); } else diff --git a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs index 6b0518c..616c2c1 100644 --- a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs +++ b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs @@ -33,6 +33,7 @@ using System.Drawing; using System.Net; using System.Reflection; using OpenSim.Services.Interfaces; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; using OpenSim.Framework; @@ -54,7 +55,7 @@ namespace OpenSim.Services.Connectors.Grid m_AssetService = assService; } - public UUID LinkRegion(SimpleRegionInfo info, out ulong realHandle) + public UUID LinkRegion(GridRegion info, out ulong realHandle) { UUID uuid = UUID.Zero; realHandle = 0; @@ -114,7 +115,7 @@ namespace OpenSim.Services.Connectors.Grid return uuid; } - public void GetMapImage(SimpleRegionInfo info) + public void GetMapImage(GridRegion info) { try { diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index b37a51b..cd462ab 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -35,6 +35,7 @@ using OpenSim.Framework; using OpenSim.Framework.Console; using OpenSim.Data; using OpenSim.Services.Interfaces; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; using OpenMetaverse; namespace OpenSim.Services.GridService @@ -48,6 +49,7 @@ namespace OpenSim.Services.GridService public GridService(IConfigSource config) : base(config) { + m_log.DebugFormat("[GRID SERVICE]: Starting..."); MainConsole.Instance.Commands.AddCommand("kfs", false, "show digest", "show digest ", @@ -62,7 +64,7 @@ namespace OpenSim.Services.GridService #region IGridService - public bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfos) + public bool RegisterRegion(UUID scopeID, GridRegion regionInfos) { if (m_Database.Get(regionInfos.RegionID, scopeID) != null) { @@ -88,9 +90,9 @@ namespace OpenSim.Services.GridService return m_Database.Delete(regionID); } - public List GetNeighbours(UUID scopeID, UUID regionID) + public List GetNeighbours(UUID scopeID, UUID regionID) { - List rinfos = new List(); + List rinfos = new List(); RegionData region = m_Database.Get(regionID, scopeID); if (region != null) { @@ -105,7 +107,7 @@ namespace OpenSim.Services.GridService return rinfos; } - public SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID) + public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID) { RegionData rdata = m_Database.Get(regionID, scopeID); if (rdata != null) @@ -114,7 +116,7 @@ namespace OpenSim.Services.GridService return null; } - public SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y) + public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) { int snapX = (int)(x / Constants.RegionSize) * (int)Constants.RegionSize; int snapY = (int)(y / Constants.RegionSize) * (int)Constants.RegionSize; @@ -125,7 +127,7 @@ namespace OpenSim.Services.GridService return null; } - public SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName) + public GridRegion GetRegionByName(UUID scopeID, string regionName) { List rdatas = m_Database.Get(regionName + "%", scopeID); if ((rdatas != null) && (rdatas.Count > 0)) @@ -134,12 +136,12 @@ namespace OpenSim.Services.GridService return null; } - public List GetRegionsByName(UUID scopeID, string name, int maxNumber) + public List GetRegionsByName(UUID scopeID, string name, int maxNumber) { List rdatas = m_Database.Get("%" + name + "%", scopeID); int count = 0; - List rinfos = new List(); + List rinfos = new List(); if (rdatas != null) { @@ -153,7 +155,7 @@ namespace OpenSim.Services.GridService return rinfos; } - public List GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) + public List GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) { int xminSnap = (int)(xmin / Constants.RegionSize) * (int)Constants.RegionSize; int xmaxSnap = (int)(xmax / Constants.RegionSize) * (int)Constants.RegionSize; @@ -161,7 +163,7 @@ namespace OpenSim.Services.GridService int ymaxSnap = (int)(ymax / Constants.RegionSize) * (int)Constants.RegionSize; List rdatas = m_Database.Get(xminSnap, yminSnap, xmaxSnap, ymaxSnap, scopeID); - List rinfos = new List(); + List rinfos = new List(); foreach (RegionData rdata in rdatas) rinfos.Add(RegionData2RegionInfo(rdata)); @@ -172,7 +174,7 @@ namespace OpenSim.Services.GridService #region Data structure conversions - protected RegionData RegionInfo2RegionData(SimpleRegionInfo rinfo) + protected RegionData RegionInfo2RegionData(GridRegion rinfo) { RegionData rdata = new RegionData(); rdata.posX = (int)rinfo.RegionLocX; @@ -184,11 +186,11 @@ namespace OpenSim.Services.GridService return rdata; } - protected SimpleRegionInfo RegionData2RegionInfo(RegionData rdata) + protected GridRegion RegionData2RegionInfo(RegionData rdata) { - SimpleRegionInfo rinfo = new SimpleRegionInfo(rdata.Data); - rinfo.RegionLocX = (uint)rdata.posX; - rinfo.RegionLocY = (uint)rdata.posY; + GridRegion rinfo = new GridRegion(rdata.Data); + rinfo.RegionLocX = rdata.posX; + rinfo.RegionLocY = rdata.posY; rinfo.RegionID = rdata.RegionID; rinfo.RegionName = rdata.RegionName; diff --git a/OpenSim/Services/GridService/GridServiceBase.cs b/OpenSim/Services/GridService/GridServiceBase.cs index 7522e64..444f79b 100644 --- a/OpenSim/Services/GridService/GridServiceBase.cs +++ b/OpenSim/Services/GridService/GridServiceBase.cs @@ -68,7 +68,7 @@ namespace OpenSim.Services.GridService connString = gridConfig.GetString("ConnectionString", connString); realm = gridConfig.GetString("Realm", realm); } - + // // We tried, but this doesn't exist. We can't proceed. // diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs index 8f6c524..a188f7e 100644 --- a/OpenSim/Services/Interfaces/IGridService.cs +++ b/OpenSim/Services/Interfaces/IGridService.cs @@ -25,8 +25,11 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -using OpenSim.Framework; +using System; using System.Collections.Generic; +using System.Net; +using System.Net.Sockets; +using OpenSim.Framework; using OpenMetaverse; namespace OpenSim.Services.Interfaces @@ -39,7 +42,7 @@ namespace OpenSim.Services.Interfaces /// /// /// Thrown if region registration failed - bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfos); + bool RegisterRegion(UUID scopeID, GridRegion regionInfos); /// /// Deregister a region with the grid service. @@ -55,9 +58,9 @@ namespace OpenSim.Services.Interfaces /// /// /// - List GetNeighbours(UUID scopeID, UUID regionID); + List GetNeighbours(UUID scopeID, UUID regionID); - SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID); + GridRegion GetRegionByUUID(UUID scopeID, UUID regionID); /// /// Get the region at the given position (in meters) @@ -66,9 +69,9 @@ namespace OpenSim.Services.Interfaces /// /// /// - SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y); - - SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName); + GridRegion GetRegionByPosition(UUID scopeID, int x, int y); + + GridRegion GetRegionByName(UUID scopeID, string regionName); /// /// Get information about regions starting with the provided name. @@ -83,9 +86,237 @@ namespace OpenSim.Services.Interfaces /// A list of s of regions with matching name. If the /// grid-server couldn't be contacted or returned an error, return null. /// - List GetRegionsByName(UUID scopeID, string name, int maxNumber); + List GetRegionsByName(UUID scopeID, string name, int maxNumber); - List GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax); + List GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax); } + + public class GridRegion + { + + /// + /// The port by which http communication occurs with the region + /// + public uint HttpPort + { + get { return m_httpPort; } + set { m_httpPort = value; } + } + protected uint m_httpPort; + + /// + /// A well-formed URI for the host region server (namely "http://" + ExternalHostName) + /// + public string ServerURI + { + get { return m_serverURI; } + set { m_serverURI = value; } + } + protected string m_serverURI; + + public string RegionName + { + get { return m_regionName; } + set { m_regionName = value; } + } + protected string m_regionName = String.Empty; + + protected bool Allow_Alternate_Ports; + public bool m_allow_alternate_ports; + + protected string m_externalHostName; + + protected IPEndPoint m_internalEndPoint; + + public int RegionLocX + { + get { return m_regionLocX; } + set { m_regionLocX = value; } + } + protected int m_regionLocX; + + public int RegionLocY + { + get { return m_regionLocY; } + set { m_regionLocY = value; } + } + protected int m_regionLocY; + + public UUID RegionID = UUID.Zero; + public UUID ScopeID = UUID.Zero; + + public GridRegion() + { + } + + public GridRegion(int regionLocX, int regionLocY, IPEndPoint internalEndPoint, string externalUri) + { + m_regionLocX = regionLocX; + m_regionLocY = regionLocY; + + m_internalEndPoint = internalEndPoint; + m_externalHostName = externalUri; + } + + public GridRegion(int regionLocX, int regionLocY, string externalUri, uint port) + { + m_regionLocX = regionLocX; + m_regionLocY = regionLocY; + + m_externalHostName = externalUri; + + m_internalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)port); + } + + public GridRegion(uint xcell, uint ycell) + { + m_regionLocX = (int)(xcell * Constants.RegionSize); + m_regionLocY = (int)(ycell * Constants.RegionSize); + } + + public GridRegion(RegionInfo ConvertFrom) + { + m_regionName = ConvertFrom.RegionName; + m_regionLocX = (int)(ConvertFrom.RegionLocX * Constants.RegionSize); + m_regionLocY = (int)(ConvertFrom.RegionLocY * Constants.RegionSize); + m_internalEndPoint = ConvertFrom.InternalEndPoint; + m_externalHostName = ConvertFrom.ExternalHostName; + m_httpPort = ConvertFrom.HttpPort; + m_allow_alternate_ports = ConvertFrom.m_allow_alternate_ports; + RegionID = UUID.Zero; + ServerURI = ConvertFrom.ServerURI; + } + + + /// + /// This accessor can throw all the exceptions that Dns.GetHostAddresses can throw. + /// + /// XXX Isn't this really doing too much to be a simple getter, rather than an explict method? + /// + public IPEndPoint ExternalEndPoint + { + get + { + // Old one defaults to IPv6 + //return new IPEndPoint(Dns.GetHostAddresses(m_externalHostName)[0], m_internalEndPoint.Port); + + IPAddress ia = null; + // If it is already an IP, don't resolve it - just return directly + if (IPAddress.TryParse(m_externalHostName, out ia)) + return new IPEndPoint(ia, m_internalEndPoint.Port); + + // Reset for next check + ia = null; + try + { + foreach (IPAddress Adr in Dns.GetHostAddresses(m_externalHostName)) + { + if (ia == null) + ia = Adr; + + if (Adr.AddressFamily == AddressFamily.InterNetwork) + { + ia = Adr; + break; + } + } + } + catch (SocketException e) + { + throw new Exception( + "Unable to resolve local hostname " + m_externalHostName + " innerException of type '" + + e + "' attached to this exception", e); + } + + return new IPEndPoint(ia, m_internalEndPoint.Port); + } + + set { m_externalHostName = value.ToString(); } + } + + public string ExternalHostName + { + get { return m_externalHostName; } + set { m_externalHostName = value; } + } + + public IPEndPoint InternalEndPoint + { + get { return m_internalEndPoint; } + set { m_internalEndPoint = value; } + } + + public ulong RegionHandle + { + get { return Util.UIntsToLong((uint)RegionLocX, (uint)RegionLocY); } + } + + public int getInternalEndPointPort() + { + return m_internalEndPoint.Port; + } + + public Dictionary ToKeyValuePairs() + { + Dictionary kvp = new Dictionary(); + kvp["uuid"] = RegionID.ToString(); + kvp["locX"] = RegionLocX.ToString(); + kvp["locY"] = RegionLocY.ToString(); + kvp["external_ip_address"] = ExternalEndPoint.Address.ToString(); + kvp["external_port"] = ExternalEndPoint.Port.ToString(); + kvp["external_host_name"] = ExternalHostName; + kvp["http_port"] = HttpPort.ToString(); + kvp["internal_ip_address"] = InternalEndPoint.Address.ToString(); + kvp["internal_port"] = InternalEndPoint.Port.ToString(); + kvp["alternate_ports"] = m_allow_alternate_ports.ToString(); + kvp["server_uri"] = ServerURI; + + return kvp; + } + + public GridRegion(Dictionary kvp) + { + if ((kvp["external_ip_address"] != null) && (kvp["external_port"] != null)) + { + int port = 0; + Int32.TryParse((string)kvp["external_port"], out port); + IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)kvp["external_ip_address"]), port); + ExternalEndPoint = ep; + } + else + ExternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0); + + if (kvp["external_host_name"] != null) + ExternalHostName = (string)kvp["external_host_name"]; + + if (kvp["http_port"] != null) + { + UInt32 port = 0; + UInt32.TryParse((string)kvp["http_port"], out port); + HttpPort = port; + } + + if ((kvp["internal_ip_address"] != null) && (kvp["internal_port"] != null)) + { + int port = 0; + Int32.TryParse((string)kvp["internal_port"], out port); + IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)kvp["internal_ip_address"]), port); + InternalEndPoint = ep; + } + else + InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0); + + if (kvp["alternate_ports"] != null) + { + bool alts = false; + Boolean.TryParse((string)kvp["alternate_ports"], out alts); + m_allow_alternate_ports = alts; + } + + if (kvp["server_uri"] != null) + ServerURI = (string)kvp["server_uri"]; + } + } + } -- cgit v1.1 From fd8fb7735b0eb6150679ccad84b2a32fd5315a38 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 23 Sep 2009 20:39:25 -0700 Subject: First test passes -- regions being registered and retrieved correctly in Data.Null. --- OpenSim/Services/GridService/GridService.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index cd462ab..1b297dc 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -101,7 +101,8 @@ namespace OpenSim.Services.GridService region.posX + (int)Constants.RegionSize, region.posY + (int)Constants.RegionSize, scopeID); foreach (RegionData rdata in rdatas) - rinfos.Add(RegionData2RegionInfo(rdata)); + if (rdata.RegionID != regionID) + rinfos.Add(RegionData2RegionInfo(rdata)); } return rinfos; -- cgit v1.1 From 2824bbc47b30ab6fb9a12bce3201bb5b79b20bd5 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 24 Sep 2009 05:48:35 -0700 Subject: Changed name of the hyperlink XMLRPC method to linkk-region, so that it doesn't conflict with the existing one. --- OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs | 2 +- OpenSim/Services/GridService/GridService.cs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs index 616c2c1..b5e8743 100644 --- a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs +++ b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs @@ -66,7 +66,7 @@ namespace OpenSim.Services.Connectors.Grid IList paramList = new ArrayList(); paramList.Add(hash); - XmlRpcRequest request = new XmlRpcRequest("link_region", paramList); + XmlRpcRequest request = new XmlRpcRequest("linkk_region", paramList); string uri = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/"; m_log.Debug("[HGrid]: Linking to " + uri); XmlRpcResponse response = request.Send(uri, 10000); diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 1b297dc..01ffa1d 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -71,7 +71,9 @@ namespace OpenSim.Services.GridService m_log.WarnFormat("[GRID SERVICE]: Region {0} already registered in scope {1}.", regionInfos.RegionID, scopeID); return false; } - if (m_Database.Get((int)regionInfos.RegionLocX, (int)regionInfos.RegionLocY, scopeID) != null) + // This needs better sanity testing. What if regionInfo is registering in + // overlapping coords? + if (m_Database.Get(regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID) != null) { m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register in coordinates {1}, {2} which are already in use in scope {3}.", regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); -- cgit v1.1 From dd3d52ae1faefbca85e2fe8d8cea67f7db4005ac Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 24 Sep 2009 13:33:58 -0700 Subject: Added test GridClient, which allowed me to remove a few bugs out of the new code. --- OpenSim/Services/Connectors/Grid/GridServiceConnector.cs | 12 ++++++++---- OpenSim/Services/Interfaces/IGridService.cs | 9 +++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs index 0a867db..fa197c8 100644 --- a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs +++ b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs @@ -97,9 +97,11 @@ namespace OpenSim.Services.Connectors sendData["METHOD"] = "register"; + string reqString = ServerUtils.BuildQueryString(sendData); + m_log.DebugFormat("[GRID CONNECTOR]: queryString = {0}", reqString); string reply = SynchronousRestFormsRequester.MakeRequest("POST", m_ServerURI + "/grid", - ServerUtils.BuildQueryString(sendData)); + reqString); Dictionary replyData = ServerUtils.ParseXmlResponse(reply); @@ -138,9 +140,10 @@ namespace OpenSim.Services.Connectors sendData["METHOD"] = "get_neighbours"; + string reqString = ServerUtils.BuildQueryString(sendData); string reply = SynchronousRestFormsRequester.MakeRequest("POST", m_ServerURI + "/grid", - ServerUtils.BuildQueryString(sendData)); + reqString); Dictionary replyData = ServerUtils.ParseXmlResponse(reply); @@ -148,6 +151,7 @@ namespace OpenSim.Services.Connectors if (replyData != null) { Dictionary.ValueCollection rinfosList = replyData.Values; + m_log.DebugFormat("[GRID CONNECTOR]: get neighbours returned {0} elements", rinfosList.Count); foreach (object r in rinfosList) { if (r is Dictionary) @@ -156,8 +160,8 @@ namespace OpenSim.Services.Connectors rinfos.Add(rinfo); } else - m_log.DebugFormat("[GRID CONNECTOR]: GetNeighbours {0}, {1} received invalid response", - scopeID, regionID); + m_log.DebugFormat("[GRID CONNECTOR]: GetNeighbours {0}, {1} received invalid response type {2}", + scopeID, regionID, r.GetType()); } } else diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs index a188f7e..d12276f 100644 --- a/OpenSim/Services/Interfaces/IGridService.cs +++ b/OpenSim/Services/Interfaces/IGridService.cs @@ -277,6 +277,15 @@ namespace OpenSim.Services.Interfaces public GridRegion(Dictionary kvp) { + if (kvp["uuid"] != null) + RegionID = new UUID((string)kvp["uuid"]); + + if (kvp["locX"] != null) + RegionLocX = Convert.ToInt32((string)kvp["locX"]); + + if (kvp["locY"] != null) + RegionLocY = Convert.ToInt32((string)kvp["locY"]); + if ((kvp["external_ip_address"] != null) && (kvp["external_port"] != null)) { int port = 0; -- cgit v1.1 From 1faaa0a43a851c44af40336336ddbe3a7dbe83af Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 24 Sep 2009 15:30:00 -0700 Subject: GridServerPostHandler finished. GridClient tests all work. More guards on getting parameters and replies over the wire. --- .../Connectors/Grid/GridServiceConnector.cs | 151 +++++++++++++-------- OpenSim/Services/Interfaces/IGridService.cs | 4 + 2 files changed, 96 insertions(+), 59 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs index fa197c8..ebb66a7 100644 --- a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs +++ b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs @@ -98,15 +98,19 @@ namespace OpenSim.Services.Connectors sendData["METHOD"] = "register"; string reqString = ServerUtils.BuildQueryString(sendData); - m_log.DebugFormat("[GRID CONNECTOR]: queryString = {0}", reqString); + //m_log.DebugFormat("[GRID CONNECTOR]: queryString = {0}", reqString); string reply = SynchronousRestFormsRequester.MakeRequest("POST", m_ServerURI + "/grid", reqString); + if (reply != string.Empty) + { + Dictionary replyData = ServerUtils.ParseXmlResponse(reply); - Dictionary replyData = ServerUtils.ParseXmlResponse(reply); - - if ((replyData["Result"] != null) && (replyData["Result"].ToString().ToLower() == "success")) - return true; + if ((replyData["Result"] != null) && (replyData["Result"].ToString().ToLower() == "success")) + return true; + } + else + m_log.DebugFormat("[GRID CONNECTOR]: RegisterRegion received null reply"); return false; } @@ -123,10 +127,15 @@ namespace OpenSim.Services.Connectors m_ServerURI + "/grid", ServerUtils.BuildQueryString(sendData)); - Dictionary replyData = ServerUtils.ParseXmlResponse(reply); + if (reply != string.Empty) + { + Dictionary replyData = ServerUtils.ParseXmlResponse(reply); - if ((replyData["Result"] != null) && (replyData["Result"].ToString().ToLower() == "success")) - return true; + if ((replyData["Result"] != null) && (replyData["Result"].ToString().ToLower() == "success")) + return true; + } + else + m_log.DebugFormat("[GRID CONNECTOR]: DeregisterRegion received null reply"); return false; } @@ -151,7 +160,7 @@ namespace OpenSim.Services.Connectors if (replyData != null) { Dictionary.ValueCollection rinfosList = replyData.Values; - m_log.DebugFormat("[GRID CONNECTOR]: get neighbours returned {0} elements", rinfosList.Count); + //m_log.DebugFormat("[GRID CONNECTOR]: get neighbours returned {0} elements", rinfosList.Count); foreach (object r in rinfosList) { if (r is Dictionary) @@ -184,20 +193,26 @@ namespace OpenSim.Services.Connectors m_ServerURI + "/grid", ServerUtils.BuildQueryString(sendData)); - Dictionary replyData = ServerUtils.ParseXmlResponse(reply); - GridRegion rinfo = null; - if ((replyData != null) && (replyData["result"] != null)) + + if (reply != string.Empty) { - if (replyData["result"] is Dictionary) - rinfo = new GridRegion((Dictionary)replyData["result"]); + Dictionary replyData = ServerUtils.ParseXmlResponse(reply); + + if ((replyData != null) && (replyData["result"] != null)) + { + if (replyData["result"] is Dictionary) + rinfo = new GridRegion((Dictionary)replyData["result"]); + //else + // m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID {0}, {1} received null response", + // scopeID, regionID); + } else - m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID {0}, {1} received invalid response", + m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID {0}, {1} received null response", scopeID, regionID); } else - m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID {0}, {1} received null response", - scopeID, regionID); + m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID received null reply"); return rinfo; } @@ -216,20 +231,25 @@ namespace OpenSim.Services.Connectors m_ServerURI + "/grid", ServerUtils.BuildQueryString(sendData)); - Dictionary replyData = ServerUtils.ParseXmlResponse(reply); - GridRegion rinfo = null; - if ((replyData != null) && (replyData["result"] != null)) + if (reply != string.Empty) { - if (replyData["result"] is Dictionary) - rinfo = new GridRegion((Dictionary)replyData["result"]); + Dictionary replyData = ServerUtils.ParseXmlResponse(reply); + + if ((replyData != null) && (replyData["result"] != null)) + { + if (replyData["result"] is Dictionary) + rinfo = new GridRegion((Dictionary)replyData["result"]); + else + m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received invalid response", + scopeID, x, y); + } else - m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received invalid response", + m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received null response", scopeID, x, y); } else - m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received null response", - scopeID, x, y); + m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition received null reply"); return rinfo; } @@ -247,20 +267,22 @@ namespace OpenSim.Services.Connectors m_ServerURI + "/grid", ServerUtils.BuildQueryString(sendData)); - Dictionary replyData = ServerUtils.ParseXmlResponse(reply); - GridRegion rinfo = null; - if ((replyData != null) && (replyData["result"] != null)) + if (reply != string.Empty) { - if (replyData["result"] is Dictionary) - rinfo = new GridRegion((Dictionary)replyData["result"]); + Dictionary replyData = ServerUtils.ParseXmlResponse(reply); + + if ((replyData != null) && (replyData["result"] != null)) + { + if (replyData["result"] is Dictionary) + rinfo = new GridRegion((Dictionary)replyData["result"]); + } else - m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1} received invalid response", + m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1} received null response", scopeID, regionName); } else - m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1} received null response", - scopeID, regionName); + m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByName received null reply"); return rinfo; } @@ -279,27 +301,33 @@ namespace OpenSim.Services.Connectors m_ServerURI + "/grid", ServerUtils.BuildQueryString(sendData)); - Dictionary replyData = ServerUtils.ParseXmlResponse(reply); - List rinfos = new List(); - if (replyData != null) + + if (reply != string.Empty) { - Dictionary.ValueCollection rinfosList = replyData.Values; - foreach (object r in rinfosList) + Dictionary replyData = ServerUtils.ParseXmlResponse(reply); + + if (replyData != null) { - if (r is Dictionary) + Dictionary.ValueCollection rinfosList = replyData.Values; + foreach (object r in rinfosList) { - GridRegion rinfo = new GridRegion((Dictionary)r); - rinfos.Add(rinfo); + if (r is Dictionary) + { + GridRegion rinfo = new GridRegion((Dictionary)r); + rinfos.Add(rinfo); + } + else + m_log.DebugFormat("[GRID CONNECTOR]: GetRegionsByName {0}, {1}, {2} received invalid response", + scopeID, name, maxNumber); } - else - m_log.DebugFormat("[GRID CONNECTOR]: GetRegionsByName {0}, {1}, {2} received invalid response", - scopeID, name, maxNumber); } + else + m_log.DebugFormat("[GRID CONNECTOR]: GetRegionsByName {0}, {1}, {2} received null response", + scopeID, name, maxNumber); } else - m_log.DebugFormat("[GRID CONNECTOR]: GetRegionsByName {0}, {1}, {2} received null response", - scopeID, name, maxNumber); + m_log.DebugFormat("[GRID CONNECTOR]: GetRegionsByName received null reply"); return rinfos; } @@ -316,31 +344,36 @@ namespace OpenSim.Services.Connectors sendData["METHOD"] = "get_region_range"; + List rinfos = new List(); + string reply = SynchronousRestFormsRequester.MakeRequest("POST", m_ServerURI + "/grid", ServerUtils.BuildQueryString(sendData)); - Dictionary replyData = ServerUtils.ParseXmlResponse(reply); + //m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply); - List rinfos = new List(); - if (replyData != null) + if (reply != string.Empty) { - Dictionary.ValueCollection rinfosList = replyData.Values; - foreach (object r in rinfosList) + Dictionary replyData = ServerUtils.ParseXmlResponse(reply); + + if (replyData != null) { - if (r is Dictionary) + Dictionary.ValueCollection rinfosList = replyData.Values; + foreach (object r in rinfosList) { - GridRegion rinfo = new GridRegion((Dictionary)r); - rinfos.Add(rinfo); + if (r is Dictionary) + { + GridRegion rinfo = new GridRegion((Dictionary)r); + rinfos.Add(rinfo); + } } - else - m_log.DebugFormat("[GRID CONNECTOR]: GetRegionRange {0}, {1}-{2} {3}-{4} received invalid response", - scopeID, xmin, xmax, ymin, ymax); } + else + m_log.DebugFormat("[GRID CONNECTOR]: GetRegionRange {0}, {1}-{2} {3}-{4} received null response", + scopeID, xmin, xmax, ymin, ymax); } else - m_log.DebugFormat("[GRID CONNECTOR]: GetRegionRange {0}, {1}-{2} {3}-{4} received null response", - scopeID, xmin, xmax, ymin, ymax); + m_log.DebugFormat("[GRID CONNECTOR]: GetRegionRange received null reply"); return rinfos; } diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs index d12276f..4bdcde2 100644 --- a/OpenSim/Services/Interfaces/IGridService.cs +++ b/OpenSim/Services/Interfaces/IGridService.cs @@ -263,6 +263,7 @@ namespace OpenSim.Services.Interfaces kvp["uuid"] = RegionID.ToString(); kvp["locX"] = RegionLocX.ToString(); kvp["locY"] = RegionLocY.ToString(); + kvp["name"] = RegionName; kvp["external_ip_address"] = ExternalEndPoint.Address.ToString(); kvp["external_port"] = ExternalEndPoint.Port.ToString(); kvp["external_host_name"] = ExternalHostName; @@ -286,6 +287,9 @@ namespace OpenSim.Services.Interfaces if (kvp["locY"] != null) RegionLocY = Convert.ToInt32((string)kvp["locY"]); + if (kvp["name"] != null) + RegionName = (string)kvp["name"]; + if ((kvp["external_ip_address"] != null) && (kvp["external_port"] != null)) { int port = 0; -- cgit v1.1 From 6a5d7650d02979c74abcbbb3595729a4a6b55411 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 24 Sep 2009 18:23:55 -0700 Subject: All tests pass for MySQL/MySQLRegionData. Added OpenSim.GridServer.ini.example that I have been using for testing the ROBUST grid service with the GridClient. --- OpenSim/Services/GridService/GridService.cs | 5 ++- OpenSim/Services/Interfaces/IGridService.cs | 61 +++++++++-------------------- 2 files changed, 21 insertions(+), 45 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 01ffa1d..41344ad 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -183,9 +183,9 @@ namespace OpenSim.Services.GridService rdata.posX = (int)rinfo.RegionLocX; rdata.posY = (int)rinfo.RegionLocY; rdata.RegionID = rinfo.RegionID; - rdata.Data = rinfo.ToKeyValuePairs(); rdata.RegionName = rinfo.RegionName; - + rdata.Data = rinfo.ToKeyValuePairs(); + rdata.Data["regionHandle"] = Utils.UIntsToLong((uint)rdata.posX, (uint)rdata.posY); return rdata; } @@ -196,6 +196,7 @@ namespace OpenSim.Services.GridService rinfo.RegionLocY = rdata.posY; rinfo.RegionID = rdata.RegionID; rinfo.RegionName = rdata.RegionName; + rinfo.ScopeID = rdata.ScopeID; return rinfo; } diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs index 4bdcde2..513b1b0 100644 --- a/OpenSim/Services/Interfaces/IGridService.cs +++ b/OpenSim/Services/Interfaces/IGridService.cs @@ -263,72 +263,47 @@ namespace OpenSim.Services.Interfaces kvp["uuid"] = RegionID.ToString(); kvp["locX"] = RegionLocX.ToString(); kvp["locY"] = RegionLocY.ToString(); - kvp["name"] = RegionName; - kvp["external_ip_address"] = ExternalEndPoint.Address.ToString(); - kvp["external_port"] = ExternalEndPoint.Port.ToString(); - kvp["external_host_name"] = ExternalHostName; - kvp["http_port"] = HttpPort.ToString(); - kvp["internal_ip_address"] = InternalEndPoint.Address.ToString(); - kvp["internal_port"] = InternalEndPoint.Port.ToString(); - kvp["alternate_ports"] = m_allow_alternate_ports.ToString(); - kvp["server_uri"] = ServerURI; + kvp["regionName"] = RegionName; + kvp["serverIP"] = ExternalHostName; //ExternalEndPoint.Address.ToString(); + kvp["serverHttpPort"] = HttpPort.ToString(); + kvp["serverURI"] = ServerURI; return kvp; } public GridRegion(Dictionary kvp) { - if (kvp["uuid"] != null) + if (kvp.ContainsKey("uuid")) RegionID = new UUID((string)kvp["uuid"]); - if (kvp["locX"] != null) + if (kvp.ContainsKey("locX")) RegionLocX = Convert.ToInt32((string)kvp["locX"]); - if (kvp["locY"] != null) + if (kvp.ContainsKey("locY")) RegionLocY = Convert.ToInt32((string)kvp["locY"]); - if (kvp["name"] != null) - RegionName = (string)kvp["name"]; + if (kvp.ContainsKey("regionName")) + RegionName = (string)kvp["regionName"]; - if ((kvp["external_ip_address"] != null) && (kvp["external_port"] != null)) + if (kvp.ContainsKey("serverIP")) { int port = 0; - Int32.TryParse((string)kvp["external_port"], out port); - IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)kvp["external_ip_address"]), port); - ExternalEndPoint = ep; + //Int32.TryParse((string)kvp["serverPort"], out port); + //IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)kvp["serverIP"]), port); + ExternalHostName = (string)kvp["serverIP"]; } else - ExternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0); + ExternalHostName = "127.0.0.1"; - if (kvp["external_host_name"] != null) - ExternalHostName = (string)kvp["external_host_name"]; - - if (kvp["http_port"] != null) + if (kvp.ContainsKey("serverHttpPort")) { UInt32 port = 0; - UInt32.TryParse((string)kvp["http_port"], out port); + UInt32.TryParse((string)kvp["serverHttpPort"], out port); HttpPort = port; } - if ((kvp["internal_ip_address"] != null) && (kvp["internal_port"] != null)) - { - int port = 0; - Int32.TryParse((string)kvp["internal_port"], out port); - IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)kvp["internal_ip_address"]), port); - InternalEndPoint = ep; - } - else - InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0); - - if (kvp["alternate_ports"] != null) - { - bool alts = false; - Boolean.TryParse((string)kvp["alternate_ports"], out alts); - m_allow_alternate_ports = alts; - } - - if (kvp["server_uri"] != null) - ServerURI = (string)kvp["server_uri"]; + if (kvp.ContainsKey("serverURI")) + ServerURI = (string)kvp["serverURI"]; } } -- cgit v1.1 From b6824c495cb04ca79c681143be2d1b8f9b5b228d Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 24 Sep 2009 18:28:38 -0700 Subject: Deleted the meaningless console commands on the GridService. Will need to add meaningful ones. --- OpenSim/Services/GridService/GridService.cs | 72 ----------------------------- 1 file changed, 72 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 41344ad..68b7cdf 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -50,16 +50,6 @@ namespace OpenSim.Services.GridService : base(config) { m_log.DebugFormat("[GRID SERVICE]: Starting..."); - MainConsole.Instance.Commands.AddCommand("kfs", false, - "show digest", - "show digest ", - "Show asset digest", HandleShowDigest); - - MainConsole.Instance.Commands.AddCommand("kfs", false, - "delete asset", - "delete asset ", - "Delete asset from database", HandleDeleteAsset); - } #region IGridService @@ -203,67 +193,5 @@ namespace OpenSim.Services.GridService #endregion - void HandleShowDigest(string module, string[] args) - { - //if (args.Length < 3) - //{ - // MainConsole.Instance.Output("Syntax: show digest "); - // return; - //} - - //AssetBase asset = Get(args[2]); - - //if (asset == null || asset.Data.Length == 0) - //{ - // MainConsole.Instance.Output("Asset not found"); - // return; - //} - - //int i; - - //MainConsole.Instance.Output(String.Format("Name: {0}", asset.Name)); - //MainConsole.Instance.Output(String.Format("Description: {0}", asset.Description)); - //MainConsole.Instance.Output(String.Format("Type: {0}", asset.Type)); - //MainConsole.Instance.Output(String.Format("Content-type: {0}", asset.Metadata.ContentType)); - - //for (i = 0 ; i < 5 ; i++) - //{ - // int off = i * 16; - // if (asset.Data.Length <= off) - // break; - // int len = 16; - // if (asset.Data.Length < off + len) - // len = asset.Data.Length - off; - - // byte[] line = new byte[len]; - // Array.Copy(asset.Data, off, line, 0, len); - - // string text = BitConverter.ToString(line); - // MainConsole.Instance.Output(String.Format("{0:x4}: {1}", off, text)); - //} - } - - void HandleDeleteAsset(string module, string[] args) - { - //if (args.Length < 3) - //{ - // MainConsole.Instance.Output("Syntax: delete asset "); - // return; - //} - - //AssetBase asset = Get(args[2]); - - //if (asset == null || asset.Data.Length == 0) - // MainConsole.Instance.Output("Asset not found"); - // return; - //} - - //Delete(args[2]); - - ////MainConsole.Instance.Output("Asset deleted"); - //// TODO: Implement this - - //MainConsole.Instance.Output("Asset deletion not supported by database"); - } } } -- cgit v1.1 From 52e477b41f137ff2a0775722dcbaaa64fa5f3bc3 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 25 Sep 2009 06:02:41 -0700 Subject: Better guards on RegisterRegion in GridService. Added serverPort to the fields that get stored (I think this is the UDP port). --- OpenSim/Services/GridService/GridService.cs | 14 ++++++++------ OpenSim/Services/Interfaces/IGridService.cs | 10 +++++++++- 2 files changed, 17 insertions(+), 7 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 68b7cdf..991acf2 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -56,19 +56,21 @@ namespace OpenSim.Services.GridService public bool RegisterRegion(UUID scopeID, GridRegion regionInfos) { - if (m_Database.Get(regionInfos.RegionID, scopeID) != null) - { - m_log.WarnFormat("[GRID SERVICE]: Region {0} already registered in scope {1}.", regionInfos.RegionID, scopeID); - return false; - } // This needs better sanity testing. What if regionInfo is registering in // overlapping coords? - if (m_Database.Get(regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID) != null) + RegionData region = m_Database.Get(regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); + if ((region != null) && (region.RegionID != regionInfos.RegionID)) { m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register in coordinates {1}, {2} which are already in use in scope {3}.", regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); return false; } + if ((region != null) && (region.RegionID == regionInfos.RegionID) && + ((region.posX != regionInfos.RegionLocX) || (region.posY != regionInfos.RegionLocY))) + { + // Region reregistering in other coordinates. Delete the old entry + m_Database.Delete(regionInfos.RegionID); + } // Everything is ok, let's register RegionData rdata = RegionInfo2RegionData(regionInfos); diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs index 513b1b0..ce432ab 100644 --- a/OpenSim/Services/Interfaces/IGridService.cs +++ b/OpenSim/Services/Interfaces/IGridService.cs @@ -267,6 +267,7 @@ namespace OpenSim.Services.Interfaces kvp["serverIP"] = ExternalHostName; //ExternalEndPoint.Address.ToString(); kvp["serverHttpPort"] = HttpPort.ToString(); kvp["serverURI"] = ServerURI; + kvp["serverPort"] = InternalEndPoint.Port.ToString(); return kvp; } @@ -287,7 +288,7 @@ namespace OpenSim.Services.Interfaces if (kvp.ContainsKey("serverIP")) { - int port = 0; + //int port = 0; //Int32.TryParse((string)kvp["serverPort"], out port); //IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)kvp["serverIP"]), port); ExternalHostName = (string)kvp["serverIP"]; @@ -295,6 +296,13 @@ namespace OpenSim.Services.Interfaces else ExternalHostName = "127.0.0.1"; + if (kvp.ContainsKey("serverPort")) + { + Int32 port = 0; + Int32.TryParse((string)kvp["serverPort"], out port); + InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), port); + } + if (kvp.ContainsKey("serverHttpPort")) { UInt32 port = 0; -- cgit v1.1 From 730458be1f8c74da1c112df36ec54233b30caed0 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 25 Sep 2009 14:31:29 +0100 Subject: minor: remove some mono compiler warnings --- OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs | 6 +++--- .../Services/AuthenticationService/PasswordAuthenticationService.cs | 6 +++--- .../Services/AuthenticationService/WebkeyAuthenticationService.cs | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs b/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs index 8904461..dcf090e 100644 --- a/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs +++ b/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs @@ -43,9 +43,9 @@ namespace OpenSim.Services.AuthenticationService // public class AuthenticationServiceBase : ServiceBase { - private static readonly ILog m_log = - LogManager.GetLogger( - MethodBase.GetCurrentMethod().DeclaringType); +// private static readonly ILog m_log = +// LogManager.GetLogger( +// MethodBase.GetCurrentMethod().DeclaringType); protected IAuthenticationData m_Database; diff --git a/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs b/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs index 6c99b66..d65665a 100644 --- a/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs +++ b/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs @@ -47,9 +47,9 @@ namespace OpenSim.Services.AuthenticationService public class PasswordAuthenticationService : AuthenticationServiceBase, IAuthenticationService { - private static readonly ILog m_log = - LogManager.GetLogger( - MethodBase.GetCurrentMethod().DeclaringType); +// private static readonly ILog m_log = +// LogManager.GetLogger( +// MethodBase.GetCurrentMethod().DeclaringType); public PasswordAuthenticationService(IConfigSource config) : base(config) diff --git a/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs b/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs index 8831c8a..d1a5b0f 100644 --- a/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs +++ b/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs @@ -43,9 +43,9 @@ namespace OpenSim.Services.AuthenticationService public class WebkeyAuthenticationService : AuthenticationServiceBase, IAuthenticationService { - private static readonly ILog m_log = - LogManager.GetLogger( - MethodBase.GetCurrentMethod().DeclaringType); +// private static readonly ILog m_log = +// LogManager.GetLogger( +// MethodBase.GetCurrentMethod().DeclaringType); public WebkeyAuthenticationService(IConfigSource config) : base(config) -- cgit v1.1 From 295868033f44edeb25230c2d4cf336c454693075 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 25 Sep 2009 07:47:58 -0700 Subject: Better error handling on the client-side grid connector. --- .../Connectors/Grid/GridServiceConnector.cs | 152 +++++++++++++++------ 1 file changed, 108 insertions(+), 44 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs index ebb66a7..748892a 100644 --- a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs +++ b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs @@ -99,18 +99,25 @@ namespace OpenSim.Services.Connectors string reqString = ServerUtils.BuildQueryString(sendData); //m_log.DebugFormat("[GRID CONNECTOR]: queryString = {0}", reqString); - string reply = SynchronousRestFormsRequester.MakeRequest("POST", - m_ServerURI + "/grid", - reqString); - if (reply != string.Empty) + try { - Dictionary replyData = ServerUtils.ParseXmlResponse(reply); + string reply = SynchronousRestFormsRequester.MakeRequest("POST", + m_ServerURI + "/grid", + reqString); + if (reply != string.Empty) + { + Dictionary replyData = ServerUtils.ParseXmlResponse(reply); - if ((replyData["Result"] != null) && (replyData["Result"].ToString().ToLower() == "success")) - return true; + if ((replyData["Result"] != null) && (replyData["Result"].ToString().ToLower() == "success")) + return true; + } + else + m_log.DebugFormat("[GRID CONNECTOR]: RegisterRegion received null reply"); + } + catch (Exception e) + { + m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message); } - else - m_log.DebugFormat("[GRID CONNECTOR]: RegisterRegion received null reply"); return false; } @@ -123,19 +130,26 @@ namespace OpenSim.Services.Connectors sendData["METHOD"] = "deregister"; - string reply = SynchronousRestFormsRequester.MakeRequest("POST", - m_ServerURI + "/grid", - ServerUtils.BuildQueryString(sendData)); - - if (reply != string.Empty) + try { - Dictionary replyData = ServerUtils.ParseXmlResponse(reply); + string reply = SynchronousRestFormsRequester.MakeRequest("POST", + m_ServerURI + "/grid", + ServerUtils.BuildQueryString(sendData)); + + if (reply != string.Empty) + { + Dictionary replyData = ServerUtils.ParseXmlResponse(reply); - if ((replyData["Result"] != null) && (replyData["Result"].ToString().ToLower() == "success")) - return true; + if ((replyData["Result"] != null) && (replyData["Result"].ToString().ToLower() == "success")) + return true; + } + else + m_log.DebugFormat("[GRID CONNECTOR]: DeregisterRegion received null reply"); + } + catch (Exception e) + { + m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message); } - else - m_log.DebugFormat("[GRID CONNECTOR]: DeregisterRegion received null reply"); return false; } @@ -149,14 +163,24 @@ namespace OpenSim.Services.Connectors sendData["METHOD"] = "get_neighbours"; + List rinfos = new List(); + string reqString = ServerUtils.BuildQueryString(sendData); - string reply = SynchronousRestFormsRequester.MakeRequest("POST", - m_ServerURI + "/grid", - reqString); + string reply = string.Empty; + try + { + reply = SynchronousRestFormsRequester.MakeRequest("POST", + m_ServerURI + "/grid", + reqString); + } + catch (Exception e) + { + m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message); + return rinfos; + } Dictionary replyData = ServerUtils.ParseXmlResponse(reply); - List rinfos = new List(); if (replyData != null) { Dictionary.ValueCollection rinfosList = replyData.Values; @@ -189,9 +213,18 @@ namespace OpenSim.Services.Connectors sendData["METHOD"] = "get_region_by_uuid"; - string reply = SynchronousRestFormsRequester.MakeRequest("POST", - m_ServerURI + "/grid", - ServerUtils.BuildQueryString(sendData)); + string reply = string.Empty; + try + { + reply = SynchronousRestFormsRequester.MakeRequest("POST", + m_ServerURI + "/grid", + ServerUtils.BuildQueryString(sendData)); + } + catch (Exception e) + { + m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message); + return null; + } GridRegion rinfo = null; @@ -226,10 +259,18 @@ namespace OpenSim.Services.Connectors sendData["Y"] = y.ToString(); sendData["METHOD"] = "get_region_by_position"; - - string reply = SynchronousRestFormsRequester.MakeRequest("POST", - m_ServerURI + "/grid", - ServerUtils.BuildQueryString(sendData)); + string reply = string.Empty; + try + { + reply = SynchronousRestFormsRequester.MakeRequest("POST", + m_ServerURI + "/grid", + ServerUtils.BuildQueryString(sendData)); + } + catch (Exception e) + { + m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message); + return null; + } GridRegion rinfo = null; if (reply != string.Empty) @@ -262,10 +303,18 @@ namespace OpenSim.Services.Connectors sendData["NAME"] = regionName; sendData["METHOD"] = "get_region_by_name"; - - string reply = SynchronousRestFormsRequester.MakeRequest("POST", - m_ServerURI + "/grid", - ServerUtils.BuildQueryString(sendData)); + string reply = string.Empty; + try + { + reply = SynchronousRestFormsRequester.MakeRequest("POST", + m_ServerURI + "/grid", + ServerUtils.BuildQueryString(sendData)); + } + catch (Exception e) + { + m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message); + return null; + } GridRegion rinfo = null; if (reply != string.Empty) @@ -296,12 +345,19 @@ namespace OpenSim.Services.Connectors sendData["MAX"] = maxNumber.ToString(); sendData["METHOD"] = "get_regions_by_name"; - - string reply = SynchronousRestFormsRequester.MakeRequest("POST", - m_ServerURI + "/grid", - ServerUtils.BuildQueryString(sendData)); - List rinfos = new List(); + string reply = string.Empty; + try + { + reply = SynchronousRestFormsRequester.MakeRequest("POST", + m_ServerURI + "/grid", + ServerUtils.BuildQueryString(sendData)); + } + catch (Exception e) + { + m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message); + return rinfos; + } if (reply != string.Empty) { @@ -345,12 +401,20 @@ namespace OpenSim.Services.Connectors sendData["METHOD"] = "get_region_range"; List rinfos = new List(); + string reply = string.Empty; + try + { + reply = SynchronousRestFormsRequester.MakeRequest("POST", + m_ServerURI + "/grid", + ServerUtils.BuildQueryString(sendData)); - string reply = SynchronousRestFormsRequester.MakeRequest("POST", - m_ServerURI + "/grid", - ServerUtils.BuildQueryString(sendData)); - - //m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply); + //m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply); + } + catch (Exception e) + { + m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message); + return rinfos; + } if (reply != string.Empty) { -- cgit v1.1 From 5757afe7665543e8b3ed4a322a7d6e095dafcdb3 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 26 Sep 2009 07:48:21 -0700 Subject: First pass at the heart surgery for grid services. Compiles and runs minimally. A few bugs to catch now. --- .../Connectors/Land/LandServiceConnector.cs | 13 +++++++---- .../Neighbour/NeighbourServiceConnector.cs | 16 ++++++++----- OpenSim/Services/Interfaces/IGridService.cs | 27 +++++++++++++++++----- 3 files changed, 39 insertions(+), 17 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/Connectors/Land/LandServiceConnector.cs b/OpenSim/Services/Connectors/Land/LandServiceConnector.cs index 0243f1f..06bc11c 100644 --- a/OpenSim/Services/Connectors/Land/LandServiceConnector.cs +++ b/OpenSim/Services/Connectors/Land/LandServiceConnector.cs @@ -38,6 +38,7 @@ using OpenSim.Framework.Servers.HttpServer; using OpenSim.Services.Interfaces; using OpenMetaverse; using Nwc.XmlRpc; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; namespace OpenSim.Services.Connectors { @@ -47,20 +48,20 @@ namespace OpenSim.Services.Connectors LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType); - protected IGridServices m_MapService = null; + protected IGridService m_GridService = null; public LandServicesConnector() { } - public LandServicesConnector(IGridServices gridServices) + public LandServicesConnector(IGridService gridServices) { Initialise(gridServices); } - public virtual void Initialise(IGridServices gridServices) + public virtual void Initialise(IGridService gridServices) { - m_MapService = gridServices; + m_GridService = gridServices; } public virtual LandData GetLandData(ulong regionHandle, uint x, uint y) @@ -76,7 +77,9 @@ namespace OpenSim.Services.Connectors try { - RegionInfo info = m_MapService.RequestNeighbourInfo(regionHandle); + uint xpos = 0, ypos = 0; + Utils.LongToUInts(regionHandle, out xpos, out ypos); + GridRegion info = m_GridService.GetRegionByPosition(UUID.Zero, (int)xpos, (int)ypos); if (info != null) // just to be sure { XmlRpcRequest request = new XmlRpcRequest("land_data", paramList); diff --git a/OpenSim/Services/Connectors/Neighbour/NeighbourServiceConnector.cs b/OpenSim/Services/Connectors/Neighbour/NeighbourServiceConnector.cs index 7fff537..1b595e7 100644 --- a/OpenSim/Services/Connectors/Neighbour/NeighbourServiceConnector.cs +++ b/OpenSim/Services/Connectors/Neighbour/NeighbourServiceConnector.cs @@ -41,6 +41,8 @@ using OpenSim.Services.Interfaces; using OpenMetaverse; using OpenMetaverse.StructuredData; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; + namespace OpenSim.Services.Connectors { public class NeighbourServicesConnector : INeighbourService @@ -49,25 +51,27 @@ namespace OpenSim.Services.Connectors LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType); - protected IGridServices m_MapService = null; + protected IGridService m_GridService = null; public NeighbourServicesConnector() { } - public NeighbourServicesConnector(IGridServices gridServices) + public NeighbourServicesConnector(IGridService gridServices) { Initialise(gridServices); } - public virtual void Initialise(IGridServices gridServices) + public virtual void Initialise(IGridService gridServices) { - m_MapService = gridServices; + m_GridService = gridServices; } public virtual bool HelloNeighbour(ulong regionHandle, RegionInfo thisRegion) { - RegionInfo regInfo = m_MapService.RequestNeighbourInfo(regionHandle); + uint x = 0, y = 0; + Utils.LongToUInts(regionHandle, out x, out y); + GridRegion regInfo = m_GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y); if ((regInfo != null) && // Don't remote-call this instance; that's a startup hickup !((regInfo.ExternalHostName == thisRegion.ExternalHostName) && (regInfo.HttpPort == thisRegion.HttpPort))) @@ -79,7 +83,7 @@ namespace OpenSim.Services.Connectors return false; } - public bool DoHelloNeighbourCall(RegionInfo region, RegionInfo thisRegion) + public bool DoHelloNeighbourCall(GridRegion region, RegionInfo thisRegion) { string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/region/" + thisRegion.RegionID + "/"; //m_log.Debug(" >>> DoHelloNeighbourCall <<< " + uri); diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs index ce432ab..96dc82b9 100644 --- a/OpenSim/Services/Interfaces/IGridService.cs +++ b/OpenSim/Services/Interfaces/IGridService.cs @@ -122,9 +122,6 @@ namespace OpenSim.Services.Interfaces } protected string m_regionName = String.Empty; - protected bool Allow_Alternate_Ports; - public bool m_allow_alternate_ports; - protected string m_externalHostName; protected IPEndPoint m_internalEndPoint; @@ -146,6 +143,10 @@ namespace OpenSim.Services.Interfaces public UUID RegionID = UUID.Zero; public UUID ScopeID = UUID.Zero; + public UUID TerrainImage = UUID.Zero; + public byte Access; + public int Maturity; + public GridRegion() { } @@ -183,9 +184,11 @@ namespace OpenSim.Services.Interfaces m_internalEndPoint = ConvertFrom.InternalEndPoint; m_externalHostName = ConvertFrom.ExternalHostName; m_httpPort = ConvertFrom.HttpPort; - m_allow_alternate_ports = ConvertFrom.m_allow_alternate_ports; - RegionID = UUID.Zero; + RegionID = ConvertFrom.RegionID; ServerURI = ConvertFrom.ServerURI; + TerrainImage = ConvertFrom.RegionSettings.TerrainImageID; + Access = ConvertFrom.AccessLevel; + Maturity = ConvertFrom.RegionSettings.Maturity; } @@ -268,7 +271,9 @@ namespace OpenSim.Services.Interfaces kvp["serverHttpPort"] = HttpPort.ToString(); kvp["serverURI"] = ServerURI; kvp["serverPort"] = InternalEndPoint.Port.ToString(); - + kvp["regionMapTexture"] = TerrainImage.ToString(); + kvp["access"] = Access.ToString(); + // Maturity doesn't seem to exist in the DB return kvp; } @@ -312,6 +317,16 @@ namespace OpenSim.Services.Interfaces if (kvp.ContainsKey("serverURI")) ServerURI = (string)kvp["serverURI"]; + + if (kvp.ContainsKey("regionMapTexture")) + { + UUID.TryParse((string)kvp["regionMapTexture"], out TerrainImage); + } + + if (kvp.ContainsKey("access")) + { + Access = Byte.Parse((string)kvp["access"]); ; + } } } -- cgit v1.1 From dcfd08b8dd57e667db8e0b5900da4648a020160e Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 26 Sep 2009 11:01:18 -0700 Subject: Fixed a bug with link-region. --- OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs index b5e8743..cf17557 100644 --- a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs +++ b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs @@ -66,7 +66,7 @@ namespace OpenSim.Services.Connectors.Grid IList paramList = new ArrayList(); paramList.Add(hash); - XmlRpcRequest request = new XmlRpcRequest("linkk_region", paramList); + XmlRpcRequest request = new XmlRpcRequest("link_region", paramList); string uri = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/"; m_log.Debug("[HGrid]: Linking to " + uri); XmlRpcResponse response = request.Send(uri, 10000); @@ -82,6 +82,7 @@ namespace OpenSim.Services.Connectors.Grid try { UUID.TryParse((string)hash["uuid"], out uuid); + m_log.Debug(">> HERE, uuid: " + uuid); info.RegionID = uuid; if ((string)hash["handle"] != null) { -- cgit v1.1 From f4bf581b96347b8d7f115eca74fa84a644eb729c Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 26 Sep 2009 21:00:51 -0700 Subject: Moved all HG1 operations to HGGridConnector.cs and HypergridServerConnector.cs/HypergridServiceConnector.cs, away from Region.Communications and HGNetworkServersInfo. Fixed small bugs with hyperlinked regions' map positions. --- .../Connectors/Grid/HypergridServiceConnector.cs | 89 ++++++++++++++++++++++ OpenSim/Services/Interfaces/IGridService.cs | 14 ++++ 2 files changed, 103 insertions(+) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs index cf17557..dd19b01 100644 --- a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs +++ b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs @@ -149,5 +149,94 @@ namespace OpenSim.Services.Connectors.Grid } } + public bool InformRegionOfUser(GridRegion regInfo, AgentCircuitData agentData, GridRegion home, string userServer, string assetServer, string inventoryServer) + { + string capsPath = agentData.CapsPath; + Hashtable loginParams = new Hashtable(); + loginParams["session_id"] = agentData.SessionID.ToString(); + + loginParams["firstname"] = agentData.firstname; + loginParams["lastname"] = agentData.lastname; + + loginParams["agent_id"] = agentData.AgentID.ToString(); + loginParams["circuit_code"] = agentData.circuitcode.ToString(); + loginParams["startpos_x"] = agentData.startpos.X.ToString(); + loginParams["startpos_y"] = agentData.startpos.Y.ToString(); + loginParams["startpos_z"] = agentData.startpos.Z.ToString(); + loginParams["caps_path"] = capsPath; + + if (home != null) + { + loginParams["region_uuid"] = home.RegionID.ToString(); + loginParams["regionhandle"] = home.RegionHandle.ToString(); + loginParams["home_address"] = home.ExternalHostName; + loginParams["home_port"] = home.HttpPort.ToString(); + loginParams["internal_port"] = home.InternalEndPoint.Port.ToString(); + + m_log.Debug(" --------- Home -------"); + m_log.Debug(" >> " + loginParams["home_address"] + " <<"); + m_log.Debug(" >> " + loginParams["region_uuid"] + " <<"); + m_log.Debug(" >> " + loginParams["regionhandle"] + " <<"); + m_log.Debug(" >> " + loginParams["home_port"] + " <<"); + m_log.Debug(" --------- ------------ -------"); + } + else + m_log.WarnFormat("[HGrid]: Home region not found for {0} {1}", agentData.firstname, agentData.lastname); + + loginParams["userserver_id"] = userServer; + loginParams["assetserver_id"] = assetServer; + loginParams["inventoryserver_id"] = inventoryServer; + + + ArrayList SendParams = new ArrayList(); + SendParams.Add(loginParams); + + // Send + string uri = "http://" + regInfo.ExternalHostName + ":" + regInfo.HttpPort + "/"; + //m_log.Debug("XXX uri: " + uri); + XmlRpcRequest request = new XmlRpcRequest("expect_hg_user", SendParams); + XmlRpcResponse reply; + try + { + reply = request.Send(uri, 6000); + } + catch (Exception e) + { + m_log.Warn("[HGrid]: Failed to notify region about user. Reason: " + e.Message); + return false; + } + + if (!reply.IsFault) + { + bool responseSuccess = true; + if (reply.Value != null) + { + Hashtable resp = (Hashtable)reply.Value; + if (resp.ContainsKey("success")) + { + if ((string)resp["success"] == "FALSE") + { + responseSuccess = false; + } + } + } + if (responseSuccess) + { + m_log.Info("[HGrid]: Successfully informed remote region about user " + agentData.AgentID); + return true; + } + else + { + m_log.ErrorFormat("[HGrid]: Region responded that it is not available to receive clients"); + return false; + } + } + else + { + m_log.ErrorFormat("[HGrid]: XmlRpc request to region failed with message {0}, code {1} ", reply.FaultString, reply.FaultCode); + return false; + } + } + } } diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs index 96dc82b9..c5495fb 100644 --- a/OpenSim/Services/Interfaces/IGridService.cs +++ b/OpenSim/Services/Interfaces/IGridService.cs @@ -191,6 +191,20 @@ namespace OpenSim.Services.Interfaces Maturity = ConvertFrom.RegionSettings.Maturity; } + public GridRegion(GridRegion ConvertFrom) + { + m_regionName = ConvertFrom.RegionName; + m_regionLocX = ConvertFrom.RegionLocX; + m_regionLocY = ConvertFrom.RegionLocY; + m_internalEndPoint = ConvertFrom.InternalEndPoint; + m_externalHostName = ConvertFrom.ExternalHostName; + m_httpPort = ConvertFrom.HttpPort; + RegionID = ConvertFrom.RegionID; + ServerURI = ConvertFrom.ServerURI; + TerrainImage = ConvertFrom.TerrainImage; + Access = ConvertFrom.Access; + Maturity = ConvertFrom.Maturity; + } /// /// This accessor can throw all the exceptions that Dns.GetHostAddresses can throw. -- cgit v1.1 From 5d09c53a1a42b38e1ee35cfbb5571d70b75380f4 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 27 Sep 2009 10:14:10 -0700 Subject: Unpacking the mess with OtherRegionUp, so we can have a real cache of the neighbours in the grid service modules. --- OpenSim/Services/Connectors/Neighbour/NeighbourServiceConnector.cs | 6 +++--- OpenSim/Services/Interfaces/INeighbourService.cs | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/Connectors/Neighbour/NeighbourServiceConnector.cs b/OpenSim/Services/Connectors/Neighbour/NeighbourServiceConnector.cs index 1b595e7..145f212 100644 --- a/OpenSim/Services/Connectors/Neighbour/NeighbourServiceConnector.cs +++ b/OpenSim/Services/Connectors/Neighbour/NeighbourServiceConnector.cs @@ -67,7 +67,7 @@ namespace OpenSim.Services.Connectors m_GridService = gridServices; } - public virtual bool HelloNeighbour(ulong regionHandle, RegionInfo thisRegion) + public virtual GridRegion HelloNeighbour(ulong regionHandle, RegionInfo thisRegion) { uint x = 0, y = 0; Utils.LongToUInts(regionHandle, out x, out y); @@ -76,11 +76,11 @@ namespace OpenSim.Services.Connectors // Don't remote-call this instance; that's a startup hickup !((regInfo.ExternalHostName == thisRegion.ExternalHostName) && (regInfo.HttpPort == thisRegion.HttpPort))) { - return DoHelloNeighbourCall(regInfo, thisRegion); + DoHelloNeighbourCall(regInfo, thisRegion); } //else // m_log.Warn("[REST COMMS]: Region not found " + regionHandle); - return false; + return regInfo; } public bool DoHelloNeighbourCall(GridRegion region, RegionInfo thisRegion) diff --git a/OpenSim/Services/Interfaces/INeighbourService.cs b/OpenSim/Services/Interfaces/INeighbourService.cs index 3944486..960e13d 100644 --- a/OpenSim/Services/Interfaces/INeighbourService.cs +++ b/OpenSim/Services/Interfaces/INeighbourService.cs @@ -28,11 +28,12 @@ using System; using OpenSim.Framework; using OpenMetaverse; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; namespace OpenSim.Services.Interfaces { public interface INeighbourService { - bool HelloNeighbour(ulong regionHandle, RegionInfo thisRegion); + GridRegion HelloNeighbour(ulong regionHandle, RegionInfo otherRegion); } } -- cgit v1.1 From c99b363f81331988ede8fa5e19306073cbb1c58b Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 27 Sep 2009 13:59:00 -0700 Subject: Added missing IHyperlinkService. --- OpenSim/Services/Interfaces/IHyperlink.cs | 49 +++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 OpenSim/Services/Interfaces/IHyperlink.cs (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/Interfaces/IHyperlink.cs b/OpenSim/Services/Interfaces/IHyperlink.cs new file mode 100644 index 0000000..ed3ff23 --- /dev/null +++ b/OpenSim/Services/Interfaces/IHyperlink.cs @@ -0,0 +1,49 @@ +/* + * 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 OpenSim.Framework; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; + +using OpenMetaverse; + +namespace OpenSim.Services.Interfaces +{ + public interface IHyperlinkService + { + GridRegion TryLinkRegion(IClientAPI client, string regionDescriptor); + GridRegion GetHyperlinkRegion(ulong handle); + ulong FindRegionHandle(ulong handle); + + bool SendUserInformation(GridRegion region, AgentCircuitData aCircuit); + void AdjustUserInformation(AgentCircuitData aCircuit); + + bool CheckUserAtEntry(UUID userID, UUID sessionID, out bool comingHome); + void AcceptUser(ForeignUserProfileData user, GridRegion home); + + bool IsLocalUser(UUID userID); + } +} -- cgit v1.1 From 500cd3505a4213363e001426f2286c1a958d345c Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 28 Sep 2009 07:20:38 -0700 Subject: Added RegionSecret to GridRegion, and corresponding saving/retrieval from DB layer. This sounds fishy to me, but it's what's used to make external currency modules work, for now. --- OpenSim/Services/Interfaces/IGridService.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs index c5495fb..46a7f09 100644 --- a/OpenSim/Services/Interfaces/IGridService.cs +++ b/OpenSim/Services/Interfaces/IGridService.cs @@ -146,6 +146,7 @@ namespace OpenSim.Services.Interfaces public UUID TerrainImage = UUID.Zero; public byte Access; public int Maturity; + public string RegionSecret; public GridRegion() { @@ -189,6 +190,7 @@ namespace OpenSim.Services.Interfaces TerrainImage = ConvertFrom.RegionSettings.TerrainImageID; Access = ConvertFrom.AccessLevel; Maturity = ConvertFrom.RegionSettings.Maturity; + RegionSecret = ConvertFrom.regionSecret; } public GridRegion(GridRegion ConvertFrom) @@ -204,6 +206,7 @@ namespace OpenSim.Services.Interfaces TerrainImage = ConvertFrom.TerrainImage; Access = ConvertFrom.Access; Maturity = ConvertFrom.Maturity; + RegionSecret = ConvertFrom.RegionSecret; } /// @@ -287,6 +290,7 @@ namespace OpenSim.Services.Interfaces kvp["serverPort"] = InternalEndPoint.Port.ToString(); kvp["regionMapTexture"] = TerrainImage.ToString(); kvp["access"] = Access.ToString(); + kvp["regionSecret"] = RegionSecret; // Maturity doesn't seem to exist in the DB return kvp; } @@ -333,14 +337,14 @@ namespace OpenSim.Services.Interfaces ServerURI = (string)kvp["serverURI"]; if (kvp.ContainsKey("regionMapTexture")) - { UUID.TryParse((string)kvp["regionMapTexture"], out TerrainImage); - } if (kvp.ContainsKey("access")) - { - Access = Byte.Parse((string)kvp["access"]); ; - } + Access = Byte.Parse((string)kvp["access"]); + + if (kvp.ContainsKey("regionSecret")) + RegionSecret =(string)kvp["regionSecret"]; + } } -- cgit v1.1 From 9bdb585a93f824223f20f248e1411ba6da760624 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 28 Sep 2009 10:56:05 -0700 Subject: Added Protocol versions back, this time in a range model. --- OpenSim/Services/Connectors/Grid/GridServiceConnector.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs index 748892a..ba46b0d 100644 --- a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs +++ b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs @@ -94,7 +94,8 @@ namespace OpenSim.Services.Connectors sendData[kvp.Key] = (string)kvp.Value; sendData["SCOPEID"] = scopeID.ToString(); - + sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString(); + sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString(); sendData["METHOD"] = "register"; string reqString = ServerUtils.BuildQueryString(sendData); -- cgit v1.1 From 6653a30487d76760451467a22849aba725f1e7cf Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 28 Sep 2009 20:58:21 -0700 Subject: Fixed bug in HG that was causing secondlife:// refs to bomb the client. Also fiddled a bit more with the initial CAP in the user server. --- .../Services/Connectors/Grid/HypergridServiceConnector.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs index dd19b01..3d7f112 100644 --- a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs +++ b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs @@ -69,7 +69,17 @@ namespace OpenSim.Services.Connectors.Grid XmlRpcRequest request = new XmlRpcRequest("link_region", paramList); string uri = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/"; m_log.Debug("[HGrid]: Linking to " + uri); - XmlRpcResponse response = request.Send(uri, 10000); + XmlRpcResponse response = null; + try + { + response = request.Send(uri, 10000); + } + catch (Exception e) + { + m_log.Debug("[HGrid]: Exception " + e.Message); + return uuid; + } + if (response.IsFault) { m_log.ErrorFormat("[HGrid]: remote call returned an error: {0}", response.FaultString); -- cgit v1.1 From ee205e7e812e170f670e690a4e0fa9caa652f226 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Thu, 1 Oct 2009 01:00:09 +0900 Subject: Formatting cleanup. --- OpenSim/Services/AssetService/AssetService.cs | 4 ++-- .../Connectors/Authorization/AuthorizationServiceConnector.cs | 2 +- OpenSim/Services/Interfaces/IGridService.cs | 2 +- OpenSim/Services/InventoryService/InventoryService.cs | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/AssetService/AssetService.cs b/OpenSim/Services/AssetService/AssetService.cs index 88a905c..ebfd47a 100644 --- a/OpenSim/Services/AssetService/AssetService.cs +++ b/OpenSim/Services/AssetService/AssetService.cs @@ -155,7 +155,7 @@ namespace OpenSim.Services.AssetService AssetBase asset = Get(args[2]); if (asset == null || asset.Data.Length == 0) - { + { MainConsole.Instance.Output("Asset not found"); return; } @@ -195,7 +195,7 @@ namespace OpenSim.Services.AssetService AssetBase asset = Get(args[2]); if (asset == null || asset.Data.Length == 0) - { + { MainConsole.Instance.Output("Asset not found"); return; } diff --git a/OpenSim/Services/Connectors/Authorization/AuthorizationServiceConnector.cs b/OpenSim/Services/Connectors/Authorization/AuthorizationServiceConnector.cs index 3167352..7926efb 100644 --- a/OpenSim/Services/Connectors/Authorization/AuthorizationServiceConnector.cs +++ b/OpenSim/Services/Connectors/Authorization/AuthorizationServiceConnector.cs @@ -113,7 +113,7 @@ namespace OpenSim.Services.Connectors message = response.Message; return response.IsAuthorized; - } + } } } diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs index 46a7f09..2290530 100644 --- a/OpenSim/Services/Interfaces/IGridService.cs +++ b/OpenSim/Services/Interfaces/IGridService.cs @@ -50,7 +50,7 @@ namespace OpenSim.Services.Interfaces /// /// /// Thrown if region deregistration failed - bool DeregisterRegion(UUID regionID); + bool DeregisterRegion(UUID regionID); /// /// Get information about the regions neighbouring the given co-ordinates (in meters). diff --git a/OpenSim/Services/InventoryService/InventoryService.cs b/OpenSim/Services/InventoryService/InventoryService.cs index b98e256..70c55a5 100644 --- a/OpenSim/Services/InventoryService/InventoryService.cs +++ b/OpenSim/Services/InventoryService/InventoryService.cs @@ -251,7 +251,7 @@ namespace OpenSim.Services.InventoryService m_log.DebugFormat("[INVENTORY SERVICE]: Found {0} items and {1} folders in folder {2}", items.Count, folders.Count, folderID); - return invCollection; + return invCollection; } public InventoryFolderBase GetFolderForType(UUID userID, AssetType type) -- cgit v1.1 From 26478ff6892ccb32741588a7854d23cd62a13716 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 1 Oct 2009 21:26:53 +0100 Subject: Add "dump asset" command to remote asset connector (the only one that uses a cache at all) --- .../Connectors/Asset/AssetServiceConnector.cs | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs b/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs index ffc8e4c..d16112d 100644 --- a/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs +++ b/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs @@ -32,9 +32,11 @@ using System.IO; using System.Reflection; using Nini.Config; using OpenSim.Framework; +using OpenSim.Framework.Console; using OpenSim.Framework.Communications; using OpenSim.Framework.Servers.HttpServer; using OpenSim.Services.Interfaces; +using OpenMetaverse; namespace OpenSim.Services.Connectors { @@ -79,6 +81,10 @@ namespace OpenSim.Services.Connectors throw new Exception("Asset connector init error"); } m_ServerURI = serviceURI; + + MainConsole.Instance.Commands.AddCommand("asset", false, "dump asset", + "dump asset ", + "dump one cached asset", HandleDumpAsset); } protected void SetCache(IImprovedAssetCache cache) @@ -264,5 +270,43 @@ namespace OpenSim.Services.Connectors } return false; } + + private void HandleDumpAsset(string module, string[] args) + { + if (args.Length != 4) + { + MainConsole.Instance.Output("Syntax: dump asset "); + return; + } + + UUID assetID; + + if (!UUID.TryParse(args[2], out assetID)) + { + MainConsole.Instance.Output("Invalid asset ID"); + return; + } + + if (m_Cache == null) + { + MainConsole.Instance.Output("Instance uses no cache"); + return; + } + + AssetBase asset = asset = m_Cache.Get(assetID.ToString()); + + if (asset == null) + { + MainConsole.Instance.Output("Asset not found in cache"); + return; + } + + string fileName = args[3]; + + FileStream fs = File.Create(fileName); + fs.Write(asset.Data, 0, asset.Data.Length); + + fs.Close(); + } } } -- cgit v1.1