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/GridService/GridService.cs | 297 ++++++++++++++++++++++++ OpenSim/Services/GridService/GridServiceBase.cs | 84 +++++++ 2 files changed, 381 insertions(+) create mode 100644 OpenSim/Services/GridService/GridService.cs create mode 100644 OpenSim/Services/GridService/GridServiceBase.cs (limited to 'OpenSim/Services/GridService') 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"); + + } + } +} -- 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/GridService') 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 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. --- OpenSim/Services/GridService/GridService.cs | 65 +++++------------------------ 1 file changed, 11 insertions(+), 54 deletions(-) (limited to 'OpenSim/Services/GridService') 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; } -- 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/GridService') 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 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. --- OpenSim/Services/GridService/GridService.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Services/GridService') 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 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. --- OpenSim/Services/GridService/GridService.cs | 32 +++++++++++++------------ OpenSim/Services/GridService/GridServiceBase.cs | 2 +- 2 files changed, 18 insertions(+), 16 deletions(-) (limited to 'OpenSim/Services/GridService') 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. // -- 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/GridService') 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/GridService/GridService.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'OpenSim/Services/GridService') 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 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 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'OpenSim/Services/GridService') 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; } -- 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/GridService') 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 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'OpenSim/Services/GridService') 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); -- cgit v1.1