From 5757afe7665543e8b3ed4a322a7d6e095dafcdb3 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 26 Sep 2009 07:48:21 -0700 Subject: First pass at the heart surgery for grid services. Compiles and runs minimally. A few bugs to catch now. --- OpenSim/Region/Framework/Scenes/Scene.cs | 114 +++++++++++++++++-------------- 1 file changed, 62 insertions(+), 52 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index d8478a2..8990f29 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -49,6 +49,7 @@ using OpenSim.Region.Framework.Scenes.Serialization; using OpenSim.Region.Physics.Manager; using Timer=System.Timers.Timer; using TPFlags = OpenSim.Framework.Constants.TeleportFlags; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; namespace OpenSim.Region.Framework.Scenes { @@ -193,6 +194,26 @@ namespace OpenSim.Region.Framework.Scenes } } + protected IGridService m_GridService = null; + + public IGridService GridService + { + get + { + if (m_GridService == null) + { + m_GridService = RequestModuleInterface(); + + if (m_GridService == null) + { + throw new Exception("No IGridService available. This could happen if the config_include folder doesn't exist or if the OpenSim.ini [Architecture] section isn't set. Please also check that you have the correct version of your inventory service dll. Sometimes old versions of this dll will still exist. Do a clean checkout and re-create the opensim.ini from the opensim.ini.example."); + } + } + + return m_GridService; + } + } + protected IXMLRPC m_xmlrpcModule; protected IWorldComm m_worldCommModule; protected IAvatarFactory m_AvatarFactory; @@ -1336,24 +1357,31 @@ namespace OpenSim.Region.Framework.Scenes RegisterCommsEvents(); // These two 'commands' *must be* next to each other or sim rebooting fails. - m_sceneGridService.RegisterRegion(m_interregionCommsOut, RegionInfo); + //m_sceneGridService.RegisterRegion(m_interregionCommsOut, RegionInfo); + + GridRegion region = new GridRegion(RegionInfo); + bool success = GridService.RegisterRegion(RegionInfo.ScopeID, region); + if (!success) + throw new Exception("Can't register with grid"); + + m_sceneGridService.SetScene(this); m_sceneGridService.InformNeighborsThatRegionisUp(RequestModuleInterface(), RegionInfo); - Dictionary dGridSettings = m_sceneGridService.GetGridSettings(); + //Dictionary dGridSettings = m_sceneGridService.GetGridSettings(); - if (dGridSettings.ContainsKey("allow_forceful_banlines")) - { - if (dGridSettings["allow_forceful_banlines"] != "TRUE") - { - m_log.Info("[GRID]: Grid is disabling forceful parcel banlists"); - EventManager.TriggerSetAllowForcefulBan(false); - } - else - { - m_log.Info("[GRID]: Grid is allowing forceful parcel banlists"); - EventManager.TriggerSetAllowForcefulBan(true); - } - } + //if (dGridSettings.ContainsKey("allow_forceful_banlines")) + //{ + // if (dGridSettings["allow_forceful_banlines"] != "TRUE") + // { + // m_log.Info("[GRID]: Grid is disabling forceful parcel banlists"); + // EventManager.TriggerSetAllowForcefulBan(false); + // } + // else + // { + // m_log.Info("[GRID]: Grid is allowing forceful parcel banlists"); + // EventManager.TriggerSetAllowForcefulBan(true); + // } + //} } /// @@ -2717,10 +2745,12 @@ namespace OpenSim.Region.Framework.Scenes UserProfileData UserProfile = CommsManager.UserService.GetUserProfile(agentId); if (UserProfile != null) { - RegionInfo regionInfo = CommsManager.GridService.RequestNeighbourInfo(UserProfile.HomeRegionID); + GridRegion regionInfo = GridService.GetRegionByUUID(UUID.Zero, UserProfile.HomeRegionID); if (regionInfo == null) { - regionInfo = CommsManager.GridService.RequestNeighbourInfo(UserProfile.HomeRegion); + uint x = 0, y = 0; + Utils.LongToUInts(UserProfile.HomeRegion, out x, out y); + regionInfo = GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y); if (regionInfo != null) // home region can be away temporarily, too { UserProfile.HomeRegionID = regionInfo.RegionID; @@ -3111,7 +3141,11 @@ namespace OpenSim.Region.Framework.Scenes if (m_interregionCommsIn != null) m_interregionCommsIn.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; + // this does nothing; should be removed m_sceneGridService.Close(); + + if (!GridService.DeregisterRegion(m_regInfo.RegionID)) + m_log.WarnFormat("[SCENE]: Deregister from grid failed for region {0}", m_regInfo.RegionName); } /// @@ -3557,30 +3591,6 @@ namespace OpenSim.Region.Framework.Scenes } /// - /// Requests information about this region from gridcomms - /// - /// - /// - public RegionInfo RequestNeighbouringRegionInfo(ulong regionHandle) - { - return m_sceneGridService.RequestNeighbouringRegionInfo(regionHandle); - } - - /// - /// Requests textures for map from minimum region to maximum region in world cordinates - /// - /// - /// - /// - /// - /// - public void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY) - { - m_log.DebugFormat("[MAPBLOCK]: {0}-{1}, {2}-{3}", minX, minY, maxX, maxY); - m_sceneGridService.RequestMapBlocks(remoteClient, minX, minY, maxX, maxY); - } - - /// /// Tries to teleport agent to other region. /// /// @@ -3591,7 +3601,7 @@ namespace OpenSim.Region.Framework.Scenes public void RequestTeleportLocation(IClientAPI remoteClient, string regionName, Vector3 position, Vector3 lookat, uint teleportFlags) { - RegionInfo regionInfo = m_sceneGridService.RequestClosestRegion(regionName); + GridRegion regionInfo = GridService.GetRegionByName(UUID.Zero, regionName); if (regionInfo == null) { // can't find the region: Tell viewer and abort @@ -3680,7 +3690,7 @@ namespace OpenSim.Region.Framework.Scenes /// public void RequestTeleportLandmark(IClientAPI remoteClient, UUID regionID, Vector3 position) { - RegionInfo info = CommsManager.GridService.RequestNeighbourInfo(regionID); + GridRegion info = GridService.GetRegionByUUID(UUID.Zero, regionID); if (info == null) { @@ -3864,10 +3874,6 @@ namespace OpenSim.Region.Framework.Scenes return LandChannel.GetLandObject((int)x, (int)y).landData; } - public RegionInfo RequestClosestRegion(string name) - { - return m_sceneGridService.RequestClosestRegion(name); - } #endregion @@ -4178,14 +4184,18 @@ namespace OpenSim.Region.Framework.Scenes public void RegionHandleRequest(IClientAPI client, UUID regionID) { - RegionInfo info; + ulong handle = 0; if (regionID == RegionInfo.RegionID) - info = RegionInfo; + handle = RegionInfo.RegionHandle; else - info = CommsManager.GridService.RequestNeighbourInfo(regionID); + { + GridRegion r = GridService.GetRegionByUUID(UUID.Zero, regionID); + if (r != null) + handle = r.RegionHandle; + } - if (info != null) - client.SendRegionHandle(regionID, info.RegionHandle); + if (handle != 0) + client.SendRegionHandle(regionID, handle); } public void TerrainUnAcked(IClientAPI client, int patchX, int patchY) -- cgit v1.1 From 5d09c53a1a42b38e1ee35cfbb5571d70b75380f4 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 27 Sep 2009 10:14:10 -0700 Subject: Unpacking the mess with OtherRegionUp, so we can have a real cache of the neighbours in the grid service modules. --- OpenSim/Region/Framework/Scenes/Scene.cs | 63 ++++++++++---------------------- 1 file changed, 20 insertions(+), 43 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs') 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 } /// - /// 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 /// /// RegionInfo handle for the new region. /// True after all operations complete, throws exceptions otherwise. - 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 old = new List(); 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); } /// @@ -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; -- cgit v1.1 From 2432cc607ec206b79149c1e9b1aa995794fec3bc Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 27 Sep 2009 13:43:57 -0700 Subject: Neighbours cache working. --- OpenSim/Region/Framework/Scenes/Scene.cs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 55478da..bb47ff4 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -611,6 +611,9 @@ namespace OpenSim.Region.Framework.Scenes int resultY = Math.Abs((int)ycell - (int)RegionInfo.RegionLocY); if (resultX <= 1 && resultY <= 1) { + // Let the grid service module know, so this can be cached + m_eventManager.TriggerOnRegionUp(otherRegion); + RegionInfo regInfo = new RegionInfo(xcell, ycell, otherRegion.InternalEndPoint, otherRegion.ExternalHostName); regInfo.RegionID = otherRegion.RegionID; regInfo.RegionName = otherRegion.RegionName; @@ -641,6 +644,7 @@ namespace OpenSim.Region.Framework.Scenes // This shouldn't happen too often anymore. m_log.Error("[SCENE]: Couldn't inform client of regionup because we got a null reference exception"); } + } else { -- cgit v1.1 From bc892c1d4c1f1e818f1dd1d3cf6d03186b19dd0b Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 29 Sep 2009 07:54:56 -0700 Subject: A little hack to see if this fixes the problems with ~20% of SOG's becoming phantom after an import to megaregions. --- OpenSim/Region/Framework/Scenes/Scene.cs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index bb47ff4..39f3007 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -4141,6 +4141,11 @@ namespace OpenSim.Region.Framework.Scenes m_sceneGraph.ForEachClient(action); } + public void ForEachSOG(Action action) + { + m_sceneGraph.ForEachSOG(action); + } + /// /// Returns a list of the entities in the scene. This is a new list so operations perform on the list itself /// will not affect the original list of objects in the scene. -- cgit v1.1 From ee205e7e812e170f670e690a4e0fa9caa652f226 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Thu, 1 Oct 2009 01:00:09 +0900 Subject: Formatting cleanup. --- OpenSim/Region/Framework/Scenes/Scene.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 39f3007..f8db354 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -996,7 +996,7 @@ namespace OpenSim.Region.Framework.Scenes // Loop it if (m_frame == Int32.MaxValue) - m_frame = 0; + m_frame = 0; otherMS = Environment.TickCount; // run through all entities looking for updates (slow) @@ -2023,12 +2023,12 @@ namespace OpenSim.Region.Framework.Scenes return true; } break; - case Cardinals.W: + case Cardinals.W: foreach (Border b in WestBorders) { if (b.TestCross(position)) return true; - } + } break; } } @@ -3270,7 +3270,7 @@ namespace OpenSim.Region.Framework.Scenes m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); //reason = String.Format("You are not currently on the access list for {0}",RegionInfo.RegionName); - return false; + return false; } } -- cgit v1.1