aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework
diff options
context:
space:
mode:
authorDiva Canto2009-09-27 10:14:10 -0700
committerDiva Canto2009-09-27 10:14:10 -0700
commit5d09c53a1a42b38e1ee35cfbb5571d70b75380f4 (patch)
tree247412b0147ea11f4113413c1fa7d7e91eec0aa5 /OpenSim/Region/Framework
parentPoof! on LocalBackend. CommsManager.GridServices deleted. (diff)
downloadopensim-SC-5d09c53a1a42b38e1ee35cfbb5571d70b75380f4.zip
opensim-SC-5d09c53a1a42b38e1ee35cfbb5571d70b75380f4.tar.gz
opensim-SC-5d09c53a1a42b38e1ee35cfbb5571d70b75380f4.tar.bz2
opensim-SC-5d09c53a1a42b38e1ee35cfbb5571d70b75380f4.tar.xz
Unpacking the mess with OtherRegionUp, so we can have a real cache of the neighbours in the grid service modules.
Diffstat (limited to 'OpenSim/Region/Framework')
-rw-r--r--OpenSim/Region/Framework/Scenes/EventManager.cs13
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs63
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneBase.cs3
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs87
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs3
5 files changed, 74 insertions, 95 deletions
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs
index 287d8d9..7424b24 100644
--- a/OpenSim/Region/Framework/Scenes/EventManager.cs
+++ b/OpenSim/Region/Framework/Scenes/EventManager.cs
@@ -32,6 +32,7 @@ using OpenSim.Framework;
32using OpenSim.Framework.Client; 32using OpenSim.Framework.Client;
33using OpenSim.Region.Framework.Interfaces; 33using OpenSim.Region.Framework.Interfaces;
34using Caps=OpenSim.Framework.Capabilities.Caps; 34using Caps=OpenSim.Framework.Capabilities.Caps;
35using GridRegion = OpenSim.Services.Interfaces.GridRegion;
35 36
36namespace OpenSim.Region.Framework.Scenes 37namespace OpenSim.Region.Framework.Scenes
37{ 38{
@@ -305,6 +306,9 @@ namespace OpenSim.Region.Framework.Scenes
305 public delegate void Attach(uint localID, UUID itemID, UUID avatarID); 306 public delegate void Attach(uint localID, UUID itemID, UUID avatarID);
306 public event Attach OnAttach; 307 public event Attach OnAttach;
307 308
309 public delegate void RegionUp(GridRegion region);
310 public event RegionUp OnRegionUp;
311
308 public class MoneyTransferArgs : EventArgs 312 public class MoneyTransferArgs : EventArgs
309 { 313 {
310 public UUID sender; 314 public UUID sender;
@@ -446,6 +450,7 @@ namespace OpenSim.Region.Framework.Scenes
446 private EmptyScriptCompileQueue handlerEmptyScriptCompileQueue = null; 450 private EmptyScriptCompileQueue handlerEmptyScriptCompileQueue = null;
447 451
448 private Attach handlerOnAttach = null; 452 private Attach handlerOnAttach = null;
453 private RegionUp handlerOnRegionUp = null;
449 454
450 public void TriggerOnAttach(uint localID, UUID itemID, UUID avatarID) 455 public void TriggerOnAttach(uint localID, UUID itemID, UUID avatarID)
451 { 456 {
@@ -1035,5 +1040,13 @@ namespace OpenSim.Region.Framework.Scenes
1035 if (handlerSetRootAgentScene != null) 1040 if (handlerSetRootAgentScene != null)
1036 handlerSetRootAgentScene(agentID, scene); 1041 handlerSetRootAgentScene(agentID, scene);
1037 } 1042 }
1043
1044 public void TriggerOnRegionUp(GridRegion otherRegion)
1045 {
1046 handlerOnRegionUp = OnRegionUp;
1047 if (handlerOnRegionUp != null)
1048 handlerOnRegionUp(otherRegion);
1049 }
1050
1038 } 1051 }
1039} 1052}
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 8990f29..55478da 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -587,10 +587,7 @@ namespace OpenSim.Region.Framework.Scenes
587 } 587 }
588 588
589 /// <summary> 589 /// <summary>
590 /// Another region is up. Gets called from Grid Comms: 590 /// Another region is up.
591 /// (OGS1 -> LocalBackEnd -> RegionListened -> SceneCommunicationService)
592 /// We have to tell all our ScenePresences about it, and add it to the
593 /// neighbor list.
594 /// 591 ///
595 /// We only add it to the neighbor list if it's within 1 region from here. 592 /// We only add it to the neighbor list if it's within 1 region from here.
596 /// Agents may have draw distance values that cross two regions though, so 593 /// Agents may have draw distance values that cross two regions though, so
@@ -599,47 +596,27 @@ namespace OpenSim.Region.Framework.Scenes
599 /// </summary> 596 /// </summary>
600 /// <param name="otherRegion">RegionInfo handle for the new region.</param> 597 /// <param name="otherRegion">RegionInfo handle for the new region.</param>
601 /// <returns>True after all operations complete, throws exceptions otherwise.</returns> 598 /// <returns>True after all operations complete, throws exceptions otherwise.</returns>
602 public override bool OtherRegionUp(RegionInfo otherRegion) 599 public override void OtherRegionUp(GridRegion otherRegion)
603 { 600 {
604 m_log.InfoFormat("[SCENE]: Region {0} up in coords {1}-{2}", otherRegion.RegionName, otherRegion.RegionLocX, otherRegion.RegionLocY); 601 uint xcell = (uint)((int)otherRegion.RegionLocX / (int)Constants.RegionSize);
602 uint ycell = (uint)((int)otherRegion.RegionLocY / (int)Constants.RegionSize);
603 m_log.InfoFormat("[SCENE]: (on region {0}): Region {1} up in coords {2}-{3}",
604 RegionInfo.RegionName, otherRegion.RegionName, xcell, ycell);
605 605
606 if (RegionInfo.RegionHandle != otherRegion.RegionHandle) 606 if (RegionInfo.RegionHandle != otherRegion.RegionHandle)
607 { 607 {
608 for (int i = 0; i < m_neighbours.Count; i++)
609 {
610 // The purpose of this loop is to re-update the known neighbors
611 // when another region comes up on top of another one.
612 // The latest region in that location ends up in the
613 // 'known neighbors list'
614 // Additionally, the commFailTF property gets reset to false.
615 if (m_neighbours[i].RegionHandle == otherRegion.RegionHandle)
616 {
617 lock (m_neighbours)
618 {
619 m_neighbours[i] = otherRegion;
620
621 }
622 }
623 }
624
625 // If the value isn't in the neighbours, add it.
626 // If the RegionInfo isn't exact but is for the same XY World location,
627 // then the above loop will fix that.
628
629 if (!(CheckNeighborRegion(otherRegion)))
630 {
631 lock (m_neighbours)
632 {
633 m_neighbours.Add(otherRegion);
634 //m_log.Info("[UP]: " + otherRegion.RegionHandle.ToString());
635 }
636 }
637 608
638 // If these are cast to INT because long + negative values + abs returns invalid data 609 // If these are cast to INT because long + negative values + abs returns invalid data
639 int resultX = Math.Abs((int)otherRegion.RegionLocX - (int)RegionInfo.RegionLocX); 610 int resultX = Math.Abs((int)xcell - (int)RegionInfo.RegionLocX);
640 int resultY = Math.Abs((int)otherRegion.RegionLocY - (int)RegionInfo.RegionLocY); 611 int resultY = Math.Abs((int)ycell - (int)RegionInfo.RegionLocY);
641 if (resultX <= 1 && resultY <= 1) 612 if (resultX <= 1 && resultY <= 1)
642 { 613 {
614 RegionInfo regInfo = new RegionInfo(xcell, ycell, otherRegion.InternalEndPoint, otherRegion.ExternalHostName);
615 regInfo.RegionID = otherRegion.RegionID;
616 regInfo.RegionName = otherRegion.RegionName;
617 regInfo.ScopeID = otherRegion.ScopeID;
618 regInfo.ExternalHostName = otherRegion.ExternalHostName;
619
643 try 620 try
644 { 621 {
645 ForEachScenePresence(delegate(ScenePresence agent) 622 ForEachScenePresence(delegate(ScenePresence agent)
@@ -653,7 +630,7 @@ namespace OpenSim.Region.Framework.Scenes
653 List<ulong> old = new List<ulong>(); 630 List<ulong> old = new List<ulong>();
654 old.Add(otherRegion.RegionHandle); 631 old.Add(otherRegion.RegionHandle);
655 agent.DropOldNeighbours(old); 632 agent.DropOldNeighbours(old);
656 InformClientOfNeighbor(agent, otherRegion); 633 InformClientOfNeighbor(agent, regInfo);
657 } 634 }
658 } 635 }
659 ); 636 );
@@ -672,7 +649,6 @@ namespace OpenSim.Region.Framework.Scenes
672 otherRegion.RegionLocY.ToString() + ")"); 649 otherRegion.RegionLocY.ToString() + ")");
673 } 650 }
674 } 651 }
675 return true;
676 } 652 }
677 653
678 public void AddNeighborRegion(RegionInfo region) 654 public void AddNeighborRegion(RegionInfo region)
@@ -704,9 +680,10 @@ namespace OpenSim.Region.Framework.Scenes
704 } 680 }
705 681
706 // Alias IncomingHelloNeighbour OtherRegionUp, for now 682 // Alias IncomingHelloNeighbour OtherRegionUp, for now
707 public bool IncomingHelloNeighbour(RegionInfo neighbour) 683 public GridRegion IncomingHelloNeighbour(RegionInfo neighbour)
708 { 684 {
709 return OtherRegionUp(neighbour); 685 OtherRegionUp(new GridRegion(neighbour));
686 return new GridRegion(RegionInfo);
710 } 687 }
711 688
712 /// <summary> 689 /// <summary>
@@ -3104,7 +3081,7 @@ namespace OpenSim.Region.Framework.Scenes
3104 m_sceneGridService.OnExpectUser += HandleNewUserConnection; 3081 m_sceneGridService.OnExpectUser += HandleNewUserConnection;
3105 m_sceneGridService.OnAvatarCrossingIntoRegion += AgentCrossing; 3082 m_sceneGridService.OnAvatarCrossingIntoRegion += AgentCrossing;
3106 m_sceneGridService.OnCloseAgentConnection += IncomingCloseAgent; 3083 m_sceneGridService.OnCloseAgentConnection += IncomingCloseAgent;
3107 m_sceneGridService.OnRegionUp += OtherRegionUp; 3084 //m_eventManager.OnRegionUp += OtherRegionUp;
3108 //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; 3085 //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate;
3109 m_sceneGridService.OnExpectPrim += IncomingInterRegionPrimGroup; 3086 m_sceneGridService.OnExpectPrim += IncomingInterRegionPrimGroup;
3110 //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar; 3087 //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar;
@@ -3132,7 +3109,7 @@ namespace OpenSim.Region.Framework.Scenes
3132 //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar; 3109 //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar;
3133 m_sceneGridService.OnExpectPrim -= IncomingInterRegionPrimGroup; 3110 m_sceneGridService.OnExpectPrim -= IncomingInterRegionPrimGroup;
3134 //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; 3111 //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate;
3135 m_sceneGridService.OnRegionUp -= OtherRegionUp; 3112 //m_eventManager.OnRegionUp -= OtherRegionUp;
3136 m_sceneGridService.OnExpectUser -= HandleNewUserConnection; 3113 m_sceneGridService.OnExpectUser -= HandleNewUserConnection;
3137 m_sceneGridService.OnAvatarCrossingIntoRegion -= AgentCrossing; 3114 m_sceneGridService.OnAvatarCrossingIntoRegion -= AgentCrossing;
3138 m_sceneGridService.OnCloseAgentConnection -= IncomingCloseAgent; 3115 m_sceneGridService.OnCloseAgentConnection -= IncomingCloseAgent;
diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs
index 2a82237..2af98cc 100644
--- a/OpenSim/Region/Framework/Scenes/SceneBase.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs
@@ -36,6 +36,7 @@ using OpenSim.Framework;
36using OpenSim.Framework.Console; 36using OpenSim.Framework.Console;
37using OpenSim.Framework.Communications.Cache; 37using OpenSim.Framework.Communications.Cache;
38using OpenSim.Region.Framework.Interfaces; 38using OpenSim.Region.Framework.Interfaces;
39using GridRegion = OpenSim.Services.Interfaces.GridRegion;
39 40
40namespace OpenSim.Region.Framework.Scenes 41namespace OpenSim.Region.Framework.Scenes
41{ 42{
@@ -227,7 +228,7 @@ namespace OpenSim.Region.Framework.Scenes
227 return false; 228 return false;
228 } 229 }
229 230
230 public abstract bool OtherRegionUp(RegionInfo thisRegion); 231 public abstract void OtherRegionUp(GridRegion otherRegion);
231 232
232 public virtual string GetSimulatorVersion() 233 public virtual string GetSimulatorVersion()
233 { 234 {
diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
index 9071701..3294ceb 100644
--- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
@@ -93,10 +93,10 @@ namespace OpenSim.Region.Framework.Scenes
93 /// </summary> 93 /// </summary>
94 public event PrimCrossing OnPrimCrossingIntoRegion; 94 public event PrimCrossing OnPrimCrossingIntoRegion;
95 95
96 /// <summary> 96 ///// <summary>
97 /// A New Region is up and available 97 ///// A New Region is up and available
98 /// </summary> 98 ///// </summary>
99 public event RegionUp OnRegionUp; 99 //public event RegionUp OnRegionUp;
100 100
101 /// <summary> 101 /// <summary>
102 /// We have a child agent for this avatar and we're getting a status update about it 102 /// 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
119 private ExpectPrimDelegate handlerExpectPrim = null; // OnExpectPrim; 119 private ExpectPrimDelegate handlerExpectPrim = null; // OnExpectPrim;
120 private CloseAgentConnection handlerCloseAgentConnection = null; // OnCloseAgentConnection; 120 private CloseAgentConnection handlerCloseAgentConnection = null; // OnCloseAgentConnection;
121 private PrimCrossing handlerPrimCrossingIntoRegion = null; // OnPrimCrossingIntoRegion; 121 private PrimCrossing handlerPrimCrossingIntoRegion = null; // OnPrimCrossingIntoRegion;
122 private RegionUp handlerRegionUp = null; // OnRegionUp; 122 //private RegionUp handlerRegionUp = null; // OnRegionUp;
123 private ChildAgentUpdate handlerChildAgentUpdate = null; // OnChildAgentUpdate; 123 private ChildAgentUpdate handlerChildAgentUpdate = null; // OnChildAgentUpdate;
124 //private RemoveKnownRegionsFromAvatarList handlerRemoveKnownRegionFromAvatar = null; // OnRemoveKnownRegionFromAvatar; 124 //private RemoveKnownRegionsFromAvatarList handlerRemoveKnownRegionFromAvatar = null; // OnRemoveKnownRegionFromAvatar;
125 private LogOffUser handlerLogOffUser = null; 125 private LogOffUser handlerLogOffUser = null;
@@ -239,22 +239,6 @@ namespace OpenSim.Region.Framework.Scenes
239 } 239 }
240 240
241 /// <summary> 241 /// <summary>
242 /// A New Region is now available. Inform the scene that there is a new region available.
243 /// </summary>
244 /// <param name="region">Information about the new region that is available</param>
245 /// <returns>True if the event was handled</returns>
246 protected bool newRegionUp(RegionInfo region)
247 {
248 handlerRegionUp = OnRegionUp;
249 if (handlerRegionUp != null)
250 {
251 //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: newRegionUp Fired for User:" + region.RegionName);
252 handlerRegionUp(region);
253 }
254 return true;
255 }
256
257 /// <summary>
258 /// Inform the scene that we've got an update about a child agent that we have 242 /// Inform the scene that we've got an update about a child agent that we have
259 /// </summary> 243 /// </summary>
260 /// <param name="cAgentData"></param> 244 /// <param name="cAgentData"></param>
@@ -647,31 +631,23 @@ namespace OpenSim.Region.Framework.Scenes
647 /// <param name="regionhandle"></param> 631 /// <param name="regionhandle"></param>
648 private void InformNeighboursThatRegionIsUpAsync(INeighbourService neighbourService, RegionInfo region, ulong regionhandle) 632 private void InformNeighboursThatRegionIsUpAsync(INeighbourService neighbourService, RegionInfo region, ulong regionhandle)
649 { 633 {
650 m_log.Info("[INTERGRID]: Starting to inform neighbors that I'm here"); 634 uint x = 0, y = 0;
651 //RegionUpData regiondata = new RegionUpData(region.RegionLocX, region.RegionLocY, region.ExternalHostName, region.InternalEndPoint.Port); 635 Utils.LongToUInts(regionhandle, out x, out y);
652 636
653 //bool regionAccepted = 637 GridRegion neighbour = null;
654 // m_commsProvider.InterRegion.RegionUp(new SerializableRegionInfo(region), regionhandle);
655
656 //bool regionAccepted = m_interregionCommsOut.SendHelloNeighbour(regionhandle, region);
657 bool regionAccepted = false;
658 if (neighbourService != null) 638 if (neighbourService != null)
659 regionAccepted = neighbourService.HelloNeighbour(regionhandle, region); 639 neighbour = neighbourService.HelloNeighbour(regionhandle, region);
660 else 640 else
661 m_log.DebugFormat("[SCS]: No neighbour service provided for informing neigbhours of this region"); 641 m_log.DebugFormat("[SCS]: No neighbour service provided for informing neigbhours of this region");
662 642
663 if (regionAccepted) 643 if (neighbour != null)
664 { 644 {
665 m_log.Info("[INTERGRID]: Completed informing neighbors that I'm here"); 645 m_log.DebugFormat("[INTERGRID]: Successfully informed neighbour {0}-{1} that I'm here", x / Constants.RegionSize, y / Constants.RegionSize);
666 handlerRegionUp = OnRegionUp; 646 m_scene.EventManager.TriggerOnRegionUp(neighbour);
667
668 // yes, we're notifying ourselves.
669 if (handlerRegionUp != null)
670 handlerRegionUp(region);
671 } 647 }
672 else 648 else
673 { 649 {
674 m_log.Warn("[INTERGRID]: Failed to inform neighbors that I'm here."); 650 m_log.WarnFormat("[INTERGRID]: Failed to inform neighbour {0}-{1} that I'm here.", x / Constants.RegionSize, y / Constants.RegionSize);
675 } 651 }
676 } 652 }
677 653
@@ -680,22 +656,33 @@ namespace OpenSim.Region.Framework.Scenes
680 { 656 {
681 //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: Sending InterRegion Notification that region is up " + region.RegionName); 657 //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: Sending InterRegion Notification that region is up " + region.RegionName);
682 658
659 for (int x = (int)region.RegionLocX - 1; x <= region.RegionLocX + 1; x++)
660 for (int y = (int)region.RegionLocY - 1; y <= region.RegionLocY + 1; y++)
661 if (!((x == region.RegionLocX) && (y == region.RegionLocY))) // skip this region
662 {
663 ulong handle = Utils.UIntsToLong((uint)x * Constants.RegionSize, (uint)y * Constants.RegionSize);
664 InformNeighbourThatRegionUpDelegate d = InformNeighboursThatRegionIsUpAsync;
683 665
684 List<GridRegion> neighbours = new List<GridRegion>(); 666 d.BeginInvoke(neighbourService, region, handle,
685 // This stays uncached because we don't already know about our neighbors at this point. 667 InformNeighborsThatRegionisUpCompleted,
668 d);
669 }
686 670
687 neighbours = m_scene.GridService.GetNeighbours(m_regionInfo.ScopeID, m_regionInfo.RegionID); 671 //List<GridRegion> neighbours = new List<GridRegion>();
688 if (neighbours != null) 672 //// This stays uncached because we don't already know about our neighbors at this point.
689 {
690 for (int i = 0; i < neighbours.Count; i++)
691 {
692 InformNeighbourThatRegionUpDelegate d = InformNeighboursThatRegionIsUpAsync;
693 673
694 d.BeginInvoke(neighbourService, region, neighbours[i].RegionHandle, 674 //neighbours = m_scene.GridService.GetNeighbours(m_regionInfo.ScopeID, m_regionInfo.RegionID);
695 InformNeighborsThatRegionisUpCompleted, 675 //if (neighbours != null)
696 d); 676 //{
697 } 677 // for (int i = 0; i < neighbours.Count; i++)
698 } 678 // {
679 // InformNeighbourThatRegionUpDelegate d = InformNeighboursThatRegionIsUpAsync;
680
681 // d.BeginInvoke(neighbourService, region, neighbours[i].RegionHandle,
682 // InformNeighborsThatRegionisUpCompleted,
683 // d);
684 // }
685 //}
699 686
700 //bool val = m_commsProvider.InterRegion.RegionUp(new SerializableRegionInfo(region)); 687 //bool val = m_commsProvider.InterRegion.RegionUp(new SerializableRegionInfo(region));
701 } 688 }
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs
index f6737a5..5c9e66f 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs
@@ -29,6 +29,7 @@ using System;
29using NUnit.Framework; 29using NUnit.Framework;
30using OpenMetaverse; 30using OpenMetaverse;
31using OpenSim.Framework; 31using OpenSim.Framework;
32using GridRegion = OpenSim.Services.Interfaces.GridRegion;
32 33
33namespace OpenSim.Region.Framework.Scenes.Tests 34namespace OpenSim.Region.Framework.Scenes.Tests
34{ 35{
@@ -65,7 +66,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
65 throw new NotImplementedException(); 66 throw new NotImplementedException();
66 } 67 }
67 68
68 public override bool OtherRegionUp(RegionInfo thisRegion) 69 public override void OtherRegionUp(GridRegion otherRegion)
69 { 70 {
70 throw new NotImplementedException(); 71 throw new NotImplementedException();
71 } 72 }