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