Added logging in places where regions are searched for by their location

This commit also fixes the log message "Region already exists in coordinates <{0},{1}>": it was actually showing the *requested* coordinates, instead of the coordinates of the previously-existing link.
0.8.2-post-fixes
Oren Hurvitz 2015-07-22 20:13:53 +03:00
parent 31a216af70
commit 3a2d4c8b05
5 changed files with 60 additions and 20 deletions

View File

@ -2196,7 +2196,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
public GridRegion GetRegionContainingWorldLocation(IGridService pGridService, UUID pScopeID, public GridRegion GetRegionContainingWorldLocation(IGridService pGridService, UUID pScopeID,
double px, double py, uint pSizeHint) double px, double py, uint pSizeHint)
{ {
m_log.DebugFormat("{0} GetRegionContainingWorldLocation: call, XY=<{1},{2}>", LogHeader, px, py); m_log.DebugFormat("{0} GetRegionContainingWorldLocation: query, loc=<{1},{2}>", LogHeader, px, py);
GridRegion ret = null; GridRegion ret = null;
const double fudge = 2.0; const double fudge = 2.0;

View File

@ -198,8 +198,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) public GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
{ {
GridRegion region = null; GridRegion region = null;
// uint regionX = Util.WorldToRegionLoc((uint)x); uint regionX = Util.WorldToRegionLoc((uint)x);
// uint regionY = Util.WorldToRegionLoc((uint)y); uint regionY = Util.WorldToRegionLoc((uint)y);
// Sanity check
if ((Util.RegionToWorldLoc(regionX) != (uint)x) || (Util.RegionToWorldLoc(regionY) != (uint)y))
{
m_log.WarnFormat("{0} GetRegionByPosition. Bad position requested: not the base of the region. Requested Pos=<{1},{2}>, Should Be=<{3},{4}>",
LogHeader, x, y, Util.RegionToWorldLoc(regionX), Util.RegionToWorldLoc(regionY));
}
// First see if it's a neighbour, even if it isn't on this sim. // First see if it's a neighbour, even if it isn't on this sim.
// Neighbour data is cached in memory, so this is fast // Neighbour data is cached in memory, so this is fast
@ -211,8 +218,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
region = rcache.GetRegionByPosition(x, y); region = rcache.GetRegionByPosition(x, y);
if (region != null) if (region != null)
{ {
// m_log.DebugFormat("{0} GetRegionByPosition. Found region {1} in cache. Pos=<{2},{3}>", m_log.DebugFormat("{0} GetRegionByPosition. Found region {1} in cache (of region {2}). Pos=<{3},{4}>",
// LogHeader, region.RegionName, x, y); LogHeader, region.RegionName,
Util.WorldToRegionLoc((uint)region.RegionLocX), Util.WorldToRegionLoc((uint)region.RegionLocY));
break; break;
} }
} }
@ -222,19 +230,20 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
if (region == null) if (region == null)
{ {
region = m_GridService.GetRegionByPosition(scopeID, x, y); region = m_GridService.GetRegionByPosition(scopeID, x, y);
/*
if (region == null) if (region == null)
{ {
m_log.DebugFormat("{0} GetRegionByPosition. Region not found by grid service. Pos=<{1},{2}>", m_log.DebugFormat("{0} GetRegionByPosition. Region not found by grid service. Pos=<{1},{2}>",
LogHeader, regionX, regionY); LogHeader, regionX, regionY);
} }
else else
{ {
m_log.DebugFormat("{0} GetRegionByPosition. Requested region {1} from grid service. Pos=<{2},{3}>", m_log.DebugFormat("{0} GetRegionByPosition. Got region {1} from grid service. Pos=<{2},{3}>",
LogHeader, region.RegionName, regionX, regionY); LogHeader, region.RegionName,
Util.WorldToRegionLoc((uint)region.RegionLocX), Util.WorldToRegionLoc((uint)region.RegionLocY));
} }
*/
} }
return region; return region;
} }

View File

@ -193,16 +193,35 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
// The coordinates are world coords (meters), NOT region units. // The coordinates are world coords (meters), NOT region units.
public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) public GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
{ {
ulong regionHandle = Util.RegionWorldLocToHandle((uint)x, (uint)y);
uint regionX = Util.WorldToRegionLoc((uint)x);
uint regionY = Util.WorldToRegionLoc((uint)y);
// Sanity check
if ((Util.RegionToWorldLoc(regionX) != (uint)x) || (Util.RegionToWorldLoc(regionY) != (uint)y))
{
m_log.WarnFormat("[REMOTE GRID CONNECTOR]: GetRegionByPosition. Bad position requested: not the base of the region. Requested Pos=<{0},{1}>, Should Be=<{2},{3}>",
x, y, Util.RegionToWorldLoc(regionX), Util.RegionToWorldLoc(regionY));
}
bool inCache = false; bool inCache = false;
GridRegion rinfo = m_RegionInfoCache.Get(scopeID, Util.RegionWorldLocToHandle((uint)x, (uint)y), out inCache); GridRegion rinfo = m_RegionInfoCache.Get(scopeID, regionHandle, out inCache);
if (inCache) if (inCache)
{
m_log.DebugFormat("[REMOTE GRID CONNECTOR]: GetRegionByPosition. Found region {0} in cache. Pos=<{1},{2}>, RegionHandle={3}",
(rinfo == null) ? "<missing>" : rinfo.RegionName, regionX, regionY, (rinfo == null) ? regionHandle : rinfo.RegionHandle);
return rinfo; return rinfo;
}
rinfo = m_LocalGridService.GetRegionByPosition(scopeID, x, y); rinfo = m_LocalGridService.GetRegionByPosition(scopeID, x, y);
if (rinfo == null) if (rinfo == null)
rinfo = m_RemoteGridService.GetRegionByPosition(scopeID, x, y); rinfo = m_RemoteGridService.GetRegionByPosition(scopeID, x, y);
m_RegionInfoCache.Cache(rinfo); m_RegionInfoCache.Cache(rinfo);
m_log.DebugFormat("[REMOTE GRID CONNECTOR]: GetRegionByPosition. Added region {0} to the cache. Pos=<{1},{2}>, RegionHandle={3}",
(rinfo == null) ? "<missing>" : rinfo.RegionName, regionX, regionY, (rinfo == null) ? regionHandle : rinfo.RegionHandle);
return rinfo; return rinfo;
} }

View File

@ -539,13 +539,24 @@ namespace OpenSim.Services.GridService
// multiples of the legacy region size (256). // multiples of the legacy region size (256).
public GridRegion 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; uint regionX = Util.WorldToRegionLoc((uint)x);
int snapY = (int)(y / Constants.RegionSize) * (int)Constants.RegionSize; uint regionY = Util.WorldToRegionLoc((uint)y);
int snapX = (int)Util.RegionToWorldLoc(regionX);
int snapY = (int)Util.RegionToWorldLoc(regionY);
RegionData rdata = m_Database.Get(snapX, snapY, scopeID); RegionData rdata = m_Database.Get(snapX, snapY, scopeID);
if (rdata != null) if (rdata != null)
{
m_log.DebugFormat("{0} GetRegionByPosition. Found region {1} in database. Pos=<{2},{3}>",
LogHeader, rdata.RegionName, regionX, regionY);
return RegionData2RegionInfo(rdata); return RegionData2RegionInfo(rdata);
}
return null; else
{
m_log.DebugFormat("{0} GetRegionByPosition. Did not find region in database. Pos=<{1},{2}>",
LogHeader, regionX, regionY);
return null;
}
} }
public GridRegion GetRegionByName(UUID scopeID, string name) public GridRegion GetRegionByName(UUID scopeID, string name)

View File

@ -282,7 +282,7 @@ namespace OpenSim.Services.GridService
public bool TryCreateLink(UUID scopeID, int xloc, int yloc, string remoteRegionName, uint externalPort, string externalHostName, string serverURI, UUID ownerID, out GridRegion regInfo, out string reason) public bool TryCreateLink(UUID scopeID, int xloc, int yloc, string remoteRegionName, uint externalPort, string externalHostName, string serverURI, UUID ownerID, out GridRegion regInfo, out string reason)
{ {
m_log.InfoFormat("[HYPERGRID LINKER]: Link to {0} {1}, in {2}-{3}", m_log.InfoFormat("[HYPERGRID LINKER]: Link to {0} {1}, in <{2},{3}>",
((serverURI == null) ? (externalHostName + ":" + externalPort) : serverURI), ((serverURI == null) ? (externalHostName + ":" + externalPort) : serverURI),
remoteRegionName, Util.WorldToRegionLoc((uint)xloc), Util.WorldToRegionLoc((uint)yloc)); remoteRegionName, Util.WorldToRegionLoc((uint)xloc), Util.WorldToRegionLoc((uint)yloc));
@ -335,7 +335,7 @@ namespace OpenSim.Services.GridService
GridRegion region = m_GridService.GetRegionByPosition(regInfo.ScopeID, regInfo.RegionLocX, regInfo.RegionLocY); GridRegion region = m_GridService.GetRegionByPosition(regInfo.ScopeID, regInfo.RegionLocX, regInfo.RegionLocY);
if (region != null) if (region != null)
{ {
m_log.WarnFormat("[HYPERGRID LINKER]: Coordinates {0}-{1} are already occupied by region {2} with uuid {3}", m_log.WarnFormat("[HYPERGRID LINKER]: Coordinates <{0},{1}> are already occupied by region {2} with uuid {3}",
Util.WorldToRegionLoc((uint)regInfo.RegionLocX), Util.WorldToRegionLoc((uint)regInfo.RegionLocY), Util.WorldToRegionLoc((uint)regInfo.RegionLocX), Util.WorldToRegionLoc((uint)regInfo.RegionLocY),
region.RegionName, region.RegionID); region.RegionName, region.RegionID);
reason = "Coordinates are already in use"; reason = "Coordinates are already in use";
@ -371,8 +371,8 @@ namespace OpenSim.Services.GridService
region = m_GridService.GetRegionByUUID(scopeID, regionID); region = m_GridService.GetRegionByUUID(scopeID, regionID);
if (region != null) if (region != null)
{ {
m_log.DebugFormat("[HYPERGRID LINKER]: Region already exists in coordinates {0} {1}", m_log.DebugFormat("[HYPERGRID LINKER]: Region already exists in coordinates <{0},{1}>",
Util.WorldToRegionLoc((uint)regInfo.RegionLocX), Util.WorldToRegionLoc((uint)regInfo.RegionLocY)); Util.WorldToRegionLoc((uint)region.RegionLocX), Util.WorldToRegionLoc((uint)region.RegionLocY));
regInfo = region; regInfo = region;
return true; return true;
} }
@ -406,7 +406,8 @@ namespace OpenSim.Services.GridService
regInfo.RegionSecret = handle.ToString(); regInfo.RegionSecret = handle.ToString();
AddHyperlinkRegion(regInfo, handle); AddHyperlinkRegion(regInfo, handle);
m_log.InfoFormat("[HYPERGRID LINKER]: Successfully linked to region {0} with image {1}", regInfo.RegionName, regInfo.TerrainImage); m_log.InfoFormat("[HYPERGRID LINKER]: Successfully linked to region {0} at <{1},{2}> with image {3}",
regInfo.RegionName, Util.WorldToRegionLoc((uint)regInfo.RegionLocX), Util.WorldToRegionLoc((uint)regInfo.RegionLocY), regInfo.TerrainImage);
return true; return true;
} }