Changed IGridService to use the new GridRegion data structure instead of old SimpleRegionInfo.

Added grid configs to standalones.
remotes/origin/0.6.7-post-fixes
Diva Canto 2009-09-23 17:20:07 -07:00
parent b8f039897b
commit 67276589c8
13 changed files with 371 additions and 120 deletions

View File

@ -40,6 +40,7 @@ namespace OpenSim.Data.Null
public NullRegionData(string connectionString, string realm) public NullRegionData(string connectionString, string realm)
{ {
Console.WriteLine("[XXX] NullRegionData constructor");
} }
public List<RegionData> Get(string regionName, UUID scopeID) public List<RegionData> Get(string regionName, UUID scopeID)

View File

@ -37,6 +37,7 @@ using OpenSim.Framework.Console;
using OpenSim.Region.Framework; using OpenSim.Region.Framework;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Scenes.Hypergrid; using OpenSim.Region.Framework.Scenes.Hypergrid;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
{ {
@ -121,12 +122,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
if (cmdparams[2].Contains(":")) if (cmdparams[2].Contains(":"))
{ {
// New format // New format
uint xloc, yloc; int xloc, yloc;
string mapName; string mapName;
try try
{ {
xloc = Convert.ToUInt32(cmdparams[0]); xloc = Convert.ToInt32(cmdparams[0]);
yloc = Convert.ToUInt32(cmdparams[1]); yloc = Convert.ToInt32(cmdparams[1]);
mapName = cmdparams[2]; mapName = cmdparams[2];
if (cmdparams.Length > 3) if (cmdparams.Length > 3)
for (int i = 3; i < cmdparams.Length; i++) for (int i = 3; i < cmdparams.Length; i++)
@ -143,19 +144,22 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
return; return;
} }
// Convert cell coordinates given by the user to meters
xloc = xloc * (int)Constants.RegionSize;
yloc = yloc * (int)Constants.RegionSize;
m_HGGridConnector.TryLinkRegionToCoords(m_scene, null, mapName, xloc, yloc); m_HGGridConnector.TryLinkRegionToCoords(m_scene, null, mapName, xloc, yloc);
} }
else else
{ {
// old format // old format
SimpleRegionInfo regInfo; GridRegion regInfo;
uint xloc, yloc; int xloc, yloc;
uint externalPort; uint externalPort;
string externalHostName; string externalHostName;
try try
{ {
xloc = Convert.ToUInt32(cmdparams[0]); xloc = Convert.ToInt32(cmdparams[0]);
yloc = Convert.ToUInt32(cmdparams[1]); yloc = Convert.ToInt32(cmdparams[1]);
externalPort = Convert.ToUInt32(cmdparams[3]); externalPort = Convert.ToUInt32(cmdparams[3]);
externalHostName = cmdparams[2]; externalHostName = cmdparams[2];
//internalPort = Convert.ToUInt32(cmdparams[4]); //internalPort = Convert.ToUInt32(cmdparams[4]);
@ -168,7 +172,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
return; return;
} }
//if (TryCreateLink(xloc, yloc, externalPort, externalHostName, out regInfo)) // Convert cell coordinates given by the user to meters
xloc = xloc * (int)Constants.RegionSize;
yloc = yloc * (int)Constants.RegionSize;
if (m_HGGridConnector.TryCreateLink(m_scene, null, xloc, yloc, "", externalPort, externalHostName, out regInfo)) if (m_HGGridConnector.TryCreateLink(m_scene, null, xloc, yloc, "", externalPort, externalHostName, out regInfo))
{ {
if (cmdparams.Length >= 5) if (cmdparams.Length >= 5)
@ -245,14 +251,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
private void ReadLinkFromConfig(IConfig config) private void ReadLinkFromConfig(IConfig config)
{ {
SimpleRegionInfo regInfo; GridRegion regInfo;
uint xloc, yloc; int xloc, yloc;
uint externalPort; uint externalPort;
string externalHostName; string externalHostName;
uint realXLoc, realYLoc; uint realXLoc, realYLoc;
xloc = Convert.ToUInt32(config.GetString("xloc", "0")); xloc = Convert.ToInt32(config.GetString("xloc", "0"));
yloc = Convert.ToUInt32(config.GetString("yloc", "0")); yloc = Convert.ToInt32(config.GetString("yloc", "0"));
externalPort = Convert.ToUInt32(config.GetString("externalPort", "0")); externalPort = Convert.ToUInt32(config.GetString("externalPort", "0"));
externalHostName = config.GetString("externalHostName", ""); externalHostName = config.GetString("externalHostName", "");
realXLoc = Convert.ToUInt32(config.GetString("real-xloc", "0")); realXLoc = Convert.ToUInt32(config.GetString("real-xloc", "0"));
@ -260,14 +266,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
if (m_enableAutoMapping) if (m_enableAutoMapping)
{ {
xloc = (uint)((xloc % 100) + m_autoMappingX); xloc = (int)((xloc % 100) + m_autoMappingX);
yloc = (uint)((yloc % 100) + m_autoMappingY); yloc = (int)((yloc % 100) + m_autoMappingY);
} }
if (((realXLoc == 0) && (realYLoc == 0)) || if (((realXLoc == 0) && (realYLoc == 0)) ||
(((realXLoc - xloc < 3896) || (xloc - realXLoc < 3896)) && (((realXLoc - xloc < 3896) || (xloc - realXLoc < 3896)) &&
((realYLoc - yloc < 3896) || (yloc - realYLoc < 3896)))) ((realYLoc - yloc < 3896) || (yloc - realYLoc < 3896))))
{ {
xloc = xloc * (int)Constants.RegionSize;
yloc = yloc * (int)Constants.RegionSize;
if ( if (
m_HGGridConnector.TryCreateLink(m_scene, null, xloc, yloc, "", externalPort, m_HGGridConnector.TryCreateLink(m_scene, null, xloc, yloc, "", externalPort,
externalHostName, out regInfo)) externalHostName, out regInfo))

View File

@ -36,6 +36,7 @@ using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Scenes.Hypergrid; using OpenSim.Region.Framework.Scenes.Hypergrid;
using OpenSim.Services.Interfaces; using OpenSim.Services.Interfaces;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
using OpenSim.Server.Base; using OpenSim.Server.Base;
using OpenSim.Services.Connectors.Grid; using OpenSim.Services.Connectors.Grid;
using OpenSim.Framework.Console; using OpenSim.Framework.Console;
@ -59,13 +60,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
private HypergridServiceConnector m_HypergridServiceConnector; private HypergridServiceConnector m_HypergridServiceConnector;
// Hyperlink regions are hyperlinks on the map // Hyperlink regions are hyperlinks on the map
protected Dictionary<UUID, SimpleRegionInfo> m_HyperlinkRegions = new Dictionary<UUID, SimpleRegionInfo>(); protected Dictionary<UUID, GridRegion> m_HyperlinkRegions = new Dictionary<UUID, GridRegion>();
// Known regions are home regions of visiting foreign users. // Known regions are home regions of visiting foreign users.
// They are not on the map as static hyperlinks. They are dynamic hyperlinks, they go away when // They are not on the map as static hyperlinks. They are dynamic hyperlinks, they go away when
// the visitor goes away. They are mapped to X=0 on the map. // the visitor goes away. They are mapped to X=0 on the map.
// This is key-ed on agent ID // This is key-ed on agent ID
protected Dictionary<UUID, SimpleRegionInfo> m_knownRegions = new Dictionary<UUID, SimpleRegionInfo>(); protected Dictionary<UUID, GridRegion> m_knownRegions = new Dictionary<UUID, GridRegion>();
protected Dictionary<UUID, ulong> m_HyperlinkHandles = new Dictionary<UUID, ulong>(); protected Dictionary<UUID, ulong> m_HyperlinkHandles = new Dictionary<UUID, ulong>();
@ -184,7 +185,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
#region IGridService #region IGridService
public bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfo) public bool RegisterRegion(UUID scopeID, GridRegion regionInfo)
{ {
// Region doesn't exist here. Trying to link remote region // Region doesn't exist here. Trying to link remote region
if (regionInfo.RegionID.Equals(UUID.Zero)) if (regionInfo.RegionID.Equals(UUID.Zero))
@ -222,7 +223,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
} }
// Try the foreign users home collection // Try the foreign users home collection
foreach (SimpleRegionInfo r in m_knownRegions.Values) foreach (GridRegion r in m_knownRegions.Values)
if (r.RegionID == regionID) if (r.RegionID == regionID)
{ {
RemoveHyperlinkHomeRegion(regionID); RemoveHyperlinkHomeRegion(regionID);
@ -233,21 +234,21 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
return m_GridServiceConnector.DeregisterRegion(regionID); return m_GridServiceConnector.DeregisterRegion(regionID);
} }
public List<SimpleRegionInfo> GetNeighbours(UUID scopeID, UUID regionID) public List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID)
{ {
// No serving neighbours on hyperliked regions. // No serving neighbours on hyperliked regions.
// Just the regular regions. // Just the regular regions.
return m_GridServiceConnector.GetNeighbours(scopeID, regionID); return m_GridServiceConnector.GetNeighbours(scopeID, regionID);
} }
public SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID) public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
{ {
// Try the hyperlink collection // Try the hyperlink collection
if (m_HyperlinkRegions.ContainsKey(regionID)) if (m_HyperlinkRegions.ContainsKey(regionID))
return m_HyperlinkRegions[regionID]; return m_HyperlinkRegions[regionID];
// Try the foreign users home collection // Try the foreign users home collection
foreach (SimpleRegionInfo r in m_knownRegions.Values) foreach (GridRegion r in m_knownRegions.Values)
if (r.RegionID == regionID) if (r.RegionID == regionID)
return m_knownRegions[regionID]; return m_knownRegions[regionID];
@ -255,19 +256,19 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
return m_GridServiceConnector.GetRegionByUUID(scopeID, regionID); return m_GridServiceConnector.GetRegionByUUID(scopeID, regionID);
} }
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 snapX = (int) (x / Constants.RegionSize) * (int)Constants.RegionSize;
int snapY = (int) (y / Constants.RegionSize) * (int)Constants.RegionSize; int snapY = (int) (y / Constants.RegionSize) * (int)Constants.RegionSize;
// Try the hyperlink collection // Try the hyperlink collection
foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values) foreach (GridRegion r in m_HyperlinkRegions.Values)
{ {
if ((r.RegionLocX == snapX) && (r.RegionLocY == snapY)) if ((r.RegionLocX == snapX) && (r.RegionLocY == snapY))
return r; return r;
} }
// Try the foreign users home collection // Try the foreign users home collection
foreach (SimpleRegionInfo r in m_knownRegions.Values) foreach (GridRegion r in m_knownRegions.Values)
{ {
if ((r.RegionLocX == snapX) && (r.RegionLocY == snapY)) if ((r.RegionLocX == snapX) && (r.RegionLocY == snapY))
return r; return r;
@ -277,22 +278,22 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
return m_GridServiceConnector.GetRegionByPosition(scopeID, x, y); return m_GridServiceConnector.GetRegionByPosition(scopeID, x, y);
} }
public SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName) public GridRegion GetRegionByName(UUID scopeID, string regionName)
{ {
// Try normal grid first // Try normal grid first
SimpleRegionInfo region = m_GridServiceConnector.GetRegionByName(scopeID, regionName); GridRegion region = m_GridServiceConnector.GetRegionByName(scopeID, regionName);
if (region != null) if (region != null)
return region; return region;
// Try the hyperlink collection // Try the hyperlink collection
foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values) foreach (GridRegion r in m_HyperlinkRegions.Values)
{ {
if (r.RegionName == regionName) if (r.RegionName == regionName)
return r; return r;
} }
// Try the foreign users home collection // Try the foreign users home collection
foreach (SimpleRegionInfo r in m_knownRegions.Values) foreach (GridRegion r in m_knownRegions.Values)
{ {
if (r.RegionName == regionName) if (r.RegionName == regionName)
return r; return r;
@ -300,9 +301,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
return null; return null;
} }
public List<SimpleRegionInfo> GetRegionsByName(UUID scopeID, string name, int maxNumber) public List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber)
{ {
List<SimpleRegionInfo> rinfos = new List<SimpleRegionInfo>(); List<GridRegion> rinfos = new List<GridRegion>();
// Commenting until regionname exists // Commenting until regionname exists
//foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values) //foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values)
@ -313,15 +314,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
return rinfos; return rinfos;
} }
public List<SimpleRegionInfo> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) public List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax)
{ {
int snapXmin = (int)(xmin / Constants.RegionSize) * (int)Constants.RegionSize; int snapXmin = (int)(xmin / Constants.RegionSize) * (int)Constants.RegionSize;
int snapXmax = (int)(xmax / Constants.RegionSize) * (int)Constants.RegionSize; int snapXmax = (int)(xmax / Constants.RegionSize) * (int)Constants.RegionSize;
int snapYmin = (int)(ymin / Constants.RegionSize) * (int)Constants.RegionSize; int snapYmin = (int)(ymin / Constants.RegionSize) * (int)Constants.RegionSize;
int snapYmax = (int)(ymax / Constants.RegionSize) * (int)Constants.RegionSize; int snapYmax = (int)(ymax / Constants.RegionSize) * (int)Constants.RegionSize;
List<SimpleRegionInfo> rinfos = new List<SimpleRegionInfo>(); List<GridRegion> rinfos = new List<GridRegion>();
foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values) foreach (GridRegion r in m_HyperlinkRegions.Values)
if ((r.RegionLocX > snapXmin) && (r.RegionLocX < snapYmax) && if ((r.RegionLocX > snapXmin) && (r.RegionLocX < snapYmax) &&
(r.RegionLocY > snapYmin) && (r.RegionLocY < snapYmax)) (r.RegionLocY > snapYmin) && (r.RegionLocY < snapYmax))
rinfos.Add(r); rinfos.Add(r);
@ -335,7 +336,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
#region Auxiliary #region Auxiliary
private void AddHyperlinkRegion(SimpleRegionInfo regionInfo, ulong regionHandle) private void AddHyperlinkRegion(GridRegion regionInfo, ulong regionHandle)
{ {
m_HyperlinkRegions.Add(regionInfo.RegionID, regionInfo); m_HyperlinkRegions.Add(regionInfo.RegionID, regionInfo);
m_HyperlinkHandles.Add(regionInfo.RegionID, regionHandle); m_HyperlinkHandles.Add(regionInfo.RegionID, regionHandle);
@ -347,7 +348,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
m_HyperlinkHandles.Remove(regionID); m_HyperlinkHandles.Remove(regionID);
} }
private void AddHyperlinkHomeRegion(UUID userID, SimpleRegionInfo regionInfo, ulong regionHandle) private void AddHyperlinkHomeRegion(UUID userID, GridRegion regionInfo, ulong regionHandle)
{ {
m_knownRegions.Add(userID, regionInfo); m_knownRegions.Add(userID, regionInfo);
m_HyperlinkHandles.Add(regionInfo.RegionID, regionHandle); m_HyperlinkHandles.Add(regionInfo.RegionID, regionHandle);
@ -355,7 +356,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
private void RemoveHyperlinkHomeRegion(UUID regionID) private void RemoveHyperlinkHomeRegion(UUID regionID)
{ {
foreach (KeyValuePair<UUID, SimpleRegionInfo> kvp in m_knownRegions) foreach (KeyValuePair<UUID, GridRegion> kvp in m_knownRegions)
{ {
if (kvp.Value.RegionID == regionID) if (kvp.Value.RegionID == regionID)
{ {
@ -370,7 +371,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
private static Random random = new Random(); private static Random random = new Random();
public SimpleRegionInfo TryLinkRegionToCoords(Scene m_scene, IClientAPI client, string mapName, uint xloc, uint yloc) public GridRegion TryLinkRegionToCoords(Scene m_scene, IClientAPI client, string mapName, int xloc, int yloc)
{ {
string host = "127.0.0.1"; string host = "127.0.0.1";
string portstr; string portstr;
@ -404,7 +405,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
if ((ipaddr != null) && if ((ipaddr != null) &&
!((m_scene.RegionInfo.ExternalEndPoint.Address.Equals(ipaddr)) && (m_scene.RegionInfo.HttpPort == port))) !((m_scene.RegionInfo.ExternalEndPoint.Address.Equals(ipaddr)) && (m_scene.RegionInfo.HttpPort == port)))
{ {
SimpleRegionInfo regInfo; GridRegion regInfo;
bool success = TryCreateLink(m_scene, client, xloc, yloc, regionName, port, host, out regInfo); bool success = TryCreateLink(m_scene, client, xloc, yloc, regionName, port, host, out regInfo);
if (success) if (success)
{ {
@ -417,18 +418,18 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
} }
// From the map search and secondlife://blah // From the map search and secondlife://blah
public SimpleRegionInfo TryLinkRegion(Scene m_scene, IClientAPI client, string mapName) public GridRegion TryLinkRegion(Scene m_scene, IClientAPI client, string mapName)
{ {
uint xloc = (uint)(random.Next(0, Int16.MaxValue)); int xloc = random.Next(0, Int16.MaxValue);
return TryLinkRegionToCoords(m_scene, client, mapName, xloc, 0); return TryLinkRegionToCoords(m_scene, client, mapName, xloc, 0);
} }
public bool TryCreateLink(Scene m_scene, IClientAPI client, uint xloc, uint yloc, public bool TryCreateLink(Scene m_scene, IClientAPI client, int xloc, int yloc,
string externalRegionName, uint externalPort, string externalHostName, out SimpleRegionInfo regInfo) string externalRegionName, uint externalPort, string externalHostName, out GridRegion regInfo)
{ {
m_log.DebugFormat("[HGrid]: Link to {0}:{1}, in {2}-{3}", externalHostName, externalPort, xloc, yloc); m_log.DebugFormat("[HGrid]: Link to {0}:{1}, in {2}-{3}", externalHostName, externalPort, xloc, yloc);
regInfo = new SimpleRegionInfo(); regInfo = new GridRegion();
regInfo.RegionName = externalRegionName; regInfo.RegionName = externalRegionName;
regInfo.HttpPort = externalPort; regInfo.HttpPort = externalPort;
regInfo.ExternalHostName = externalHostName; regInfo.ExternalHostName = externalHostName;
@ -456,7 +457,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
return false; return false;
} }
uint x, y; int x, y;
if (!Check4096(m_scene, regInfo, out x, out y)) if (!Check4096(m_scene, regInfo, out x, out y))
{ {
DeregisterRegion(regInfo.RegionID); DeregisterRegion(regInfo.RegionID);
@ -481,7 +482,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
public bool TryUnlinkRegion(Scene m_scene, string mapName) public bool TryUnlinkRegion(Scene m_scene, string mapName)
{ {
SimpleRegionInfo regInfo = null; GridRegion regInfo = null;
if (mapName.Contains(":")) if (mapName.Contains(":"))
{ {
string host = "127.0.0.1"; string host = "127.0.0.1";
@ -504,13 +505,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
// { // {
// regionName = parts[2]; // regionName = parts[2];
// } // }
foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values) foreach (GridRegion r in m_HyperlinkRegions.Values)
if (host.Equals(r.ExternalHostName) && (port == r.HttpPort)) if (host.Equals(r.ExternalHostName) && (port == r.HttpPort))
regInfo = r; regInfo = r;
} }
else else
{ {
foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values) foreach (GridRegion r in m_HyperlinkRegions.Values)
if (r.RegionName.Equals(mapName)) if (r.RegionName.Equals(mapName))
regInfo = r; regInfo = r;
} }
@ -530,22 +531,23 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
/// </summary> /// </summary>
/// <param name="regInfo"></param> /// <param name="regInfo"></param>
/// <returns></returns> /// <returns></returns>
public bool Check4096(Scene m_scene, SimpleRegionInfo regInfo, out uint x, out uint y) public bool Check4096(Scene m_scene, GridRegion regInfo, out int x, out int y)
{ {
ulong realHandle = m_HyperlinkHandles[regInfo.RegionID]; ulong realHandle = m_HyperlinkHandles[regInfo.RegionID];
Utils.LongToUInts(realHandle, out x, out y); uint ux = 0, uy = 0;
x = x / Constants.RegionSize; Utils.LongToUInts(realHandle, out ux, out uy);
y = y / Constants.RegionSize; x = (int)(ux / Constants.RegionSize);
y = (int)(uy / Constants.RegionSize);
if ((Math.Abs((int)m_scene.RegionInfo.RegionLocX - (int)x) >= 4096) || if ((Math.Abs((int)(m_scene.RegionInfo.RegionLocX / Constants.RegionSize) - x) >= 4096) ||
(Math.Abs((int)m_scene.RegionInfo.RegionLocY - (int)y) >= 4096)) (Math.Abs((int)(m_scene.RegionInfo.RegionLocY / Constants.RegionSize) - y) >= 4096))
{ {
return false; return false;
} }
return true; return true;
} }
public bool CheckCoords(uint thisx, uint thisy, uint x, uint y) public bool CheckCoords(uint thisx, uint thisy, int x, int y)
{ {
if ((thisx == x) && (thisy == y)) if ((thisx == x) && (thisy == y))
return false; return false;

View File

@ -35,6 +35,7 @@ using OpenSim.Server.Base;
using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
using OpenSim.Services.Interfaces; using OpenSim.Services.Interfaces;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
using OpenMetaverse; using OpenMetaverse;
namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
@ -56,6 +57,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
public LocalGridServicesConnector(IConfigSource source) public LocalGridServicesConnector(IConfigSource source)
{ {
m_log.Debug("[LOCAL GRID CONNECTOR]: LocalGridServicesConnector instantiated");
InitialiseService(source); InitialiseService(source);
} }
@ -111,7 +113,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
if (m_GridService == null) if (m_GridService == null)
{ {
m_log.Error("[LOCAL GRID CONNECTOR]: Can't load asset service"); m_log.Error("[LOCAL GRID CONNECTOR]: Can't load grid service");
return; return;
} }
} }
@ -144,7 +146,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
#region IGridService #region IGridService
public bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfo) public bool RegisterRegion(UUID scopeID, GridRegion regionInfo)
{ {
return m_GridService.RegisterRegion(scopeID, regionInfo); return m_GridService.RegisterRegion(scopeID, regionInfo);
} }
@ -154,32 +156,32 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
return m_GridService.DeregisterRegion(regionID); return m_GridService.DeregisterRegion(regionID);
} }
public List<SimpleRegionInfo> GetNeighbours(UUID scopeID, UUID regionID) public List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID)
{ {
return m_GridService.GetNeighbours(scopeID, regionID); return m_GridService.GetNeighbours(scopeID, regionID);
} }
public SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID) public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
{ {
return m_GridService.GetRegionByUUID(scopeID, regionID); return m_GridService.GetRegionByUUID(scopeID, regionID);
} }
public SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y) public GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
{ {
return m_GridService.GetRegionByPosition(scopeID, x, y); return m_GridService.GetRegionByPosition(scopeID, x, y);
} }
public SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName) public GridRegion GetRegionByName(UUID scopeID, string regionName)
{ {
return m_GridService.GetRegionByName(scopeID, regionName); return m_GridService.GetRegionByName(scopeID, regionName);
} }
public List<SimpleRegionInfo> GetRegionsByName(UUID scopeID, string name, int maxNumber) public List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber)
{ {
return m_GridService.GetRegionsByName(scopeID, name, maxNumber); return m_GridService.GetRegionsByName(scopeID, name, maxNumber);
} }
public List<SimpleRegionInfo> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) public List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax)
{ {
return m_GridService.GetRegionRange(scopeID, xmin, xmax, ymin, ymax); return m_GridService.GetRegionRange(scopeID, xmin, xmax, ymin, ymax);
} }

View File

@ -37,6 +37,7 @@ using OpenSim.Services.Connectors;
using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
using OpenSim.Services.Interfaces; using OpenSim.Services.Interfaces;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
{ {
@ -129,7 +130,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
#region IGridService #region IGridService
public override bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfo) public override bool RegisterRegion(UUID scopeID, GridRegion regionInfo)
{ {
if (m_LocalGridService.RegisterRegion(scopeID, regionInfo)) if (m_LocalGridService.RegisterRegion(scopeID, regionInfo))
return base.RegisterRegion(scopeID, regionInfo); return base.RegisterRegion(scopeID, regionInfo);
@ -147,27 +148,27 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
// Let's not override GetNeighbours -- let's get them all from the grid server // Let's not override GetNeighbours -- let's get them all from the grid server
public override SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID) public override GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
{ {
SimpleRegionInfo rinfo = m_LocalGridService.GetRegionByUUID(scopeID, regionID); GridRegion rinfo = m_LocalGridService.GetRegionByUUID(scopeID, regionID);
if (rinfo == null) if (rinfo == null)
rinfo = base.GetRegionByUUID(scopeID, regionID); rinfo = base.GetRegionByUUID(scopeID, regionID);
return rinfo; return rinfo;
} }
public override SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y) public override GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
{ {
SimpleRegionInfo rinfo = m_LocalGridService.GetRegionByPosition(scopeID, x, y); GridRegion rinfo = m_LocalGridService.GetRegionByPosition(scopeID, x, y);
if (rinfo == null) if (rinfo == null)
rinfo = base.GetRegionByPosition(scopeID, x, y); rinfo = base.GetRegionByPosition(scopeID, x, y);
return rinfo; return rinfo;
} }
public override SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName) public override GridRegion GetRegionByName(UUID scopeID, string regionName)
{ {
SimpleRegionInfo rinfo = m_LocalGridService.GetRegionByName(scopeID, regionName); GridRegion rinfo = m_LocalGridService.GetRegionByName(scopeID, regionName);
if (rinfo == null) if (rinfo == null)
rinfo = base.GetRegionByName(scopeID, regionName); rinfo = base.GetRegionByName(scopeID, regionName);

View File

@ -38,6 +38,7 @@ using System.Xml.Serialization;
using System.Collections.Generic; using System.Collections.Generic;
using OpenSim.Server.Base; using OpenSim.Server.Base;
using OpenSim.Services.Interfaces; using OpenSim.Services.Interfaces;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Servers.HttpServer; using OpenSim.Framework.Servers.HttpServer;
using OpenMetaverse; using OpenMetaverse;
@ -117,7 +118,7 @@ namespace OpenSim.Server.Handlers.Grid
Dictionary<string, object> rinfoData = new Dictionary<string, object>(); Dictionary<string, object> rinfoData = new Dictionary<string, object>();
foreach (KeyValuePair<string, string> kvp in request) foreach (KeyValuePair<string, string> kvp in request)
rinfoData[kvp.Key] = kvp.Value; rinfoData[kvp.Key] = kvp.Value;
SimpleRegionInfo rinfo = new SimpleRegionInfo(rinfoData); GridRegion rinfo = new GridRegion(rinfoData);
bool result = m_GridService.RegisterRegion(scopeID, rinfo); bool result = m_GridService.RegisterRegion(scopeID, rinfo);
@ -158,11 +159,11 @@ namespace OpenSim.Server.Handlers.Grid
else else
m_log.WarnFormat("[GRID HANDLER]: no regionID in request to get neighbours"); m_log.WarnFormat("[GRID HANDLER]: no regionID in request to get neighbours");
List<SimpleRegionInfo> rinfos = m_GridService.GetNeighbours(scopeID, regionID); List<GridRegion> rinfos = m_GridService.GetNeighbours(scopeID, regionID);
Dictionary<string, object> result = new Dictionary<string, object>(); Dictionary<string, object> result = new Dictionary<string, object>();
int i = 0; int i = 0;
foreach (SimpleRegionInfo rinfo in rinfos) foreach (GridRegion rinfo in rinfos)
{ {
Dictionary<string, object> rinfoDict = rinfo.ToKeyValuePairs(); Dictionary<string, object> rinfoDict = rinfo.ToKeyValuePairs();
result["region" + i] = rinfoDict; result["region" + i] = rinfoDict;

View File

@ -35,6 +35,7 @@ using OpenSim.Framework;
using OpenSim.Framework.Communications; using OpenSim.Framework.Communications;
using OpenSim.Framework.Servers.HttpServer; using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Services.Interfaces; using OpenSim.Services.Interfaces;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
using OpenSim.Server.Base; using OpenSim.Server.Base;
using OpenMetaverse; using OpenMetaverse;
@ -85,7 +86,7 @@ namespace OpenSim.Services.Connectors
#region IGridService #region IGridService
public virtual bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfo) public virtual bool RegisterRegion(UUID scopeID, GridRegion regionInfo)
{ {
Dictionary<string, object> rinfo = regionInfo.ToKeyValuePairs(); Dictionary<string, object> rinfo = regionInfo.ToKeyValuePairs();
Dictionary<string, string> sendData = new Dictionary<string,string>(); Dictionary<string, string> sendData = new Dictionary<string,string>();
@ -128,7 +129,7 @@ namespace OpenSim.Services.Connectors
return false; return false;
} }
public virtual List<SimpleRegionInfo> GetNeighbours(UUID scopeID, UUID regionID) public virtual List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID)
{ {
Dictionary<string, string> sendData = new Dictionary<string, string>(); Dictionary<string, string> sendData = new Dictionary<string, string>();
@ -143,7 +144,7 @@ namespace OpenSim.Services.Connectors
Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
List<SimpleRegionInfo> rinfos = new List<SimpleRegionInfo>(); List<GridRegion> rinfos = new List<GridRegion>();
if (replyData != null) if (replyData != null)
{ {
Dictionary<string, object>.ValueCollection rinfosList = replyData.Values; Dictionary<string, object>.ValueCollection rinfosList = replyData.Values;
@ -151,7 +152,7 @@ namespace OpenSim.Services.Connectors
{ {
if (r is Dictionary<string, object>) if (r is Dictionary<string, object>)
{ {
SimpleRegionInfo rinfo = new SimpleRegionInfo((Dictionary<string, object>)r); GridRegion rinfo = new GridRegion((Dictionary<string, object>)r);
rinfos.Add(rinfo); rinfos.Add(rinfo);
} }
else else
@ -166,7 +167,7 @@ namespace OpenSim.Services.Connectors
return rinfos; return rinfos;
} }
public virtual SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID) public virtual GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
{ {
Dictionary<string, string> sendData = new Dictionary<string, string>(); Dictionary<string, string> sendData = new Dictionary<string, string>();
@ -181,11 +182,11 @@ namespace OpenSim.Services.Connectors
Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
SimpleRegionInfo rinfo = null; GridRegion rinfo = null;
if ((replyData != null) && (replyData["result"] != null)) if ((replyData != null) && (replyData["result"] != null))
{ {
if (replyData["result"] is Dictionary<string, object>) if (replyData["result"] is Dictionary<string, object>)
rinfo = new SimpleRegionInfo((Dictionary<string, object>)replyData["result"]); rinfo = new GridRegion((Dictionary<string, object>)replyData["result"]);
else else
m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID {0}, {1} received invalid response", m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID {0}, {1} received invalid response",
scopeID, regionID); scopeID, regionID);
@ -197,7 +198,7 @@ namespace OpenSim.Services.Connectors
return rinfo; return rinfo;
} }
public virtual SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y) public virtual GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
{ {
Dictionary<string, string> sendData = new Dictionary<string, string>(); Dictionary<string, string> sendData = new Dictionary<string, string>();
@ -213,11 +214,11 @@ namespace OpenSim.Services.Connectors
Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
SimpleRegionInfo rinfo = null; GridRegion rinfo = null;
if ((replyData != null) && (replyData["result"] != null)) if ((replyData != null) && (replyData["result"] != null))
{ {
if (replyData["result"] is Dictionary<string, object>) if (replyData["result"] is Dictionary<string, object>)
rinfo = new SimpleRegionInfo((Dictionary<string, object>)replyData["result"]); rinfo = new GridRegion((Dictionary<string, object>)replyData["result"]);
else else
m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received invalid response", m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received invalid response",
scopeID, x, y); scopeID, x, y);
@ -229,7 +230,7 @@ namespace OpenSim.Services.Connectors
return rinfo; return rinfo;
} }
public virtual SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName) public virtual GridRegion GetRegionByName(UUID scopeID, string regionName)
{ {
Dictionary<string, string> sendData = new Dictionary<string, string>(); Dictionary<string, string> sendData = new Dictionary<string, string>();
@ -244,11 +245,11 @@ namespace OpenSim.Services.Connectors
Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
SimpleRegionInfo rinfo = null; GridRegion rinfo = null;
if ((replyData != null) && (replyData["result"] != null)) if ((replyData != null) && (replyData["result"] != null))
{ {
if (replyData["result"] is Dictionary<string, object>) if (replyData["result"] is Dictionary<string, object>)
rinfo = new SimpleRegionInfo((Dictionary<string, object>)replyData["result"]); rinfo = new GridRegion((Dictionary<string, object>)replyData["result"]);
else else
m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1} received invalid response", m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1} received invalid response",
scopeID, regionName); scopeID, regionName);
@ -260,7 +261,7 @@ namespace OpenSim.Services.Connectors
return rinfo; return rinfo;
} }
public virtual List<SimpleRegionInfo> GetRegionsByName(UUID scopeID, string name, int maxNumber) public virtual List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber)
{ {
Dictionary<string, string> sendData = new Dictionary<string, string>(); Dictionary<string, string> sendData = new Dictionary<string, string>();
@ -276,7 +277,7 @@ namespace OpenSim.Services.Connectors
Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
List<SimpleRegionInfo> rinfos = new List<SimpleRegionInfo>(); List<GridRegion> rinfos = new List<GridRegion>();
if (replyData != null) if (replyData != null)
{ {
Dictionary<string, object>.ValueCollection rinfosList = replyData.Values; Dictionary<string, object>.ValueCollection rinfosList = replyData.Values;
@ -284,7 +285,7 @@ namespace OpenSim.Services.Connectors
{ {
if (r is Dictionary<string, object>) if (r is Dictionary<string, object>)
{ {
SimpleRegionInfo rinfo = new SimpleRegionInfo((Dictionary<string, object>)r); GridRegion rinfo = new GridRegion((Dictionary<string, object>)r);
rinfos.Add(rinfo); rinfos.Add(rinfo);
} }
else else
@ -299,7 +300,7 @@ namespace OpenSim.Services.Connectors
return rinfos; return rinfos;
} }
public virtual List<SimpleRegionInfo> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) public virtual List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax)
{ {
Dictionary<string, string> sendData = new Dictionary<string, string>(); Dictionary<string, string> sendData = new Dictionary<string, string>();
@ -317,7 +318,7 @@ namespace OpenSim.Services.Connectors
Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
List<SimpleRegionInfo> rinfos = new List<SimpleRegionInfo>(); List<GridRegion> rinfos = new List<GridRegion>();
if (replyData != null) if (replyData != null)
{ {
Dictionary<string, object>.ValueCollection rinfosList = replyData.Values; Dictionary<string, object>.ValueCollection rinfosList = replyData.Values;
@ -325,7 +326,7 @@ namespace OpenSim.Services.Connectors
{ {
if (r is Dictionary<string, object>) if (r is Dictionary<string, object>)
{ {
SimpleRegionInfo rinfo = new SimpleRegionInfo((Dictionary<string, object>)r); GridRegion rinfo = new GridRegion((Dictionary<string, object>)r);
rinfos.Add(rinfo); rinfos.Add(rinfo);
} }
else else

View File

@ -33,6 +33,7 @@ using System.Drawing;
using System.Net; using System.Net;
using System.Reflection; using System.Reflection;
using OpenSim.Services.Interfaces; using OpenSim.Services.Interfaces;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
using OpenSim.Framework; using OpenSim.Framework;
@ -54,7 +55,7 @@ namespace OpenSim.Services.Connectors.Grid
m_AssetService = assService; m_AssetService = assService;
} }
public UUID LinkRegion(SimpleRegionInfo info, out ulong realHandle) public UUID LinkRegion(GridRegion info, out ulong realHandle)
{ {
UUID uuid = UUID.Zero; UUID uuid = UUID.Zero;
realHandle = 0; realHandle = 0;
@ -114,7 +115,7 @@ namespace OpenSim.Services.Connectors.Grid
return uuid; return uuid;
} }
public void GetMapImage(SimpleRegionInfo info) public void GetMapImage(GridRegion info)
{ {
try try
{ {

View File

@ -35,6 +35,7 @@ using OpenSim.Framework;
using OpenSim.Framework.Console; using OpenSim.Framework.Console;
using OpenSim.Data; using OpenSim.Data;
using OpenSim.Services.Interfaces; using OpenSim.Services.Interfaces;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
using OpenMetaverse; using OpenMetaverse;
namespace OpenSim.Services.GridService namespace OpenSim.Services.GridService
@ -48,6 +49,7 @@ namespace OpenSim.Services.GridService
public GridService(IConfigSource config) public GridService(IConfigSource config)
: base(config) : base(config)
{ {
m_log.DebugFormat("[GRID SERVICE]: Starting...");
MainConsole.Instance.Commands.AddCommand("kfs", false, MainConsole.Instance.Commands.AddCommand("kfs", false,
"show digest", "show digest",
"show digest <ID>", "show digest <ID>",
@ -62,7 +64,7 @@ namespace OpenSim.Services.GridService
#region IGridService #region IGridService
public bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfos) public bool RegisterRegion(UUID scopeID, GridRegion regionInfos)
{ {
if (m_Database.Get(regionInfos.RegionID, scopeID) != null) if (m_Database.Get(regionInfos.RegionID, scopeID) != null)
{ {
@ -88,9 +90,9 @@ namespace OpenSim.Services.GridService
return m_Database.Delete(regionID); return m_Database.Delete(regionID);
} }
public List<SimpleRegionInfo> GetNeighbours(UUID scopeID, UUID regionID) public List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID)
{ {
List<SimpleRegionInfo> rinfos = new List<SimpleRegionInfo>(); List<GridRegion> rinfos = new List<GridRegion>();
RegionData region = m_Database.Get(regionID, scopeID); RegionData region = m_Database.Get(regionID, scopeID);
if (region != null) if (region != null)
{ {
@ -105,7 +107,7 @@ namespace OpenSim.Services.GridService
return rinfos; return rinfos;
} }
public SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID) public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
{ {
RegionData rdata = m_Database.Get(regionID, scopeID); RegionData rdata = m_Database.Get(regionID, scopeID);
if (rdata != null) if (rdata != null)
@ -114,7 +116,7 @@ namespace OpenSim.Services.GridService
return null; 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 snapX = (int)(x / Constants.RegionSize) * (int)Constants.RegionSize;
int snapY = (int)(y / Constants.RegionSize) * (int)Constants.RegionSize; int snapY = (int)(y / Constants.RegionSize) * (int)Constants.RegionSize;
@ -125,7 +127,7 @@ namespace OpenSim.Services.GridService
return null; return null;
} }
public SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName) public GridRegion GetRegionByName(UUID scopeID, string regionName)
{ {
List<RegionData> rdatas = m_Database.Get(regionName + "%", scopeID); List<RegionData> rdatas = m_Database.Get(regionName + "%", scopeID);
if ((rdatas != null) && (rdatas.Count > 0)) if ((rdatas != null) && (rdatas.Count > 0))
@ -134,12 +136,12 @@ namespace OpenSim.Services.GridService
return null; return null;
} }
public List<SimpleRegionInfo> GetRegionsByName(UUID scopeID, string name, int maxNumber) public List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber)
{ {
List<RegionData> rdatas = m_Database.Get("%" + name + "%", scopeID); List<RegionData> rdatas = m_Database.Get("%" + name + "%", scopeID);
int count = 0; int count = 0;
List<SimpleRegionInfo> rinfos = new List<SimpleRegionInfo>(); List<GridRegion> rinfos = new List<GridRegion>();
if (rdatas != null) if (rdatas != null)
{ {
@ -153,7 +155,7 @@ namespace OpenSim.Services.GridService
return rinfos; return rinfos;
} }
public List<SimpleRegionInfo> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) public List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax)
{ {
int xminSnap = (int)(xmin / Constants.RegionSize) * (int)Constants.RegionSize; int xminSnap = (int)(xmin / Constants.RegionSize) * (int)Constants.RegionSize;
int xmaxSnap = (int)(xmax / 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; int ymaxSnap = (int)(ymax / Constants.RegionSize) * (int)Constants.RegionSize;
List<RegionData> rdatas = m_Database.Get(xminSnap, yminSnap, xmaxSnap, ymaxSnap, scopeID); List<RegionData> rdatas = m_Database.Get(xminSnap, yminSnap, xmaxSnap, ymaxSnap, scopeID);
List<SimpleRegionInfo> rinfos = new List<SimpleRegionInfo>(); List<GridRegion> rinfos = new List<GridRegion>();
foreach (RegionData rdata in rdatas) foreach (RegionData rdata in rdatas)
rinfos.Add(RegionData2RegionInfo(rdata)); rinfos.Add(RegionData2RegionInfo(rdata));
@ -172,7 +174,7 @@ namespace OpenSim.Services.GridService
#region Data structure conversions #region Data structure conversions
protected RegionData RegionInfo2RegionData(SimpleRegionInfo rinfo) protected RegionData RegionInfo2RegionData(GridRegion rinfo)
{ {
RegionData rdata = new RegionData(); RegionData rdata = new RegionData();
rdata.posX = (int)rinfo.RegionLocX; rdata.posX = (int)rinfo.RegionLocX;
@ -184,11 +186,11 @@ namespace OpenSim.Services.GridService
return rdata; return rdata;
} }
protected SimpleRegionInfo RegionData2RegionInfo(RegionData rdata) protected GridRegion RegionData2RegionInfo(RegionData rdata)
{ {
SimpleRegionInfo rinfo = new SimpleRegionInfo(rdata.Data); GridRegion rinfo = new GridRegion(rdata.Data);
rinfo.RegionLocX = (uint)rdata.posX; rinfo.RegionLocX = rdata.posX;
rinfo.RegionLocY = (uint)rdata.posY; rinfo.RegionLocY = rdata.posY;
rinfo.RegionID = rdata.RegionID; rinfo.RegionID = rdata.RegionID;
rinfo.RegionName = rdata.RegionName; rinfo.RegionName = rdata.RegionName;

View File

@ -25,8 +25,11 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
using OpenSim.Framework; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;
using OpenSim.Framework;
using OpenMetaverse; using OpenMetaverse;
namespace OpenSim.Services.Interfaces namespace OpenSim.Services.Interfaces
@ -39,7 +42,7 @@ namespace OpenSim.Services.Interfaces
/// <param name="regionInfos"> </param> /// <param name="regionInfos"> </param>
/// <returns></returns> /// <returns></returns>
/// <exception cref="System.Exception">Thrown if region registration failed</exception> /// <exception cref="System.Exception">Thrown if region registration failed</exception>
bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfos); bool RegisterRegion(UUID scopeID, GridRegion regionInfos);
/// <summary> /// <summary>
/// Deregister a region with the grid service. /// Deregister a region with the grid service.
@ -55,9 +58,9 @@ namespace OpenSim.Services.Interfaces
/// <param name="x"></param> /// <param name="x"></param>
/// <param name="y"></param> /// <param name="y"></param>
/// <returns></returns> /// <returns></returns>
List<SimpleRegionInfo> GetNeighbours(UUID scopeID, UUID regionID); List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID);
SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID); GridRegion GetRegionByUUID(UUID scopeID, UUID regionID);
/// <summary> /// <summary>
/// Get the region at the given position (in meters) /// Get the region at the given position (in meters)
@ -66,9 +69,9 @@ namespace OpenSim.Services.Interfaces
/// <param name="x"></param> /// <param name="x"></param>
/// <param name="y"></param> /// <param name="y"></param>
/// <returns></returns> /// <returns></returns>
SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y); GridRegion GetRegionByPosition(UUID scopeID, int x, int y);
SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName); GridRegion GetRegionByName(UUID scopeID, string regionName);
/// <summary> /// <summary>
/// Get information about regions starting with the provided name. /// Get information about regions starting with the provided name.
@ -83,9 +86,237 @@ namespace OpenSim.Services.Interfaces
/// A list of <see cref="RegionInfo"/>s of regions with matching name. If the /// A list of <see cref="RegionInfo"/>s of regions with matching name. If the
/// grid-server couldn't be contacted or returned an error, return null. /// grid-server couldn't be contacted or returned an error, return null.
/// </returns> /// </returns>
List<SimpleRegionInfo> GetRegionsByName(UUID scopeID, string name, int maxNumber); List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber);
List<SimpleRegionInfo> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax); List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax);
} }
public class GridRegion
{
/// <summary>
/// The port by which http communication occurs with the region
/// </summary>
public uint HttpPort
{
get { return m_httpPort; }
set { m_httpPort = value; }
}
protected uint m_httpPort;
/// <summary>
/// A well-formed URI for the host region server (namely "http://" + ExternalHostName)
/// </summary>
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;
}
/// <value>
/// 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?
/// </value>
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<string, object> ToKeyValuePairs()
{
Dictionary<string, object> kvp = new Dictionary<string, object>();
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<string, object> 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"];
}
}
} }

View File

@ -25,4 +25,5 @@
[GridService] [GridService]
LocalServiceModule = "OpenSim.Services.GridService.dll:GridService" LocalServiceModule = "OpenSim.Services.GridService.dll:GridService"
StorageProvider = "OpenSim.Data.Null.dll:NullRegionData"

View File

@ -43,5 +43,5 @@
[GridService] [GridService]
LocalServiceModule = "OpenSim.Services.GridService.dll:GridService" LocalServiceModule = "OpenSim.Services.GridService.dll:GridService"
GridServiceConnectorModule = "OpenSim.Region.CoreModules.dll:LocalGridServiceConnector" GridServiceConnectorModule = "OpenSim.Region.CoreModules.dll:LocalGridServicesConnector"
StorageProvider = "OpenSim.Data.Null.dll" StorageProvider = "OpenSim.Data.Null.dll:NullRegionData"