Unpacking the mess with OtherRegionUp, so we can have a real cache of the neighbours in the grid service modules.

0.6.8-post-fixes
Diva Canto 2009-09-27 10:14:10 -07:00
parent 68e40a87ca
commit 5d09c53a1a
16 changed files with 99 additions and 127 deletions

View File

@ -46,8 +46,6 @@ namespace OpenSim.Framework
public delegate bool CloseAgentConnection(UUID agentID);
public delegate bool RegionUp(RegionInfo region);
public delegate bool ChildAgentUpdate(ChildAgentDataUpdate cAgentData);
public delegate void LogOffUser(UUID agentID, UUID regionSecret, string message);
@ -65,7 +63,6 @@ namespace OpenSim.Framework
event AcknowledgePrimCross OnAcknowledgePrimCrossed;
event UpdateNeighbours OnNeighboursUpdate;
event CloseAgentConnection OnCloseAgentConnection;
event RegionUp OnRegionUp;
event ChildAgentUpdate OnChildAgentUpdate;
event LogOffUser OnLogOffUser;
event GetLandData OnGetLandData;

View File

@ -74,7 +74,7 @@ namespace OpenSim.Framework
void CloseAllAgents(uint circuitcode);
void Restart(int seconds);
bool OtherRegionUp(RegionInfo thisRegion);
//RegionInfo OtherRegionUp(RegionInfo thisRegion);
string GetSimulatorVersion();

View File

@ -47,7 +47,6 @@ namespace OpenSim.Framework
private ExpectUserDelegate handlerExpectUser = null; // OnExpectUser
private UpdateNeighbours handlerNeighboursUpdate = null; // OnNeighboursUpdate;
private PrimCrossing handlerPrimCrossingIntoRegion = null; // OnPrimCrossingIntoRegion;
private RegionUp handlerRegionUp = null; // OnRegionUp;
private LogOffUser handlerLogOffUser = null;
private GetLandData handlerGetLandData = null;
@ -62,7 +61,6 @@ namespace OpenSim.Framework
public event AcknowledgeAgentCross OnAcknowledgeAgentCrossed;
public event AcknowledgePrimCross OnAcknowledgePrimCrossed;
public event CloseAgentConnection OnCloseAgentConnection;
public event RegionUp OnRegionUp;
public event ChildAgentUpdate OnChildAgentUpdate;
public event LogOffUser OnLogOffUser;
public event GetLandData OnGetLandData;
@ -108,17 +106,6 @@ namespace OpenSim.Framework
return false;
}
public virtual bool TriggerRegionUp(RegionInfo region)
{
handlerRegionUp = OnRegionUp;
if (handlerRegionUp != null)
{
handlerRegionUp(region);
return true;
}
return false;
}
public virtual bool TriggerChildAgentUpdate(ChildAgentDataUpdate cAgentData)
{
handlerChildAgentUpdate = OnChildAgentUpdate;

View File

@ -28,6 +28,7 @@
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Region.Framework.Scenes;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.ClientStack.LindenUDP.Tests
{
@ -58,7 +59,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
public override void RemoveClient(UUID agentID) {}
public override void CloseAllAgents(uint circuitcode) {}
public override bool OtherRegionUp(RegionInfo thisRegion) { return false; }
public override void OtherRegionUp(GridRegion otherRegion) { }
/// <summary>
/// Doesn't really matter what the call is - we're using this to test that a packet has actually been received

View File

@ -121,7 +121,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Neighbour
#region INeighbourService
public bool HelloNeighbour(ulong regionHandle, RegionInfo thisRegion)
public GridRegion HelloNeighbour(ulong regionHandle, RegionInfo thisRegion)
{
m_log.DebugFormat("[NEIGHBOUR IN CONNECTOR]: HelloNeighbour from {0}, to {1}. Count = {2}",
thisRegion.RegionName, regionHandle, m_Scenes.Count);
@ -134,7 +134,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Neighbour
}
}
m_log.DebugFormat("[NEIGHBOUR IN CONNECTOR]: region handle {0} not found", regionHandle);
return false;
return null;
}
#endregion INeighbourService

View File

@ -119,7 +119,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Neighbour
#region INeighbourService
public bool HelloNeighbour(ulong regionHandle, RegionInfo thisRegion)
public GridRegion HelloNeighbour(ulong regionHandle, RegionInfo thisRegion)
{
m_log.DebugFormat("[NEIGHBOUR CONNECTOR]: HelloNeighbour from {0}, to {1}. Count = {2}",
thisRegion.RegionName, regionHandle, m_Scenes.Count);
@ -132,7 +132,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Neighbour
}
}
m_log.DebugFormat("[NEIGHBOUR CONNECTOR]: region handle {0} not found", regionHandle);
return false;
return null;
}
#endregion INeighbourService

View File

@ -141,10 +141,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Neighbour
#region INeighbourService
public override bool HelloNeighbour(ulong regionHandle, RegionInfo thisRegion)
public override GridRegion HelloNeighbour(ulong regionHandle, RegionInfo thisRegion)
{
if (m_LocalService.HelloNeighbour(regionHandle, thisRegion))
return true;
GridRegion region = m_LocalService.HelloNeighbour(regionHandle, thisRegion);
if (region != null)
return region;
return base.HelloNeighbour(regionHandle, thisRegion);
}

View File

@ -32,6 +32,7 @@ using OpenSim.Framework;
using OpenSim.Framework.Client;
using OpenSim.Region.Framework.Interfaces;
using Caps=OpenSim.Framework.Capabilities.Caps;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.Framework.Scenes
{
@ -305,6 +306,9 @@ namespace OpenSim.Region.Framework.Scenes
public delegate void Attach(uint localID, UUID itemID, UUID avatarID);
public event Attach OnAttach;
public delegate void RegionUp(GridRegion region);
public event RegionUp OnRegionUp;
public class MoneyTransferArgs : EventArgs
{
public UUID sender;
@ -446,6 +450,7 @@ namespace OpenSim.Region.Framework.Scenes
private EmptyScriptCompileQueue handlerEmptyScriptCompileQueue = null;
private Attach handlerOnAttach = null;
private RegionUp handlerOnRegionUp = null;
public void TriggerOnAttach(uint localID, UUID itemID, UUID avatarID)
{
@ -1035,5 +1040,13 @@ namespace OpenSim.Region.Framework.Scenes
if (handlerSetRootAgentScene != null)
handlerSetRootAgentScene(agentID, scene);
}
public void TriggerOnRegionUp(GridRegion otherRegion)
{
handlerOnRegionUp = OnRegionUp;
if (handlerOnRegionUp != null)
handlerOnRegionUp(otherRegion);
}
}
}

View File

@ -587,10 +587,7 @@ namespace OpenSim.Region.Framework.Scenes
}
/// <summary>
/// Another region is up. Gets called from Grid Comms:
/// (OGS1 -> LocalBackEnd -> RegionListened -> SceneCommunicationService)
/// We have to tell all our ScenePresences about it, and add it to the
/// neighbor list.
/// Another region is up.
///
/// We only add it to the neighbor list if it's within 1 region from here.
/// Agents may have draw distance values that cross two regions though, so
@ -599,47 +596,27 @@ namespace OpenSim.Region.Framework.Scenes
/// </summary>
/// <param name="otherRegion">RegionInfo handle for the new region.</param>
/// <returns>True after all operations complete, throws exceptions otherwise.</returns>
public override bool OtherRegionUp(RegionInfo otherRegion)
public override void OtherRegionUp(GridRegion otherRegion)
{
m_log.InfoFormat("[SCENE]: Region {0} up in coords {1}-{2}", otherRegion.RegionName, otherRegion.RegionLocX, otherRegion.RegionLocY);
uint xcell = (uint)((int)otherRegion.RegionLocX / (int)Constants.RegionSize);
uint ycell = (uint)((int)otherRegion.RegionLocY / (int)Constants.RegionSize);
m_log.InfoFormat("[SCENE]: (on region {0}): Region {1} up in coords {2}-{3}",
RegionInfo.RegionName, otherRegion.RegionName, xcell, ycell);
if (RegionInfo.RegionHandle != otherRegion.RegionHandle)
{
for (int i = 0; i < m_neighbours.Count; i++)
{
// The purpose of this loop is to re-update the known neighbors
// when another region comes up on top of another one.
// The latest region in that location ends up in the
// 'known neighbors list'
// Additionally, the commFailTF property gets reset to false.
if (m_neighbours[i].RegionHandle == otherRegion.RegionHandle)
{
lock (m_neighbours)
{
m_neighbours[i] = otherRegion;
}
}
}
// If the value isn't in the neighbours, add it.
// If the RegionInfo isn't exact but is for the same XY World location,
// then the above loop will fix that.
if (!(CheckNeighborRegion(otherRegion)))
{
lock (m_neighbours)
{
m_neighbours.Add(otherRegion);
//m_log.Info("[UP]: " + otherRegion.RegionHandle.ToString());
}
}
// If these are cast to INT because long + negative values + abs returns invalid data
int resultX = Math.Abs((int)otherRegion.RegionLocX - (int)RegionInfo.RegionLocX);
int resultY = Math.Abs((int)otherRegion.RegionLocY - (int)RegionInfo.RegionLocY);
int resultX = Math.Abs((int)xcell - (int)RegionInfo.RegionLocX);
int resultY = Math.Abs((int)ycell - (int)RegionInfo.RegionLocY);
if (resultX <= 1 && resultY <= 1)
{
RegionInfo regInfo = new RegionInfo(xcell, ycell, otherRegion.InternalEndPoint, otherRegion.ExternalHostName);
regInfo.RegionID = otherRegion.RegionID;
regInfo.RegionName = otherRegion.RegionName;
regInfo.ScopeID = otherRegion.ScopeID;
regInfo.ExternalHostName = otherRegion.ExternalHostName;
try
{
ForEachScenePresence(delegate(ScenePresence agent)
@ -653,7 +630,7 @@ namespace OpenSim.Region.Framework.Scenes
List<ulong> old = new List<ulong>();
old.Add(otherRegion.RegionHandle);
agent.DropOldNeighbours(old);
InformClientOfNeighbor(agent, otherRegion);
InformClientOfNeighbor(agent, regInfo);
}
}
);
@ -672,7 +649,6 @@ namespace OpenSim.Region.Framework.Scenes
otherRegion.RegionLocY.ToString() + ")");
}
}
return true;
}
public void AddNeighborRegion(RegionInfo region)
@ -704,9 +680,10 @@ namespace OpenSim.Region.Framework.Scenes
}
// Alias IncomingHelloNeighbour OtherRegionUp, for now
public bool IncomingHelloNeighbour(RegionInfo neighbour)
public GridRegion IncomingHelloNeighbour(RegionInfo neighbour)
{
return OtherRegionUp(neighbour);
OtherRegionUp(new GridRegion(neighbour));
return new GridRegion(RegionInfo);
}
/// <summary>
@ -3104,7 +3081,7 @@ namespace OpenSim.Region.Framework.Scenes
m_sceneGridService.OnExpectUser += HandleNewUserConnection;
m_sceneGridService.OnAvatarCrossingIntoRegion += AgentCrossing;
m_sceneGridService.OnCloseAgentConnection += IncomingCloseAgent;
m_sceneGridService.OnRegionUp += OtherRegionUp;
//m_eventManager.OnRegionUp += OtherRegionUp;
//m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate;
m_sceneGridService.OnExpectPrim += IncomingInterRegionPrimGroup;
//m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar;
@ -3132,7 +3109,7 @@ namespace OpenSim.Region.Framework.Scenes
//m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar;
m_sceneGridService.OnExpectPrim -= IncomingInterRegionPrimGroup;
//m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate;
m_sceneGridService.OnRegionUp -= OtherRegionUp;
//m_eventManager.OnRegionUp -= OtherRegionUp;
m_sceneGridService.OnExpectUser -= HandleNewUserConnection;
m_sceneGridService.OnAvatarCrossingIntoRegion -= AgentCrossing;
m_sceneGridService.OnCloseAgentConnection -= IncomingCloseAgent;

View File

@ -36,6 +36,7 @@ using OpenSim.Framework;
using OpenSim.Framework.Console;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Region.Framework.Interfaces;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.Framework.Scenes
{
@ -227,7 +228,7 @@ namespace OpenSim.Region.Framework.Scenes
return false;
}
public abstract bool OtherRegionUp(RegionInfo thisRegion);
public abstract void OtherRegionUp(GridRegion otherRegion);
public virtual string GetSimulatorVersion()
{

View File

@ -93,10 +93,10 @@ namespace OpenSim.Region.Framework.Scenes
/// </summary>
public event PrimCrossing OnPrimCrossingIntoRegion;
/// <summary>
/// A New Region is up and available
/// </summary>
public event RegionUp OnRegionUp;
///// <summary>
///// A New Region is up and available
///// </summary>
//public event RegionUp OnRegionUp;
/// <summary>
/// We have a child agent for this avatar and we're getting a status update about it
@ -119,7 +119,7 @@ namespace OpenSim.Region.Framework.Scenes
private ExpectPrimDelegate handlerExpectPrim = null; // OnExpectPrim;
private CloseAgentConnection handlerCloseAgentConnection = null; // OnCloseAgentConnection;
private PrimCrossing handlerPrimCrossingIntoRegion = null; // OnPrimCrossingIntoRegion;
private RegionUp handlerRegionUp = null; // OnRegionUp;
//private RegionUp handlerRegionUp = null; // OnRegionUp;
private ChildAgentUpdate handlerChildAgentUpdate = null; // OnChildAgentUpdate;
//private RemoveKnownRegionsFromAvatarList handlerRemoveKnownRegionFromAvatar = null; // OnRemoveKnownRegionFromAvatar;
private LogOffUser handlerLogOffUser = null;
@ -238,22 +238,6 @@ namespace OpenSim.Region.Framework.Scenes
}
}
/// <summary>
/// A New Region is now available. Inform the scene that there is a new region available.
/// </summary>
/// <param name="region">Information about the new region that is available</param>
/// <returns>True if the event was handled</returns>
protected bool newRegionUp(RegionInfo region)
{
handlerRegionUp = OnRegionUp;
if (handlerRegionUp != null)
{
//m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: newRegionUp Fired for User:" + region.RegionName);
handlerRegionUp(region);
}
return true;
}
/// <summary>
/// Inform the scene that we've got an update about a child agent that we have
/// </summary>
@ -647,31 +631,23 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="regionhandle"></param>
private void InformNeighboursThatRegionIsUpAsync(INeighbourService neighbourService, RegionInfo region, ulong regionhandle)
{
m_log.Info("[INTERGRID]: Starting to inform neighbors that I'm here");
//RegionUpData regiondata = new RegionUpData(region.RegionLocX, region.RegionLocY, region.ExternalHostName, region.InternalEndPoint.Port);
uint x = 0, y = 0;
Utils.LongToUInts(regionhandle, out x, out y);
//bool regionAccepted =
// m_commsProvider.InterRegion.RegionUp(new SerializableRegionInfo(region), regionhandle);
//bool regionAccepted = m_interregionCommsOut.SendHelloNeighbour(regionhandle, region);
bool regionAccepted = false;
GridRegion neighbour = null;
if (neighbourService != null)
regionAccepted = neighbourService.HelloNeighbour(regionhandle, region);
neighbour = neighbourService.HelloNeighbour(regionhandle, region);
else
m_log.DebugFormat("[SCS]: No neighbour service provided for informing neigbhours of this region");
if (regionAccepted)
if (neighbour != null)
{
m_log.Info("[INTERGRID]: Completed informing neighbors that I'm here");
handlerRegionUp = OnRegionUp;
// yes, we're notifying ourselves.
if (handlerRegionUp != null)
handlerRegionUp(region);
m_log.DebugFormat("[INTERGRID]: Successfully informed neighbour {0}-{1} that I'm here", x / Constants.RegionSize, y / Constants.RegionSize);
m_scene.EventManager.TriggerOnRegionUp(neighbour);
}
else
{
m_log.Warn("[INTERGRID]: Failed to inform neighbors that I'm here.");
m_log.WarnFormat("[INTERGRID]: Failed to inform neighbour {0}-{1} that I'm here.", x / Constants.RegionSize, y / Constants.RegionSize);
}
}
@ -680,22 +656,33 @@ namespace OpenSim.Region.Framework.Scenes
{
//m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: Sending InterRegion Notification that region is up " + region.RegionName);
List<GridRegion> neighbours = new List<GridRegion>();
// This stays uncached because we don't already know about our neighbors at this point.
neighbours = m_scene.GridService.GetNeighbours(m_regionInfo.ScopeID, m_regionInfo.RegionID);
if (neighbours != null)
{
for (int i = 0; i < neighbours.Count; i++)
for (int x = (int)region.RegionLocX - 1; x <= region.RegionLocX + 1; x++)
for (int y = (int)region.RegionLocY - 1; y <= region.RegionLocY + 1; y++)
if (!((x == region.RegionLocX) && (y == region.RegionLocY))) // skip this region
{
ulong handle = Utils.UIntsToLong((uint)x * Constants.RegionSize, (uint)y * Constants.RegionSize);
InformNeighbourThatRegionUpDelegate d = InformNeighboursThatRegionIsUpAsync;
d.BeginInvoke(neighbourService, region, neighbours[i].RegionHandle,
d.BeginInvoke(neighbourService, region, handle,
InformNeighborsThatRegionisUpCompleted,
d);
}
}
//List<GridRegion> neighbours = new List<GridRegion>();
//// This stays uncached because we don't already know about our neighbors at this point.
//neighbours = m_scene.GridService.GetNeighbours(m_regionInfo.ScopeID, m_regionInfo.RegionID);
//if (neighbours != null)
//{
// for (int i = 0; i < neighbours.Count; i++)
// {
// InformNeighbourThatRegionUpDelegate d = InformNeighboursThatRegionIsUpAsync;
// d.BeginInvoke(neighbourService, region, neighbours[i].RegionHandle,
// InformNeighborsThatRegionisUpCompleted,
// d);
// }
//}
//bool val = m_commsProvider.InterRegion.RegionUp(new SerializableRegionInfo(region));
}

View File

@ -29,6 +29,7 @@ using System;
using NUnit.Framework;
using OpenMetaverse;
using OpenSim.Framework;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.Framework.Scenes.Tests
{
@ -65,7 +66,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
throw new NotImplementedException();
}
public override bool OtherRegionUp(RegionInfo thisRegion)
public override void OtherRegionUp(GridRegion otherRegion)
{
throw new NotImplementedException();
}

View File

@ -36,6 +36,7 @@ using OpenSim.Server.Handlers.Base;
using OpenSim.Services.Interfaces;
using OpenSim.Framework;
using OpenSim.Framework.Servers.HttpServer;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
@ -148,11 +149,14 @@ namespace OpenSim.Server.Handlers.Neighbour
}
// Finally!
bool success = m_NeighbourService.HelloNeighbour(regionhandle, aRegion);
GridRegion thisRegion = m_NeighbourService.HelloNeighbour(regionhandle, aRegion);
OSDMap resp = new OSDMap(1);
resp["success"] = OSD.FromBoolean(success);
if (thisRegion != null)
resp["success"] = OSD.FromBoolean(true);
else
resp["success"] = OSD.FromBoolean(false);
httpResponse.StatusCode = (int)HttpStatusCode.OK;

View File

@ -67,7 +67,7 @@ namespace OpenSim.Services.Connectors
m_GridService = gridServices;
}
public virtual bool HelloNeighbour(ulong regionHandle, RegionInfo thisRegion)
public virtual GridRegion HelloNeighbour(ulong regionHandle, RegionInfo thisRegion)
{
uint x = 0, y = 0;
Utils.LongToUInts(regionHandle, out x, out y);
@ -76,11 +76,11 @@ namespace OpenSim.Services.Connectors
// Don't remote-call this instance; that's a startup hickup
!((regInfo.ExternalHostName == thisRegion.ExternalHostName) && (regInfo.HttpPort == thisRegion.HttpPort)))
{
return DoHelloNeighbourCall(regInfo, thisRegion);
DoHelloNeighbourCall(regInfo, thisRegion);
}
//else
// m_log.Warn("[REST COMMS]: Region not found " + regionHandle);
return false;
return regInfo;
}
public bool DoHelloNeighbourCall(GridRegion region, RegionInfo thisRegion)

View File

@ -28,11 +28,12 @@
using System;
using OpenSim.Framework;
using OpenMetaverse;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Services.Interfaces
{
public interface INeighbourService
{
bool HelloNeighbour(ulong regionHandle, RegionInfo thisRegion);
GridRegion HelloNeighbour(ulong regionHandle, RegionInfo otherRegion);
}
}

View File

@ -3655,6 +3655,7 @@
<Reference name="OpenSim.Region.Framework"/>
<Reference name="OpenSim.Region.CoreModules"/>
<Reference name="OpenSim.Region.Physics.Manager"/>
<Reference name="OpenSim.Services.Interfaces"/>
<!-- Unit tests -->
<!-- <Reference name="OpenSim.Tests.Common"/> -->
@ -3708,6 +3709,7 @@
<Reference name="OpenSim.Region.ClientStack"/>
<Reference name="OpenSim.Region.ClientStack.LindenUDP"/>
<Reference name="OpenSim.Region.Framework"/>
<Reference name="OpenSim.Services.Interfaces"/>
<Reference name="OpenSim.Tests.Common"/>
<Files>