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. --- .../Communications/Clients/RegionClient.cs | 16 +- OpenSim/Region/Application/HGCommands.cs | 212 ---------------- OpenSim/Region/Application/OpenSim.cs | 5 - OpenSim/Region/Application/OpenSimBase.cs | 2 +- .../CoreModules/Avatar/Friends/FriendsModule.cs | 13 +- .../Avatar/InstantMessage/MessageTransferModule.cs | 8 +- .../Avatar/InstantMessage/PresenceModule.cs | 6 +- .../Framework/Services/RegionMapService.cs | 208 ---------------- .../CoreModules/Hypergrid/HGWorldMapModule.cs | 13 +- .../ServiceConnectorsOut/Grid/HGGridConnector.cs | 28 ++- .../Interregion/RESTInterregionComms.cs | 36 ++- .../Land/RemoteLandServiceConnector.cs | 3 +- .../Neighbour/RemoteNeighourServiceConnector.cs | 3 +- .../CoreModules/World/Land/LandManagementModule.cs | 26 +- .../CoreModules/World/WorldMap/MapSearchModule.cs | 26 +- .../CoreModules/World/WorldMap/WorldMapModule.cs | 94 +++++-- .../Framework/Scenes/Hypergrid/HGHyperlink.cs | 232 ----------------- .../Region/Framework/Scenes/Hypergrid/HGScene.cs | 3 +- .../Hypergrid/HGSceneCommunicationService.cs | 6 +- OpenSim/Region/Framework/Scenes/Scene.cs | 114 +++++---- .../Framework/Scenes/SceneCommunicationService.cs | 275 ++++++++------------- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 6 +- .../Shared/Api/Implementation/LSL_Api.cs | 11 +- .../Shared/Api/Implementation/OSSL_Api.cs | 25 +- .../Connectors/Land/LandServiceConnector.cs | 13 +- .../Neighbour/NeighbourServiceConnector.cs | 16 +- OpenSim/Services/Interfaces/IGridService.cs | 27 +- 27 files changed, 444 insertions(+), 983 deletions(-) delete mode 100644 OpenSim/Region/CoreModules/Framework/Services/RegionMapService.cs delete mode 100644 OpenSim/Region/Framework/Scenes/Hypergrid/HGHyperlink.cs (limited to 'OpenSim') diff --git a/OpenSim/Framework/Communications/Clients/RegionClient.cs b/OpenSim/Framework/Communications/Clients/RegionClient.cs index 73e2db0..3419ce2 100644 --- a/OpenSim/Framework/Communications/Clients/RegionClient.cs +++ b/OpenSim/Framework/Communications/Clients/RegionClient.cs @@ -35,6 +35,8 @@ using System.Text; using OpenMetaverse; using OpenMetaverse.StructuredData; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; + using log4net; namespace OpenSim.Framework.Communications.Clients @@ -43,7 +45,7 @@ namespace OpenSim.Framework.Communications.Clients { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - public bool DoCreateChildAgentCall(RegionInfo region, AgentCircuitData aCircuit, string authKey, out string reason) + public bool DoCreateChildAgentCall(GridRegion region, AgentCircuitData aCircuit, string authKey, out string reason) { reason = String.Empty; @@ -166,7 +168,7 @@ namespace OpenSim.Framework.Communications.Clients } - public bool DoChildAgentUpdateCall(RegionInfo region, IAgentData cAgentData) + public bool DoChildAgentUpdateCall(GridRegion region, IAgentData cAgentData) { // Eventually, we want to use a caps url instead of the agentID string uri = string.Empty; @@ -260,7 +262,7 @@ namespace OpenSim.Framework.Communications.Clients return true; } - public bool DoRetrieveRootAgentCall(RegionInfo region, UUID id, out IAgentData agent) + public bool DoRetrieveRootAgentCall(GridRegion region, UUID id, out IAgentData agent) { agent = null; // Eventually, we want to use a caps url instead of the agentID @@ -348,7 +350,7 @@ namespace OpenSim.Framework.Communications.Clients } - public bool DoCloseAgentCall(RegionInfo region, UUID id) + public bool DoCloseAgentCall(GridRegion region, UUID id) { string uri = string.Empty; try @@ -391,7 +393,7 @@ namespace OpenSim.Framework.Communications.Clients return true; } - public bool DoCreateObjectCall(RegionInfo region, ISceneObject sog, string sogXml2, bool allowScriptCrossing) + public bool DoCreateObjectCall(GridRegion region, ISceneObject sog, string sogXml2, bool allowScriptCrossing) { ulong regionHandle = GetRegionHandle(region.RegionHandle); string uri @@ -474,7 +476,7 @@ namespace OpenSim.Framework.Communications.Clients } - public bool DoCreateObjectCall(RegionInfo region, UUID userID, UUID itemID) + public bool DoCreateObjectCall(GridRegion region, UUID userID, UUID itemID) { ulong regionHandle = GetRegionHandle(region.RegionHandle); string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/object/" + UUID.Zero + "/" + regionHandle.ToString() + "/"; @@ -646,7 +648,7 @@ namespace OpenSim.Framework.Communications.Clients return false; } - public virtual void SendUserInformation(RegionInfo regInfo, AgentCircuitData aCircuit) + public virtual void SendUserInformation(GridRegion regInfo, AgentCircuitData aCircuit) { } diff --git a/OpenSim/Region/Application/HGCommands.cs b/OpenSim/Region/Application/HGCommands.cs index 1786e54..f99c1a5 100644 --- a/OpenSim/Region/Application/HGCommands.cs +++ b/OpenSim/Region/Application/HGCommands.cs @@ -45,10 +45,6 @@ namespace OpenSim private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public static IHyperlink HGServices = null; - private static uint m_autoMappingX = 0; - private static uint m_autoMappingY = 0; - private static bool m_enableAutoMapping = false; - public static Scene CreateScene(RegionInfo regionInfo, AgentCircuitManager circuitManager, CommunicationsManager m_commsManager, StorageManager storageManager, ModuleLoader m_moduleLoader, ConfigSettings m_configSettings, OpenSimConfigSource m_config, string m_version) { @@ -61,213 +57,5 @@ namespace OpenSim m_configSettings.See_into_region_from_neighbor, m_config.Source, m_version); } - public static void RunHGCommand(string command, string[] cmdparams, Scene scene) - { - if (command.Equals("link-mapping")) - { - if (cmdparams.Length == 2) - { - try - { - m_autoMappingX = Convert.ToUInt32(cmdparams[0]); - m_autoMappingY = Convert.ToUInt32(cmdparams[1]); - m_enableAutoMapping = true; - } - catch (Exception) - { - m_autoMappingX = 0; - m_autoMappingY = 0; - m_enableAutoMapping = false; - } - } - } - else if (command.Equals("link-region")) - { - if (cmdparams.Length < 3) - { - if ((cmdparams.Length == 1) || (cmdparams.Length == 2)) - { - LoadXmlLinkFile(cmdparams, scene); - } - else - { - LinkRegionCmdUsage(); - } - return; - } - - if (cmdparams[2].Contains(":")) - { - // New format - uint xloc, yloc; - string mapName; - try - { - xloc = Convert.ToUInt32(cmdparams[0]); - yloc = Convert.ToUInt32(cmdparams[1]); - mapName = cmdparams[2]; - if (cmdparams.Length > 3) - for (int i = 3; i < cmdparams.Length; i++) - mapName += " " + cmdparams[i]; - - m_log.Info(">> MapName: " + mapName); - //internalPort = Convert.ToUInt32(cmdparams[4]); - //remotingPort = Convert.ToUInt32(cmdparams[5]); - } - catch (Exception e) - { - m_log.Warn("[HGrid] Wrong format for link-region command: " + e.Message); - LinkRegionCmdUsage(); - return; - } - - HGHyperlink.TryLinkRegionToCoords(scene, null, mapName, xloc, yloc); - } - else - { - // old format - RegionInfo regInfo; - uint xloc, yloc; - uint externalPort; - string externalHostName; - try - { - xloc = Convert.ToUInt32(cmdparams[0]); - yloc = Convert.ToUInt32(cmdparams[1]); - externalPort = Convert.ToUInt32(cmdparams[3]); - externalHostName = cmdparams[2]; - //internalPort = Convert.ToUInt32(cmdparams[4]); - //remotingPort = Convert.ToUInt32(cmdparams[5]); - } - catch (Exception e) - { - m_log.Warn("[HGrid] Wrong format for link-region command: " + e.Message); - LinkRegionCmdUsage(); - return; - } - - //if (TryCreateLink(xloc, yloc, externalPort, externalHostName, out regInfo)) - if (HGHyperlink.TryCreateLink(scene, null, xloc, yloc, "", externalPort, externalHostName, out regInfo)) - { - if (cmdparams.Length >= 5) - { - regInfo.RegionName = ""; - for (int i = 4; i < cmdparams.Length; i++) - regInfo.RegionName += cmdparams[i] + " "; - } - } - } - return; - } - else if (command.Equals("unlink-region")) - { - if (cmdparams.Length < 1) - { - UnlinkRegionCmdUsage(); - return; - } - if (HGHyperlink.TryUnlinkRegion(scene, cmdparams[0])) - m_log.InfoFormat("[HGrid]: Successfully unlinked {0}", cmdparams[0]); - else - m_log.InfoFormat("[HGrid]: Unable to unlink {0}, region not found", cmdparams[0]); - } - } - - private static void LoadXmlLinkFile(string[] cmdparams, Scene scene) - { - //use http://www.hgurl.com/hypergrid.xml for test - try - { - XmlReader r = XmlReader.Create(cmdparams[0]); - XmlConfigSource cs = new XmlConfigSource(r); - string[] excludeSections = null; - - if (cmdparams.Length == 2) - { - if (cmdparams[1].ToLower().StartsWith("excludelist:")) - { - string excludeString = cmdparams[1].ToLower(); - excludeString = excludeString.Remove(0, 12); - char[] splitter = {';'}; - - excludeSections = excludeString.Split(splitter); - } - } - - for (int i = 0; i < cs.Configs.Count; i++) - { - bool skip = false; - if ((excludeSections != null) && (excludeSections.Length > 0)) - { - for (int n = 0; n < excludeSections.Length; n++) - { - if (excludeSections[n] == cs.Configs[i].Name.ToLower()) - { - skip = true; - break; - } - } - } - if (!skip) - { - ReadLinkFromConfig(cs.Configs[i], scene); - } - } - } - catch (Exception e) - { - m_log.Error(e.ToString()); - } - } - - - private static void ReadLinkFromConfig(IConfig config, Scene scene) - { - RegionInfo regInfo; - uint xloc, yloc; - uint externalPort; - string externalHostName; - uint realXLoc, realYLoc; - - xloc = Convert.ToUInt32(config.GetString("xloc", "0")); - yloc = Convert.ToUInt32(config.GetString("yloc", "0")); - externalPort = Convert.ToUInt32(config.GetString("externalPort", "0")); - externalHostName = config.GetString("externalHostName", ""); - realXLoc = Convert.ToUInt32(config.GetString("real-xloc", "0")); - realYLoc = Convert.ToUInt32(config.GetString("real-yloc", "0")); - - if (m_enableAutoMapping) - { - xloc = (uint) ((xloc%100) + m_autoMappingX); - yloc = (uint) ((yloc%100) + m_autoMappingY); - } - - if (((realXLoc == 0) && (realYLoc == 0)) || - (((realXLoc - xloc < 3896) || (xloc - realXLoc < 3896)) && - ((realYLoc - yloc < 3896) || (yloc - realYLoc < 3896)))) - { - if ( - HGHyperlink.TryCreateLink(scene, null, xloc, yloc, "", externalPort, - externalHostName, out regInfo)) - { - regInfo.RegionName = config.GetString("localName", ""); - } - } - } - - - private static void LinkRegionCmdUsage() - { - m_log.Info("Usage: link-region :[:]"); - m_log.Info("Usage: link-region []"); - m_log.Info("Usage: link-region []"); - } - - private static void UnlinkRegionCmdUsage() - { - m_log.Info("Usage: unlink-region :"); - m_log.Info("Usage: unlink-region "); - } - } } diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index e9c9dc1..c0bdc1e 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs @@ -755,11 +755,6 @@ namespace OpenSim } break; - case "link-region": - case "unlink-region": - case "link-mapping": - HGCommands.RunHGCommand(command, cmdparams, m_sceneManager.CurrentOrFirstScene); - break; } } diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index 4d13e83..821de35 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs @@ -399,7 +399,7 @@ namespace OpenSim } catch (Exception e) { - m_log.ErrorFormat("[STARTUP]: Registration of region with grid failed, aborting startup - {0}", e); + m_log.ErrorFormat("[STARTUP]: Registration of region with grid failed, aborting startup - {0}", e.StackTrace); // Carrying on now causes a lot of confusion down the // line - we need to get the user's attention diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index 49b2b5c..dd9b318 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -40,6 +40,7 @@ using OpenSim.Framework.Communications.Cache; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using OpenSim.Services.Interfaces; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; namespace OpenSim.Region.CoreModules.Avatar.Friends { @@ -108,7 +109,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends private Dictionary m_scenes = new Dictionary(); private IMessageTransferModule m_TransferModule = null; - private IGridServices m_gridServices = null; + private IGridService m_gridServices = null; #region IRegionModule Members @@ -142,7 +143,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends if (m_scenes.Count > 0) { m_TransferModule = m_initialScene.RequestModuleInterface(); - m_gridServices = m_initialScene.CommsManager.GridService; + m_gridServices = m_initialScene.GridService; } if (m_TransferModule == null) m_log.Error("[FRIENDS]: Unable to find a message transfer module, friendship offers will not work"); @@ -171,7 +172,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends List tpdAway = new List(); // destRegionHandle is a region on another server - RegionInfo info = m_gridServices.RequestNeighbourInfo(destRegionHandle); + uint x = 0, y = 0; + Utils.LongToUInts(destRegionHandle, out x, out y); + GridRegion info = m_gridServices.GetRegionByPosition(m_initialScene.RegionInfo.ScopeID, (int)x, (int)y); if (info != null) { string httpServer = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/presence_update_bulk"; @@ -223,7 +226,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends public bool TriggerTerminateFriend(ulong destRegionHandle, UUID agentID, UUID exFriendID) { // destRegionHandle is a region on another server - RegionInfo info = m_gridServices.RequestNeighbourInfo(destRegionHandle); + uint x = 0, y = 0; + Utils.LongToUInts(destRegionHandle, out x, out y); + GridRegion info = m_gridServices.GetRegionByPosition(m_initialScene.RegionInfo.ScopeID, (int)x, (int)y); if (info == null) { m_log.WarnFormat("[OGS1 GRID SERVICES]: Couldn't find region {0}", destRegionHandle); diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs index 4495303..e5159b3 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs @@ -36,6 +36,7 @@ using OpenMetaverse; using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; namespace OpenSim.Region.CoreModules.Avatar.InstantMessage { @@ -497,7 +498,10 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage { if (upd.AgentOnline) { - RegionInfo reginfo = m_Scenes[0].SceneGridService.RequestNeighbouringRegionInfo(upd.Handle); + uint x = 0, y = 0; + Utils.LongToUInts(upd.Handle, out x, out y); + GridRegion reginfo = m_Scenes[0].GridService.GetRegionByPosition(m_Scenes[0].RegionInfo.ScopeID, + (int)x, (int)y); if (reginfo != null) { Hashtable msgdata = ConvertGridInstantMessageToXMLRPC(im); @@ -559,7 +563,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage /// RegionInfo we pull the data out of to send the request to /// The Instant Message data Hashtable /// Bool if the message was successfully delivered at the other side. - protected virtual bool doIMSending(RegionInfo reginfo, Hashtable xmlrpcdata) + protected virtual bool doIMSending(GridRegion reginfo, Hashtable xmlrpcdata) { ArrayList SendParams = new ArrayList(); diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs index ebd9a72..6daab44 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs @@ -35,6 +35,7 @@ using OpenMetaverse; using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; namespace OpenSim.Region.CoreModules.Avatar.InstantMessage { @@ -171,7 +172,10 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage { // TODO this is the old messaging-server protocol; only the regionHandle is available. // Fetch region-info to get the id - RegionInfo regionInfo = m_initialScene.RequestNeighbouringRegionInfo(info.regionHandle); + uint x = 0, y = 0; + Utils.LongToUInts(info.regionHandle, out x, out y); + GridRegion regionInfo = m_initialScene.GridService.GetRegionByPosition(m_initialScene.RegionInfo.ScopeID, + (int)x, (int)y); regionID = regionInfo.RegionID; } result[indices[i]] = new PresenceInfo(uuids[i], regionID); diff --git a/OpenSim/Region/CoreModules/Framework/Services/RegionMapService.cs b/OpenSim/Region/CoreModules/Framework/Services/RegionMapService.cs deleted file mode 100644 index 8c92727..0000000 --- a/OpenSim/Region/CoreModules/Framework/Services/RegionMapService.cs +++ /dev/null @@ -1,208 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Net; -using System.Reflection; -using log4net; -using Nini.Config; -using OpenMetaverse; -using OpenSim.Data; -using OpenSim.Framework; -using OpenSim.Framework.Communications; -using OpenSim.Framework.Communications.Cache; -using OpenSim.Framework.Servers.HttpServer; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes; - -using Nwc.XmlRpc; - - -namespace OpenSim.Region.CoreModules.Framework.Services -{ - public class RegionMapService : IRegionModule - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private static bool initialized = false; - private static bool enabled = false; - - Scene m_scene; - //AssetService m_assetService; - - #region IRegionModule interface - - public void Initialise(Scene scene, IConfigSource config) - { - if (!initialized) - { - initialized = true; - m_scene = scene; - - // This module is only on for hypergrid mode - enabled = config.Configs["Startup"].GetBoolean("hypergrid", false); - } - } - - public void PostInitialise() - { - if (enabled) - { - m_log.Info("[RegionMapService]: Starting..."); - - //m_assetService = new AssetService(m_scene); - new GridService(m_scene); - } - } - - public void Close() - { - } - - public string Name - { - get { return "RegionMapService"; } - } - - public bool IsSharedModule - { - get { return true; } - } - - #endregion - - } - - public class GridService - { -// private IUserService m_userService; - private IGridServices m_gridService; - private bool m_doLookup = false; - - public bool DoLookup - { - get { return m_doLookup; } - set { m_doLookup = value; } - } - private static readonly ILog m_log - = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - public GridService(Scene m_scene) - { - AddHandlers(m_scene); -// m_userService = m_scene.CommsManager.UserService; - m_gridService = m_scene.CommsManager.GridService; - } - - protected void AddHandlers(Scene m_scene) - { -// IAssetDataPlugin m_assetProvider -// = ((AssetServerBase)m_scene.CommsManager.AssetCache.AssetServer).AssetProviderPlugin; - - IHttpServer httpServer = MainServer.Instance; - httpServer.AddXmlRPCHandler("simulator_data_request", XmlRpcSimulatorDataRequestMethod); - //m_httpServer.AddXmlRPCHandler("map_block", XmlRpcMapBlockMethod); - //m_httpServer.AddXmlRPCHandler("search_for_region_by_name", XmlRpcSearchForRegionMethod); - - } - - /// - /// Returns an XML RPC response to a simulator profile request - /// - /// - /// - public XmlRpcResponse XmlRpcSimulatorDataRequestMethod(XmlRpcRequest request, IPEndPoint remoteClient) - { - Hashtable requestData = (Hashtable)request.Params[0]; - Hashtable responseData = new Hashtable(); - RegionInfo simData = null; - if (requestData.ContainsKey("region_UUID")) - { - UUID regionID = new UUID((string)requestData["region_UUID"]); - simData = m_gridService.RequestNeighbourInfo(regionID); //.GetRegion(regionID); - if (simData == null) - { - m_log.WarnFormat("[HGGridService] didn't find region for regionID {0} from {1}", - regionID, request.Params.Count > 1 ? request.Params[1] : "unknwon source"); - } - } - else if (requestData.ContainsKey("region_handle")) - { - //CFK: The if/else below this makes this message redundant. - //CFK: m_log.Info("requesting data for region " + (string) requestData["region_handle"]); - ulong regionHandle = Convert.ToUInt64((string)requestData["region_handle"]); - simData = m_gridService.RequestNeighbourInfo(regionHandle); //m_gridDBService.GetRegion(regionHandle); - if (simData == null) - { - m_log.WarnFormat("[HGGridService] didn't find region for regionHandle {0} from {1}", - regionHandle, request.Params.Count > 1 ? request.Params[1] : "unknwon source"); - } - } - else if (requestData.ContainsKey("region_name_search")) - { - string regionName = (string)requestData["region_name_search"]; - List regInfos = m_gridService.RequestNamedRegions(regionName, 1);//m_gridDBService.GetRegion(regionName); - if (regInfos != null) - simData = regInfos[0]; - - if (simData == null) - { - m_log.WarnFormat("[HGGridService] didn't find region for regionName {0} from {1}", - regionName, request.Params.Count > 1 ? request.Params[1] : "unknwon source"); - } - } - else m_log.Warn("[HGGridService] regionlookup without regionID, regionHandle or regionHame"); - - if (simData == null) - { - //Sim does not exist - responseData["error"] = "Sim does not exist"; - } - else - { - m_log.Debug("[HGGridService]: found " + (string)simData.RegionName + " regionHandle = " + - (string)requestData["region_handle"]); - responseData["sim_ip"] = simData.ExternalEndPoint.Address.ToString(); - responseData["sim_port"] = simData.ExternalEndPoint.Port.ToString(); - //responseData["server_uri"] = simData.serverURI; - responseData["http_port"] = simData.HttpPort.ToString(); - //responseData["remoting_port"] = simData.remotingPort.ToString(); - responseData["region_locx"] = simData.RegionLocX.ToString(); - responseData["region_locy"] = simData.RegionLocY.ToString(); - responseData["region_UUID"] = simData.RegionID.ToString(); - responseData["region_name"] = simData.RegionName; - responseData["region_secret"] = simData.regionSecret; - } - - XmlRpcResponse response = new XmlRpcResponse(); - response.Value = responseData; - return response; - } - - } -} diff --git a/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs b/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs index 6774060..9957e46 100644 --- a/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs +++ b/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs @@ -34,6 +34,7 @@ using OpenSim.Framework; using OpenSim.Region.CoreModules.World.WorldMap; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; namespace OpenSim.Region.CoreModules.Hypergrid { @@ -59,7 +60,17 @@ namespace OpenSim.Region.CoreModules.Hypergrid protected override void GetAndSendBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag) { - List mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks(minX - 4, minY - 4, maxX + 4, maxY + 4); + List mapBlocks = new List(); + List regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID, + (minX - 4) * (int)Constants.RegionSize, (minY - 4) * (int)Constants.RegionSize, + (maxX + 4) * (int)Constants.RegionSize, (maxY + 4) * (int)Constants.RegionSize); + + foreach (GridRegion r in regions) + { + MapBlockData block = new MapBlockData(); + MapBlockFromGridRegion(block, r); + mapBlocks.Add(block); + } // Different from super FillInMap(mapBlocks, minX, minY, maxX, maxY); diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs index 0c2a835..b5bade6 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs @@ -47,7 +47,7 @@ using Nini.Config; namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid { - public class HGGridConnector : ISharedRegionModule, IGridService + public class HGGridConnector : ISharedRegionModule, IGridService, IHyperlinkService { private static readonly ILog m_log = LogManager.GetLogger( @@ -142,6 +142,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid return; scene.RegisterModuleInterface(this); + scene.RegisterModuleInterface(this); } @@ -367,10 +368,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid } #endregion - #region Hyperlinks + #region IHyperlinkService private static Random random = new Random(); + public GridRegion TryLinkRegionToCoords(Scene m_scene, IClientAPI client, string mapName, int xloc, int yloc) { string host = "127.0.0.1"; @@ -417,6 +419,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid return null; } + // From the map search and secondlife://blah public GridRegion TryLinkRegion(Scene m_scene, IClientAPI client, string mapName) { @@ -554,6 +557,27 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid return true; } + public GridRegion TryLinkRegion(IClientAPI client, string regionDescriptor) + { + return TryLinkRegion((Scene)client.Scene, client, regionDescriptor); + } + + public GridRegion GetHyperlinkRegion(ulong handle) + { + foreach (GridRegion r in m_HyperlinkRegions.Values) + if (r.RegionHandle == handle) + return r; + return null; + } + + public ulong FindRegionHandle(ulong handle) + { + foreach (GridRegion r in m_HyperlinkRegions.Values) + if ((r.RegionHandle == handle) && (m_HyperlinkHandles.ContainsKey(r.RegionID))) + return m_HyperlinkHandles[r.RegionID]; + return 0; + } + #endregion } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs index 9519e23..f27b2f9 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs @@ -42,6 +42,7 @@ using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes.Hypergrid; using OpenSim.Region.Framework.Scenes.Serialization; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion { @@ -161,7 +162,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion // else do the remote thing if (!m_localBackend.IsLocalRegion(regionHandle)) { - RegionInfo regInfo = m_commsManager.GridService.RequestNeighbourInfo(regionHandle); + uint x = 0, y = 0; + Utils.LongToUInts(regionHandle, out x, out y); + GridRegion regInfo = m_aScene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y); if (regInfo != null) { m_regionClient.SendUserInformation(regInfo, aCircuit); @@ -183,7 +186,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion // else do the remote thing if (!m_localBackend.IsLocalRegion(regionHandle)) { - RegionInfo regInfo = m_commsManager.GridService.RequestNeighbourInfo(regionHandle); + uint x = 0, y = 0; + Utils.LongToUInts(regionHandle, out x, out y); + GridRegion regInfo = m_aScene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y); if (regInfo != null) { return m_regionClient.DoChildAgentUpdateCall(regInfo, cAgentData); @@ -204,7 +209,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion // else do the remote thing if (!m_localBackend.IsLocalRegion(regionHandle)) { - RegionInfo regInfo = m_commsManager.GridService.RequestNeighbourInfo(regionHandle); + uint x = 0, y = 0; + Utils.LongToUInts(regionHandle, out x, out y); + GridRegion regInfo = m_aScene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y); if (regInfo != null) { return m_regionClient.DoChildAgentUpdateCall(regInfo, cAgentData); @@ -225,7 +232,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion // else do the remote thing if (!m_localBackend.IsLocalRegion(regionHandle)) { - RegionInfo regInfo = m_commsManager.GridService.RequestNeighbourInfo(regionHandle); + uint x = 0, y = 0; + Utils.LongToUInts(regionHandle, out x, out y); + GridRegion regInfo = m_aScene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y); if (regInfo != null) { return m_regionClient.DoRetrieveRootAgentCall(regInfo, id, out agent); @@ -257,7 +266,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion // else do the remote thing if (!m_localBackend.IsLocalRegion(regionHandle)) { - RegionInfo regInfo = m_commsManager.GridService.RequestNeighbourInfo(regionHandle); + uint x = 0, y = 0; + Utils.LongToUInts(regionHandle, out x, out y); + GridRegion regInfo = m_aScene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y); if (regInfo != null) { return m_regionClient.DoCloseAgentCall(regInfo, id); @@ -284,7 +295,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion // else do the remote thing if (!m_localBackend.IsLocalRegion(regionHandle)) { - RegionInfo regInfo = m_commsManager.GridService.RequestNeighbourInfo(regionHandle); + uint x = 0, y = 0; + Utils.LongToUInts(regionHandle, out x, out y); + GridRegion regInfo = m_aScene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y); if (regInfo != null) { return m_regionClient.DoCreateObjectCall( @@ -798,13 +811,20 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion return false; } - public override void SendUserInformation(RegionInfo regInfo, AgentCircuitData aCircuit) + public override void SendUserInformation(GridRegion regInfo, AgentCircuitData aCircuit) { try { if (m_aScene.SceneGridService is HGSceneCommunicationService) { - ((HGSceneCommunicationService)(m_aScene.SceneGridService)).m_hg.SendUserInformation(regInfo, aCircuit); + // big hack for now + RegionInfo r = new RegionInfo(); + r.ExternalHostName = regInfo.ExternalHostName; + r.HttpPort = regInfo.HttpPort; + r.RegionID = regInfo.RegionID; + r.RegionLocX = (uint)regInfo.RegionLocX; + r.RegionLocY = (uint)regInfo.RegionLocY; + ((HGSceneCommunicationService)(m_aScene.SceneGridService)).m_hg.SendUserInformation(r, aCircuit); } } catch // Bad cast diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Land/RemoteLandServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Land/RemoteLandServiceConnector.cs index a52c70b..b0ace39 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Land/RemoteLandServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Land/RemoteLandServiceConnector.cs @@ -37,6 +37,7 @@ using OpenSim.Region.Framework.Scenes; using OpenSim.Services.Interfaces; using OpenSim.Server.Base; + namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Land { public class RemoteLandServicesConnector : @@ -89,7 +90,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Land if (!m_Enabled) return; - m_MapService = scene.CommsManager.GridService; + m_GridService = scene.GridService; m_LocalService.AddRegion(scene); scene.RegisterModuleInterface(this); } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/RemoteNeighourServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/RemoteNeighourServiceConnector.cs index c5bc03b..912c393 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/RemoteNeighourServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/RemoteNeighourServiceConnector.cs @@ -118,7 +118,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Neighbour if (!m_Enabled) return; - m_MapService = scene.CommsManager.GridService; m_LocalService.AddRegion(scene); scene.RegisterModuleInterface(this); } @@ -134,6 +133,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Neighbour if (!m_Enabled) return; + m_GridService = scene.GridService; + m_log.InfoFormat("[NEIGHBOUR CONNECTOR]: Enabled remote neighbours for region {0}", scene.RegionInfo.RegionName); } diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index 76ff6da..fdff61e 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs @@ -36,10 +36,12 @@ using OpenSim.Framework; using OpenSim.Framework.Capabilities; using OpenSim.Framework.Servers; using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Services.Interfaces; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Physics.Manager; using Caps=OpenSim.Framework.Capabilities.Caps; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; namespace OpenSim.Region.CoreModules.World.Land { @@ -1301,7 +1303,7 @@ namespace OpenSim.Region.CoreModules.World.Land else { // a parcel request for a parcel in another region. Ask the grid about the region - RegionInfo info = m_scene.CommsManager.GridService.RequestNeighbourInfo(regionID); + GridRegion info = m_scene.GridService.GetRegionByUUID(UUID.Zero, regionID); if (info != null) parcelID = Util.BuildFakeParcelID(info.RegionHandle, x, y); } @@ -1359,9 +1361,10 @@ namespace OpenSim.Region.CoreModules.World.Land } else { - extLandData.landData = m_scene.CommsManager.GridService.RequestLandData(extLandData.regionHandle, - extLandData.x, - extLandData.y); + ILandService landService = m_scene.RequestModuleInterface(); + extLandData.landData = landService.GetLandData(extLandData.regionHandle, + extLandData.x, + extLandData.y); if (extLandData.landData == null) { // we didn't find the region/land => don't cache @@ -1373,20 +1376,27 @@ namespace OpenSim.Region.CoreModules.World.Land if (data != null) // if we found some data, send it { - RegionInfo info; + GridRegion info; if (data.regionHandle == m_scene.RegionInfo.RegionHandle) { - info = m_scene.RegionInfo; + info = new GridRegion(m_scene.RegionInfo); } else { // most likely still cached from building the extLandData entry - info = m_scene.CommsManager.GridService.RequestNeighbourInfo(data.regionHandle); + uint x = 0, y = 0; + Utils.LongToUInts(data.regionHandle, out x, out y); + info = m_scene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y); } // we need to transfer the fake parcelID, not the one in landData, so the viewer can match it to the landmark. m_log.DebugFormat("[LAND] got parcelinfo for parcel {0} in region {1}; sending...", data.landData.Name, data.regionHandle); - remoteClient.SendParcelInfo(info, data.landData, parcelID, data.x, data.y); + // HACK for now + RegionInfo r = new RegionInfo(); + r.RegionName = info.RegionName; + r.RegionLocX = (uint)info.RegionLocX; + r.RegionLocY = (uint)info.RegionLocY; + remoteClient.SendParcelInfo(r, data.landData, parcelID, data.x, data.y); } else m_log.Debug("[LAND] got no parcelinfo; not sending"); diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs index 4783b35..e3661fa 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs @@ -33,6 +33,8 @@ using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes.Hypergrid; +using OpenSim.Services.Interfaces; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; namespace OpenSim.Region.CoreModules.World.WorldMap { @@ -92,13 +94,13 @@ namespace OpenSim.Region.CoreModules.World.WorldMap } // try to fetch from GridServer - List regionInfos = m_scene.SceneGridService.RequestNamedRegions(mapName, 20); + List regionInfos = m_scene.GridService.GetRegionsByName(UUID.Zero, mapName, 20); if (regionInfos == null) { m_log.Warn("[MAPSEARCHMODULE]: RequestNamedRegions returned null. Old gridserver?"); // service wasn't available; maybe still an old GridServer. Try the old API, though it will return only one region - regionInfos = new List(); - RegionInfo info = m_scene.SceneGridService.RequestClosestRegion(mapName); + regionInfos = new List(); + GridRegion info = m_scene.GridService.GetRegionByName(UUID.Zero, mapName); if (info != null) regionInfos.Add(info); } @@ -109,11 +111,15 @@ namespace OpenSim.Region.CoreModules.World.WorldMap if (mapName.Contains(".") && mapName.Contains(":")) { // It probably is a domain name. Try to link to it. - RegionInfo regInfo; + GridRegion regInfo; Scene cScene = GetClientScene(remoteClient); - regInfo = HGHyperlink.TryLinkRegion(cScene, remoteClient, mapName); - if (regInfo != null) - regionInfos.Add(regInfo); + IHyperlinkService hyperService = cScene.RequestModuleInterface(); + if (hyperService != null) + { + regInfo = hyperService.TryLinkRegion(remoteClient, mapName); + if (regInfo != null) + regionInfos.Add(regInfo); + } } } @@ -122,12 +128,12 @@ namespace OpenSim.Region.CoreModules.World.WorldMap MapBlockData data; if (regionInfos.Count > 0) { - foreach (RegionInfo info in regionInfos) + foreach (GridRegion info in regionInfos) { data = new MapBlockData(); data.Agents = 0; - data.Access = info.AccessLevel; - data.MapImageId = info.RegionSettings.TerrainImageID; + data.Access = info.Access; + data.MapImageId = info.TerrainImage; data.Name = info.RegionName; data.RegionFlags = 0; // TODO not used? data.WaterHeight = 0; // not used diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index 1f25f28..bd12218 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs @@ -48,6 +48,7 @@ using OpenSim.Region.Framework.Scenes; using Caps=OpenSim.Framework.Capabilities.Caps; using OSDArray=OpenMetaverse.StructuredData.OSDArray; using OSDMap=OpenMetaverse.StructuredData.OSDMap; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; namespace OpenSim.Region.CoreModules.World.WorldMap { @@ -232,10 +233,20 @@ namespace OpenSim.Region.CoreModules.World.WorldMap } if (lookup) { - List mapBlocks; - - mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks((int)m_scene.RegionInfo.RegionLocX - 8, (int)m_scene.RegionInfo.RegionLocY - 8, (int)m_scene.RegionInfo.RegionLocX + 8, (int)m_scene.RegionInfo.RegionLocY + 8); - avatarPresence.ControllingClient.SendMapBlock(mapBlocks,0); + List mapBlocks = new List(); ; + + List regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID, + (int)(m_scene.RegionInfo.RegionLocX - 8) * (int)Constants.RegionSize, + (int)(m_scene.RegionInfo.RegionLocY - 8) * (int)Constants.RegionSize, + (int)(m_scene.RegionInfo.RegionLocX + 8) * (int)Constants.RegionSize, + (int)(m_scene.RegionInfo.RegionLocY + 8) * (int)Constants.RegionSize); + foreach (GridRegion r in regions) + { + MapBlockData block = new MapBlockData(); + MapBlockFromGridRegion(block, r); + mapBlocks.Add(block); + } + avatarPresence.ControllingClient.SendMapBlock(mapBlocks, 0); lock (cachedMapBlocks) cachedMapBlocks = mapBlocks; @@ -579,7 +590,9 @@ namespace OpenSim.Region.CoreModules.World.WorldMap } if (httpserver.Length == 0) { - RegionInfo mreg = m_scene.SceneGridService.RequestNeighbouringRegionInfo(regionhandle); + uint x = 0, y = 0; + Utils.LongToUInts(regionhandle, out x, out y); + GridRegion mreg = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y); if (mreg != null) { @@ -719,15 +732,23 @@ namespace OpenSim.Region.CoreModules.World.WorldMap { List response = new List(); - // this should return one mapblock at most. But make sure: Look whether the one we requested is in there - List mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks(minX, minY, maxX, maxY); - if (mapBlocks != null) + // this should return one mapblock at most. + // (diva note: why?? in that case we should GetRegionByPosition) + // But make sure: Look whether the one we requested is in there + List regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID, + minX * (int)Constants.RegionSize, minY * (int)Constants.RegionSize, + maxX * (int)Constants.RegionSize, maxY * (int)Constants.RegionSize); + + if (regions != null) { - foreach (MapBlockData block in mapBlocks) + foreach (GridRegion r in regions) { - if (block.X == minX && block.Y == minY) + if ((r.RegionLocX == minX * (int)Constants.RegionSize) && + (r.RegionLocY == minY * (int)Constants.RegionSize)) { // found it => add it to response + MapBlockData block = new MapBlockData(); + MapBlockFromGridRegion(block, r); response.Add(block); break; } @@ -754,10 +775,28 @@ namespace OpenSim.Region.CoreModules.World.WorldMap protected virtual void GetAndSendBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag) { - List mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks(minX - 4, minY - 4, maxX + 4, maxY + 4); + List mapBlocks = new List(); + List regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID, + (minX - 4) * (int)Constants.RegionSize, (minY - 4) * (int)Constants.RegionSize, + (maxX + 4) * (int)Constants.RegionSize, (maxY + 4) * (int)Constants.RegionSize); + foreach (GridRegion r in regions) + { + MapBlockData block = new MapBlockData(); + MapBlockFromGridRegion(block, r); + mapBlocks.Add(block); + } remoteClient.SendMapBlock(mapBlocks, flag); } + protected void MapBlockFromGridRegion(MapBlockData block, GridRegion r) + { + block.Access = r.Access; + block.MapImageId = r.TerrainImage; + block.Name = r.RegionName; + block.X = (ushort)(r.RegionLocX / Constants.RegionSize); + block.Y = (ushort)(r.RegionLocY / Constants.RegionSize); + } + public Hashtable OnHTTPGetMapImage(Hashtable keysvals) { m_log.Debug("[WORLD MAP]: Sending map image jpeg"); @@ -874,31 +913,34 @@ namespace OpenSim.Region.CoreModules.World.WorldMap m_log.InfoFormat( "[WORLD MAP]: Exporting world map for {0} to {1}", m_scene.RegionInfo.RegionName, exportPath); - List mapBlocks = - m_scene.CommsManager.GridService.RequestNeighbourMapBlocks( - (int)(m_scene.RegionInfo.RegionLocX - 9), - (int)(m_scene.RegionInfo.RegionLocY - 9), - (int)(m_scene.RegionInfo.RegionLocX + 9), - (int)(m_scene.RegionInfo.RegionLocY + 9)); + List mapBlocks = new List(); + List regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID, + (int)(m_scene.RegionInfo.RegionLocX - 9) * (int)Constants.RegionSize, + (int)(m_scene.RegionInfo.RegionLocY - 9) * (int)Constants.RegionSize, + (int)(m_scene.RegionInfo.RegionLocX + 9) * (int)Constants.RegionSize, + (int)(m_scene.RegionInfo.RegionLocY + 9) * (int)Constants.RegionSize); List textures = new List(); List bitImages = new List(); - foreach (MapBlockData mapBlock in mapBlocks) + foreach (GridRegion r in regions) { + MapBlockData mapBlock = new MapBlockData(); + MapBlockFromGridRegion(mapBlock, r); AssetBase texAsset = m_scene.AssetService.Get(mapBlock.MapImageId.ToString()); if (texAsset != null) { textures.Add(texAsset); } - else - { - texAsset = m_scene.AssetService.Get(mapBlock.MapImageId.ToString()); - if (texAsset != null) - { - textures.Add(texAsset); - } - } + //else + //{ + // // WHAT?!? This doesn't seem right. Commenting (diva) + // texAsset = m_scene.AssetService.Get(mapBlock.MapImageId.ToString()); + // if (texAsset != null) + // { + // textures.Add(texAsset); + // } + //} } foreach (AssetBase asset in textures) diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGHyperlink.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGHyperlink.cs deleted file mode 100644 index a576feb..0000000 --- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGHyperlink.cs +++ /dev/null @@ -1,232 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Net; -using System.Reflection; -using log4net; -using OpenMetaverse; -using OpenSim.Framework; - -namespace OpenSim.Region.Framework.Scenes.Hypergrid -{ - public class HGHyperlink - { - private static readonly ILog m_log = - LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private static Random random = new Random(); - - public static RegionInfo TryLinkRegionToCoords(Scene m_scene, IClientAPI client, string mapName, uint xloc, uint yloc) - { - string host = "127.0.0.1"; - string portstr; - string regionName = ""; - uint port = 9000; - string[] parts = mapName.Split(new char[] { ':' }); - if (parts.Length >= 1) - { - host = parts[0]; - } - if (parts.Length >= 2) - { - portstr = parts[1]; - if (!UInt32.TryParse(portstr, out port)) - regionName = parts[1]; - } - // always take the last one - if (parts.Length >= 3) - { - regionName = parts[2]; - } - - // Sanity check. Don't ever link to this sim. - IPAddress ipaddr = null; - try - { - ipaddr = Util.GetHostFromDNS(host); - } - catch { } - - if ((ipaddr != null) && - !((m_scene.RegionInfo.ExternalEndPoint.Address.Equals(ipaddr)) && (m_scene.RegionInfo.HttpPort == port))) - { - RegionInfo regInfo; - bool success = TryCreateLink(m_scene, client, xloc, yloc, regionName, port, host, out regInfo); - if (success) - { - regInfo.RegionName = mapName; - return regInfo; - } - } - - return null; - } - - public static RegionInfo TryLinkRegion(Scene m_scene, IClientAPI client, string mapName) - { - uint xloc = (uint)(random.Next(0, Int16.MaxValue)); - return TryLinkRegionToCoords(m_scene, client, mapName, xloc, 0); - } - - public static bool TryCreateLink(Scene m_scene, IClientAPI client, uint xloc, uint yloc, - string externalRegionName, uint externalPort, string externalHostName, out RegionInfo regInfo) - { - m_log.DebugFormat("[HGrid]: Link to {0}:{1}, in {2}-{3}", externalHostName, externalPort, xloc, yloc); - - regInfo = new RegionInfo(); - regInfo.RegionName = externalRegionName; - regInfo.HttpPort = externalPort; - regInfo.ExternalHostName = externalHostName; - regInfo.RegionLocX = xloc; - regInfo.RegionLocY = yloc; - - try - { - regInfo.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)0); - } - catch (Exception e) - { - m_log.Warn("[HGrid]: Wrong format for link-region: " + e.Message); - return false; - } - regInfo.RemotingAddress = regInfo.ExternalEndPoint.Address.ToString(); - - // Finally, link it - try - { - m_scene.CommsManager.GridService.RegisterRegion(regInfo); - } - catch (Exception e) - { - m_log.Warn("[HGrid]: Unable to link region: " + e.Message); - return false; - } - - uint x, y; - if (!Check4096(m_scene, regInfo, out x, out y)) - { - m_scene.CommsManager.GridService.DeregisterRegion(regInfo); - if (client != null) - client.SendAlertMessage("Region is too far (" + x + ", " + y + ")"); - m_log.Info("[HGrid]: Unable to link, region is too far (" + x + ", " + y + ")"); - return false; - } - - if (!CheckCoords(m_scene.RegionInfo.RegionLocX, m_scene.RegionInfo.RegionLocY, x, y)) - { - m_scene.CommsManager.GridService.DeregisterRegion(regInfo); - if (client != null) - client.SendAlertMessage("Region has incompatible coordinates (" + x + ", " + y + ")"); - m_log.Info("[HGrid]: Unable to link, region has incompatible coordinates (" + x + ", " + y + ")"); - return false; - } - - m_log.Debug("[HGrid]: link region succeeded"); - return true; - } - - public static bool TryUnlinkRegion(Scene m_scene, string mapName) - { - RegionInfo regInfo = null; - if (mapName.Contains(":")) - { - string host = "127.0.0.1"; - //string portstr; - //string regionName = ""; - uint port = 9000; - string[] parts = mapName.Split(new char[] { ':' }); - if (parts.Length >= 1) - { - host = parts[0]; - } -// if (parts.Length >= 2) -// { -// portstr = parts[1]; -// if (!UInt32.TryParse(portstr, out port)) -// regionName = parts[1]; -// } - // always take the last one -// if (parts.Length >= 3) -// { -// regionName = parts[2]; -// } - regInfo = m_scene.CommsManager.GridService.RequestNeighbourInfo(host, port); - } - else - { - regInfo = m_scene.CommsManager.GridService.RequestNeighbourInfo(mapName); - } - if (regInfo != null) - { - return m_scene.CommsManager.GridService.DeregisterRegion(regInfo); - } - else - { - m_log.InfoFormat("[HGrid]: Region {0} not found", mapName); - return false; - } - } - - /// - /// Cope with this viewer limitation. - /// - /// - /// - public static bool Check4096(Scene m_scene, RegionInfo regInfo, out uint x, out uint y) - { - ulong realHandle; - if (UInt64.TryParse(regInfo.regionSecret, out realHandle)) - { - Utils.LongToUInts(realHandle, out x, out y); - x = x / Constants.RegionSize; - y = y / Constants.RegionSize; - - if ((Math.Abs((int)m_scene.RegionInfo.RegionLocX - (int)x) >= 4096) || - (Math.Abs((int)m_scene.RegionInfo.RegionLocY - (int)y) >= 4096)) - { - return false; - } - return true; - } - else - { - m_scene.CommsManager.GridService.RegisterRegion(regInfo); - m_log.Debug("[HGrid]: Gnomes. Region deregistered."); - x = y = 0; - return false; - } - } - - public static bool CheckCoords(uint thisx, uint thisy, uint x, uint y) - { - if ((thisx == x) && (thisy == y)) - return false; - return true; - } - - } -} diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.cs index bf55df7..b1981b6 100644 --- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.cs +++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.cs @@ -29,6 +29,7 @@ using OpenMetaverse; using OpenSim.Framework; using OpenSim.Framework.Communications.Cache; using TPFlags = OpenSim.Framework.Constants.TeleportFlags; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; namespace OpenSim.Region.Framework.Scenes.Hypergrid { @@ -50,7 +51,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid if (UserProfile != null) { - RegionInfo regionInfo = CommsManager.GridService.RequestNeighbourInfo(UserProfile.HomeRegion); + GridRegion regionInfo = GridService.GetRegionByUUID(UUID.Zero, UserProfile.HomeRegionID); //if (regionInfo != null) //{ // UserProfile.HomeRegionID = regionInfo.RegionID; diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs index 5c99d73..e8e5e78 100644 --- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs +++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs @@ -38,6 +38,7 @@ using OpenSim.Framework.Communications; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Capabilities; using OpenSim.Region.Framework.Interfaces; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; namespace OpenSim.Region.Framework.Scenes.Hypergrid { @@ -106,7 +107,10 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid } else { - RegionInfo reg = RequestNeighbouringRegionInfo(regionHandle); + uint x = 0, y = 0; + Utils.LongToUInts(regionHandle, out x, out y); + GridRegion reg = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y); + if (reg != null) { 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) diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs index 56cd87d..60e89e0 100644 --- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs @@ -41,6 +41,7 @@ using OpenSim.Framework.Capabilities; using OpenSim.Region.Framework.Interfaces; using OpenSim.Services.Interfaces; using OSD = OpenMetaverse.StructuredData.OSD; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; namespace OpenSim.Region.Framework.Scenes { @@ -58,6 +59,7 @@ namespace OpenSim.Region.Framework.Scenes protected CommunicationsManager m_commsProvider; protected IInterregionCommsOut m_interregionCommsOut; protected RegionInfo m_regionInfo; + protected Scene m_scene; protected RegionCommsListener regionCommsHost; @@ -131,6 +133,13 @@ namespace OpenSim.Region.Framework.Scenes m_agentsInTransit = new List(); } + public void SetScene(Scene s) + { + m_scene = s; + m_regionInfo = s.RegionInfo; + m_interregionCommsOut = m_scene.RequestModuleInterface(); + } + /// /// Register a region with the grid /// @@ -138,40 +147,30 @@ namespace OpenSim.Region.Framework.Scenes /// Thrown if region registration fails. public void RegisterRegion(IInterregionCommsOut comms_out, RegionInfo regionInfos) { - m_interregionCommsOut = comms_out; + //m_interregionCommsOut = comms_out; - m_regionInfo = regionInfos; - m_commsProvider.GridService.gdebugRegionName = regionInfos.RegionName; - regionCommsHost = m_commsProvider.GridService.RegisterRegion(m_regionInfo); + //m_regionInfo = regionInfos; + //m_commsProvider.GridService.gdebugRegionName = regionInfos.RegionName; + //regionCommsHost = m_commsProvider.GridService.RegisterRegion(m_regionInfo); - if (regionCommsHost != null) - { - //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: registered with gridservice and got" + regionCommsHost.ToString()); - - regionCommsHost.debugRegionName = regionInfos.RegionName; - regionCommsHost.OnExpectPrim += IncomingPrimCrossing; - regionCommsHost.OnExpectUser += NewUserConnection; - regionCommsHost.OnAvatarCrossingIntoRegion += AgentCrossing; - regionCommsHost.OnCloseAgentConnection += CloseConnection; - regionCommsHost.OnRegionUp += newRegionUp; - regionCommsHost.OnChildAgentUpdate += ChildAgentUpdate; - regionCommsHost.OnLogOffUser += GridLogOffUser; - regionCommsHost.OnGetLandData += FetchLandData; - } - else - { - //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: registered with gridservice and got null"); - } - } - - /// - /// Returns a region with the name closest to string provided - /// - /// Partial Region Name for matching - /// Region Information for the region - public RegionInfo RequestClosestRegion(string name) - { - return m_commsProvider.GridService.RequestClosestRegion(name); + //if (regionCommsHost != null) + //{ + // //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: registered with gridservice and got" + regionCommsHost.ToString()); + + // regionCommsHost.debugRegionName = regionInfos.RegionName; + // regionCommsHost.OnExpectPrim += IncomingPrimCrossing; + // regionCommsHost.OnExpectUser += NewUserConnection; + // regionCommsHost.OnAvatarCrossingIntoRegion += AgentCrossing; + // regionCommsHost.OnCloseAgentConnection += CloseConnection; + // regionCommsHost.OnRegionUp += newRegionUp; + // regionCommsHost.OnChildAgentUpdate += ChildAgentUpdate; + // regionCommsHost.OnLogOffUser += GridLogOffUser; + // regionCommsHost.OnGetLandData += FetchLandData; + //} + //else + //{ + // //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: registered with gridservice and got null"); + //} } /// @@ -180,30 +179,31 @@ namespace OpenSim.Region.Framework.Scenes /// public void Close() { - if (regionCommsHost != null) - { - regionCommsHost.OnLogOffUser -= GridLogOffUser; - regionCommsHost.OnChildAgentUpdate -= ChildAgentUpdate; - regionCommsHost.OnRegionUp -= newRegionUp; - regionCommsHost.OnExpectUser -= NewUserConnection; - regionCommsHost.OnExpectPrim -= IncomingPrimCrossing; - regionCommsHost.OnAvatarCrossingIntoRegion -= AgentCrossing; - regionCommsHost.OnCloseAgentConnection -= CloseConnection; - regionCommsHost.OnGetLandData -= FetchLandData; + + //if (regionCommsHost != null) + //{ + // regionCommsHost.OnLogOffUser -= GridLogOffUser; + // regionCommsHost.OnChildAgentUpdate -= ChildAgentUpdate; + // regionCommsHost.OnRegionUp -= newRegionUp; + // regionCommsHost.OnExpectUser -= NewUserConnection; + // regionCommsHost.OnExpectPrim -= IncomingPrimCrossing; + // regionCommsHost.OnAvatarCrossingIntoRegion -= AgentCrossing; + // regionCommsHost.OnCloseAgentConnection -= CloseConnection; + // regionCommsHost.OnGetLandData -= FetchLandData; - try - { - m_commsProvider.GridService.DeregisterRegion(m_regionInfo); - } - catch (Exception e) - { - m_log.ErrorFormat( - "[GRID]: Deregistration of region {0} from the grid failed - {1}. Continuing", - m_regionInfo.RegionName, e); - } + // try + // { + // m_commsProvider.GridService.DeregisterRegion(m_regionInfo); + // } + // catch (Exception e) + // { + // m_log.ErrorFormat( + // "[GRID]: Deregistration of region {0} from the grid failed - {1}. Continuing", + // m_regionInfo.RegionName, e); + // } - regionCommsHost = null; - } + // regionCommsHost = null; + //} } #region CommsManager Event handlers @@ -337,7 +337,7 @@ namespace OpenSim.Region.Framework.Scenes #region Inform Client of Neighbours private delegate void InformClientOfNeighbourDelegate( - ScenePresence avatar, AgentCircuitData a, SimpleRegionInfo reg, IPEndPoint endPoint, bool newAgent); + ScenePresence avatar, AgentCircuitData a, GridRegion reg, IPEndPoint endPoint, bool newAgent); private void InformClientOfNeighbourCompleted(IAsyncResult iar) { @@ -355,7 +355,7 @@ namespace OpenSim.Region.Framework.Scenes /// /// /// - private void InformClientOfNeighbourAsync(ScenePresence avatar, AgentCircuitData a, SimpleRegionInfo reg, + private void InformClientOfNeighbourAsync(ScenePresence avatar, AgentCircuitData a, GridRegion reg, IPEndPoint endPoint, bool newAgent) { // Let's wait just a little to give time to originating regions to catch up with closing child agents @@ -371,11 +371,15 @@ namespace OpenSim.Region.Framework.Scenes string capsPath = "http://" + reg.ExternalHostName + ":" + reg.HttpPort + "/CAPS/" + a.CapsPath + "0000/"; + m_log.DebugFormat("[XXX] CAPS = {0}", capsPath); + m_log.DebugFormat("[XXX] ExternalEndPoint = {0}", endPoint.ToString()); + string reason = String.Empty; //bool regionAccepted = m_commsProvider.InterRegion.InformRegionOfChildAgent(reg.RegionHandle, a); bool regionAccepted = m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, a, out reason); + m_log.DebugFormat("[XXX] Here 1 {0}", regionAccepted); if (regionAccepted && newAgent) { @@ -390,6 +394,7 @@ namespace OpenSim.Region.Framework.Scenes } #endregion + m_log.DebugFormat("[XXX] HERE 2"); eq.EnableSimulator(reg.RegionHandle, endPoint, avatar.UUID); eq.EstablishAgentCommunication(avatar.UUID, endPoint, capsPath); m_log.DebugFormat("[CAPS]: Sending new CAPS seed url {0} to client {1} in region {2}", @@ -407,17 +412,7 @@ namespace OpenSim.Region.Framework.Scenes } - public void RequestNeighbors(RegionInfo region) - { - // List neighbours = - m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY); - //IPEndPoint blah = new IPEndPoint(); - - //blah.Address = region.RemotingAddress; - //blah.Port = region.RemotingPort; - } - - public List RequestNeighbors(Scene pScene, uint pRegionLocX, uint pRegionLocY) + public List RequestNeighbours(Scene pScene, uint pRegionLocX, uint pRegionLocY) { Border[] northBorders = pScene.NorthBorders.ToArray(); Border[] southBorders = pScene.SouthBorders.ToArray(); @@ -427,50 +422,34 @@ namespace OpenSim.Region.Framework.Scenes // Legacy one region. Provided for simplicity while testing the all inclusive method in the else statement. if (northBorders.Length <= 1 && southBorders.Length <= 1 && eastBorders.Length <= 1 && westBorders.Length <= 1) { - return m_commsProvider.GridService.RequestNeighbours(pRegionLocX, pRegionLocY); + return m_scene.GridService.GetNeighbours(m_regionInfo.ScopeID, m_regionInfo.RegionID); } else { Vector2 extent = Vector2.Zero; - for (int i=0;i extent.X) ? eastBorders[i].BorderLine.Z : extent.X; } - for (int i=0;i extent.Y) ? northBorders[i].BorderLine.Z : extent.Y; } - List neighbourList = new List(); - // Loss of fraction on purpose extent.X = ((int)extent.X / (int)Constants.RegionSize) + 1; extent.Y = ((int)extent.Y / (int)Constants.RegionSize) + 1; - int startX = (int) pRegionLocX - 1; - int startY = (int) pRegionLocY - 1; + int startX = (int)(pRegionLocX - 1) * (int)Constants.RegionSize; + int startY = (int)(pRegionLocY - 1) * (int)Constants.RegionSize; - int endX = (int) pRegionLocX + (int)extent.X; - int endY = (int) pRegionLocY + (int)extent.Y; + int endX = ((int)pRegionLocX + (int)extent.X) * (int)Constants.RegionSize; + int endY = ((int)pRegionLocY + (int)extent.Y) * (int)Constants.RegionSize; - for (int i=startX;i neighbours = m_scene.GridService.GetRegionRange(m_regionInfo.ScopeID, startX, endX, startY, endY); + neighbours.RemoveAll(delegate(GridRegion r) { return r.RegionID == m_regionInfo.RegionID; }); + + return neighbours; //SimpleRegionInfo regionData = m_commsProvider.GridService.RequestNeighbourInfo() //return m_commsProvider.GridService.RequestNeighbours(pRegionLocX, pRegionLocY); } @@ -482,23 +461,24 @@ namespace OpenSim.Region.Framework.Scenes /// public void EnableNeighbourChildAgents(ScenePresence avatar, List lstneighbours) { - List neighbours = new List(); + //List neighbours = new List(); + List neighbours = new List(); - //m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY); - for (int i = 0; i < lstneighbours.Count; i++) - { - // We don't want to keep sending to regions that consistently fail on comms. - if (!(lstneighbours[i].commFailTF)) - { - neighbours.Add(new SimpleRegionInfo(lstneighbours[i])); - } - } + ////m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY); + //for (int i = 0; i < lstneighbours.Count; i++) + //{ + // // We don't want to keep sending to regions that consistently fail on comms. + // if (!(lstneighbours[i].commFailTF)) + // { + // neighbours.Add(new SimpleRegionInfo(lstneighbours[i])); + // } + //} // we're going to be using the above code once neighbour cache is correct. Currently it doesn't appear to be // So we're temporarily going back to the old method of grabbing it from the Grid Server Every time :/ if (m_regionInfo != null) { neighbours = - RequestNeighbors(avatar.Scene,m_regionInfo.RegionLocX, m_regionInfo.RegionLocY); + RequestNeighbours(avatar.Scene,m_regionInfo.RegionLocX, m_regionInfo.RegionLocY); } else { @@ -547,8 +527,9 @@ namespace OpenSim.Region.Framework.Scenes /// Create the necessary child agents List cagents = new List(); - foreach (SimpleRegionInfo neighbour in neighbours) - { + //foreach (SimpleRegionInfo neighbour in neighbours) + foreach (GridRegion neighbour in neighbours) + { if (neighbour.RegionHandle != avatar.Scene.RegionInfo.RegionHandle) { @@ -588,7 +569,7 @@ namespace OpenSim.Region.Framework.Scenes bool newAgent = false; int count = 0; - foreach (SimpleRegionInfo neighbour in neighbours) + foreach (GridRegion neighbour in neighbours) { // Don't do it if there's already an agent in that region if (newRegions.Contains(neighbour.RegionHandle)) @@ -641,7 +622,7 @@ namespace OpenSim.Region.Framework.Scenes /// This informs a single neighboring region about agent "avatar". /// Calls an asynchronous method to do so.. so it doesn't lag the sim. /// - public void InformNeighborChildAgent(ScenePresence avatar, SimpleRegionInfo region) + public void InformNeighborChildAgent(ScenePresence avatar, GridRegion region) { AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo(); agent.BaseFolder = UUID.Zero; @@ -700,18 +681,16 @@ namespace OpenSim.Region.Framework.Scenes } } - /// - /// Called by scene when region is initialized (not always when it's listening for agents) - /// This is an inter-region message that informs the surrounding neighbors that the sim is up. - /// + public void InformNeighborsThatRegionisUp(INeighbourService neighbourService, RegionInfo region) { //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: Sending InterRegion Notification that region is up " + region.RegionName); - - List neighbours = new List(); + + List neighbours = new List(); // This stays uncached because we don't already know about our neighbors at this point. - neighbours = m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY); + + neighbours = m_scene.GridService.GetNeighbours(m_regionInfo.ScopeID, m_regionInfo.RegionID); if (neighbours != null) { for (int i = 0; i < neighbours.Count; i++) @@ -727,6 +706,7 @@ namespace OpenSim.Region.Framework.Scenes //bool val = m_commsProvider.InterRegion.RegionUp(new SerializableRegionInfo(region)); } + public delegate void SendChildAgentDataUpdateDelegate(AgentPosition cAgentData, ulong regionHandle); /// @@ -822,41 +802,6 @@ namespace OpenSim.Region.Framework.Scenes } } - /// - /// Helper function to request neighbors from grid-comms - /// - /// - /// - public virtual RegionInfo RequestNeighbouringRegionInfo(ulong regionHandle) - { - //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: Sending Grid Services Request about neighbor " + regionHandle.ToString()); - return m_commsProvider.GridService.RequestNeighbourInfo(regionHandle); - } - - /// - /// Helper function to request neighbors from grid-comms - /// - /// - /// - public virtual RegionInfo RequestNeighbouringRegionInfo(UUID regionID) - { - //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: Sending Grid Services Request about neighbor " + regionID); - return m_commsProvider.GridService.RequestNeighbourInfo(regionID); - } - - /// - /// Requests map blocks in area of minX, maxX, minY, MaxY in world cordinates - /// - /// - /// - /// - /// - public virtual void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY) - { - List mapBlocks; - mapBlocks = m_commsProvider.GridService.RequestNeighbourMapBlocks(minX - 4, minY - 4, minX + 4, minY + 4); - remoteClient.SendMapBlock(mapBlocks, 0); - } /// /// Try to teleport an agent to a new region. @@ -921,7 +866,10 @@ namespace OpenSim.Region.Framework.Scenes } else { - RegionInfo reg = RequestNeighbouringRegionInfo(regionHandle); + uint x = 0, y = 0; + Utils.LongToUInts(regionHandle, out x, out y); + GridRegion reg = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y); + if (reg != null) { m_log.DebugFormat( @@ -1228,10 +1176,10 @@ namespace OpenSim.Region.Framework.Scenes return false; } - private List NeighbourHandles(List neighbours) + private List NeighbourHandles(List neighbours) { List handles = new List(); - foreach (SimpleRegionInfo reg in neighbours) + foreach (GridRegion reg in neighbours) { handles.Add(reg.RegionHandle); } @@ -1482,7 +1430,10 @@ namespace OpenSim.Region.Framework.Scenes m_log.DebugFormat("[SCENE COMM]: Crossing agent {0} {1} to {2}-{3}", agent.Firstname, agent.Lastname, neighbourx, neighboury); ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize)); - SimpleRegionInfo neighbourRegion = RequestNeighbouringRegionInfo(neighbourHandle); + + int x = (int)(neighbourx * Constants.RegionSize), y = (int)(neighboury * Constants.RegionSize); + GridRegion neighbourRegion = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y); + if (neighbourRegion != null && agent.ValidateAttachments()) { pos = pos + (agent.Velocity); @@ -1609,11 +1560,6 @@ namespace OpenSim.Region.Framework.Scenes } - public Dictionary GetGridSettings() - { - return m_commsProvider.GridService.GetGridSettings(); - } - public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat) { m_commsProvider.LogOffUser(userid, regionid, regionhandle, position, lookat); @@ -1650,19 +1596,14 @@ namespace OpenSim.Region.Framework.Scenes return m_commsProvider.GetUserFriendList(friendlistowner); } - public List RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY) - { - return m_commsProvider.GridService.RequestNeighbourMapBlocks(minX, minY, maxX, maxY); - } - public List GenerateAgentPickerRequestResponse(UUID queryID, string query) { return m_commsProvider.GenerateAgentPickerRequestResponse(queryID, query); } - public List RequestNamedRegions(string name, int maxNumber) + public List RequestNamedRegions(string name, int maxNumber) { - return m_commsProvider.GridService.RequestNamedRegions(name, maxNumber); + return m_scene.GridService.GetRegionsByName(UUID.Zero, name, maxNumber); } //private void Dump(string msg, List handles) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 6772f75..286b7ca 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -36,6 +36,7 @@ using OpenSim.Framework.Communications.Cache; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes.Types; using OpenSim.Region.Physics.Manager; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; namespace OpenSim.Region.Framework.Scenes { @@ -2934,8 +2935,9 @@ namespace OpenSim.Region.Framework.Scenes else if (dir > 3 && dir < 7) // Heading Sout neighboury--; - ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize)); - SimpleRegionInfo neighbourRegion = m_scene.RequestNeighbouringRegionInfo(neighbourHandle); + int x = (int)(neighbourx * Constants.RegionSize); + int y = (int)(neighboury * Constants.RegionSize); + GridRegion neighbourRegion = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, x, y); if (neighbourRegion == null) { diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 4c52b11..1ebe24e 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -50,6 +50,9 @@ using OpenSim.Region.ScriptEngine.Shared.Api.Plugins; using OpenSim.Region.ScriptEngine.Shared.ScriptBase; using OpenSim.Region.ScriptEngine.Interfaces; using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces; +using OpenSim.Services.Interfaces; + +using GridRegion = OpenSim.Services.Interfaces.GridRegion; using AssetLandmark = OpenSim.Framework.AssetLandmark; @@ -5226,12 +5229,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } - List neighbors = World.CommsManager.GridService.RequestNeighbours(World.RegionInfo.RegionLocX, World.RegionInfo.RegionLocY); + List neighbors = World.GridService.GetNeighbours(World.RegionInfo.ScopeID, World.RegionInfo.RegionID); uint neighborX = World.RegionInfo.RegionLocX + (uint)dir.x; uint neighborY = World.RegionInfo.RegionLocY + (uint)dir.y; - foreach (SimpleRegionInfo sri in neighbors) + foreach (GridRegion sri in neighbors) { if (sri.RegionLocX == neighborX && sri.RegionLocY == neighborY) return 0; @@ -8181,7 +8184,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api string reply = String.Empty; - RegionInfo info = m_ScriptEngine.World.RequestClosestRegion(simulator); + GridRegion info = m_ScriptEngine.World.GridService.GetRegionByName(m_ScriptEngine.World.RegionInfo.ScopeID, simulator); switch (data) { @@ -8208,7 +8211,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api ConditionalScriptSleep(1000); return UUID.Zero.ToString(); } - int access = info.RegionSettings.Maturity; + int access = info.Maturity; if (access == 0) reply = "PG"; else if (access == 1) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index ccdd4c5..0b95abc 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -48,6 +48,8 @@ using OpenSim.Region.ScriptEngine.Shared.ScriptBase; using OpenSim.Region.ScriptEngine.Interfaces; using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces; using TPFlags = OpenSim.Framework.Constants.TeleportFlags; +using OpenSim.Services.Interfaces; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; using System.Text.RegularExpressions; using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; @@ -599,17 +601,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (regionName.Contains(".") && regionName.Contains(":")) { // Try to link the region - RegionInfo regInfo = HGHyperlink.TryLinkRegion(World, - presence.ControllingClient, - regionName); - // Get the region name - if (regInfo != null) + IHyperlinkService hyperService = World.RequestModuleInterface(); + if (hyperService != null) { - regionName = regInfo.RegionName; - } - else - { - // Might need to ping the client here in case of failure?? + GridRegion regInfo = hyperService.TryLinkRegion(presence.ControllingClient, + regionName); + // Get the region name + if (regInfo != null) + { + regionName = regInfo.RegionName; + } + else + { + // Might need to ping the client here in case of failure?? + } } } presence.ControllingClient.SendTeleportLocationStart(); diff --git a/OpenSim/Services/Connectors/Land/LandServiceConnector.cs b/OpenSim/Services/Connectors/Land/LandServiceConnector.cs index 0243f1f..06bc11c 100644 --- a/OpenSim/Services/Connectors/Land/LandServiceConnector.cs +++ b/OpenSim/Services/Connectors/Land/LandServiceConnector.cs @@ -38,6 +38,7 @@ using OpenSim.Framework.Servers.HttpServer; using OpenSim.Services.Interfaces; using OpenMetaverse; using Nwc.XmlRpc; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; namespace OpenSim.Services.Connectors { @@ -47,20 +48,20 @@ namespace OpenSim.Services.Connectors LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType); - protected IGridServices m_MapService = null; + protected IGridService m_GridService = null; public LandServicesConnector() { } - public LandServicesConnector(IGridServices gridServices) + public LandServicesConnector(IGridService gridServices) { Initialise(gridServices); } - public virtual void Initialise(IGridServices gridServices) + public virtual void Initialise(IGridService gridServices) { - m_MapService = gridServices; + m_GridService = gridServices; } public virtual LandData GetLandData(ulong regionHandle, uint x, uint y) @@ -76,7 +77,9 @@ namespace OpenSim.Services.Connectors try { - RegionInfo info = m_MapService.RequestNeighbourInfo(regionHandle); + uint xpos = 0, ypos = 0; + Utils.LongToUInts(regionHandle, out xpos, out ypos); + GridRegion info = m_GridService.GetRegionByPosition(UUID.Zero, (int)xpos, (int)ypos); if (info != null) // just to be sure { XmlRpcRequest request = new XmlRpcRequest("land_data", paramList); diff --git a/OpenSim/Services/Connectors/Neighbour/NeighbourServiceConnector.cs b/OpenSim/Services/Connectors/Neighbour/NeighbourServiceConnector.cs index 7fff537..1b595e7 100644 --- a/OpenSim/Services/Connectors/Neighbour/NeighbourServiceConnector.cs +++ b/OpenSim/Services/Connectors/Neighbour/NeighbourServiceConnector.cs @@ -41,6 +41,8 @@ using OpenSim.Services.Interfaces; using OpenMetaverse; using OpenMetaverse.StructuredData; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; + namespace OpenSim.Services.Connectors { public class NeighbourServicesConnector : INeighbourService @@ -49,25 +51,27 @@ namespace OpenSim.Services.Connectors LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType); - protected IGridServices m_MapService = null; + protected IGridService m_GridService = null; public NeighbourServicesConnector() { } - public NeighbourServicesConnector(IGridServices gridServices) + public NeighbourServicesConnector(IGridService gridServices) { Initialise(gridServices); } - public virtual void Initialise(IGridServices gridServices) + public virtual void Initialise(IGridService gridServices) { - m_MapService = gridServices; + m_GridService = gridServices; } public virtual bool HelloNeighbour(ulong regionHandle, RegionInfo thisRegion) { - RegionInfo regInfo = m_MapService.RequestNeighbourInfo(regionHandle); + uint x = 0, y = 0; + Utils.LongToUInts(regionHandle, out x, out y); + GridRegion regInfo = m_GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y); if ((regInfo != null) && // Don't remote-call this instance; that's a startup hickup !((regInfo.ExternalHostName == thisRegion.ExternalHostName) && (regInfo.HttpPort == thisRegion.HttpPort))) @@ -79,7 +83,7 @@ namespace OpenSim.Services.Connectors return false; } - public bool DoHelloNeighbourCall(RegionInfo region, RegionInfo thisRegion) + public bool DoHelloNeighbourCall(GridRegion region, RegionInfo thisRegion) { string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/region/" + thisRegion.RegionID + "/"; //m_log.Debug(" >>> DoHelloNeighbourCall <<< " + uri); diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs index ce432ab..96dc82b9 100644 --- a/OpenSim/Services/Interfaces/IGridService.cs +++ b/OpenSim/Services/Interfaces/IGridService.cs @@ -122,9 +122,6 @@ namespace OpenSim.Services.Interfaces } protected string m_regionName = String.Empty; - protected bool Allow_Alternate_Ports; - public bool m_allow_alternate_ports; - protected string m_externalHostName; protected IPEndPoint m_internalEndPoint; @@ -146,6 +143,10 @@ namespace OpenSim.Services.Interfaces public UUID RegionID = UUID.Zero; public UUID ScopeID = UUID.Zero; + public UUID TerrainImage = UUID.Zero; + public byte Access; + public int Maturity; + public GridRegion() { } @@ -183,9 +184,11 @@ namespace OpenSim.Services.Interfaces m_internalEndPoint = ConvertFrom.InternalEndPoint; m_externalHostName = ConvertFrom.ExternalHostName; m_httpPort = ConvertFrom.HttpPort; - m_allow_alternate_ports = ConvertFrom.m_allow_alternate_ports; - RegionID = UUID.Zero; + RegionID = ConvertFrom.RegionID; ServerURI = ConvertFrom.ServerURI; + TerrainImage = ConvertFrom.RegionSettings.TerrainImageID; + Access = ConvertFrom.AccessLevel; + Maturity = ConvertFrom.RegionSettings.Maturity; } @@ -268,7 +271,9 @@ namespace OpenSim.Services.Interfaces kvp["serverHttpPort"] = HttpPort.ToString(); kvp["serverURI"] = ServerURI; kvp["serverPort"] = InternalEndPoint.Port.ToString(); - + kvp["regionMapTexture"] = TerrainImage.ToString(); + kvp["access"] = Access.ToString(); + // Maturity doesn't seem to exist in the DB return kvp; } @@ -312,6 +317,16 @@ namespace OpenSim.Services.Interfaces if (kvp.ContainsKey("serverURI")) ServerURI = (string)kvp["serverURI"]; + + if (kvp.ContainsKey("regionMapTexture")) + { + UUID.TryParse((string)kvp["regionMapTexture"], out TerrainImage); + } + + if (kvp.ContainsKey("access")) + { + Access = Byte.Parse((string)kvp["access"]); ; + } } } -- cgit v1.1 From d39e67d5b2ca974e7e2506bcb717ec25ae061e75 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 26 Sep 2009 08:06:14 -0700 Subject: More redirects to HGGridConnector-as-HyperlinkService. --- .../ServiceConnectorsOut/Grid/HGGridConnector.cs | 5 ++++- .../Interregion/RESTInterregionComms.cs | 21 ++++++++++++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs index b5bade6..66cde91 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs @@ -567,6 +567,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid foreach (GridRegion r in m_HyperlinkRegions.Values) if (r.RegionHandle == handle) return r; + foreach (GridRegion r in m_knownRegions.Values) + if (r.RegionHandle == handle) + return r; return null; } @@ -575,7 +578,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid foreach (GridRegion r in m_HyperlinkRegions.Values) if ((r.RegionHandle == handle) && (m_HyperlinkHandles.ContainsKey(r.RegionID))) return m_HyperlinkHandles[r.RegionID]; - return 0; + return handle; } #endregion diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs index f27b2f9..adf747a 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs @@ -42,6 +42,7 @@ using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes.Hypergrid; using OpenSim.Region.Framework.Scenes.Serialization; +using OpenSim.Services.Interfaces; using GridRegion = OpenSim.Services.Interfaces.GridRegion; namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion @@ -60,6 +61,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion protected RegionToRegionClient m_regionClient; + protected IHyperlinkService m_hyperlinkService; + protected bool m_safemode; protected IPAddress m_thisIP; @@ -135,7 +138,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion m_localBackend = new LocalInterregionComms(); m_commsManager = scene.CommsManager; m_aScene = scene; - m_regionClient = new RegionToRegionClient(m_aScene); + m_hyperlinkService = m_aScene.RequestModuleInterface(); + m_regionClient = new RegionToRegionClient(m_aScene, m_hyperlinkService); m_thisIP = Util.GetHostFromDNS(scene.RegionInfo.ExternalHostName); } @@ -789,16 +793,21 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion protected class RegionToRegionClient : RegionClient { Scene m_aScene = null; + IHyperlinkService m_hyperlinkService; - public RegionToRegionClient(Scene s) + public RegionToRegionClient(Scene s, IHyperlinkService hyperService) { m_aScene = s; + m_hyperlinkService = hyperService; } public override ulong GetRegionHandle(ulong handle) { if (m_aScene.SceneGridService is HGSceneCommunicationService) - return ((HGSceneCommunicationService)(m_aScene.SceneGridService)).m_hg.FindRegionHandle(handle); + { + if (m_hyperlinkService != null) + return m_hyperlinkService.FindRegionHandle(handle); + } return handle; } @@ -806,8 +815,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion public override bool IsHyperlink(ulong handle) { if (m_aScene.SceneGridService is HGSceneCommunicationService) - return ((HGSceneCommunicationService)(m_aScene.SceneGridService)).m_hg.IsHyperlinkRegion(handle); - + { + if ((m_hyperlinkService != null) && (m_hyperlinkService.GetHyperlinkRegion(handle) != null)) + return true; + } return false; } -- cgit v1.1 From 632bb7126277b6e8b524b76fb181a079b51adcf4 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 26 Sep 2009 08:49:48 -0700 Subject: Fixed MapBlocks bug, wrong order of arguments. First version that seems completely functional. Also fixed the notification of the message server in standalone -- that server doesn't usually exist. --- OpenSim/Framework/NetworkServersInfo.cs | 3 +-- .../CoreModules/Avatar/InstantMessage/PresenceModule.cs | 12 ++++++++++++ OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs | 4 ++-- OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs | 8 +------- 4 files changed, 16 insertions(+), 11 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/NetworkServersInfo.cs b/OpenSim/Framework/NetworkServersInfo.cs index 3b00af3..7e66742 100644 --- a/OpenSim/Framework/NetworkServersInfo.cs +++ b/OpenSim/Framework/NetworkServersInfo.cs @@ -102,8 +102,7 @@ namespace OpenSim.Framework ConfigSettings.DefaultInventoryServerHttpPort.ToString()); secureInventoryServer = config.Configs["Network"].GetBoolean("secure_inventory_server", true); - MessagingURL = config.Configs["Network"].GetString("messaging_server_url", - "http://127.0.0.1:" + ConfigSettings.DefaultMessageServerHttpPort); + MessagingURL = config.Configs["Network"].GetString("messaging_server_url", string.Empty); } } } diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs index 6daab44..5a9b452 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs @@ -330,6 +330,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage private void NotifyMessageServerOfStartup(Scene scene) { + if (m_Scenes[0].CommsManager.NetworkServersInfo.MessagingURL == string.Empty) + return; + Hashtable xmlrpcdata = new Hashtable(); xmlrpcdata["RegionUUID"] = scene.RegionInfo.RegionID.ToString(); ArrayList SendParams = new ArrayList(); @@ -353,6 +356,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage private void NotifyMessageServerOfShutdown(Scene scene) { + if (m_Scenes[0].CommsManager.NetworkServersInfo.MessagingURL == string.Empty) + return; + Hashtable xmlrpcdata = new Hashtable(); xmlrpcdata["RegionUUID"] = scene.RegionInfo.RegionID.ToString(); ArrayList SendParams = new ArrayList(); @@ -376,6 +382,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage private void NotifyMessageServerOfAgentLocation(UUID agentID, UUID region, ulong regionHandle) { + if (m_Scenes[0].CommsManager.NetworkServersInfo.MessagingURL == string.Empty) + return; + Hashtable xmlrpcdata = new Hashtable(); xmlrpcdata["AgentID"] = agentID.ToString(); xmlrpcdata["RegionUUID"] = region.ToString(); @@ -401,6 +410,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage private void NotifyMessageServerOfAgentLeaving(UUID agentID, UUID region, ulong regionHandle) { + if (m_Scenes[0].CommsManager.NetworkServersInfo.MessagingURL == string.Empty) + return; + Hashtable xmlrpcdata = new Hashtable(); xmlrpcdata["AgentID"] = agentID.ToString(); xmlrpcdata["RegionUUID"] = region.ToString(); diff --git a/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs b/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs index 9957e46..a0ccdc7 100644 --- a/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs +++ b/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs @@ -62,8 +62,8 @@ namespace OpenSim.Region.CoreModules.Hypergrid { List mapBlocks = new List(); List regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID, - (minX - 4) * (int)Constants.RegionSize, (minY - 4) * (int)Constants.RegionSize, - (maxX + 4) * (int)Constants.RegionSize, (maxY + 4) * (int)Constants.RegionSize); + (minX - 4) * (int)Constants.RegionSize, (maxX + 4) * (int)Constants.RegionSize, + (minY - 4) * (int)Constants.RegionSize, (maxY + 4) * (int)Constants.RegionSize); foreach (GridRegion r in regions) { diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs index d0b0f01..9071701 100644 --- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs @@ -371,15 +371,10 @@ namespace OpenSim.Region.Framework.Scenes string capsPath = "http://" + reg.ExternalHostName + ":" + reg.HttpPort + "/CAPS/" + a.CapsPath + "0000/"; - m_log.DebugFormat("[XXX] CAPS = {0}", capsPath); - m_log.DebugFormat("[XXX] ExternalEndPoint = {0}", endPoint.ToString()); - string reason = String.Empty; - //bool regionAccepted = m_commsProvider.InterRegion.InformRegionOfChildAgent(reg.RegionHandle, a); - + bool regionAccepted = m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, a, out reason); - m_log.DebugFormat("[XXX] Here 1 {0}", regionAccepted); if (regionAccepted && newAgent) { @@ -394,7 +389,6 @@ namespace OpenSim.Region.Framework.Scenes } #endregion - m_log.DebugFormat("[XXX] HERE 2"); eq.EnableSimulator(reg.RegionHandle, endPoint, avatar.UUID); eq.EstablishAgentCommunication(avatar.UUID, endPoint, capsPath); m_log.DebugFormat("[CAPS]: Sending new CAPS seed url {0} to client {1} in region {2}", -- cgit v1.1 From 368ae02dc9f7786545342d7bffae5de28678e85f Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 26 Sep 2009 10:18:22 -0700 Subject: Corrected the port number to 8001 in the test client and grid ini. --- OpenSim/Tests/Clients/Grid/GridClient.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Tests/Clients/Grid/GridClient.cs b/OpenSim/Tests/Clients/Grid/GridClient.cs index 941406e..ccda661 100644 --- a/OpenSim/Tests/Clients/Grid/GridClient.cs +++ b/OpenSim/Tests/Clients/Grid/GridClient.cs @@ -28,7 +28,7 @@ namespace OpenSim.Tests.Clients.GridClient new PatternLayout("%date [%thread] %-5level %logger [%property{NDC}] - %message%newline"); log4net.Config.BasicConfigurator.Configure(consoleAppender); - string serverURI = "http://127.0.0.1:8002"; + string serverURI = "http://127.0.0.1:8001"; GridServicesConnector m_Connector = new GridServicesConnector(serverURI); GridRegion r1 = CreateRegion("Test Region 1", 1000, 1000); -- cgit v1.1 From b5163889b915c4405bdd266d32bcaf39aaf8079f Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 26 Sep 2009 10:30:45 -0700 Subject: Fixed the order of params to GetRegionRange. --- .../Region/CoreModules/World/WorldMap/WorldMapModule.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index bd12218..05ed70a 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs @@ -237,8 +237,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap List regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID, (int)(m_scene.RegionInfo.RegionLocX - 8) * (int)Constants.RegionSize, - (int)(m_scene.RegionInfo.RegionLocY - 8) * (int)Constants.RegionSize, (int)(m_scene.RegionInfo.RegionLocX + 8) * (int)Constants.RegionSize, + (int)(m_scene.RegionInfo.RegionLocY - 8) * (int)Constants.RegionSize, (int)(m_scene.RegionInfo.RegionLocY + 8) * (int)Constants.RegionSize); foreach (GridRegion r in regions) { @@ -736,8 +736,10 @@ namespace OpenSim.Region.CoreModules.World.WorldMap // (diva note: why?? in that case we should GetRegionByPosition) // But make sure: Look whether the one we requested is in there List regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID, - minX * (int)Constants.RegionSize, minY * (int)Constants.RegionSize, - maxX * (int)Constants.RegionSize, maxY * (int)Constants.RegionSize); + minX * (int)Constants.RegionSize, + maxX * (int)Constants.RegionSize, + minY * (int)Constants.RegionSize, + maxY * (int)Constants.RegionSize); if (regions != null) { @@ -777,8 +779,10 @@ namespace OpenSim.Region.CoreModules.World.WorldMap { List mapBlocks = new List(); List regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID, - (minX - 4) * (int)Constants.RegionSize, (minY - 4) * (int)Constants.RegionSize, - (maxX + 4) * (int)Constants.RegionSize, (maxY + 4) * (int)Constants.RegionSize); + (minX - 4) * (int)Constants.RegionSize, + (maxX + 4) * (int)Constants.RegionSize, + (minY - 4) * (int)Constants.RegionSize, + (maxY + 4) * (int)Constants.RegionSize); foreach (GridRegion r in regions) { MapBlockData block = new MapBlockData(); @@ -916,8 +920,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap List mapBlocks = new List(); List regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID, (int)(m_scene.RegionInfo.RegionLocX - 9) * (int)Constants.RegionSize, - (int)(m_scene.RegionInfo.RegionLocY - 9) * (int)Constants.RegionSize, (int)(m_scene.RegionInfo.RegionLocX + 9) * (int)Constants.RegionSize, + (int)(m_scene.RegionInfo.RegionLocY - 9) * (int)Constants.RegionSize, (int)(m_scene.RegionInfo.RegionLocY + 9) * (int)Constants.RegionSize); List textures = new List(); List bitImages = new List(); -- cgit v1.1 From dcfd08b8dd57e667db8e0b5900da4648a020160e Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 26 Sep 2009 11:01:18 -0700 Subject: Fixed a bug with link-region. --- .../Grid/HypergridServiceInConnectorModule.cs | 5 ++-- .../ServiceConnectorsOut/Grid/HGCommands.cs | 6 ++--- .../ServiceConnectorsOut/Grid/HGGridConnector.cs | 31 ++++++---------------- .../Handlers/Grid/HypergridServerConnector.cs | 17 ++++++------ .../Connectors/Grid/HypergridServiceConnector.cs | 3 ++- 5 files changed, 25 insertions(+), 37 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs index 4fbee7f..41f96b3 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs @@ -37,6 +37,7 @@ using OpenSim.Region.Framework.Interfaces; using OpenSim.Server.Base; using OpenSim.Server.Handlers.Base; using OpenSim.Server.Handlers.Grid; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid { @@ -106,7 +107,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid //ServerUtils.LoadPlugin("OpenSim.Server.Handlers.dll:HypergridServiceInConnector", args); } - SimpleRegionInfo rinfo = new SimpleRegionInfo(scene.RegionInfo); + GridRegion rinfo = new GridRegion(scene.RegionInfo); m_HypergridHandler.AddRegion(rinfo); } @@ -115,7 +116,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid if (!m_Enabled) return; - SimpleRegionInfo rinfo = new SimpleRegionInfo(scene.RegionInfo); + GridRegion rinfo = new GridRegion(scene.RegionInfo); m_HypergridHandler.RemoveRegion(rinfo); } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs index 36915ef..0974372 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs @@ -86,7 +86,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid private void RunHGCommand(string command, string[] cmdparams) { - if (command.Equals("linkk-mapping")) + if (command.Equals("link-mapping")) { if (cmdparams.Length == 2) { @@ -104,7 +104,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid } } } - else if (command.Equals("linkk-region")) + else if (command.Equals("link-region")) { if (cmdparams.Length < 3) { @@ -187,7 +187,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid } return; } - else if (command.Equals("unlinkk-region")) + else if (command.Equals("unlink-region")) { if (cmdparams.Length < 1) { diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs index 66cde91..0bb4206 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs @@ -159,27 +159,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid { m_HypergridServiceConnector = new HypergridServiceConnector(scene.AssetService); HGCommands hgCommands = new HGCommands(this, scene); - MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "linkk-region", + MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "link-region", "link-region :[:] ", "Link a hypergrid region", hgCommands.RunCommand); - MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "unlinkk-region", + MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "unlink-region", "unlink-region or : ", "Unlink a hypergrid region", hgCommands.RunCommand); - MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "linkk-mapping", "link-mapping [ ] ", + MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "link-mapping", "link-mapping [ ] ", "Set local coordinate to map HG regions to", hgCommands.RunCommand); m_Initialized = true; } - - - //scene.AddCommand("HGGridServicesConnector", "linkk-region", - // "link-region :[:] ", - // "Link a hypergrid region", hgCommands.RunCommand); - //scene.AddCommand("HGGridServicesConnector", "unlinkk-region", - // "unlink-region or : ", - // "Unlink a hypergrid region", hgCommands.RunCommand); - //scene.AddCommand("HGGridServicesConnector", "linkk-mapping", "link-mapping [ ] ", - // "Set local coordinate to map HG regions to", hgCommands.RunCommand); - } #endregion @@ -450,15 +439,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid } // Finally, link it - try - { - RegisterRegion(UUID.Zero, regInfo); - } - catch (Exception e) - { - m_log.Warn("[HGrid]: Unable to link region: " + e.Message); - return false; - } + if (!RegisterRegion(UUID.Zero, regInfo)) + { + m_log.Warn("[HGrid]: Unable to link region"); + return false; + } int x, y; if (!Check4096(m_scene, regInfo, out x, out y)) diff --git a/OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs b/OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs index ad63485..d2e791b 100644 --- a/OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs +++ b/OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs @@ -36,6 +36,7 @@ using OpenSim.Server.Base; using OpenSim.Services.Interfaces; using OpenSim.Framework.Servers.HttpServer; using OpenSim.Server.Handlers.Base; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; using log4net; using Nwc.XmlRpc; @@ -48,12 +49,12 @@ namespace OpenSim.Server.Handlers.Grid LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType); - private List m_RegionsOnSim = new List(); + private List m_RegionsOnSim = new List(); public HypergridServiceInConnector(IConfigSource config, IHttpServer server) : base(config, server) { - server.AddXmlRPCHandler("linkk_region", LinkRegionRequest, false); + server.AddXmlRPCHandler("link_region", LinkRegionRequest, false); } /// @@ -70,8 +71,8 @@ namespace OpenSim.Server.Handlers.Grid m_log.DebugFormat("[HGrid]: Hyperlink request"); - SimpleRegionInfo regInfo = null; - foreach (SimpleRegionInfo r in m_RegionsOnSim) + GridRegion regInfo = null; + foreach (GridRegion r in m_RegionsOnSim) { if ((r.RegionName != null) && (name != null) && (r.RegionName.ToLower() == name.ToLower())) { @@ -85,9 +86,9 @@ namespace OpenSim.Server.Handlers.Grid Hashtable hash = new Hashtable(); hash["uuid"] = regInfo.RegionID.ToString(); + m_log.Debug(">> Here " + regInfo.RegionID); hash["handle"] = regInfo.RegionHandle.ToString(); - //m_log.Debug(">> Here " + regInfo.RegionHandle); - //hash["region_image"] = regInfo.RegionSettings.TerrainImageID.ToString(); + hash["region_image"] = regInfo.TerrainImage.ToString(); hash["region_name"] = regInfo.RegionName; hash["internal_port"] = regInfo.InternalEndPoint.Port.ToString(); //m_log.Debug(">> Here: " + regInfo.InternalEndPoint.Port); @@ -98,12 +99,12 @@ namespace OpenSim.Server.Handlers.Grid return response; } - public void AddRegion(SimpleRegionInfo rinfo) + public void AddRegion(GridRegion rinfo) { m_RegionsOnSim.Add(rinfo); } - public void RemoveRegion(SimpleRegionInfo rinfo) + public void RemoveRegion(GridRegion rinfo) { if (m_RegionsOnSim.Contains(rinfo)) m_RegionsOnSim.Remove(rinfo); diff --git a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs index b5e8743..cf17557 100644 --- a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs +++ b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs @@ -66,7 +66,7 @@ namespace OpenSim.Services.Connectors.Grid IList paramList = new ArrayList(); paramList.Add(hash); - XmlRpcRequest request = new XmlRpcRequest("linkk_region", paramList); + XmlRpcRequest request = new XmlRpcRequest("link_region", paramList); string uri = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/"; m_log.Debug("[HGrid]: Linking to " + uri); XmlRpcResponse response = request.Send(uri, 10000); @@ -82,6 +82,7 @@ namespace OpenSim.Services.Connectors.Grid try { UUID.TryParse((string)hash["uuid"], out uuid); + m_log.Debug(">> HERE, uuid: " + uuid); info.RegionID = uuid; if ((string)hash["handle"] != null) { -- cgit v1.1 From f4bf581b96347b8d7f115eca74fa84a644eb729c Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 26 Sep 2009 21:00:51 -0700 Subject: Moved all HG1 operations to HGGridConnector.cs and HypergridServerConnector.cs/HypergridServiceConnector.cs, away from Region.Communications and HGNetworkServersInfo. Fixed small bugs with hyperlinked regions' map positions. --- .../CreateCommsManager/CreateCommsManagerPlugin.cs | 1 - OpenSim/Framework/Util.cs | 26 +++ OpenSim/Region/Application/HGCommands.cs | 3 +- .../Communications/Hypergrid/HGGridServices.cs | 50 ++--- .../Grid/HypergridServiceInConnectorModule.cs | 29 +-- .../ServiceConnectorsOut/Grid/HGGridConnector.cs | 227 ++++++++++++++++++++- .../Interregion/RESTInterregionComms.cs | 22 +- .../Inventory/HGInventoryBroker.cs | 9 +- .../CoreModules/World/WorldMap/MapSearchModule.cs | 4 +- .../Framework/Scenes/Hypergrid/HGAssetMapper.cs | 33 ++- .../Hypergrid/HGSceneCommunicationService.cs | 19 +- .../Handlers/Grid/HypergridServerConnector.cs | 111 +++++++++- .../Connectors/Grid/HypergridServiceConnector.cs | 89 ++++++++ OpenSim/Services/Interfaces/IGridService.cs | 14 ++ 14 files changed, 537 insertions(+), 100 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/ApplicationPlugins/CreateCommsManager/CreateCommsManagerPlugin.cs b/OpenSim/ApplicationPlugins/CreateCommsManager/CreateCommsManagerPlugin.cs index 6a66116..18641f1 100644 --- a/OpenSim/ApplicationPlugins/CreateCommsManager/CreateCommsManagerPlugin.cs +++ b/OpenSim/ApplicationPlugins/CreateCommsManager/CreateCommsManagerPlugin.cs @@ -144,7 +144,6 @@ namespace OpenSim.ApplicationPlugins.CreateCommsManager // We are in grid mode InitialiseHGGridServices(libraryRootFolder); } - HGCommands.HGServices = HGServices; } protected void InitialiseStandardServices(LibraryRootFolder libraryRootFolder) diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 45b5a10..a28a617 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs @@ -1203,6 +1203,32 @@ namespace OpenSim.Framework return found.ToArray(); } + public static string ServerURI(string uri) + { + if (uri == string.Empty) + return string.Empty; + + // Get rid of eventual slashes at the end + uri = uri.TrimEnd('/'); + + IPAddress ipaddr1 = null; + string port1 = ""; + try + { + ipaddr1 = Util.GetHostFromURL(uri); + } + catch { } + + try + { + port1 = uri.Split(new char[] { ':' })[2]; + } + catch { } + + // We tried our best to convert the domain names to IP addresses + return (ipaddr1 != null) ? "http://" + ipaddr1.ToString() + ":" + port1 : uri; + } + #region FireAndForget Threading Pattern public static void FireAndForget(System.Threading.WaitCallback callback) diff --git a/OpenSim/Region/Application/HGCommands.cs b/OpenSim/Region/Application/HGCommands.cs index f99c1a5..f503db7 100644 --- a/OpenSim/Region/Application/HGCommands.cs +++ b/OpenSim/Region/Application/HGCommands.cs @@ -43,12 +43,11 @@ namespace OpenSim public class HGCommands { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - public static IHyperlink HGServices = null; public static Scene CreateScene(RegionInfo regionInfo, AgentCircuitManager circuitManager, CommunicationsManager m_commsManager, StorageManager storageManager, ModuleLoader m_moduleLoader, ConfigSettings m_configSettings, OpenSimConfigSource m_config, string m_version) { - HGSceneCommunicationService sceneGridService = new HGSceneCommunicationService(m_commsManager, HGServices); + HGSceneCommunicationService sceneGridService = new HGSceneCommunicationService(m_commsManager); return new HGScene( diff --git a/OpenSim/Region/Communications/Hypergrid/HGGridServices.cs b/OpenSim/Region/Communications/Hypergrid/HGGridServices.cs index 54cde0f..85bfab4 100644 --- a/OpenSim/Region/Communications/Hypergrid/HGGridServices.cs +++ b/OpenSim/Region/Communications/Hypergrid/HGGridServices.cs @@ -596,16 +596,16 @@ namespace OpenSim.Region.Communications.Hypergrid //m_log.Debug(" >> " + loginParams["region_uuid"] + " <<"); //m_log.Debug(" --------- ---------------- -------"); - string serverURI = ""; - if (u.UserProfile is ForeignUserProfileData) - serverURI = HGNetworkServersInfo.ServerURI(((ForeignUserProfileData)u.UserProfile).UserServerURI); - loginParams["userserver_id"] = (serverURI == "") || (serverURI == null) ? HGNetworkServersInfo.Singleton.LocalUserServerURI : serverURI; + //string serverURI = ""; + //if (u.UserProfile is ForeignUserProfileData) + // serverURI = Util.ServerURI(((ForeignUserProfileData)u.UserProfile).UserServerURI); + //loginParams["userserver_id"] = (serverURI == "") || (serverURI == null) ? HGNetworkServersInfo.Singleton.LocalUserServerURI : serverURI; - serverURI = HGNetworkServersInfo.ServerURI(u.UserProfile.UserAssetURI); - loginParams["assetserver_id"] = (serverURI == "") || (serverURI == null) ? HGNetworkServersInfo.Singleton.LocalAssetServerURI : serverURI; + //serverURI = HGNetworkServersInfo.ServerURI(u.UserProfile.UserAssetURI); + //loginParams["assetserver_id"] = (serverURI == "") || (serverURI == null) ? HGNetworkServersInfo.Singleton.LocalAssetServerURI : serverURI; - serverURI = HGNetworkServersInfo.ServerURI(u.UserProfile.UserInventoryURI); - loginParams["inventoryserver_id"] = (serverURI == "") || (serverURI == null) ? HGNetworkServersInfo.Singleton.LocalInventoryServerURI : serverURI; + //serverURI = HGNetworkServersInfo.ServerURI(u.UserProfile.UserInventoryURI); + //loginParams["inventoryserver_id"] = (serverURI == "") || (serverURI == null) ? HGNetworkServersInfo.Singleton.LocalInventoryServerURI : serverURI; loginParams["root_folder_id"] = u.UserProfile.RootInventoryFolderID; @@ -949,33 +949,35 @@ namespace OpenSim.Region.Communications.Hypergrid protected bool IsComingHome(ForeignUserProfileData userData) { - return (userData.UserServerURI == HGNetworkServersInfo.Singleton.LocalUserServerURI); + return false; //(userData.UserServerURI == HGNetworkServersInfo.Singleton.LocalUserServerURI); } protected bool IsGoingHome(CachedUserInfo uinfo, RegionInfo rinfo) { - if (uinfo.UserProfile == null) - return false; + return false; + //if (uinfo.UserProfile == null) + // return false; - string userUserServerURI = String.Empty; - if (uinfo.UserProfile is ForeignUserProfileData) - { - userUserServerURI = HGNetworkServersInfo.ServerURI(((ForeignUserProfileData)uinfo.UserProfile).UserServerURI); - } + //string userUserServerURI = String.Empty; + //if (uinfo.UserProfile is ForeignUserProfileData) + //{ + // userUserServerURI = HGNetworkServersInfo.ServerURI(((ForeignUserProfileData)uinfo.UserProfile).UserServerURI); + //} - return ((uinfo.UserProfile.HomeRegionID == rinfo.RegionID) && - (userUserServerURI != HGNetworkServersInfo.Singleton.LocalUserServerURI)); + //return ((uinfo.UserProfile.HomeRegionID == rinfo.RegionID) && + // (userUserServerURI != HGNetworkServersInfo.Singleton.LocalUserServerURI)); } protected bool IsLocalUser(CachedUserInfo uinfo) { - if (uinfo == null) - return true; + return true; + //if (uinfo == null) + // return true; - if (uinfo.UserProfile is ForeignUserProfileData) - return HGNetworkServersInfo.Singleton.IsLocalUser(((ForeignUserProfileData)uinfo.UserProfile).UserServerURI); - else - return true; + //if (uinfo.UserProfile is ForeignUserProfileData) + // return HGNetworkServersInfo.Singleton.IsLocalUser(((ForeignUserProfileData)uinfo.UserProfile).UserServerURI); + //else + // return true; } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs index 41f96b3..9bf31a4 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs @@ -37,6 +37,7 @@ using OpenSim.Region.Framework.Interfaces; using OpenSim.Server.Base; using OpenSim.Server.Handlers.Base; using OpenSim.Server.Handlers.Grid; +using OpenSim.Services.Interfaces; using GridRegion = OpenSim.Services.Interfaces.GridRegion; namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid @@ -95,20 +96,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid if (!m_Enabled) return; - if (!m_Registered) - { - m_Registered = true; - - m_log.Info("[HypergridService]: Starting..."); - - Object[] args = new Object[] { m_Config, MainServer.Instance }; - - m_HypergridHandler = new HypergridServiceInConnector(m_Config, MainServer.Instance); - //ServerUtils.LoadPlugin("OpenSim.Server.Handlers.dll:HypergridServiceInConnector", args); - } - - GridRegion rinfo = new GridRegion(scene.RegionInfo); - m_HypergridHandler.AddRegion(rinfo); } public void RemoveRegion(Scene scene) @@ -122,6 +109,20 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid public void RegionLoaded(Scene scene) { + if (!m_Registered) + { + m_Registered = true; + + m_log.Info("[HypergridService]: Starting..."); + + Object[] args = new Object[] { m_Config, MainServer.Instance }; + + m_HypergridHandler = new HypergridServiceInConnector(m_Config, MainServer.Instance, scene.RequestModuleInterface()); + //ServerUtils.LoadPlugin("OpenSim.Server.Handlers.dll:HypergridServiceInConnector", args); + } + + GridRegion rinfo = new GridRegion(scene.RegionInfo); + m_HypergridHandler.AddRegion(rinfo); } #endregion diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs index 0bb4206..52db400 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs @@ -31,6 +31,7 @@ using System.Net; using System.Reflection; using System.Xml; +using OpenSim.Framework.Communications.Cache; using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; @@ -52,10 +53,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid private static readonly ILog m_log = LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType); + private static string LocalAssetServerURI, LocalInventoryServerURI, LocalUserServerURI; private bool m_Enabled = false; private bool m_Initialized = false; + private Scene m_aScene; + private Dictionary m_LocalScenes = new Dictionary(); + private IGridService m_GridServiceConnector; private HypergridServiceConnector m_HypergridServiceConnector; @@ -141,6 +146,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid if (!m_Enabled) return; + m_LocalScenes[scene.RegionInfo.RegionHandle] = scene; scene.RegisterModuleInterface(this); scene.RegisterModuleInterface(this); @@ -148,6 +154,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid public void RemoveRegion(Scene scene) { + m_LocalScenes.Remove(scene.RegionInfo.RegionHandle); } public void RegionLoaded(Scene scene) @@ -157,7 +164,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid if (!m_Initialized) { + m_aScene = scene; + LocalAssetServerURI = m_aScene.CommsManager.NetworkServersInfo.UserURL; + LocalInventoryServerURI = m_aScene.CommsManager.NetworkServersInfo.InventoryURL; + LocalUserServerURI = m_aScene.CommsManager.NetworkServersInfo.UserURL; + m_HypergridServiceConnector = new HypergridServiceConnector(scene.AssetService); + HGCommands hgCommands = new HGCommands(this, scene); MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "link-region", "link-region :[:] ", @@ -167,6 +180,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid "Unlink a hypergrid region", hgCommands.RunCommand); MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "link-mapping", "link-mapping [ ] ", "Set local coordinate to map HG regions to", hgCommands.RunCommand); + + // Yikes!! Remove this as soon as user services get refactored + HGNetworkServersInfo.Init(LocalAssetServerURI, LocalInventoryServerURI, LocalUserServerURI); + m_Initialized = true; } } @@ -240,7 +257,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid // Try the foreign users home collection foreach (GridRegion r in m_knownRegions.Values) if (r.RegionID == regionID) - return m_knownRegions[regionID]; + return r; // Finally, try the normal route return m_GridServiceConnector.GetRegionByUUID(scopeID, regionID); @@ -261,7 +278,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid foreach (GridRegion r in m_knownRegions.Values) { if ((r.RegionLocX == snapX) && (r.RegionLocY == snapY)) + { return r; + } } // Finally, try the normal route @@ -328,8 +347,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid private void AddHyperlinkRegion(GridRegion regionInfo, ulong regionHandle) { - m_HyperlinkRegions.Add(regionInfo.RegionID, regionInfo); - m_HyperlinkHandles.Add(regionInfo.RegionID, regionHandle); + m_HyperlinkRegions[regionInfo.RegionID] = regionInfo; + m_HyperlinkHandles[regionInfo.RegionID] = regionHandle; } private void RemoveHyperlinkRegion(UUID regionID) @@ -340,8 +359,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid private void AddHyperlinkHomeRegion(UUID userID, GridRegion regionInfo, ulong regionHandle) { - m_knownRegions.Add(userID, regionInfo); - m_HyperlinkHandles.Add(regionInfo.RegionID, regionHandle); + m_knownRegions[userID] = regionInfo; + m_HyperlinkHandles[regionInfo.RegionID] = regionHandle; } private void RemoveHyperlinkHomeRegion(UUID regionID) @@ -412,7 +431,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid // From the map search and secondlife://blah public GridRegion TryLinkRegion(Scene m_scene, IClientAPI client, string mapName) { - int xloc = random.Next(0, Int16.MaxValue); + int xloc = random.Next(0, Int16.MaxValue) * (int) Constants.RegionSize; return TryLinkRegionToCoords(m_scene, client, mapName, xloc, 0); } @@ -563,10 +582,206 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid foreach (GridRegion r in m_HyperlinkRegions.Values) if ((r.RegionHandle == handle) && (m_HyperlinkHandles.ContainsKey(r.RegionID))) return m_HyperlinkHandles[r.RegionID]; + + foreach (GridRegion r in m_knownRegions.Values) + if ((r.RegionHandle == handle) && (m_HyperlinkHandles.ContainsKey(r.RegionID))) + return m_HyperlinkHandles[r.RegionID]; + return handle; } + public bool SendUserInformation(GridRegion regInfo, AgentCircuitData agentData) + { + CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(agentData.AgentID); + + if ((IsLocalUser(uinfo) && (GetHyperlinkRegion(regInfo.RegionHandle) != null)) || + (!IsLocalUser(uinfo) && !IsGoingHome(uinfo, regInfo))) + { + m_log.Info("[HGrid]: Local user is going to foreign region or foreign user is going elsewhere"); + + // Set the position of the region on the remote grid + ulong realHandle = FindRegionHandle(regInfo.RegionHandle); + uint x = 0, y = 0; + Utils.LongToUInts(regInfo.RegionHandle, out x, out y); + GridRegion clonedRegion = new GridRegion(regInfo); + clonedRegion.RegionLocX = (int)x; + clonedRegion.RegionLocY = (int)y; + + // Get the user's home region information + GridRegion home = m_aScene.GridService.GetRegionByUUID(m_aScene.RegionInfo.ScopeID, uinfo.UserProfile.HomeRegionID); + + // Get the user's service URLs + string serverURI = ""; + if (uinfo.UserProfile is ForeignUserProfileData) + serverURI = Util.ServerURI(((ForeignUserProfileData)uinfo.UserProfile).UserServerURI); + string userServer = (serverURI == "") || (serverURI == null) ? LocalUserServerURI : serverURI; + + string assetServer = Util.ServerURI(uinfo.UserProfile.UserAssetURI); + if ((assetServer == null) || (assetServer == "")) + assetServer = LocalAssetServerURI; + + string inventoryServer = Util.ServerURI(uinfo.UserProfile.UserInventoryURI); + if ((inventoryServer == null) || (inventoryServer == "")) + inventoryServer = LocalInventoryServerURI; + + if (!m_HypergridServiceConnector.InformRegionOfUser(clonedRegion, agentData, home, userServer, assetServer, inventoryServer)) + { + m_log.Warn("[HGrid]: Could not inform remote region of transferring user."); + return false; + } + } + //if ((uinfo == null) || !IsGoingHome(uinfo, regInfo)) + //{ + // m_log.Info("[HGrid]: User seems to be going to foreign region."); + // if (!InformRegionOfUser(regInfo, agentData)) + // { + // m_log.Warn("[HGrid]: Could not inform remote region of transferring user."); + // return false; + // } + //} + //else + // m_log.Info("[HGrid]: User seems to be going home " + uinfo.UserProfile.FirstName + " " + uinfo.UserProfile.SurName); + + // May need to change agent's name + if (IsLocalUser(uinfo) && (GetHyperlinkRegion(regInfo.RegionHandle) != null)) + { + agentData.firstname = agentData.firstname + "." + agentData.lastname; + agentData.lastname = "@" + LocalUserServerURI.Replace("http://", ""); ; //HGNetworkServersInfo.Singleton.LocalUserServerURI; + } + + return true; + } + + public void AdjustUserInformation(AgentCircuitData agentData) + { + CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(agentData.AgentID); + if ((uinfo != null) && (uinfo.UserProfile != null) && + (IsLocalUser(uinfo) || !(uinfo.UserProfile is ForeignUserProfileData))) + { + //m_log.Debug("---------------> Local User!"); + string[] parts = agentData.firstname.Split(new char[] { '.' }); + if (parts.Length == 2) + { + agentData.firstname = parts[0]; + agentData.lastname = parts[1]; + } + } + //else + // m_log.Debug("---------------> Foreign User!"); + } + + // Check if a local user exists with the same UUID as the incoming foreign user + public bool CheckUserAtEntry(UUID userID, UUID sessionID, out bool comingHome) + { + comingHome = false; + if (!m_aScene.SceneGridService.RegionLoginsEnabled) + return false; + + CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(userID); + if (uinfo != null) + { + // uh-oh we have a potential intruder + if (uinfo.SessionID != sessionID) + // can't have a foreigner with a local UUID + return false; + else + // oh, so it's you! welcome back + comingHome = true; + } + + // OK, user can come in + return true; + } + + public void AcceptUser(ForeignUserProfileData user, GridRegion home) + { + m_aScene.CommsManager.UserProfileCacheService.PreloadUserCache(user); + ulong realHandle = home.RegionHandle; + // Change the local coordinates + // X=0 on the map + home.RegionLocX = 0; + home.RegionLocY = random.Next(0, 10000) * (int)Constants.RegionSize; + + AddHyperlinkHomeRegion(user.ID, home, realHandle); + + DumpUserData(user); + DumpRegionData(home); + + } + + public bool IsLocalUser(UUID userID) + { + CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(userID); + return IsLocalUser(uinfo); + } + #endregion + #region IHyperlink Misc + + protected bool IsComingHome(ForeignUserProfileData userData) + { + return (userData.UserServerURI == LocalUserServerURI); + } + + // Is the user going back to the home region or the home grid? + protected bool IsGoingHome(CachedUserInfo uinfo, GridRegion rinfo) + { + if (uinfo.UserProfile == null) + return false; + + if (!(uinfo.UserProfile is ForeignUserProfileData)) + // it's a home user, can't be outside to return home + return false; + + // OK, it's a foreign user with a ForeignUserProfileData + // and is going back to exactly the home region. + // We can't check if it's going back to a non-home region + // of the home grid. That will be dealt with in the + // receiving end + return (uinfo.UserProfile.HomeRegionID == rinfo.RegionID); + } + + protected bool IsLocalUser(CachedUserInfo uinfo) + { + if (uinfo == null) + return false; + + return !(uinfo.UserProfile is ForeignUserProfileData); + + } + + protected bool IsLocalRegion(ulong handle) + { + return m_LocalScenes.ContainsKey(handle); + } + + private void DumpUserData(ForeignUserProfileData userData) + { + m_log.Info(" ------------ User Data Dump ----------"); + m_log.Info(" >> Name: " + userData.FirstName + " " + userData.SurName); + m_log.Info(" >> HomeID: " + userData.HomeRegionID); + m_log.Info(" >> UserServer: " + userData.UserServerURI); + m_log.Info(" >> InvServer: " + userData.UserInventoryURI); + m_log.Info(" >> AssetServer: " + userData.UserAssetURI); + m_log.Info(" ------------ -------------- ----------"); + } + + private void DumpRegionData(GridRegion rinfo) + { + m_log.Info(" ------------ Region Data Dump ----------"); + m_log.Info(" >> handle: " + rinfo.RegionHandle); + m_log.Info(" >> coords: " + rinfo.RegionLocX + ", " + rinfo.RegionLocY); + m_log.Info(" >> external host name: " + rinfo.ExternalHostName); + m_log.Info(" >> http port: " + rinfo.HttpPort); + m_log.Info(" >> external EP address: " + rinfo.ExternalEndPoint.Address); + m_log.Info(" >> external EP port: " + rinfo.ExternalEndPoint.Port); + m_log.Info(" ------------ -------------- ----------"); + } + + + #endregion + + } } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs index adf747a..696225c 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs @@ -824,29 +824,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion public override void SendUserInformation(GridRegion regInfo, AgentCircuitData aCircuit) { - try - { - if (m_aScene.SceneGridService is HGSceneCommunicationService) - { - // big hack for now - RegionInfo r = new RegionInfo(); - r.ExternalHostName = regInfo.ExternalHostName; - r.HttpPort = regInfo.HttpPort; - r.RegionID = regInfo.RegionID; - r.RegionLocX = (uint)regInfo.RegionLocX; - r.RegionLocY = (uint)regInfo.RegionLocY; - ((HGSceneCommunicationService)(m_aScene.SceneGridService)).m_hg.SendUserInformation(r, aCircuit); - } - } - catch // Bad cast - { } + if (m_hyperlinkService != null) + m_hyperlinkService.SendUserInformation(regInfo, aCircuit); } public override void AdjustUserInformation(AgentCircuitData aCircuit) { - if (m_aScene.SceneGridService is HGSceneCommunicationService) - ((HGSceneCommunicationService)(m_aScene.SceneGridService)).m_hg.AdjustUserInformation(aCircuit); + if (m_hyperlinkService != null) + m_hyperlinkService.AdjustUserInformation(aCircuit); } } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs index 1c66254..fd1a759 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs @@ -525,7 +525,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory return true; } - string userInventoryServerURI = HGNetworkServersInfo.ServerURI(uinfo.UserProfile.UserInventoryURI); + if ((uinfo.UserProfile.UserInventoryURI == null) || (uinfo.UserProfile.UserInventoryURI == "")) + // this happens in standalone profiles, apparently + return true; + + string userInventoryServerURI = Util.ServerURI(uinfo.UserProfile.UserInventoryURI); + string uri = m_LocalGridInventoryURI.TrimEnd('/'); if ((userInventoryServerURI == uri) || (userInventoryServerURI == "")) @@ -544,7 +549,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory if ((uinfo == null) || (uinfo.UserProfile == null)) return invURI; - string userInventoryServerURI = HGNetworkServersInfo.ServerURI(uinfo.UserProfile.UserInventoryURI); + string userInventoryServerURI = Util.ServerURI(uinfo.UserProfile.UserInventoryURI); if ((userInventoryServerURI != null) && (userInventoryServerURI != "")) diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs index e3661fa..436f332 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs @@ -137,8 +137,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap data.Name = info.RegionName; data.RegionFlags = 0; // TODO not used? data.WaterHeight = 0; // not used - data.X = (ushort)info.RegionLocX; - data.Y = (ushort)info.RegionLocY; + data.X = (ushort)(info.RegionLocX / Constants.RegionSize); + data.Y = (ushort)(info.RegionLocY / Constants.RegionSize); blocks.Add(data); } } diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs index 62efd60..b6fa41d 100644 --- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs +++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs @@ -35,6 +35,7 @@ using OpenSim.Framework; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Communications.Clients; using OpenSim.Region.Framework.Scenes.Serialization; +using OpenSim.Services.Interfaces; //using HyperGrid.Framework; //using OpenSim.Region.Communications.Hypergrid; @@ -50,6 +51,18 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid // private Dictionary m_inventoryServers = new Dictionary(); private Scene m_scene; + + private IHyperlinkService m_hyper; + IHyperlinkService HyperlinkService + { + get + { + if (m_hyper == null) + m_hyper = m_scene.RequestModuleInterface(); + return m_hyper; + } + } + #endregion #region Constructor @@ -79,22 +92,6 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid // return null; // } - private bool IsLocalUser(UUID userID) - { - CachedUserInfo uinfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(userID); - - if (uinfo != null) - { - if (HGNetworkServersInfo.Singleton.IsLocalUser(uinfo.UserProfile)) - { - m_log.Debug("[HGScene]: Home user " + uinfo.UserProfile.FirstName + " " + uinfo.UserProfile.SurName); - return true; - } - } - - m_log.Debug("[HGScene]: Foreign user " + uinfo.UserProfile.FirstName + " " + uinfo.UserProfile.SurName); - return false; - } public AssetBase FetchAsset(string url, UUID assetID) { @@ -170,7 +167,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid public void Get(UUID assetID, UUID ownerID) { - if (!IsLocalUser(ownerID)) + if (!HyperlinkService.IsLocalUser(ownerID)) { // Get the item from the remote asset server onto the local AssetCache // and place an entry in m_assetMap @@ -228,7 +225,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid public void Post(UUID assetID, UUID ownerID) { - if (!IsLocalUser(ownerID)) + if (!HyperlinkService.IsLocalUser(ownerID)) { // Post the item from the local AssetCache onto the remote asset server // and place an entry in m_assetMap diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs index ee5eb90..1217f9b 100644 --- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs +++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs @@ -38,6 +38,7 @@ using OpenSim.Framework.Communications; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Capabilities; using OpenSim.Region.Framework.Interfaces; +using OpenSim.Services.Interfaces; using GridRegion = OpenSim.Services.Interfaces.GridRegion; namespace OpenSim.Region.Framework.Scenes.Hypergrid @@ -46,11 +47,19 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - public readonly IHyperlink m_hg; + private IHyperlinkService m_hg; + IHyperlinkService HyperlinkService + { + get + { + if (m_hg == null) + m_hg = m_scene.RequestModuleInterface(); + return m_hg; + } + } - public HGSceneCommunicationService(CommunicationsManager commsMan, IHyperlink hg) : base(commsMan) + public HGSceneCommunicationService(CommunicationsManager commsMan) : base(commsMan) { - m_hg = hg; } @@ -129,13 +138,13 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid /// Hypergrid mod start /// /// - bool isHyperLink = m_hg.IsHyperlinkRegion(reg.RegionHandle); + bool isHyperLink = (HyperlinkService.GetHyperlinkRegion(reg.RegionHandle) != null); bool isHomeUser = true; ulong realHandle = regionHandle; CachedUserInfo uinfo = m_commsProvider.UserProfileCacheService.GetUserDetails(avatar.UUID); if (uinfo != null) { - isHomeUser = HGNetworkServersInfo.Singleton.IsLocalUser(uinfo.UserProfile); + isHomeUser = HyperlinkService.IsLocalUser(uinfo.UserProfile.ID); realHandle = m_hg.FindRegionHandle(regionHandle); m_log.Debug("XXX ---- home user? " + isHomeUser + " --- hyperlink? " + isHyperLink + " --- real handle: " + realHandle.ToString()); } diff --git a/OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs b/OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs index d2e791b..c47f652 100644 --- a/OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs +++ b/OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs @@ -38,6 +38,7 @@ using OpenSim.Framework.Servers.HttpServer; using OpenSim.Server.Handlers.Base; using GridRegion = OpenSim.Services.Interfaces.GridRegion; +using OpenMetaverse; using log4net; using Nwc.XmlRpc; @@ -50,11 +51,25 @@ namespace OpenSim.Server.Handlers.Grid MethodBase.GetCurrentMethod().DeclaringType); private List m_RegionsOnSim = new List(); + private IHyperlinkService m_HyperlinkService; - public HypergridServiceInConnector(IConfigSource config, IHttpServer server) : + public HypergridServiceInConnector(IConfigSource config, IHttpServer server, IHyperlinkService hyperService) : base(config, server) { + m_HyperlinkService = hyperService; server.AddXmlRPCHandler("link_region", LinkRegionRequest, false); + server.AddXmlRPCHandler("expect_hg_user", ExpectHGUser, false); + } + + public void AddRegion(GridRegion rinfo) + { + m_RegionsOnSim.Add(rinfo); + } + + public void RemoveRegion(GridRegion rinfo) + { + if (m_RegionsOnSim.Contains(rinfo)) + m_RegionsOnSim.Remove(rinfo); } /// @@ -99,15 +114,95 @@ namespace OpenSim.Server.Handlers.Grid return response; } - public void AddRegion(GridRegion rinfo) + /// + /// Received from other HGrid nodes when a user wants to teleport here. This call allows + /// the region to prepare for direct communication from the client. Sends back an empty + /// xmlrpc response on completion. + /// This is somewhat similar to OGS1's ExpectUser, but with the additional task of + /// registering the user in the local user cache. + /// + /// + /// + public XmlRpcResponse ExpectHGUser(XmlRpcRequest request, IPEndPoint remoteClient) { - m_RegionsOnSim.Add(rinfo); - } + Hashtable requestData = (Hashtable)request.Params[0]; + ForeignUserProfileData userData = new ForeignUserProfileData(); - public void RemoveRegion(GridRegion rinfo) - { - if (m_RegionsOnSim.Contains(rinfo)) - m_RegionsOnSim.Remove(rinfo); + userData.FirstName = (string)requestData["firstname"]; + userData.SurName = (string)requestData["lastname"]; + userData.ID = new UUID((string)requestData["agent_id"]); + UUID sessionID = new UUID((string)requestData["session_id"]); + userData.HomeLocation = new Vector3((float)Convert.ToDecimal((string)requestData["startpos_x"]), + (float)Convert.ToDecimal((string)requestData["startpos_y"]), + (float)Convert.ToDecimal((string)requestData["startpos_z"])); + + userData.UserServerURI = (string)requestData["userserver_id"]; + userData.UserAssetURI = (string)requestData["assetserver_id"]; + userData.UserInventoryURI = (string)requestData["inventoryserver_id"]; + + m_log.DebugFormat("[HGrid]: Prepare for connection from {0} {1} (@{2}) UUID={3}", + userData.FirstName, userData.SurName, userData.UserServerURI, userData.ID); + + ulong userRegionHandle = 0; + int userhomeinternalport = 0; + if (requestData.ContainsKey("region_uuid")) + { + UUID uuid = UUID.Zero; + UUID.TryParse((string)requestData["region_uuid"], out uuid); + userData.HomeRegionID = uuid; + userRegionHandle = Convert.ToUInt64((string)requestData["regionhandle"]); + userData.UserHomeAddress = (string)requestData["home_address"]; + userData.UserHomePort = (string)requestData["home_port"]; + userhomeinternalport = Convert.ToInt32((string)requestData["internal_port"]); + + m_log.Debug("[HGrid]: home_address: " + userData.UserHomeAddress + + "; home_port: " + userData.UserHomePort); + } + else + m_log.WarnFormat("[HGrid]: User has no home region information"); + + XmlRpcResponse resp = new XmlRpcResponse(); + + // Let's check if someone is trying to get in with a stolen local identity. + // The need for this test is a consequence of not having truly global names :-/ + bool comingHome = false; + if (m_HyperlinkService.CheckUserAtEntry(userData.ID, sessionID, out comingHome) == false) + { + m_log.WarnFormat("[HGrid]: Access denied to foreign user."); + Hashtable respdata = new Hashtable(); + respdata["success"] = "FALSE"; + respdata["reason"] = "Foreign user has the same ID as a local user, or logins disabled."; + resp.Value = respdata; + return resp; + } + + // Finally, everything looks ok + //m_log.Debug("XXX---- EVERYTHING OK ---XXX"); + + if (!comingHome) + { + // We don't do this if the user is coming to the home grid + GridRegion home = new GridRegion(); + home.RegionID = userData.HomeRegionID; + home.ExternalHostName = userData.UserHomeAddress; + home.HttpPort = Convert.ToUInt32(userData.UserHomePort); + uint x = 0, y = 0; + Utils.LongToUInts(userRegionHandle, out x, out y); + home.RegionLocX = (int)x; + home.RegionLocY = (int)y; + home.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)userhomeinternalport); + + m_HyperlinkService.AcceptUser(userData, home); + } + // else the user is coming to a non-home region of the home grid + // We simply drop this user information altogether + + Hashtable respdata2 = new Hashtable(); + respdata2["success"] = "TRUE"; + resp.Value = respdata2; + + return resp; } + } } diff --git a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs index cf17557..dd19b01 100644 --- a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs +++ b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs @@ -149,5 +149,94 @@ namespace OpenSim.Services.Connectors.Grid } } + public bool InformRegionOfUser(GridRegion regInfo, AgentCircuitData agentData, GridRegion home, string userServer, string assetServer, string inventoryServer) + { + string capsPath = agentData.CapsPath; + Hashtable loginParams = new Hashtable(); + loginParams["session_id"] = agentData.SessionID.ToString(); + + loginParams["firstname"] = agentData.firstname; + loginParams["lastname"] = agentData.lastname; + + loginParams["agent_id"] = agentData.AgentID.ToString(); + loginParams["circuit_code"] = agentData.circuitcode.ToString(); + loginParams["startpos_x"] = agentData.startpos.X.ToString(); + loginParams["startpos_y"] = agentData.startpos.Y.ToString(); + loginParams["startpos_z"] = agentData.startpos.Z.ToString(); + loginParams["caps_path"] = capsPath; + + if (home != null) + { + loginParams["region_uuid"] = home.RegionID.ToString(); + loginParams["regionhandle"] = home.RegionHandle.ToString(); + loginParams["home_address"] = home.ExternalHostName; + loginParams["home_port"] = home.HttpPort.ToString(); + loginParams["internal_port"] = home.InternalEndPoint.Port.ToString(); + + m_log.Debug(" --------- Home -------"); + m_log.Debug(" >> " + loginParams["home_address"] + " <<"); + m_log.Debug(" >> " + loginParams["region_uuid"] + " <<"); + m_log.Debug(" >> " + loginParams["regionhandle"] + " <<"); + m_log.Debug(" >> " + loginParams["home_port"] + " <<"); + m_log.Debug(" --------- ------------ -------"); + } + else + m_log.WarnFormat("[HGrid]: Home region not found for {0} {1}", agentData.firstname, agentData.lastname); + + loginParams["userserver_id"] = userServer; + loginParams["assetserver_id"] = assetServer; + loginParams["inventoryserver_id"] = inventoryServer; + + + ArrayList SendParams = new ArrayList(); + SendParams.Add(loginParams); + + // Send + string uri = "http://" + regInfo.ExternalHostName + ":" + regInfo.HttpPort + "/"; + //m_log.Debug("XXX uri: " + uri); + XmlRpcRequest request = new XmlRpcRequest("expect_hg_user", SendParams); + XmlRpcResponse reply; + try + { + reply = request.Send(uri, 6000); + } + catch (Exception e) + { + m_log.Warn("[HGrid]: Failed to notify region about user. Reason: " + e.Message); + return false; + } + + if (!reply.IsFault) + { + bool responseSuccess = true; + if (reply.Value != null) + { + Hashtable resp = (Hashtable)reply.Value; + if (resp.ContainsKey("success")) + { + if ((string)resp["success"] == "FALSE") + { + responseSuccess = false; + } + } + } + if (responseSuccess) + { + m_log.Info("[HGrid]: Successfully informed remote region about user " + agentData.AgentID); + return true; + } + else + { + m_log.ErrorFormat("[HGrid]: Region responded that it is not available to receive clients"); + return false; + } + } + else + { + m_log.ErrorFormat("[HGrid]: XmlRpc request to region failed with message {0}, code {1} ", reply.FaultString, reply.FaultCode); + return false; + } + } + } } diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs index 96dc82b9..c5495fb 100644 --- a/OpenSim/Services/Interfaces/IGridService.cs +++ b/OpenSim/Services/Interfaces/IGridService.cs @@ -191,6 +191,20 @@ namespace OpenSim.Services.Interfaces Maturity = ConvertFrom.RegionSettings.Maturity; } + public GridRegion(GridRegion ConvertFrom) + { + m_regionName = ConvertFrom.RegionName; + m_regionLocX = ConvertFrom.RegionLocX; + m_regionLocY = ConvertFrom.RegionLocY; + m_internalEndPoint = ConvertFrom.InternalEndPoint; + m_externalHostName = ConvertFrom.ExternalHostName; + m_httpPort = ConvertFrom.HttpPort; + RegionID = ConvertFrom.RegionID; + ServerURI = ConvertFrom.ServerURI; + TerrainImage = ConvertFrom.TerrainImage; + Access = ConvertFrom.Access; + Maturity = ConvertFrom.Maturity; + } /// /// This accessor can throw all the exceptions that Dns.GetHostAddresses can throw. -- cgit v1.1 From 989382352dc5b5b75876607f6fc2f1f753f0fd15 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 26 Sep 2009 21:14:41 -0700 Subject: Poof! on Region.Communications.Hypergrid. Grid code deleted. --- .../CreateCommsManager/CreateCommsManagerPlugin.cs | 9 - .../Hypergrid/HGCommunicationsGridMode.cs | 9 - .../Hypergrid/HGCommunicationsStandalone.cs | 3 - .../Communications/Hypergrid/HGGridServices.cs | 1026 -------------------- .../Hypergrid/HGGridServicesGridMode.cs | 159 --- .../Hypergrid/HGGridServicesStandalone.cs | 259 ----- 6 files changed, 1465 deletions(-) delete mode 100644 OpenSim/Region/Communications/Hypergrid/HGGridServices.cs delete mode 100644 OpenSim/Region/Communications/Hypergrid/HGGridServicesGridMode.cs delete mode 100644 OpenSim/Region/Communications/Hypergrid/HGGridServicesStandalone.cs (limited to 'OpenSim') diff --git a/OpenSim/ApplicationPlugins/CreateCommsManager/CreateCommsManagerPlugin.cs b/OpenSim/ApplicationPlugins/CreateCommsManager/CreateCommsManagerPlugin.cs index 18641f1..cd93bea 100644 --- a/OpenSim/ApplicationPlugins/CreateCommsManager/CreateCommsManagerPlugin.cs +++ b/OpenSim/ApplicationPlugins/CreateCommsManager/CreateCommsManagerPlugin.cs @@ -187,18 +187,11 @@ namespace OpenSim.ApplicationPlugins.CreateCommsManager protected virtual void InitialiseHGStandaloneServices(LibraryRootFolder libraryRootFolder) { - HGGridServicesStandalone gridService - = new HGGridServicesStandalone( - m_openSim.NetServersInfo, m_httpServer, m_openSim.SceneManager); - m_commsManager = new HGCommunicationsStandalone( m_openSim.ConfigurationSettings, m_openSim.NetServersInfo, m_httpServer, - gridService, libraryRootFolder, false); - HGServices = gridService; - CreateGridInfoService(); } @@ -209,8 +202,6 @@ namespace OpenSim.ApplicationPlugins.CreateCommsManager m_openSim.NetServersInfo, m_openSim.SceneManager, libraryRootFolder); - HGServices = ((HGCommunicationsGridMode) m_commsManager).HGServices; - m_httpServer.AddStreamHandler(new OpenSim.SimStatusHandler()); m_httpServer.AddStreamHandler(new OpenSim.XSimStatusHandler(m_openSim)); if (m_openSim.userStatsURI != String.Empty) diff --git a/OpenSim/Region/Communications/Hypergrid/HGCommunicationsGridMode.cs b/OpenSim/Region/Communications/Hypergrid/HGCommunicationsGridMode.cs index 80f2e79..002ea17 100644 --- a/OpenSim/Region/Communications/Hypergrid/HGCommunicationsGridMode.cs +++ b/OpenSim/Region/Communications/Hypergrid/HGCommunicationsGridMode.cs @@ -40,21 +40,12 @@ namespace OpenSim.Region.Communications.Hypergrid { public class HGCommunicationsGridMode : CommunicationsManager // CommunicationsOGS1 { - IHyperlink m_osw = null; - public IHyperlink HGServices - { - get { return m_osw; } - } public HGCommunicationsGridMode( NetworkServersInfo serversInfo, SceneManager sman, LibraryRootFolder libraryRootFolder) : base(serversInfo, libraryRootFolder) { - // From constructor at CommunicationsOGS1 - HGGridServices gridInterComms = new HGGridServicesGridMode(serversInfo, sman, m_userProfileCacheService); - m_gridService = gridInterComms; - m_osw = gridInterComms; HGUserServices userServices = new HGUserServices(this); // This plugin arrangement could eventually be configurable rather than hardcoded here. diff --git a/OpenSim/Region/Communications/Hypergrid/HGCommunicationsStandalone.cs b/OpenSim/Region/Communications/Hypergrid/HGCommunicationsStandalone.cs index e4e12d4..f5126ca 100644 --- a/OpenSim/Region/Communications/Hypergrid/HGCommunicationsStandalone.cs +++ b/OpenSim/Region/Communications/Hypergrid/HGCommunicationsStandalone.cs @@ -44,7 +44,6 @@ namespace OpenSim.Region.Communications.Hypergrid ConfigSettings configSettings, NetworkServersInfo serversInfo, BaseHttpServer httpServer, - HGGridServices gridService, LibraryRootFolder libraryRootFolder, bool dumpAssetsToFile) : base(serversInfo, libraryRootFolder) @@ -64,8 +63,6 @@ namespace OpenSim.Region.Communications.Hypergrid m_avatarService = hgUserService; m_messageService = hgUserService; - gridService.UserProfileCache = m_userProfileCacheService; - m_gridService = gridService; } } } diff --git a/OpenSim/Region/Communications/Hypergrid/HGGridServices.cs b/OpenSim/Region/Communications/Hypergrid/HGGridServices.cs deleted file mode 100644 index 85bfab4..0000000 --- a/OpenSim/Region/Communications/Hypergrid/HGGridServices.cs +++ /dev/null @@ -1,1026 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Drawing; -using System.Net; -using System.Net.Sockets; -using System.Reflection; -using System.Runtime.Remoting; -using System.Security.Authentication; -using log4net; -using Nwc.XmlRpc; -using OpenMetaverse; -using OpenMetaverse.Imaging; -using OpenSim.Framework; -using OpenSim.Framework.Communications; -using OpenSim.Framework.Communications.Cache; -using OpenSim.Framework.Servers; -using OpenSim.Framework.Servers.HttpServer; -using OpenSim.Region.Communications.OGS1; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Services.Interfaces; -// using OpenSim.Region.Environment.Modules.Framework; - -namespace OpenSim.Region.Communications.Hypergrid -{ - /// - /// This class encapsulates the main hypergrid functions related to creating and managing - /// hyperlinks, as well as processing all the inter-region comms between a region and - /// an hyperlinked region. - /// - public class HGGridServices : IGridServices, IHyperlink - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - - public BaseHttpServer httpListener; - public NetworkServersInfo serversInfo; - - protected List m_regionsOnInstance = new List(); - - // Hyperlink regions are hyperlinks on the map - protected List m_hyperlinkRegions = new List(); - - // Known regions are home regions of visiting foreign users. - // They are not on the map as static hyperlinks. They are dynamic hyperlinks, they go away when - // the visitor goes away. They are mapped to X=0 on the map. - // This is key-ed on agent ID - protected Dictionary m_knownRegions = new Dictionary(); - - protected UserProfileCacheService m_userProfileCache; - protected SceneManager m_sceneman; - - private Dictionary m_queuedGridSettings = new Dictionary(); - - public virtual string gdebugRegionName - { - get { return "Override me"; } - set { ; } - } - - public string rdebugRegionName - { - get { return _rdebugRegionName; } - set { _rdebugRegionName = value; } - } - private string _rdebugRegionName = String.Empty; - - public virtual bool RegionLoginsEnabled - { - get { return true; } - set { ; } - } - - public UserProfileCacheService UserProfileCache - { - set { m_userProfileCache = value; } - } - - private Random random; - - /// - /// Contructor. Adds "expect_hg_user" and "check" xmlrpc method handlers - /// - /// - public HGGridServices(NetworkServersInfo servers_info, SceneManager sman) - { - serversInfo = servers_info; - m_sceneman = sman; - - random = new Random(); - - MainServer.Instance.AddXmlRPCHandler("link_region", LinkRegionRequest); - MainServer.Instance.AddXmlRPCHandler("expect_hg_user", ExpectHGUser); - - HGNetworkServersInfo.Init(servers_info.AssetURL, servers_info.InventoryURL, servers_info.UserURL); - } - - // see IGridServices - public virtual RegionCommsListener RegisterRegion(RegionInfo regionInfo) - { - // Region doesn't exist here. Trying to link remote region - - m_log.Info("[HGrid]: Linking remote region " + regionInfo.ExternalHostName + ":" + regionInfo.HttpPort); - regionInfo.RegionID = LinkRegion(regionInfo); // UUID.Random(); - if (!regionInfo.RegionID.Equals(UUID.Zero)) - { - m_hyperlinkRegions.Add(regionInfo); - m_log.Info("[HGrid]: Successfully linked to region_uuid " + regionInfo.RegionID); - - //Try get the map image - GetMapImage(regionInfo); - } - else - { - m_log.Info("[HGrid]: No such region " + regionInfo.ExternalHostName + ":" + regionInfo.HttpPort + "(" + regionInfo.InternalEndPoint.Port + ")"); - } - // Note that these remote regions aren't registered in localBackend, so return null, no local listeners - return null; - } - - // see IGridServices - public virtual bool DeregisterRegion(RegionInfo regionInfo) - { - if (m_hyperlinkRegions.Contains(regionInfo)) - { - m_hyperlinkRegions.Remove(regionInfo); - return true; - } - foreach (KeyValuePair kvp in m_knownRegions) - { - if (kvp.Value == regionInfo) - { - m_knownRegions.Remove(kvp.Key); - return true; - } - } - return false; - } - - public virtual Dictionary GetGridSettings() - { - Dictionary returnGridSettings = new Dictionary(); - lock (m_queuedGridSettings) - { - foreach (string Dictkey in m_queuedGridSettings.Keys) - { - returnGridSettings.Add(Dictkey, m_queuedGridSettings[Dictkey]); - } - - m_queuedGridSettings.Clear(); - } - - return returnGridSettings; - } - - // see IGridServices - public virtual List RequestNeighbours(uint x, uint y) - { - List neighbours = new List(); - foreach (RegionInfo reg in m_hyperlinkRegions) - { - if (reg.RegionLocX != x || reg.RegionLocY != y) - { - //m_log.Debug("CommsManager- RequestNeighbours() - found a different region in list, checking location"); - if ((reg.RegionLocX > (x - 2)) && (reg.RegionLocX < (x + 2))) - { - if ((reg.RegionLocY > (y - 2)) && (reg.RegionLocY < (y + 2))) - { - neighbours.Add(reg); - } - } - } - } - - return neighbours; - } - - /// - /// Request information about a region. - /// - /// - /// - /// null on a failure to contact or get a response from the grid server - /// FIXME: Might be nicer to return a proper exception here since we could inform the client more about the - /// nature of the faiulre. - /// - public virtual RegionInfo RequestNeighbourInfo(UUID Region_UUID) - { - foreach (RegionInfo info in m_hyperlinkRegions) - { - if (info.RegionID == Region_UUID) return info; - } - - // I don't trust region uuids to be unique... - //foreach (RegionInfo info in m_knownRegions.Values) - //{ - // if (info.RegionID == Region_UUID) return info; - //} - - return null; - } - - /// - /// Request information about a region. - /// - /// - /// - public virtual RegionInfo RequestNeighbourInfo(ulong regionHandle) - { - //m_log.Debug(" >> RequestNeighbourInfo for " + regionHandle); - foreach (RegionInfo info in m_hyperlinkRegions) - { - //m_log.Debug(" .. " + info.RegionHandle); - if (info.RegionHandle == regionHandle) return info; - } - - foreach (RegionInfo info in m_knownRegions.Values) - { - if (info.RegionHandle == regionHandle) - { - //m_log.Debug("XXX------ known region " + info.RegionHandle); - return info; - } - } - - return null; - } - - public virtual RegionInfo RequestNeighbourInfo(string name) - { - foreach (RegionInfo info in m_hyperlinkRegions) - { - //m_log.Debug(" .. " + info.RegionHandle); - if (info.RegionName == name) return info; - } - - foreach (RegionInfo info in m_knownRegions.Values) - { - if (info.RegionName == name) - { - //m_log.Debug("XXX------ known region " + info.RegionHandle); - return info; - } - } - - return null; - } - - public virtual RegionInfo RequestNeighbourInfo(string hostName, uint port) - { - foreach (RegionInfo info in m_hyperlinkRegions) - { - //m_log.Debug(" .. " + info.RegionHandle); - if ((info.ExternalHostName == hostName) && (info.HttpPort == port)) - return info; - } - - foreach (RegionInfo info in m_knownRegions.Values) - { - if ((info.ExternalHostName == hostName) && (info.HttpPort == port)) - { - //m_log.Debug("XXX------ known region " + info.RegionHandle); - return info; - } - } - - return null; - } - - public virtual RegionInfo RequestClosestRegion(string regionName) - { - foreach (RegionInfo info in m_hyperlinkRegions) - { - if (info.RegionName == regionName) return info; - } - - return null; - } - - /// - /// - /// - /// - /// - /// - /// - /// - public virtual List RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY) - { - List neighbours = new List(); - - foreach (RegionInfo regInfo in m_hyperlinkRegions) - { - if (((regInfo.RegionLocX >= minX) && (regInfo.RegionLocX <= maxX)) && - ((regInfo.RegionLocY >= minY) && (regInfo.RegionLocY <= maxY))) - { - MapBlockData map = new MapBlockData(); - map.Name = regInfo.RegionName; - map.X = (ushort)regInfo.RegionLocX; - map.Y = (ushort)regInfo.RegionLocY; - map.WaterHeight = (byte)regInfo.RegionSettings.WaterHeight; - map.MapImageId = regInfo.RegionSettings.TerrainImageID; - // m_log.Debug("ImgID: " + map.MapImageId); - map.Agents = 1; - map.RegionFlags = 72458694; - map.Access = regInfo.AccessLevel; - neighbours.Add(map); - } - } - - return neighbours; - } - - - protected virtual void GetMapImage(RegionInfo info) - { - try - { - string regionimage = "regionImage" + info.RegionID.ToString(); - regionimage = regionimage.Replace("-", ""); - - WebClient c = new WebClient(); - string uri = "http://" + info.ExternalHostName + ":" + info.HttpPort + "/index.php?method=" + regionimage; - //m_log.Debug("JPEG: " + uri); - c.DownloadFile(uri, info.RegionID.ToString() + ".jpg"); - Bitmap m = new Bitmap(info.RegionID.ToString() + ".jpg"); - //m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width); - byte[] imageData = OpenJPEG.EncodeFromImage(m, true); - AssetBase ass = new AssetBase(UUID.Random(), "region " + info.RegionID.ToString()); - info.RegionSettings.TerrainImageID = ass.FullID; - ass.Type = (int)AssetType.Texture; - ass.Temporary = false; - ass.Local = true; - ass.Data = imageData; - - m_sceneman.CurrentOrFirstScene.AssetService.Store(ass); - - } - catch // LEGIT: Catching problems caused by OpenJPEG p/invoke - { - m_log.Warn("[HGrid]: Failed getting/storing map image, because it is probably already in the cache"); - } - } - - // A little ugly, since this code is exactly the same as OSG1's, and we're already - // calling that for when the region in in grid mode... (for the grid regions) - // - public virtual LandData RequestLandData (ulong regionHandle, uint x, uint y) - { - m_log.DebugFormat("[HGrid]: requests land data in {0}, at {1}, {2}", - regionHandle, x, y); - - // Remote region - - Hashtable hash = new Hashtable(); - hash["region_handle"] = regionHandle.ToString(); - hash["x"] = x.ToString(); - hash["y"] = y.ToString(); - - IList paramList = new ArrayList(); - paramList.Add(hash); - LandData landData = null; - - try - { - RegionInfo info = RequestNeighbourInfo(regionHandle); - if (info != null) // just to be sure - { - XmlRpcRequest request = new XmlRpcRequest("land_data", paramList); - string uri = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/"; - XmlRpcResponse response = request.Send(uri, 10000); - if (response.IsFault) - { - m_log.ErrorFormat("[HGrid]: remote call returned an error: {0}", response.FaultString); - } - else - { - hash = (Hashtable)response.Value; - try - { - landData = new LandData(); - landData.AABBMax = Vector3.Parse((string)hash["AABBMax"]); - landData.AABBMin = Vector3.Parse((string)hash["AABBMin"]); - landData.Area = Convert.ToInt32(hash["Area"]); - landData.AuctionID = Convert.ToUInt32(hash["AuctionID"]); - landData.Description = (string)hash["Description"]; - landData.Flags = Convert.ToUInt32(hash["Flags"]); - landData.GlobalID = new UUID((string)hash["GlobalID"]); - landData.Name = (string)hash["Name"]; - landData.OwnerID = new UUID((string)hash["OwnerID"]); - landData.SalePrice = Convert.ToInt32(hash["SalePrice"]); - landData.SnapshotID = new UUID((string)hash["SnapshotID"]); - landData.UserLocation = Vector3.Parse((string)hash["UserLocation"]); - m_log.DebugFormat("[HGrid]: Got land data for parcel {0}", landData.Name); - } - catch (Exception e) - { - m_log.Error("[HGrid]: Got exception while parsing land-data:", e); - } - } - } - else m_log.WarnFormat("[HGrid]: Couldn't find region with handle {0}", regionHandle); - } - catch (Exception e) - { - m_log.ErrorFormat("[HGrid]: Couldn't contact region {0}: {1}", regionHandle, e); - } - - return landData; - } - - // Grid Request Processing - public virtual List RequestNamedRegions (string name, int maxNumber) - { - List infos = new List(); - foreach (RegionInfo info in m_hyperlinkRegions) - { - if (info.RegionName.ToLower().Contains(name)) - { - infos.Add(info); - } - } - return infos; - } - - - private UUID LinkRegion(RegionInfo info) - { - UUID uuid = UUID.Zero; - - Hashtable hash = new Hashtable(); - hash["region_name"] = info.RegionName; - - IList paramList = new ArrayList(); - paramList.Add(hash); - - XmlRpcRequest request = new XmlRpcRequest("link_region", paramList); - string uri = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/"; - m_log.Debug("[HGrid]: Linking to " + uri); - XmlRpcResponse response = request.Send(uri, 10000); - if (response.IsFault) - { - m_log.ErrorFormat("[HGrid]: remote call returned an error: {0}", response.FaultString); - } - else - { - hash = (Hashtable)response.Value; - //foreach (Object o in hash) - // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); - try - { - UUID.TryParse((string)hash["uuid"], out uuid); - info.RegionID = uuid; - if ((string)hash["handle"] != null) - { - info.regionSecret = (string)hash["handle"]; - //m_log.Debug(">> HERE: " + info.regionSecret); - } - if (hash["region_image"] != null) - { - UUID img = UUID.Zero; - UUID.TryParse((string)hash["region_image"], out img); - info.RegionSettings.TerrainImageID = img; - } - if (hash["region_name"] != null) - { - info.RegionName = (string)hash["region_name"]; - //m_log.Debug(">> " + info.RegionName); - } - if (hash["internal_port"] != null) - { - int port = Convert.ToInt32((string)hash["internal_port"]); - info.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), port); - //m_log.Debug(">> " + info.InternalEndPoint.ToString()); - } - if (hash["remoting_port"] != null) - { - info.RemotingPort = Convert.ToUInt32(hash["remoting_port"]); - //m_log.Debug(">> " + info.RemotingPort); - } - - } - catch (Exception e) - { - m_log.Error("[HGrid]: Got exception while parsing hyperlink response " + e.StackTrace); - } - } - return uuid; - } - - /// - /// Someone wants to link to us - /// - /// - /// - public XmlRpcResponse LinkRegionRequest(XmlRpcRequest request, IPEndPoint remoteClient) - { - Hashtable requestData = (Hashtable)request.Params[0]; - //string host = (string)requestData["host"]; - //string portstr = (string)requestData["port"]; - string name = (string)requestData["region_name"]; - - m_log.DebugFormat("[HGrid]: Hyperlink request"); - - - RegionInfo regInfo = null; - foreach (RegionInfo r in m_regionsOnInstance) - { - if ((r.RegionName != null) && (name != null) && (r.RegionName.ToLower() == name.ToLower())) - { - regInfo = r; - break; - } - } - - if (regInfo == null) - regInfo = m_regionsOnInstance[0]; // Send out the first region - - Hashtable hash = new Hashtable(); - hash["uuid"] = regInfo.RegionID.ToString(); - hash["handle"] = regInfo.RegionHandle.ToString(); - //m_log.Debug(">> Here " + regInfo.RegionHandle); - hash["region_image"] = regInfo.RegionSettings.TerrainImageID.ToString(); - hash["region_name"] = regInfo.RegionName; - hash["internal_port"] = regInfo.InternalEndPoint.Port.ToString(); - hash["remoting_port"] = ConfigSettings.DefaultRegionRemotingPort.ToString(); - //m_log.Debug(">> Here: " + regInfo.InternalEndPoint.Port); - - - XmlRpcResponse response = new XmlRpcResponse(); - response.Value = hash; - return response; - } - - public bool InformRegionOfUser(RegionInfo regInfo, AgentCircuitData agentData) - { - //ulong regionHandle = regInfo.RegionHandle; - try - { - //regionHandle = Convert.ToUInt64(regInfo.regionSecret); - m_log.Info("[HGrid]: InformRegionOfUser: Remote hyperlinked region " + regInfo.regionSecret); - } - catch - { - m_log.Info("[HGrid]: InformRegionOfUser: Local grid region " + regInfo.regionSecret); - } - - string capsPath = agentData.CapsPath; - Hashtable loginParams = new Hashtable(); - loginParams["session_id"] = agentData.SessionID.ToString(); - loginParams["secure_session_id"] = agentData.SecureSessionID.ToString(); - - loginParams["firstname"] = agentData.firstname; - loginParams["lastname"] = agentData.lastname; - - loginParams["agent_id"] = agentData.AgentID.ToString(); - loginParams["circuit_code"] = agentData.circuitcode.ToString(); - loginParams["startpos_x"] = agentData.startpos.X.ToString(); - loginParams["startpos_y"] = agentData.startpos.Y.ToString(); - loginParams["startpos_z"] = agentData.startpos.Z.ToString(); - loginParams["caps_path"] = capsPath; - - CachedUserInfo u = m_userProfileCache.GetUserDetails(agentData.AgentID); - if (u != null && u.UserProfile != null) - { - loginParams["region_uuid"] = u.UserProfile.HomeRegionID.ToString(); // This seems to be always Zero - //m_log.Debug(" --------- Home Region UUID -------"); - //m_log.Debug(" >> " + loginParams["region_uuid"] + " <<"); - //m_log.Debug(" --------- ---------------- -------"); - - //string serverURI = ""; - //if (u.UserProfile is ForeignUserProfileData) - // serverURI = Util.ServerURI(((ForeignUserProfileData)u.UserProfile).UserServerURI); - //loginParams["userserver_id"] = (serverURI == "") || (serverURI == null) ? HGNetworkServersInfo.Singleton.LocalUserServerURI : serverURI; - - //serverURI = HGNetworkServersInfo.ServerURI(u.UserProfile.UserAssetURI); - //loginParams["assetserver_id"] = (serverURI == "") || (serverURI == null) ? HGNetworkServersInfo.Singleton.LocalAssetServerURI : serverURI; - - //serverURI = HGNetworkServersInfo.ServerURI(u.UserProfile.UserInventoryURI); - //loginParams["inventoryserver_id"] = (serverURI == "") || (serverURI == null) ? HGNetworkServersInfo.Singleton.LocalInventoryServerURI : serverURI; - - loginParams["root_folder_id"] = u.UserProfile.RootInventoryFolderID; - - RegionInfo rinfo = RequestNeighbourInfo(u.UserProfile.HomeRegion); - if (rinfo != null) - { - loginParams["internal_port"] = rinfo.InternalEndPoint.Port.ToString(); - if (!IsLocalUser(u)) - { - loginParams["regionhandle"] = rinfo.regionSecret; // user.CurrentAgent.Handle.ToString(); - //m_log.Debug("XXX--- informregionofuser (foreign user) here handle: " + rinfo.regionSecret); - - loginParams["home_address"] = ((ForeignUserProfileData)(u.UserProfile)).UserHomeAddress; - loginParams["home_port"] = ((ForeignUserProfileData)(u.UserProfile)).UserHomePort; - loginParams["home_remoting"] = ((ForeignUserProfileData)(u.UserProfile)).UserHomeRemotingPort; - } - else - { - //m_log.Debug("XXX--- informregionofuser (local user) here handle: " + rinfo.regionSecret); - - //// local user about to jump out, let's process the name - // On second thoughts, let's not do this for the *user*; let's only do it for the *agent* - //loginParams["firstname"] = agentData.firstname + "." + agentData.lastname; - //loginParams["lastname"] = serversInfo.UserURL; - - // local user, first time out. let's ask the grid about this user's home region - loginParams["regionhandle"] = u.UserProfile.HomeRegion.ToString(); // user.CurrentAgent.Handle.ToString(); - - loginParams["home_address"] = rinfo.ExternalHostName; - m_log.Debug(" --------- Home Address -------"); - m_log.Debug(" >> " + loginParams["home_address"] + " <<"); - m_log.Debug(" --------- ------------ -------"); - loginParams["home_port"] = rinfo.HttpPort.ToString(); - loginParams["home_remoting"] = ConfigSettings.DefaultRegionRemotingPort.ToString(); ; - } - } - else - { - m_log.Warn("[HGrid]: User's home region info not found: " + u.UserProfile.HomeRegionX + ", " + u.UserProfile.HomeRegionY); - } - } - - ArrayList SendParams = new ArrayList(); - SendParams.Add(loginParams); - - // Send - string uri = "http://" + regInfo.ExternalHostName + ":" + regInfo.HttpPort + "/"; - //m_log.Debug("XXX uri: " + uri); - XmlRpcRequest request = new XmlRpcRequest("expect_hg_user", SendParams); - XmlRpcResponse reply; - try - { - reply = request.Send(uri, 6000); - } - catch (Exception e) - { - m_log.Warn("[HGrid]: Failed to notify region about user. Reason: " + e.Message); - return false; - } - - if (!reply.IsFault) - { - bool responseSuccess = true; - if (reply.Value != null) - { - Hashtable resp = (Hashtable)reply.Value; - if (resp.ContainsKey("success")) - { - if ((string)resp["success"] == "FALSE") - { - responseSuccess = false; - } - } - } - if (responseSuccess) - { - m_log.Info("[HGrid]: Successfully informed remote region about user " + agentData.AgentID); - return true; - } - else - { - m_log.ErrorFormat("[HGrid]: Region responded that it is not available to receive clients"); - return false; - } - } - else - { - m_log.ErrorFormat("[HGrid]: XmlRpc request to region failed with message {0}, code {1} ", reply.FaultString, reply.FaultCode); - return false; - } - } - - - /// - /// Received from other HGrid nodes when a user wants to teleport here. This call allows - /// the region to prepare for direct communication from the client. Sends back an empty - /// xmlrpc response on completion. - /// This is somewhat similar to OGS1's ExpectUser, but with the additional task of - /// registering the user in the local user cache. - /// - /// - /// - public XmlRpcResponse ExpectHGUser(XmlRpcRequest request, IPEndPoint remoteClient) - { - Hashtable requestData = (Hashtable)request.Params[0]; - ForeignUserProfileData userData = new ForeignUserProfileData(); - - userData.FirstName = (string)requestData["firstname"]; - userData.SurName = (string)requestData["lastname"]; - userData.ID = new UUID((string)requestData["agent_id"]); - userData.HomeLocation = new Vector3((float)Convert.ToDecimal((string)requestData["startpos_x"]), - (float)Convert.ToDecimal((string)requestData["startpos_y"]), - (float)Convert.ToDecimal((string)requestData["startpos_z"])); - - userData.UserServerURI = (string)requestData["userserver_id"]; - userData.UserAssetURI = (string)requestData["assetserver_id"]; - userData.UserInventoryURI = (string)requestData["inventoryserver_id"]; - - UUID rootID = UUID.Zero; - UUID.TryParse((string)requestData["root_folder_id"], out rootID); - userData.RootInventoryFolderID = rootID; - - UUID uuid = UUID.Zero; - UUID.TryParse((string)requestData["region_uuid"], out uuid); - userData.HomeRegionID = uuid; // not quite comfortable about this... - ulong userRegionHandle = Convert.ToUInt64((string)requestData["regionhandle"]); - //userData.HomeRegion = userRegionHandle; - userData.UserHomeAddress = (string)requestData["home_address"]; - userData.UserHomePort = (string)requestData["home_port"]; - int userhomeinternalport = Convert.ToInt32((string)requestData["internal_port"]); - userData.UserHomeRemotingPort = (string)requestData["home_remoting"]; - - - m_log.DebugFormat("[HGrid]: Prepare for connection from {0} {1} (@{2}) UUID={3}", - userData.FirstName, userData.SurName, userData.UserServerURI, userData.ID); - m_log.Debug("[HGrid]: home_address: " + userData.UserHomeAddress + - "; home_port: " + userData.UserHomePort + "; remoting: " + userData.UserHomeRemotingPort); - - XmlRpcResponse resp = new XmlRpcResponse(); - - // Let's check if someone is trying to get in with a stolen local identity. - // The need for this test is a consequence of not having truly global names :-/ - CachedUserInfo uinfo = m_userProfileCache.GetUserDetails(userData.ID); - if ((uinfo != null) && !(uinfo.UserProfile is ForeignUserProfileData)) - { - m_log.WarnFormat("[HGrid]: Foreign user trying to get in with local identity. Access denied."); - Hashtable respdata = new Hashtable(); - respdata["success"] = "FALSE"; - respdata["reason"] = "Foreign user has the same ID as a local user."; - resp.Value = respdata; - return resp; - } - - if (!RegionLoginsEnabled) - { - m_log.InfoFormat( - "[HGrid]: Denying access for user {0} {1} because region login is currently disabled", - userData.FirstName, userData.SurName); - - Hashtable respdata = new Hashtable(); - respdata["success"] = "FALSE"; - respdata["reason"] = "region login currently disabled"; - resp.Value = respdata; - } - else - { - // Finally, everything looks ok - //m_log.Debug("XXX---- EVERYTHING OK ---XXX"); - - // 1 - Preload the user data - m_userProfileCache.PreloadUserCache(userData); - - if (m_knownRegions.ContainsKey(userData.ID)) - { - // This was left here when the user departed - m_knownRegions.Remove(userData.ID); - } - - // 2 - Load the region info into list of known regions - RegionInfo rinfo = new RegionInfo(); - rinfo.RegionID = userData.HomeRegionID; - rinfo.ExternalHostName = userData.UserHomeAddress; - rinfo.HttpPort = Convert.ToUInt32(userData.UserHomePort); - rinfo.RemotingPort = Convert.ToUInt32(userData.UserHomeRemotingPort); - rinfo.RegionID = userData.HomeRegionID; - // X=0 on the map - rinfo.RegionLocX = 0; - rinfo.RegionLocY = (uint)(random.Next(0, Int32.MaxValue)); //(uint)m_knownRegions.Count; - rinfo.regionSecret = userRegionHandle.ToString(); - //m_log.Debug("XXX--- Here: handle = " + rinfo.regionSecret); - try - { - rinfo.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)userhomeinternalport); - } - catch (Exception e) - { - m_log.Warn("[HGrid]: Exception while constructing internal endpoint: " + e); - } - rinfo.RemotingAddress = rinfo.ExternalEndPoint.Address.ToString(); //userData.UserHomeAddress; - - if (!IsComingHome(userData)) - { - // Change the user's home region here!!! - userData.HomeRegion = rinfo.RegionHandle; - } - - if (!m_knownRegions.ContainsKey(userData.ID)) - m_knownRegions.Add(userData.ID, rinfo); - - // 3 - Send the reply - Hashtable respdata = new Hashtable(); - respdata["success"] = "TRUE"; - resp.Value = respdata; - - DumpUserData(userData); - DumpRegionData(rinfo); - - } - - return resp; - } - - public bool SendUserInformation(RegionInfo regInfo, AgentCircuitData agentData) - { - CachedUserInfo uinfo = m_userProfileCache.GetUserDetails(agentData.AgentID); - - if ((IsLocalUser(uinfo) && IsHyperlinkRegion(regInfo.RegionHandle)) || - (!IsLocalUser(uinfo) && !IsGoingHome(uinfo, regInfo))) - { - m_log.Info("[HGrid]: Local user is going to foreign region or foreign user is going elsewhere"); - if (!InformRegionOfUser(regInfo, agentData)) - { - m_log.Warn("[HGrid]: Could not inform remote region of transferring user."); - return false; - } - } - //if ((uinfo == null) || !IsGoingHome(uinfo, regInfo)) - //{ - // m_log.Info("[HGrid]: User seems to be going to foreign region."); - // if (!InformRegionOfUser(regInfo, agentData)) - // { - // m_log.Warn("[HGrid]: Could not inform remote region of transferring user."); - // return false; - // } - //} - //else - // m_log.Info("[HGrid]: User seems to be going home " + uinfo.UserProfile.FirstName + " " + uinfo.UserProfile.SurName); - - // May need to change agent's name - if (IsLocalUser(uinfo) && IsHyperlinkRegion(regInfo.RegionHandle)) - { - agentData.firstname = agentData.firstname + "." + agentData.lastname; - agentData.lastname = "@" + serversInfo.UserURL.Replace("http://", ""); ; //HGNetworkServersInfo.Singleton.LocalUserServerURI; - } - - return true; - } - - - #region Methods triggered by calls from external instances - - /// - /// - /// - /// - /// - /// - public void AdjustUserInformation(AgentCircuitData agentData) - { - CachedUserInfo uinfo = m_userProfileCache.GetUserDetails(agentData.AgentID); - if ((uinfo != null) && (uinfo.UserProfile != null) && - (IsLocalUser(uinfo) || !(uinfo.UserProfile is ForeignUserProfileData))) - { - //m_log.Debug("---------------> Local User!"); - string[] parts = agentData.firstname.Split(new char[] { '.' }); - if (parts.Length == 2) - { - agentData.firstname = parts[0]; - agentData.lastname = parts[1]; - } - } - //else - // m_log.Debug("---------------> Foreign User!"); - } - #endregion - - - #region IHyperGrid interface - - public virtual bool IsHyperlinkRegion(ulong ihandle) - { - if (GetHyperlinkRegion(ihandle) == null) - return false; - else - return true; - } - - public virtual RegionInfo GetHyperlinkRegion(ulong ihandle) - { - foreach (RegionInfo info in m_hyperlinkRegions) - { - if (info.RegionHandle == ihandle) - return info; - } - - foreach (RegionInfo info in m_knownRegions.Values) - { - if (info.RegionHandle == ihandle) - return info; - } - - return null; - } - - public virtual ulong FindRegionHandle(ulong ihandle) - { - long ohandle = -1; - List rlist = new List(m_hyperlinkRegions); - rlist.AddRange(m_knownRegions.Values); - foreach (RegionInfo info in rlist) - { - if (info.RegionHandle == ihandle) - { - try - { - ohandle = Convert.ToInt64(info.regionSecret); - m_log.Info("[HGrid] remote region " + ohandle); - } - catch - { - m_log.Error("[HGrid] Could not convert secret for " + ihandle + " (" + info.regionSecret + ")"); - } - break; - } - } - return ohandle < 0 ? ihandle : (ulong)ohandle; - } - #endregion - - #region Misc - - protected bool IsComingHome(ForeignUserProfileData userData) - { - return false; //(userData.UserServerURI == HGNetworkServersInfo.Singleton.LocalUserServerURI); - } - - protected bool IsGoingHome(CachedUserInfo uinfo, RegionInfo rinfo) - { - return false; - //if (uinfo.UserProfile == null) - // return false; - - //string userUserServerURI = String.Empty; - //if (uinfo.UserProfile is ForeignUserProfileData) - //{ - // userUserServerURI = HGNetworkServersInfo.ServerURI(((ForeignUserProfileData)uinfo.UserProfile).UserServerURI); - //} - - //return ((uinfo.UserProfile.HomeRegionID == rinfo.RegionID) && - // (userUserServerURI != HGNetworkServersInfo.Singleton.LocalUserServerURI)); - } - - protected bool IsLocalUser(CachedUserInfo uinfo) - { - return true; - //if (uinfo == null) - // return true; - - //if (uinfo.UserProfile is ForeignUserProfileData) - // return HGNetworkServersInfo.Singleton.IsLocalUser(((ForeignUserProfileData)uinfo.UserProfile).UserServerURI); - //else - // return true; - - } - - protected bool IsLocalRegion(ulong handle) - { - foreach (RegionInfo reg in m_regionsOnInstance) - if (reg.RegionHandle == handle) - return true; - return false; - } - - private void DumpUserData(ForeignUserProfileData userData) - { - m_log.Info(" ------------ User Data Dump ----------"); - m_log.Info(" >> Name: " + userData.FirstName + " " + userData.SurName); - m_log.Info(" >> HomeID: " + userData.HomeRegionID); - m_log.Info(" >> HomeHandle: " + userData.HomeRegion); - m_log.Info(" >> HomeX: " + userData.HomeRegionX); - m_log.Info(" >> HomeY: " + userData.HomeRegionY); - m_log.Info(" >> UserServer: " + userData.UserServerURI); - m_log.Info(" >> InvServer: " + userData.UserInventoryURI); - m_log.Info(" >> AssetServer: " + userData.UserAssetURI); - m_log.Info(" ------------ -------------- ----------"); - } - - private void DumpRegionData(RegionInfo rinfo) - { - m_log.Info(" ------------ Region Data Dump ----------"); - m_log.Info(" >> handle: " + rinfo.RegionHandle); - m_log.Info(" >> coords: " + rinfo.RegionLocX + ", " + rinfo.RegionLocY); - m_log.Info(" >> secret: " + rinfo.regionSecret); - m_log.Info(" >> remoting address: " + rinfo.RemotingAddress); - m_log.Info(" >> remoting port: " + rinfo.RemotingPort); - m_log.Info(" >> external host name: " + rinfo.ExternalHostName); - m_log.Info(" >> http port: " + rinfo.HttpPort); - m_log.Info(" >> external EP address: " + rinfo.ExternalEndPoint.Address); - m_log.Info(" >> external EP port: " + rinfo.ExternalEndPoint.Port); - m_log.Info(" ------------ -------------- ----------"); - } - - - #endregion - - - } -} diff --git a/OpenSim/Region/Communications/Hypergrid/HGGridServicesGridMode.cs b/OpenSim/Region/Communications/Hypergrid/HGGridServicesGridMode.cs deleted file mode 100644 index 5ce1e79..0000000 --- a/OpenSim/Region/Communications/Hypergrid/HGGridServicesGridMode.cs +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections.Generic; -using System.Reflection; -using log4net; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Framework.Communications.Cache; -using OpenSim.Framework.Servers.HttpServer; -using OpenSim.Region.Communications.OGS1; -using OpenSim.Region.Framework.Scenes; - -namespace OpenSim.Region.Communications.Hypergrid -{ - public class HGGridServicesGridMode : HGGridServices - { - //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - /// - /// Encapsulate remote backend services for manipulation of grid regions - /// - private OGS1GridServices m_remoteBackend = null; - - public OGS1GridServices RemoteBackend - { - get { return m_remoteBackend; } - } - - - public override string gdebugRegionName - { - get { return m_remoteBackend.gdebugRegionName; } - set { m_remoteBackend.gdebugRegionName = value; } - } - - public override bool RegionLoginsEnabled - { - get { return m_remoteBackend.RegionLoginsEnabled; } - set { m_remoteBackend.RegionLoginsEnabled = value; } - } - - public HGGridServicesGridMode(NetworkServersInfo servers_info, - SceneManager sman, UserProfileCacheService userv) - : base(servers_info, sman) - { - m_remoteBackend = new OGS1GridServices(servers_info); - m_userProfileCache = userv; - } - - #region IGridServices interface - - public override RegionCommsListener RegisterRegion(RegionInfo regionInfo) - { - if (!regionInfo.RegionID.Equals(UUID.Zero)) - { - m_regionsOnInstance.Add(regionInfo); - return m_remoteBackend.RegisterRegion(regionInfo); - } - else - return base.RegisterRegion(regionInfo); - } - - public override bool DeregisterRegion(RegionInfo regionInfo) - { - bool success = base.DeregisterRegion(regionInfo); - if (!success) - success = m_remoteBackend.DeregisterRegion(regionInfo); - return success; - } - - public override List RequestNeighbours(uint x, uint y) - { - List neighbours = m_remoteBackend.RequestNeighbours(x, y); - //List remotes = base.RequestNeighbours(x, y); - //neighbours.AddRange(remotes); - - return neighbours; - } - - public override RegionInfo RequestNeighbourInfo(UUID Region_UUID) - { - RegionInfo info = m_remoteBackend.RequestNeighbourInfo(Region_UUID); - if (info == null) - info = base.RequestNeighbourInfo(Region_UUID); - return info; - } - - public override RegionInfo RequestNeighbourInfo(ulong regionHandle) - { - RegionInfo info = base.RequestNeighbourInfo(regionHandle); - if (info == null) - info = m_remoteBackend.RequestNeighbourInfo(regionHandle); - return info; - } - - public override RegionInfo RequestClosestRegion(string regionName) - { - RegionInfo info = m_remoteBackend.RequestClosestRegion(regionName); - if (info == null) - info = base.RequestClosestRegion(regionName); - return info; - } - - public override List RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY) - { - List neighbours = m_remoteBackend.RequestNeighbourMapBlocks(minX, minY, maxX, maxY); - List remotes = base.RequestNeighbourMapBlocks(minX, minY, maxX, maxY); - neighbours.AddRange(remotes); - - return neighbours; - } - - public override LandData RequestLandData(ulong regionHandle, uint x, uint y) - { - LandData land = m_remoteBackend.RequestLandData(regionHandle, x, y); - if (land == null) - land = base.RequestLandData(regionHandle, x, y); - return land; - } - - public override List RequestNamedRegions(string name, int maxNumber) - { - List infos = m_remoteBackend.RequestNamedRegions(name, maxNumber); - List remotes = base.RequestNamedRegions(name, maxNumber); - infos.AddRange(remotes); - return infos; - } - - #endregion - - - } -} diff --git a/OpenSim/Region/Communications/Hypergrid/HGGridServicesStandalone.cs b/OpenSim/Region/Communications/Hypergrid/HGGridServicesStandalone.cs deleted file mode 100644 index 94cfc49..0000000 --- a/OpenSim/Region/Communications/Hypergrid/HGGridServicesStandalone.cs +++ /dev/null @@ -1,259 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Net; -using System.Net.Sockets; -using System.Reflection; -using System.Runtime.Remoting; -using System.Runtime.Remoting.Channels; -using System.Runtime.Remoting.Channels.Tcp; -using System.Security.Authentication; -using log4net; -using Nwc.XmlRpc; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Framework.Servers; -using OpenSim.Framework.Servers.HttpServer; -using OpenSim.Region.Communications.Local; -using OpenSim.Region.Communications.OGS1; -using OpenSim.Region.Framework.Scenes; - -namespace OpenSim.Region.Communications.Hypergrid -{ - public class HGGridServicesStandalone : HGGridServices - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - /// - /// Encapsulate local backend services for manipulation of local regions - /// - protected LocalBackEndServices m_localBackend = new LocalBackEndServices(); - - //private Dictionary m_deadRegionCache = new Dictionary(); - - public LocalBackEndServices LocalBackend - { - get { return m_localBackend; } - } - - public override string gdebugRegionName - { - get { return m_localBackend.gdebugRegionName; } - set { m_localBackend.gdebugRegionName = value; } - } - - public override bool RegionLoginsEnabled - { - get { return m_localBackend.RegionLoginsEnabled; } - set { m_localBackend.RegionLoginsEnabled = value; } - } - - - public HGGridServicesStandalone(NetworkServersInfo servers_info, BaseHttpServer httpServe, SceneManager sman) - : base(servers_info, sman) - { - //Respond to Grid Services requests - MainServer.Instance.AddXmlRPCHandler("logoff_user", LogOffUser); - MainServer.Instance.AddXmlRPCHandler("check", PingCheckReply); - MainServer.Instance.AddXmlRPCHandler("land_data", LandData); - - } - - #region IGridServices interface - - public override RegionCommsListener RegisterRegion(RegionInfo regionInfo) - { - if (!regionInfo.RegionID.Equals(UUID.Zero)) - { - m_regionsOnInstance.Add(regionInfo); - return m_localBackend.RegisterRegion(regionInfo); - } - else - return base.RegisterRegion(regionInfo); - - } - - public override bool DeregisterRegion(RegionInfo regionInfo) - { - bool success = m_localBackend.DeregisterRegion(regionInfo); - if (!success) - success = base.DeregisterRegion(regionInfo); - return success; - } - - public override List RequestNeighbours(uint x, uint y) - { - List neighbours = m_localBackend.RequestNeighbours(x, y); - //List remotes = base.RequestNeighbours(x, y); - //neighbours.AddRange(remotes); - - return neighbours; - } - - public override RegionInfo RequestNeighbourInfo(UUID Region_UUID) - { - RegionInfo info = m_localBackend.RequestNeighbourInfo(Region_UUID); - if (info == null) - info = base.RequestNeighbourInfo(Region_UUID); - return info; - } - - public override RegionInfo RequestNeighbourInfo(ulong regionHandle) - { - RegionInfo info = m_localBackend.RequestNeighbourInfo(regionHandle); - //m_log.Info("[HGrid] Request neighbor info, local backend returned " + info); - if (info == null) - info = base.RequestNeighbourInfo(regionHandle); - return info; - } - - public override RegionInfo RequestClosestRegion(string regionName) - { - RegionInfo info = m_localBackend.RequestClosestRegion(regionName); - if (info == null) - info = base.RequestClosestRegion(regionName); - return info; - } - - public override List RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY) - { - //m_log.Info("[HGrid] Request map blocks " + minX + "-" + minY + "-" + maxX + "-" + maxY); - List neighbours = m_localBackend.RequestNeighbourMapBlocks(minX, minY, maxX, maxY); - List remotes = base.RequestNeighbourMapBlocks(minX, minY, maxX, maxY); - neighbours.AddRange(remotes); - - return neighbours; - } - - public override LandData RequestLandData(ulong regionHandle, uint x, uint y) - { - LandData land = m_localBackend.RequestLandData(regionHandle, x, y); - if (land == null) - land = base.RequestLandData(regionHandle, x, y); - return land; - } - - public override List RequestNamedRegions(string name, int maxNumber) - { - List infos = m_localBackend.RequestNamedRegions(name, maxNumber); - List remotes = base.RequestNamedRegions(name, maxNumber); - infos.AddRange(remotes); - return infos; - } - - #endregion - - #region XML Request Handlers - - /// - /// A ping / version check - /// - /// - /// - public virtual XmlRpcResponse PingCheckReply(XmlRpcRequest request, IPEndPoint remoteClient) - { - XmlRpcResponse response = new XmlRpcResponse(); - - Hashtable respData = new Hashtable(); - respData["online"] = "true"; - - m_localBackend.PingCheckReply(respData); - - response.Value = respData; - - return response; - } - - - // Grid Request Processing - /// - /// Ooops, our Agent must be dead if we're getting this request! - /// - /// - /// - public XmlRpcResponse LogOffUser(XmlRpcRequest request, IPEndPoint remoteClient) - { - m_log.Debug("[HGrid]: LogOff User Called"); - - Hashtable requestData = (Hashtable)request.Params[0]; - string message = (string)requestData["message"]; - UUID agentID = UUID.Zero; - UUID RegionSecret = UUID.Zero; - UUID.TryParse((string)requestData["agent_id"], out agentID); - UUID.TryParse((string)requestData["region_secret"], out RegionSecret); - - ulong regionHandle = Convert.ToUInt64((string)requestData["regionhandle"]); - - m_localBackend.TriggerLogOffUser(regionHandle, agentID, RegionSecret, message); - - return new XmlRpcResponse(); - } - - /// - /// Someone asked us about parcel-information - /// - /// - /// - public XmlRpcResponse LandData(XmlRpcRequest request, IPEndPoint remoteClient) - { - Hashtable requestData = (Hashtable)request.Params[0]; - ulong regionHandle = Convert.ToUInt64(requestData["region_handle"]); - uint x = Convert.ToUInt32(requestData["x"]); - uint y = Convert.ToUInt32(requestData["y"]); - m_log.DebugFormat("[HGrid]: Got XML reqeuest for land data at {0}, {1} in region {2}", x, y, regionHandle); - - LandData landData = m_localBackend.RequestLandData(regionHandle, x, y); - Hashtable hash = new Hashtable(); - if (landData != null) - { - // for now, only push out the data we need for answering a ParcelInfoReqeust - hash["AABBMax"] = landData.AABBMax.ToString(); - hash["AABBMin"] = landData.AABBMin.ToString(); - hash["Area"] = landData.Area.ToString(); - hash["AuctionID"] = landData.AuctionID.ToString(); - hash["Description"] = landData.Description; - hash["Flags"] = landData.Flags.ToString(); - hash["GlobalID"] = landData.GlobalID.ToString(); - hash["Name"] = landData.Name; - hash["OwnerID"] = landData.OwnerID.ToString(); - hash["SalePrice"] = landData.SalePrice.ToString(); - hash["SnapshotID"] = landData.SnapshotID.ToString(); - hash["UserLocation"] = landData.UserLocation.ToString(); - } - - XmlRpcResponse response = new XmlRpcResponse(); - response.Value = hash; - return response; - } - - #endregion - - } -} -- cgit v1.1 From 620fa2b77234ae0600bbd1b4df8e520b0e87c3fa Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 26 Sep 2009 21:21:06 -0700 Subject: Poof! on OGS1 GridServices. --- .../Communications/OGS1/CommunicationsOGS1.cs | 2 - .../Region/Communications/OGS1/OGS1GridServices.cs | 937 --------------------- 2 files changed, 939 deletions(-) delete mode 100644 OpenSim/Region/Communications/OGS1/OGS1GridServices.cs (limited to 'OpenSim') diff --git a/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs b/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs index 8b5779f..c2b8f26 100644 --- a/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs +++ b/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs @@ -39,8 +39,6 @@ namespace OpenSim.Region.Communications.OGS1 LibraryRootFolder libraryRootFolder) : base(serversInfo, libraryRootFolder) { - OGS1GridServices gridInterComms = new OGS1GridServices(serversInfo); - m_gridService = gridInterComms; // This plugin arrangement could eventually be configurable rather than hardcoded here. OGS1UserServices userServices = new OGS1UserServices(this); diff --git a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs deleted file mode 100644 index 47c7fe4..0000000 --- a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs +++ /dev/null @@ -1,937 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Net; -using System.Net.Sockets; -using System.Reflection; -using log4net; -using Nwc.XmlRpc; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Framework.Communications; -using OpenSim.Framework.Servers.HttpServer; -using OpenSim.Region.Communications.Local; - -namespace OpenSim.Region.Communications.OGS1 -{ - public class OGS1GridServices : IGridServices - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - private bool m_useRemoteRegionCache = true; - /// - /// Encapsulate local backend services for manipulation of local regions - /// - private LocalBackEndServices m_localBackend = new LocalBackEndServices(); - - private Dictionary m_remoteRegionInfoCache = new Dictionary(); - // private List m_knownRegions = new List(); - private Dictionary m_deadRegionCache = new Dictionary(); - private Dictionary m_queuedGridSettings = new Dictionary(); - private List m_regionsOnInstance = new List(); - - public BaseHttpServer httpListener; - public NetworkServersInfo serversInfo; - - public string gdebugRegionName - { - get { return m_localBackend.gdebugRegionName; } - set { m_localBackend.gdebugRegionName = value; } - } - - public string rdebugRegionName - { - get { return _rdebugRegionName; } - set { _rdebugRegionName = value; } - } - private string _rdebugRegionName = String.Empty; - - public bool RegionLoginsEnabled - { - get { return m_localBackend.RegionLoginsEnabled; } - set { m_localBackend.RegionLoginsEnabled = value; } - } - - /// - /// Contructor. Adds "expect_user" and "check" xmlrpc method handlers - /// - /// - /// - public OGS1GridServices(NetworkServersInfo servers_info) - { - serversInfo = servers_info; - - //Respond to Grid Services requests - MainServer.Instance.AddXmlRPCHandler("check", PingCheckReply); - } - - // see IGridServices - public RegionCommsListener RegisterRegion(RegionInfo regionInfo) - { - if (m_regionsOnInstance.Contains(regionInfo)) - { - m_log.Error("[OGS1 GRID SERVICES]: Foobar! Caller is confused, region already registered " + regionInfo.RegionName); - Exception e = new Exception(String.Format("Unable to register region")); - - throw e; - } - - m_log.InfoFormat( - "[OGS1 GRID SERVICES]: Registering region {0} with grid at {1}", - regionInfo.RegionName, serversInfo.GridURL); - - m_regionsOnInstance.Add(regionInfo); - - Hashtable GridParams = new Hashtable(); - // Login / Authentication - - GridParams["authkey"] = serversInfo.GridSendKey; - GridParams["recvkey"] = serversInfo.GridRecvKey; - GridParams["UUID"] = regionInfo.RegionID.ToString(); - GridParams["sim_ip"] = regionInfo.ExternalHostName; - GridParams["sim_port"] = regionInfo.InternalEndPoint.Port.ToString(); - GridParams["region_locx"] = regionInfo.RegionLocX.ToString(); - GridParams["region_locy"] = regionInfo.RegionLocY.ToString(); - GridParams["sim_name"] = regionInfo.RegionName; - GridParams["http_port"] = serversInfo.HttpListenerPort.ToString(); - GridParams["remoting_port"] = ConfigSettings.DefaultRegionRemotingPort.ToString(); - GridParams["map-image-id"] = regionInfo.RegionSettings.TerrainImageID.ToString(); - GridParams["originUUID"] = regionInfo.originRegionID.ToString(); - GridParams["server_uri"] = regionInfo.ServerURI; - GridParams["region_secret"] = regionInfo.regionSecret; - GridParams["major_interface_version"] = VersionInfo.MajorInterfaceVersion.ToString(); - - if (regionInfo.MasterAvatarAssignedUUID != UUID.Zero) - GridParams["master_avatar_uuid"] = regionInfo.MasterAvatarAssignedUUID.ToString(); - else - GridParams["master_avatar_uuid"] = regionInfo.EstateSettings.EstateOwner.ToString(); - - GridParams["maturity"] = regionInfo.RegionSettings.Maturity.ToString(); - - // Package into an XMLRPC Request - ArrayList SendParams = new ArrayList(); - SendParams.Add(GridParams); - - // Send Request - XmlRpcRequest GridReq = new XmlRpcRequest("simulator_login", SendParams); - XmlRpcResponse GridResp; - - try - { - // The timeout should always be significantly larger than the timeout for the grid server to request - // the initial status of the region before confirming registration. - GridResp = GridReq.Send(serversInfo.GridURL, 9999999); - } - catch (Exception e) - { - Exception e2 - = new Exception( - String.Format( - "Unable to register region with grid at {0}. Grid service not running?", - serversInfo.GridURL), - e); - - throw e2; - } - - Hashtable GridRespData = (Hashtable)GridResp.Value; - // Hashtable griddatahash = GridRespData; - - // Process Response - if (GridRespData.ContainsKey("error")) - { - string errorstring = (string) GridRespData["error"]; - - Exception e = new Exception( - String.Format("Unable to connect to grid at {0}: {1}", serversInfo.GridURL, errorstring)); - - throw e; - } - else - { - // m_knownRegions = RequestNeighbours(regionInfo.RegionLocX, regionInfo.RegionLocY); - if (GridRespData.ContainsKey("allow_forceful_banlines")) - { - if ((string) GridRespData["allow_forceful_banlines"] != "TRUE") - { - //m_localBackend.SetForcefulBanlistsDisallowed(regionInfo.RegionHandle); - if (!m_queuedGridSettings.ContainsKey("allow_forceful_banlines")) - m_queuedGridSettings.Add("allow_forceful_banlines", "FALSE"); - } - } - - m_log.InfoFormat( - "[OGS1 GRID SERVICES]: Region {0} successfully registered with grid at {1}", - regionInfo.RegionName, serversInfo.GridURL); - } - - return m_localBackend.RegisterRegion(regionInfo); - } - - // see IGridServices - public bool DeregisterRegion(RegionInfo regionInfo) - { - Hashtable GridParams = new Hashtable(); - - GridParams["UUID"] = regionInfo.RegionID.ToString(); - - // Package into an XMLRPC Request - ArrayList SendParams = new ArrayList(); - SendParams.Add(GridParams); - - // Send Request - XmlRpcRequest GridReq = new XmlRpcRequest("simulator_after_region_moved", SendParams); - XmlRpcResponse GridResp = null; - - try - { - GridResp = GridReq.Send(serversInfo.GridURL, 10000); - } - catch (Exception e) - { - Exception e2 - = new Exception( - String.Format( - "Unable to deregister region with grid at {0}. Grid service not running?", - serversInfo.GridURL), - e); - - throw e2; - } - - Hashtable GridRespData = (Hashtable) GridResp.Value; - - // Hashtable griddatahash = GridRespData; - - // Process Response - if (GridRespData != null && GridRespData.ContainsKey("error")) - { - string errorstring = (string)GridRespData["error"]; - m_log.Error("Unable to connect to grid: " + errorstring); - return false; - } - - return m_localBackend.DeregisterRegion(regionInfo); - } - - public virtual Dictionary GetGridSettings() - { - Dictionary returnGridSettings = new Dictionary(); - lock (m_queuedGridSettings) - { - foreach (string Dictkey in m_queuedGridSettings.Keys) - { - returnGridSettings.Add(Dictkey, m_queuedGridSettings[Dictkey]); - } - - m_queuedGridSettings.Clear(); - } - - return returnGridSettings; - } - - // see IGridServices - public List RequestNeighbours(uint x, uint y) - { - Hashtable respData = MapBlockQuery((int) x - 1, (int) y - 1, (int) x + 1, (int) y + 1); - - List neighbours = new List(); - - foreach (ArrayList neighboursList in respData.Values) - { - foreach (Hashtable neighbourData in neighboursList) - { - uint regX = Convert.ToUInt32(neighbourData["x"]); - uint regY = Convert.ToUInt32(neighbourData["y"]); - if ((x != regX) || (y != regY)) - { - string simIp = (string) neighbourData["sim_ip"]; - - uint port = Convert.ToUInt32(neighbourData["sim_port"]); - // string externalUri = (string) neighbourData["sim_uri"]; - - // string externalIpStr = String.Empty; - try - { - // externalIpStr = Util.GetHostFromDNS(simIp).ToString(); - Util.GetHostFromDNS(simIp).ToString(); - } - catch (SocketException e) - { - m_log.WarnFormat( - "[OGS1 GRID SERVICES]: RequestNeighbours(): Lookup of neighbour {0} failed! Not including in neighbours list. {1}", - simIp, e); - - continue; - } - - SimpleRegionInfo sri = new SimpleRegionInfo(regX, regY, simIp, port); - - sri.RemotingPort = Convert.ToUInt32(neighbourData["remoting_port"]); - - if (neighbourData.ContainsKey("http_port")) - { - sri.HttpPort = Convert.ToUInt32(neighbourData["http_port"]); - } - else - { - m_log.Error("[OGS1 GRID SERVICES]: Couldn't find httpPort, using default 9000; please upgrade your grid-server to r7621 or later"); - sri.HttpPort = 9000; // that's the default and will probably be wrong - } - - sri.RegionID = new UUID((string) neighbourData["uuid"]); - - neighbours.Add(sri); - } - } - } - - return neighbours; - } - - /// - /// Request information about a region. - /// - /// - /// - /// null on a failure to contact or get a response from the grid server - /// FIXME: Might be nicer to return a proper exception here since we could inform the client more about the - /// nature of the faiulre. - /// - public RegionInfo RequestNeighbourInfo(UUID Region_UUID) - { - // don't ask the gridserver about regions on this instance... - foreach (RegionInfo info in m_regionsOnInstance) - { - if (info.RegionID == Region_UUID) return info; - } - - // didn't find it so far, we have to go the long way - RegionInfo regionInfo; - Hashtable requestData = new Hashtable(); - requestData["region_UUID"] = Region_UUID.ToString(); - requestData["authkey"] = serversInfo.GridSendKey; - ArrayList SendParams = new ArrayList(); - SendParams.Add(requestData); - XmlRpcRequest gridReq = new XmlRpcRequest("simulator_data_request", SendParams); - XmlRpcResponse gridResp = null; - - try - { - gridResp = gridReq.Send(serversInfo.GridURL, 3000); - } - catch (Exception e) - { - m_log.ErrorFormat( - "[OGS1 GRID SERVICES]: Communication with the grid server at {0} failed, {1}", - serversInfo.GridURL, e); - - return null; - } - - Hashtable responseData = (Hashtable)gridResp.Value; - - if (responseData.ContainsKey("error")) - { - m_log.WarnFormat("[OGS1 GRID SERVICES]: Error received from grid server: {0}", responseData["error"]); - return null; - } - - regionInfo = buildRegionInfo(responseData, String.Empty); - if ((m_useRemoteRegionCache) && (requestData.ContainsKey("regionHandle"))) - { - m_remoteRegionInfoCache.Add(Convert.ToUInt64((string) requestData["regionHandle"]), regionInfo); - } - - return regionInfo; - } - - /// - /// Request information about a region. - /// - /// - /// - public RegionInfo RequestNeighbourInfo(ulong regionHandle) - { - RegionInfo regionInfo = m_localBackend.RequestNeighbourInfo(regionHandle); - - if (regionInfo != null) - { - return regionInfo; - } - - if ((!m_useRemoteRegionCache) || (!m_remoteRegionInfoCache.TryGetValue(regionHandle, out regionInfo))) - { - try - { - Hashtable requestData = new Hashtable(); - requestData["region_handle"] = regionHandle.ToString(); - requestData["authkey"] = serversInfo.GridSendKey; - ArrayList SendParams = new ArrayList(); - SendParams.Add(requestData); - XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams); - XmlRpcResponse GridResp = GridReq.Send(serversInfo.GridURL, 3000); - - Hashtable responseData = (Hashtable) GridResp.Value; - - if (responseData.ContainsKey("error")) - { - m_log.Error("[OGS1 GRID SERVICES]: Error received from grid server: " + responseData["error"]); - return null; - } - - uint regX = Convert.ToUInt32((string) responseData["region_locx"]); - uint regY = Convert.ToUInt32((string) responseData["region_locy"]); - string externalHostName = (string) responseData["sim_ip"]; - uint simPort = Convert.ToUInt32(responseData["sim_port"]); - string regionName = (string)responseData["region_name"]; - UUID regionID = new UUID((string)responseData["region_UUID"]); - uint remotingPort = Convert.ToUInt32((string)responseData["remoting_port"]); - - uint httpPort = 9000; - if (responseData.ContainsKey("http_port")) - { - httpPort = Convert.ToUInt32((string)responseData["http_port"]); - } - - // Ok, so this is definitively the wrong place to do this, way too hard coded, but it doesn't seem we GET this info? - - string simURI = "http://" + externalHostName + ":" + simPort; - - // string externalUri = (string) responseData["sim_uri"]; - - //IPEndPoint neighbourInternalEndPoint = new IPEndPoint(IPAddress.Parse(internalIpStr), (int) port); - regionInfo = RegionInfo.Create(regionID, regionName, regX, regY, externalHostName, httpPort, simPort, remotingPort, simURI); - - if (m_useRemoteRegionCache) - { - lock (m_remoteRegionInfoCache) - { - if (!m_remoteRegionInfoCache.ContainsKey(regionHandle)) - { - m_remoteRegionInfoCache.Add(regionHandle, regionInfo); - } - } - } - } - catch (Exception e) - { - m_log.Error("[OGS1 GRID SERVICES]: " + - "Region lookup failed for: " + regionHandle.ToString() + - " - Is the GridServer down?" + e.ToString()); - return null; - } - } - - return regionInfo; - } - - /// - /// Get information about a neighbouring region - /// - /// - /// - public RegionInfo RequestNeighbourInfo(string name) - { - // Not implemented yet - return null; - } - - /// - /// Get information about a neighbouring region - /// - /// - /// - public RegionInfo RequestNeighbourInfo(string host, uint port) - { - // Not implemented yet - return null; - } - - public RegionInfo RequestClosestRegion(string regionName) - { - if (m_useRemoteRegionCache) - { - foreach (RegionInfo ri in m_remoteRegionInfoCache.Values) - { - if (ri.RegionName == regionName) - return ri; - } - } - - RegionInfo regionInfo = null; - try - { - Hashtable requestData = new Hashtable(); - requestData["region_name_search"] = regionName; - requestData["authkey"] = serversInfo.GridSendKey; - ArrayList SendParams = new ArrayList(); - SendParams.Add(requestData); - XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams); - XmlRpcResponse GridResp = GridReq.Send(serversInfo.GridURL, 3000); - - Hashtable responseData = (Hashtable) GridResp.Value; - - if (responseData.ContainsKey("error")) - { - m_log.ErrorFormat("[OGS1 GRID SERVICES]: Error received from grid server: ", responseData["error"]); - return null; - } - - regionInfo = buildRegionInfo(responseData, ""); - - if ((m_useRemoteRegionCache) && (!m_remoteRegionInfoCache.ContainsKey(regionInfo.RegionHandle))) - m_remoteRegionInfoCache.Add(regionInfo.RegionHandle, regionInfo); - } - catch - { - m_log.Error("[OGS1 GRID SERVICES]: " + - "Region lookup failed for: " + regionName + - " - Is the GridServer down?"); - } - - return regionInfo; - } - - /// - /// - /// - /// - /// - /// - /// - /// - public List RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY) - { - int temp = 0; - - if (minX > maxX) - { - temp = minX; - minX = maxX; - maxX = temp; - } - if (minY > maxY) - { - temp = minY; - minY = maxY; - maxY = temp; - } - - Hashtable respData = MapBlockQuery(minX, minY, maxX, maxY); - - List neighbours = new List(); - - foreach (ArrayList a in respData.Values) - { - foreach (Hashtable n in a) - { - MapBlockData neighbour = new MapBlockData(); - - neighbour.X = Convert.ToUInt16(n["x"]); - neighbour.Y = Convert.ToUInt16(n["y"]); - - neighbour.Name = (string) n["name"]; - neighbour.Access = Convert.ToByte(n["access"]); - neighbour.RegionFlags = Convert.ToUInt32(n["region-flags"]); - neighbour.WaterHeight = Convert.ToByte(n["water-height"]); - neighbour.MapImageId = new UUID((string) n["map-image-id"]); - - neighbours.Add(neighbour); - } - } - - return neighbours; - } - - /// - /// Performs a XML-RPC query against the grid server returning mapblock information in the specified coordinates - /// - /// REDUNDANT - OGS1 is to be phased out in favour of OGS2 - /// Minimum X value - /// Minimum Y value - /// Maximum X value - /// Maximum Y value - /// Hashtable of hashtables containing map data elements - private Hashtable MapBlockQuery(int minX, int minY, int maxX, int maxY) - { - Hashtable param = new Hashtable(); - param["xmin"] = minX; - param["ymin"] = minY; - param["xmax"] = maxX; - param["ymax"] = maxY; - IList parameters = new ArrayList(); - parameters.Add(param); - - try - { - XmlRpcRequest req = new XmlRpcRequest("map_block", parameters); - XmlRpcResponse resp = req.Send(serversInfo.GridURL, 10000); - Hashtable respData = (Hashtable) resp.Value; - return respData; - } - catch (Exception e) - { - m_log.Error("MapBlockQuery XMLRPC failure: " + e); - return new Hashtable(); - } - } - - /// - /// A ping / version check - /// - /// - /// - public XmlRpcResponse PingCheckReply(XmlRpcRequest request, IPEndPoint remoteClient) - { - XmlRpcResponse response = new XmlRpcResponse(); - - Hashtable respData = new Hashtable(); - respData["online"] = "true"; - - m_localBackend.PingCheckReply(respData); - - response.Value = respData; - - return response; - } - - /// - /// Received from the user server when a user starts logging in. This call allows - /// the region to prepare for direct communication from the client. Sends back an empty - /// xmlrpc response on completion. - /// - /// - /// - public XmlRpcResponse ExpectUser(XmlRpcRequest request) - { - Hashtable requestData = (Hashtable) request.Params[0]; - AgentCircuitData agentData = new AgentCircuitData(); - agentData.SessionID = new UUID((string) requestData["session_id"]); - agentData.SecureSessionID = new UUID((string) requestData["secure_session_id"]); - agentData.firstname = (string) requestData["firstname"]; - agentData.lastname = (string) requestData["lastname"]; - agentData.AgentID = new UUID((string) requestData["agent_id"]); - agentData.circuitcode = Convert.ToUInt32(requestData["circuit_code"]); - agentData.CapsPath = (string)requestData["caps_path"]; - ulong regionHandle = Convert.ToUInt64((string) requestData["regionhandle"]); - - // Appearance - if (requestData["appearance"] != null) - agentData.Appearance = new AvatarAppearance((Hashtable)requestData["appearance"]); - - m_log.DebugFormat( - "[CLIENT]: Told by user service to prepare for a connection from {0} {1} {2}, circuit {3}", - agentData.firstname, agentData.lastname, agentData.AgentID, agentData.circuitcode); - - if (requestData.ContainsKey("child_agent") && requestData["child_agent"].Equals("1")) - { - //m_log.Debug("[CLIENT]: Child agent detected"); - agentData.child = true; - } - else - { - //m_log.Debug("[CLIENT]: Main agent detected"); - agentData.startpos = - new Vector3((float)Convert.ToDecimal((string)requestData["startpos_x"]), - (float)Convert.ToDecimal((string)requestData["startpos_y"]), - (float)Convert.ToDecimal((string)requestData["startpos_z"])); - agentData.child = false; - } - - XmlRpcResponse resp = new XmlRpcResponse(); - - if (!RegionLoginsEnabled) - { - m_log.InfoFormat( - "[CLIENT]: Denying access for user {0} {1} because region login is currently disabled", - agentData.firstname, agentData.lastname); - - Hashtable respdata = new Hashtable(); - respdata["success"] = "FALSE"; - respdata["reason"] = "region login currently disabled"; - resp.Value = respdata; - } - else - { - RegionInfo[] regions = m_regionsOnInstance.ToArray(); - bool banned = false; - - for (int i = 0; i < regions.Length; i++) - { - if (regions[i] != null) - { - if (regions[i].RegionHandle == regionHandle) - { - if (regions[i].EstateSettings.IsBanned(agentData.AgentID)) - { - banned = true; - break; - } - } - } - } - - if (banned) - { - m_log.InfoFormat( - "[CLIENT]: Denying access for user {0} {1} because user is banned", - agentData.firstname, agentData.lastname); - - Hashtable respdata = new Hashtable(); - respdata["success"] = "FALSE"; - respdata["reason"] = "banned"; - resp.Value = respdata; - } - else - { - m_localBackend.TriggerExpectUser(regionHandle, agentData); - Hashtable respdata = new Hashtable(); - respdata["success"] = "TRUE"; - resp.Value = respdata; - } - } - - return resp; - } - - // Grid Request Processing - /// - /// Ooops, our Agent must be dead if we're getting this request! - /// - /// - /// - public XmlRpcResponse LogOffUser(XmlRpcRequest request) - { - m_log.Debug("[CONNECTION DEBUGGING]: LogOff User Called"); - - Hashtable requestData = (Hashtable)request.Params[0]; - string message = (string)requestData["message"]; - UUID agentID = UUID.Zero; - UUID RegionSecret = UUID.Zero; - UUID.TryParse((string)requestData["agent_id"], out agentID); - UUID.TryParse((string)requestData["region_secret"], out RegionSecret); - - ulong regionHandle = Convert.ToUInt64((string)requestData["regionhandle"]); - - m_localBackend.TriggerLogOffUser(regionHandle, agentID, RegionSecret,message); - - return new XmlRpcResponse(); - } - - public void NoteDeadRegion(ulong regionhandle) - { - lock (m_deadRegionCache) - { - if (m_deadRegionCache.ContainsKey(regionhandle)) - { - m_deadRegionCache[regionhandle] = m_deadRegionCache[regionhandle] + 1; - } - else - { - m_deadRegionCache.Add(regionhandle, 1); - } - } - } - - public LandData RequestLandData (ulong regionHandle, uint x, uint y) - { - m_log.DebugFormat("[OGS1 GRID SERVICES] requests land data in {0}, at {1}, {2}", - regionHandle, x, y); - LandData landData = m_localBackend.RequestLandData(regionHandle, x, y); - if (landData == null) - { - Hashtable hash = new Hashtable(); - hash["region_handle"] = regionHandle.ToString(); - hash["x"] = x.ToString(); - hash["y"] = y.ToString(); - - IList paramList = new ArrayList(); - paramList.Add(hash); - - try - { - // this might be cached, as we probably requested it just a moment ago... - RegionInfo info = RequestNeighbourInfo(regionHandle); - if (info != null) // just to be sure - { - XmlRpcRequest request = new XmlRpcRequest("land_data", paramList); - string uri = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/"; - XmlRpcResponse response = request.Send(uri, 10000); - if (response.IsFault) - { - m_log.ErrorFormat("[OGS1 GRID SERVICES] remote call returned an error: {0}", response.FaultString); - } - else - { - hash = (Hashtable)response.Value; - try - { - landData = new LandData(); - landData.AABBMax = Vector3.Parse((string)hash["AABBMax"]); - landData.AABBMin = Vector3.Parse((string)hash["AABBMin"]); - landData.Area = Convert.ToInt32(hash["Area"]); - landData.AuctionID = Convert.ToUInt32(hash["AuctionID"]); - landData.Description = (string)hash["Description"]; - landData.Flags = Convert.ToUInt32(hash["Flags"]); - landData.GlobalID = new UUID((string)hash["GlobalID"]); - landData.Name = (string)hash["Name"]; - landData.OwnerID = new UUID((string)hash["OwnerID"]); - landData.SalePrice = Convert.ToInt32(hash["SalePrice"]); - landData.SnapshotID = new UUID((string)hash["SnapshotID"]); - landData.UserLocation = Vector3.Parse((string)hash["UserLocation"]); - m_log.DebugFormat("[OGS1 GRID SERVICES] Got land data for parcel {0}", landData.Name); - } - catch (Exception e) - { - m_log.Error("[OGS1 GRID SERVICES] Got exception while parsing land-data:", e); - } - } - } - else m_log.WarnFormat("[OGS1 GRID SERVICES] Couldn't find region with handle {0}", regionHandle); - } - catch (Exception e) - { - m_log.ErrorFormat("[OGS1 GRID SERVICES] Couldn't contact region {0}: {1}", regionHandle, e); - } - } - return landData; - } - - // Grid Request Processing - /// - /// Someone asked us about parcel-information - /// - /// - /// - public XmlRpcResponse LandData(XmlRpcRequest request, IPEndPoint remoteClient) - { - Hashtable requestData = (Hashtable)request.Params[0]; - ulong regionHandle = Convert.ToUInt64(requestData["region_handle"]); - uint x = Convert.ToUInt32(requestData["x"]); - uint y = Convert.ToUInt32(requestData["y"]); - m_log.DebugFormat("[OGS1 GRID SERVICES]: Got XML reqeuest for land data at {0}, {1} in region {2}", x, y, regionHandle); - - LandData landData = m_localBackend.RequestLandData(regionHandle, x, y); - Hashtable hash = new Hashtable(); - if (landData != null) - { - // for now, only push out the data we need for answering a ParcelInfoReqeust - hash["AABBMax"] = landData.AABBMax.ToString(); - hash["AABBMin"] = landData.AABBMin.ToString(); - hash["Area"] = landData.Area.ToString(); - hash["AuctionID"] = landData.AuctionID.ToString(); - hash["Description"] = landData.Description; - hash["Flags"] = landData.Flags.ToString(); - hash["GlobalID"] = landData.GlobalID.ToString(); - hash["Name"] = landData.Name; - hash["OwnerID"] = landData.OwnerID.ToString(); - hash["SalePrice"] = landData.SalePrice.ToString(); - hash["SnapshotID"] = landData.SnapshotID.ToString(); - hash["UserLocation"] = landData.UserLocation.ToString(); - } - - XmlRpcResponse response = new XmlRpcResponse(); - response.Value = hash; - return response; - } - - public List RequestNamedRegions (string name, int maxNumber) - { - // no asking of the local backend first, here, as we have to ask the gridserver anyway. - Hashtable hash = new Hashtable(); - hash["name"] = name; - hash["maxNumber"] = maxNumber.ToString(); - - IList paramList = new ArrayList(); - paramList.Add(hash); - - Hashtable result = XmlRpcSearchForRegionByName(paramList); - if (result == null) return null; - - uint numberFound = Convert.ToUInt32(result["numFound"]); - List infos = new List(); - for (int i = 0; i < numberFound; ++i) - { - string prefix = "region" + i + "."; - RegionInfo info = buildRegionInfo(result, prefix); - infos.Add(info); - } - return infos; - } - - private RegionInfo buildRegionInfo(Hashtable responseData, string prefix) - { - uint regX = Convert.ToUInt32((string) responseData[prefix + "region_locx"]); - uint regY = Convert.ToUInt32((string) responseData[prefix + "region_locy"]); - string internalIpStr = (string) responseData[prefix + "sim_ip"]; - uint port = Convert.ToUInt32(responseData[prefix + "sim_port"]); - - IPEndPoint neighbourInternalEndPoint = new IPEndPoint(Util.GetHostFromDNS(internalIpStr), (int) port); - - RegionInfo regionInfo = new RegionInfo(regX, regY, neighbourInternalEndPoint, internalIpStr); - regionInfo.RemotingPort = Convert.ToUInt32((string) responseData[prefix + "remoting_port"]); - regionInfo.RemotingAddress = internalIpStr; - - if (responseData.ContainsKey(prefix + "http_port")) - { - regionInfo.HttpPort = Convert.ToUInt32((string) responseData[prefix + "http_port"]); - } - - regionInfo.RegionID = new UUID((string) responseData[prefix + "region_UUID"]); - regionInfo.RegionName = (string) responseData[prefix + "region_name"]; - - regionInfo.RegionSettings.TerrainImageID = new UUID((string) responseData[prefix + "map_UUID"]); - return regionInfo; - } - - private Hashtable XmlRpcSearchForRegionByName(IList parameters) - { - try - { - XmlRpcRequest request = new XmlRpcRequest("search_for_region_by_name", parameters); - XmlRpcResponse resp = request.Send(serversInfo.GridURL, 10000); - Hashtable respData = (Hashtable) resp.Value; - if (respData != null && respData.Contains("faultCode")) - { - m_log.WarnFormat("[OGS1 GRID SERVICES]: Got an error while contacting GridServer: {0}", respData["faultString"]); - return null; - } - - return respData; - } - catch (Exception e) - { - m_log.Error("[OGS1 GRID SERVICES]: MapBlockQuery XMLRPC failure: ", e); - return null; - } - } - } -} -- cgit v1.1 From 68e40a87cafcab580ab484956f187068c098e84e Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 26 Sep 2009 21:29:54 -0700 Subject: Poof! on LocalBackend. CommsManager.GridServices deleted. --- .../Communications/CommunicationsManager.cs | 5 - .../Communications/Local/CommunicationsLocal.cs | 2 - .../Communications/Local/LocalBackEndServices.cs | 410 --------------------- .../Tests/Common/Mock/TestCommunicationsManager.cs | 2 - 4 files changed, 419 deletions(-) delete mode 100644 OpenSim/Region/Communications/Local/LocalBackEndServices.cs (limited to 'OpenSim') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index e9a6adb..9f377a6 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -59,11 +59,6 @@ namespace OpenSim.Framework.Communications } protected IMessagingService m_messageService; - public IGridServices GridService - { - get { return m_gridService; } - } - protected IGridServices m_gridService; public UserProfileCacheService UserProfileCacheService { diff --git a/OpenSim/Region/Communications/Local/CommunicationsLocal.cs b/OpenSim/Region/Communications/Local/CommunicationsLocal.cs index a658416..99bcea3 100644 --- a/OpenSim/Region/Communications/Local/CommunicationsLocal.cs +++ b/OpenSim/Region/Communications/Local/CommunicationsLocal.cs @@ -53,8 +53,6 @@ namespace OpenSim.Region.Communications.Local m_avatarService = lus; m_messageService = lus; - m_gridService = new LocalBackEndServices(); - //LocalLoginService loginService = CreateLoginService(libraryRootFolder, inventoryService, userService, backendService); } } diff --git a/OpenSim/Region/Communications/Local/LocalBackEndServices.cs b/OpenSim/Region/Communications/Local/LocalBackEndServices.cs deleted file mode 100644 index 0ab9374..0000000 --- a/OpenSim/Region/Communications/Local/LocalBackEndServices.cs +++ /dev/null @@ -1,410 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Reflection; -using log4net; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Framework.Communications; - -namespace OpenSim.Region.Communications.Local -{ - public class LocalBackEndServices : IGridServices - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - protected Dictionary m_regions = new Dictionary(); - - protected Dictionary m_regionListeners = - new Dictionary(); - - // private Dictionary m_remoteRegionInfoCache = new Dictionary(); - - private Dictionary m_queuedGridSettings = new Dictionary(); - - public string _gdebugRegionName = String.Empty; - - public bool RegionLoginsEnabled - { - get { return m_regionLoginsEnabled; } - set { m_regionLoginsEnabled = value; } - } - private bool m_regionLoginsEnabled; - - public bool CheckRegion(string address, uint port) - { - return true; - } - - public string gdebugRegionName - { - get { return _gdebugRegionName; } - set { _gdebugRegionName = value; } - } - - public string _rdebugRegionName = String.Empty; - - public string rdebugRegionName - { - get { return _rdebugRegionName; } - set { _rdebugRegionName = value; } - } - - /// - /// Register a region method with the BackEnd Services. - /// - /// - /// - public RegionCommsListener RegisterRegion(RegionInfo regionInfo) - { - //m_log.Debug("CommsManager - Region " + regionInfo.RegionHandle + " , " + regionInfo.RegionLocX + " , "+ regionInfo.RegionLocY +" is registering"); - if (!m_regions.ContainsKey(regionInfo.RegionHandle)) - { - //m_log.Debug("CommsManager - Adding Region " + regionInfo.RegionHandle); - m_regions.Add(regionInfo.RegionHandle, regionInfo); - - RegionCommsListener regionHost = new RegionCommsListener(); - if (m_regionListeners.ContainsKey(regionInfo.RegionHandle)) - { - m_log.Error("[INTERREGION STANDALONE]: " + - "Error:Region registered twice as an Events listener for Interregion Communications but not as a listed region. " + - "In Standalone mode this will cause BIG issues. In grid mode, it means a region went down and came back up."); - m_regionListeners.Remove(regionInfo.RegionHandle); - } - m_regionListeners.Add(regionInfo.RegionHandle, regionHost); - - return regionHost; - } - else - { - // Already in our list, so the region went dead and restarted. - // don't replace the old regioninfo.. this might be a locking issue.. however we need to - // remove it and let it add normally below or we get extremely strange and intermittant - // connectivity errors. - // Don't change this line below to 'm_regions[regionInfo.RegionHandle] = regionInfo' unless you - // *REALLY* know what you are doing here. - m_regions[regionInfo.RegionHandle] = regionInfo; - - m_log.Warn("[INTERREGION STANDALONE]: Region registered twice. Region went down and came back up."); - - RegionCommsListener regionHost = new RegionCommsListener(); - if (m_regionListeners.ContainsKey(regionInfo.RegionHandle)) - { - m_regionListeners.Remove(regionInfo.RegionHandle); - } - m_regionListeners.Add(regionInfo.RegionHandle, regionHost); - - return regionHost; - } - } - - public bool DeregisterRegion(RegionInfo regionInfo) - { - if (m_regions.ContainsKey(regionInfo.RegionHandle)) - { - m_regions.Remove(regionInfo.RegionHandle); - if (m_regionListeners.ContainsKey(regionInfo.RegionHandle)) - { - m_regionListeners.Remove(regionInfo.RegionHandle); - } - return true; - } - return false; - } - - /// - /// - /// - /// - public List RequestNeighbours(uint x, uint y) - { - // m_log.Debug("Finding Neighbours to " + regionInfo.RegionHandle); - List neighbours = new List(); - - foreach (RegionInfo reg in m_regions.Values) - { - // m_log.Debug("CommsManager- RequestNeighbours() checking region " + reg.RegionLocX + " , "+ reg.RegionLocY); - if (reg.RegionLocX != x || reg.RegionLocY != y) - { - //m_log.Debug("CommsManager- RequestNeighbours() - found a different region in list, checking location"); - if ((reg.RegionLocX > (x - 2)) && (reg.RegionLocX < (x + 2))) - { - if ((reg.RegionLocY > (y - 2)) && (reg.RegionLocY < (y + 2))) - { - neighbours.Add(reg); - } - } - } - } - return neighbours; - } - - /// - /// Get information about a neighbouring region - /// - /// - /// - public RegionInfo RequestNeighbourInfo(ulong regionHandle) - { - if (m_regions.ContainsKey(regionHandle)) - { - return m_regions[regionHandle]; - } - - return null; - } - - /// - /// Get information about a neighbouring region - /// - /// - /// - public RegionInfo RequestNeighbourInfo(UUID regionID) - { - // TODO add a dictionary for faster lookup - foreach (RegionInfo info in m_regions.Values) - { - if (info.RegionID == regionID) - return info; - } - - return null; - } - - /// - /// Get information about a neighbouring region - /// - /// - /// - public RegionInfo RequestNeighbourInfo(string name) - { - foreach (RegionInfo info in m_regions.Values) - { - if (info.RegionName == name) - return info; - } - - return null; - } - - /// - /// Get information about a neighbouring region - /// - /// - /// - public RegionInfo RequestNeighbourInfo(string host, uint port) - { - foreach (RegionInfo info in m_regions.Values) - { - if ((info.ExternalHostName == host) && (info.HttpPort == port)) - return info; - } - - return null; - } - - /// - /// Get information about the closet region given a region name. - /// - /// - /// - public RegionInfo RequestClosestRegion(string regionName) - { - foreach (RegionInfo regInfo in m_regions.Values) - { - if (regInfo.RegionName == regionName) - return regInfo; - } - return null; - } - - /// - /// - /// - /// - /// - /// - /// - /// - public List RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY) - { - List mapBlocks = new List(); - foreach (RegionInfo regInfo in m_regions.Values) - { - if (((regInfo.RegionLocX >= minX) && (regInfo.RegionLocX <= maxX)) && - ((regInfo.RegionLocY >= minY) && (regInfo.RegionLocY <= maxY))) - { - MapBlockData map = new MapBlockData(); - map.Name = regInfo.RegionName; - map.X = (ushort) regInfo.RegionLocX; - map.Y = (ushort) regInfo.RegionLocY; - map.WaterHeight = (byte) regInfo.RegionSettings.WaterHeight; - map.MapImageId = regInfo.RegionSettings.TerrainImageID; - map.Agents = 1; - map.RegionFlags = 72458694; - map.Access = regInfo.AccessLevel; - mapBlocks.Add(map); - } - } - return mapBlocks; - } - - // This function is only here to keep this class in line with the Grid Interface. - // It never gets called. - public virtual Dictionary GetGridSettings() - { - Dictionary returnGridSettings = new Dictionary(); - lock (m_queuedGridSettings) - { - returnGridSettings = m_queuedGridSettings; - m_queuedGridSettings.Clear(); - } - - return returnGridSettings; - } - - public virtual void SetForcefulBanlistsDisallowed() - { - m_queuedGridSettings.Add("allow_forceful_banlines", "FALSE"); - } - - - /// - /// Is a Sandbox mode method, used by the local Login server to inform a region of a connection user/session - /// - /// - /// - /// - public void AddNewSession(ulong regionHandle, Login loginData) - { - AgentCircuitData agent = new AgentCircuitData(); - agent.AgentID = loginData.Agent; - agent.firstname = loginData.First; - agent.lastname = loginData.Last; - agent.SessionID = loginData.Session; - agent.SecureSessionID = loginData.SecureSession; - agent.circuitcode = loginData.CircuitCode; - agent.BaseFolder = loginData.BaseFolder; - agent.InventoryFolder = loginData.InventoryFolder; - agent.startpos = loginData.StartPos; - agent.CapsPath = loginData.CapsPath; - if (loginData.Appearance != null) - agent.Appearance = loginData.Appearance; - else - { - m_log.WarnFormat("[INTER]: Appearance not found for {0} {1}. Creating default.", agent.firstname, agent.lastname); - agent.Appearance = new AvatarAppearance(agent.AgentID); - } - - TriggerExpectUser(regionHandle, agent); - } - - public void TriggerExpectUser(ulong regionHandle, AgentCircuitData agent) - { - //m_log.Info("[INTER]: " + rdebugRegionName + ":Local BackEnd: Other region is sending child agent our way: " + agent.firstname + " " + agent.lastname); - - if (m_regionListeners.ContainsKey(regionHandle)) - { - //m_log.Info("[INTER]: " + rdebugRegionName + ":Local BackEnd: FoundLocalRegion To send it to: " + agent.firstname + " " + agent.lastname); - - m_regionListeners[regionHandle].TriggerExpectUser(agent); - } - } - - public void TriggerLogOffUser(ulong regionHandle, UUID agentID, UUID RegionSecret, string message) - { - if (m_regionListeners.ContainsKey(regionHandle)) - { - //m_log.Info("[INTER]: " + rdebugRegionName + ":Local BackEnd: FoundLocalRegion To send it to: " + agent.firstname + " " + agent.lastname); - - m_regionListeners[regionHandle].TriggerLogOffUser(agentID, RegionSecret, message); - } - } - - public void PingCheckReply(Hashtable respData) - { - foreach (ulong region in m_regions.Keys) - { - Hashtable regData = new Hashtable(); - RegionInfo reg = m_regions[region]; - regData["status"] = "active"; - regData["handle"] = region.ToString(); - - respData[reg.RegionID.ToString()] = regData; - } - } - - - public LandData RequestLandData (ulong regionHandle, uint x, uint y) - { - m_log.DebugFormat("[INTERREGION STANDALONE] requests land data in {0}, at {1}, {2}", - regionHandle, x, y); - - if (m_regionListeners.ContainsKey(regionHandle)) - { - LandData land = m_regionListeners[regionHandle].TriggerGetLandData(x, y); - return land; - } - - m_log.Debug("[INTERREGION STANDALONE] didn't find land data locally."); - return null; - } - - public List RequestNamedRegions (string name, int maxNumber) - { - List lowercase_regions = new List(); - List regions = new List(); - foreach (RegionInfo info in m_regions.Values) - { - // Prioritizes exact match - if (info.RegionName.StartsWith(name)) - { - regions.Add(info); - if (regions.Count >= maxNumber) break; - } - // But still saves lower case matches - else if (info.RegionName.ToLower().StartsWith(name)) - { - if (lowercase_regions.Count < maxNumber) - { - lowercase_regions.Add(info); - } - } - } - - // If no exact matches found, return lowercase matches (libOMV compatiblity) - if (regions.Count == 0 && lowercase_regions.Count != 0) - { - return lowercase_regions; - } - return regions; - } - } -} diff --git a/OpenSim/Tests/Common/Mock/TestCommunicationsManager.cs b/OpenSim/Tests/Common/Mock/TestCommunicationsManager.cs index 4313c96..de73663 100644 --- a/OpenSim/Tests/Common/Mock/TestCommunicationsManager.cs +++ b/OpenSim/Tests/Common/Mock/TestCommunicationsManager.cs @@ -65,8 +65,6 @@ namespace OpenSim.Tests.Common.Mock m_userService = lus; m_userAdminService = lus; - LocalBackEndServices gs = new LocalBackEndServices(); - m_gridService = gs; } } } -- 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/Framework/IRegionCommsListener.cs | 3 - OpenSim/Framework/IScene.cs | 2 +- OpenSim/Framework/RegionCommsListener.cs | 13 ---- .../ClientStack/LindenUDP/Tests/MockScene.cs | 3 +- .../Neighbour/NeighbourServiceInConnectorModule.cs | 4 +- .../Neighbour/LocalNeighbourServiceConnector.cs | 4 +- .../Neighbour/RemoteNeighourServiceConnector.cs | 7 +- OpenSim/Region/Framework/Scenes/EventManager.cs | 13 ++++ OpenSim/Region/Framework/Scenes/Scene.cs | 63 +++++----------- OpenSim/Region/Framework/Scenes/SceneBase.cs | 3 +- .../Framework/Scenes/SceneCommunicationService.cs | 87 +++++++++------------- .../Framework/Scenes/Tests/SceneBaseTests.cs | 3 +- .../Server/Handlers/Neighbour/NeighbourHandlers.cs | 10 ++- .../Neighbour/NeighbourServiceConnector.cs | 6 +- OpenSim/Services/Interfaces/INeighbourService.cs | 3 +- 15 files changed, 97 insertions(+), 127 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/IRegionCommsListener.cs b/OpenSim/Framework/IRegionCommsListener.cs index ba4c616..307c6bc 100644 --- a/OpenSim/Framework/IRegionCommsListener.cs +++ b/OpenSim/Framework/IRegionCommsListener.cs @@ -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; diff --git a/OpenSim/Framework/IScene.cs b/OpenSim/Framework/IScene.cs index 2e2c703..d61e08c 100644 --- a/OpenSim/Framework/IScene.cs +++ b/OpenSim/Framework/IScene.cs @@ -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(); diff --git a/OpenSim/Framework/RegionCommsListener.cs b/OpenSim/Framework/RegionCommsListener.cs index 016c78c..90200d6 100644 --- a/OpenSim/Framework/RegionCommsListener.cs +++ b/OpenSim/Framework/RegionCommsListener.cs @@ -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; diff --git a/OpenSim/Region/ClientStack/LindenUDP/Tests/MockScene.cs b/OpenSim/Region/ClientStack/LindenUDP/Tests/MockScene.cs index c831f68..34c21aa 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/Tests/MockScene.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/Tests/MockScene.cs @@ -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) { } /// /// Doesn't really matter what the call is - we're using this to test that a packet has actually been received diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Neighbour/NeighbourServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Neighbour/NeighbourServiceInConnectorModule.cs index a31ce8e..8a90370 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Neighbour/NeighbourServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Neighbour/NeighbourServiceInConnectorModule.cs @@ -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 diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/LocalNeighbourServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/LocalNeighbourServiceConnector.cs index 61bf481..daba0b3 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/LocalNeighbourServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/LocalNeighbourServiceConnector.cs @@ -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 diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/RemoteNeighourServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/RemoteNeighourServiceConnector.cs index 912c393..c6fc2a1 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/RemoteNeighourServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/RemoteNeighourServiceConnector.cs @@ -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); } 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; 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); + } + } } 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; 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; 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() { 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 /// public event PrimCrossing OnPrimCrossingIntoRegion; - /// - /// A New Region is up and available - /// - public event RegionUp OnRegionUp; + ///// + ///// A New Region is up and available + ///// + //public event RegionUp OnRegionUp; /// /// 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; @@ -239,22 +239,6 @@ namespace OpenSim.Region.Framework.Scenes } /// - /// A New Region is now available. Inform the scene that there is a new region available. - /// - /// Information about the new region that is available - /// True if the event was handled - 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; - } - - /// /// Inform the scene that we've got an update about a child agent that we have /// /// @@ -647,31 +631,23 @@ namespace OpenSim.Region.Framework.Scenes /// 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); + 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; - List neighbours = new List(); - // This stays uncached because we don't already know about our neighbors at this point. + d.BeginInvoke(neighbourService, region, handle, + InformNeighborsThatRegionisUpCompleted, + d); + } - 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; + //List neighbours = new List(); + //// This stays uncached because we don't already know about our neighbors at this point. - d.BeginInvoke(neighbourService, region, neighbours[i].RegionHandle, - InformNeighborsThatRegionisUpCompleted, - d); - } - } + //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)); } 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; 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(); } diff --git a/OpenSim/Server/Handlers/Neighbour/NeighbourHandlers.cs b/OpenSim/Server/Handlers/Neighbour/NeighbourHandlers.cs index c0933a8..d6ef22e 100644 --- a/OpenSim/Server/Handlers/Neighbour/NeighbourHandlers.cs +++ b/OpenSim/Server/Handlers/Neighbour/NeighbourHandlers.cs @@ -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; diff --git a/OpenSim/Services/Connectors/Neighbour/NeighbourServiceConnector.cs b/OpenSim/Services/Connectors/Neighbour/NeighbourServiceConnector.cs index 1b595e7..145f212 100644 --- a/OpenSim/Services/Connectors/Neighbour/NeighbourServiceConnector.cs +++ b/OpenSim/Services/Connectors/Neighbour/NeighbourServiceConnector.cs @@ -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) diff --git a/OpenSim/Services/Interfaces/INeighbourService.cs b/OpenSim/Services/Interfaces/INeighbourService.cs index 3944486..960e13d 100644 --- a/OpenSim/Services/Interfaces/INeighbourService.cs +++ b/OpenSim/Services/Interfaces/INeighbourService.cs @@ -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); } } -- 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. --- .../ServiceConnectorsOut/Grid/HGGridConnector.cs | 4 ++ .../Grid/LocalGridServiceConnector.cs | 54 ++++++++++++++++++++-- .../ServiceConnectorsOut/Grid/RegionCache.cs | 52 +++++++++++++++++++++ .../Grid/RemoteGridServiceConnector.cs | 19 ++++++-- OpenSim/Region/Framework/Scenes/Scene.cs | 4 ++ .../Framework/Scenes/SceneCommunicationService.cs | 4 +- 6 files changed, 126 insertions(+), 11 deletions(-) create mode 100644 OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs index 52db400..c8062d7 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs @@ -135,6 +135,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid public void PostInitialise() { + ((ISharedRegionModule)m_GridServiceConnector).PostInitialise(); } public void Close() @@ -150,11 +151,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid scene.RegisterModuleInterface(this); scene.RegisterModuleInterface(this); + ((ISharedRegionModule)m_GridServiceConnector).AddRegion(scene); + } public void RemoveRegion(Scene scene) { m_LocalScenes.Remove(scene.RegionInfo.RegionHandle); + ((ISharedRegionModule)m_GridServiceConnector).RemoveRegion(scene); } public void RegionLoaded(Scene scene) diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs index 743d3b9..6c2928a 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs @@ -31,6 +31,7 @@ using System; using System.Collections.Generic; using System.Reflection; using OpenSim.Framework; +using OpenSim.Framework.Console; using OpenSim.Server.Base; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; @@ -47,7 +48,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType); + private static LocalGridServicesConnector m_MainInstance; + private IGridService m_GridService; + private Dictionary m_LocalCache = new Dictionary(); private bool m_Enabled = false; @@ -58,6 +62,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid public LocalGridServicesConnector(IConfigSource source) { m_log.Debug("[LOCAL GRID CONNECTOR]: LocalGridServicesConnector instantiated"); + m_MainInstance = this; InitialiseService(source); } @@ -82,6 +87,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid if (name == Name) { InitialiseService(source); + m_MainInstance = this; m_Enabled = true; m_log.Info("[LOCAL GRID CONNECTOR]: Local grid connector enabled"); } @@ -120,6 +126,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid public void PostInitialise() { + if (m_MainInstance == this) + { + MainConsole.Instance.Commands.AddCommand("LocalGridConnector", false, "show neighbours", + "show neighbours", + "Shows the local regions' neighbours", NeighboursCommand); + } } public void Close() @@ -128,14 +140,26 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid public void AddRegion(Scene scene) { - if (!m_Enabled) - return; + if (m_Enabled) + scene.RegisterModuleInterface(this); + + if (m_MainInstance == this) + { + if (m_LocalCache.ContainsKey(scene.RegionInfo.RegionID)) + m_log.ErrorFormat("[LOCAL GRID CONNECTOR]: simulator seems to have more than one region with the same UUID. Please correct this!"); + else + m_LocalCache.Add(scene.RegionInfo.RegionID, new RegionCache(scene)); - scene.RegisterModuleInterface(this); + } } public void RemoveRegion(Scene scene) { + if (m_MainInstance == this) + { + m_LocalCache[scene.RegionInfo.RegionID].Clear(); + m_LocalCache.Remove(scene.RegionInfo.RegionID); + } } public void RegionLoaded(Scene scene) @@ -158,7 +182,18 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid public List GetNeighbours(UUID scopeID, UUID regionID) { - return m_GridService.GetNeighbours(scopeID, regionID); + if (m_LocalCache.ContainsKey(regionID)) + { + return m_LocalCache[regionID].GetNeighbours(); + } + else + { + m_log.WarnFormat("[LOCAL GRID CONNECTOR]: GetNeighbours: Requested region {0} is not on this sim", regionID); + return new List(); + } + + // Don't go to the DB + //return m_GridService.GetNeighbours(scopeID, regionID); } public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID) @@ -187,5 +222,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid } #endregion + + public void NeighboursCommand(string module, string[] cmdparams) + { + foreach (KeyValuePair kvp in m_LocalCache) + { + m_log.InfoFormat("*** Neighbours of {0} {1} ***", kvp.Key, kvp.Value.RegionName); + List regions = kvp.Value.GetNeighbours(); + foreach (GridRegion r in regions) + m_log.InfoFormat(" {0} @ {1}={2}", r.RegionName, r.RegionLocX / Constants.RegionSize, r.RegionLocY / Constants.RegionSize); + } + } } } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs new file mode 100644 index 0000000..ea205a2 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.Reflection; + +using OpenSim.Region.Framework.Scenes; +using OpenSim.Services.Interfaces; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; + +using log4net; + +namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid +{ + public class RegionCache + { + private static readonly ILog m_log = + LogManager.GetLogger( + MethodBase.GetCurrentMethod().DeclaringType); + + private Scene m_scene; + private Dictionary m_neighbours = new Dictionary(); + + public string RegionName + { + get { return m_scene.RegionInfo.RegionName; } + } + + public RegionCache(Scene s) + { + m_scene = s; + m_scene.EventManager.OnRegionUp += OnRegionUp; + } + + private void OnRegionUp(GridRegion otherRegion) + { + m_log.DebugFormat("[REGION CACHE]: (on region {0}) Region {1} is up @ {2}-{3}", + m_scene.RegionInfo.RegionName, otherRegion.RegionName, otherRegion.RegionLocX, otherRegion.RegionLocY); + + m_neighbours[otherRegion.RegionHandle] = otherRegion; + } + + public void Clear() + { + m_scene.EventManager.OnRegionUp -= OnRegionUp; + m_neighbours.Clear(); + } + + public List GetNeighbours() + { + return new List(m_neighbours.Values); + } + } +} diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs index 91a808b..72c00fc 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs @@ -104,6 +104,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid public void PostInitialise() { + if (m_LocalGridService != null) + ((ISharedRegionModule)m_LocalGridService).PostInitialise(); } public void Close() @@ -112,14 +114,17 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid public void AddRegion(Scene scene) { - if (!m_Enabled) - return; + if (m_Enabled) + scene.RegisterModuleInterface(this); - scene.RegisterModuleInterface(this); + if (m_LocalGridService != null) + ((ISharedRegionModule)m_LocalGridService).AddRegion(scene); } public void RemoveRegion(Scene scene) { + if (m_LocalGridService != null) + ((ISharedRegionModule)m_LocalGridService).RemoveRegion(scene); } public void RegionLoaded(Scene scene) @@ -146,7 +151,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid return false; } - // Let's not override GetNeighbours -- let's get them all from the grid server + // Let's override GetNeighbours completely -- never go to the grid server + // Neighbours are/should be cached locally + // For retrieval from the DB, caller should call GetRegionByPosition + public override List GetNeighbours(UUID scopeID, UUID regionID) + { + return m_LocalGridService.GetNeighbours(scopeID, regionID); + } public override GridRegion GetRegionByUUID(UUID scopeID, UUID regionID) { 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 { diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs index 3294ceb..4a2db5e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs @@ -455,14 +455,12 @@ namespace OpenSim.Region.Framework.Scenes // So we're temporarily going back to the old method of grabbing it from the Grid Server Every time :/ if (m_regionInfo != null) { - neighbours = - RequestNeighbours(avatar.Scene,m_regionInfo.RegionLocX, m_regionInfo.RegionLocY); + neighbours = RequestNeighbours(avatar.Scene,m_regionInfo.RegionLocX, m_regionInfo.RegionLocY); } else { m_log.Debug("[ENABLENEIGHBOURCHILDAGENTS]: m_regionInfo was null in EnableNeighbourChildAgents, is this a NPC?"); } - /// We need to find the difference between the new regions where there are no child agents /// and the regions where there are already child agents. We only send notification to the former. -- cgit v1.1 From c99b363f81331988ede8fa5e19306073cbb1c58b Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 27 Sep 2009 13:59:00 -0700 Subject: Added missing IHyperlinkService. --- OpenSim/Services/Interfaces/IHyperlink.cs | 49 +++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 OpenSim/Services/Interfaces/IHyperlink.cs (limited to 'OpenSim') diff --git a/OpenSim/Services/Interfaces/IHyperlink.cs b/OpenSim/Services/Interfaces/IHyperlink.cs new file mode 100644 index 0000000..ed3ff23 --- /dev/null +++ b/OpenSim/Services/Interfaces/IHyperlink.cs @@ -0,0 +1,49 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using OpenSim.Framework; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; + +using OpenMetaverse; + +namespace OpenSim.Services.Interfaces +{ + public interface IHyperlinkService + { + GridRegion TryLinkRegion(IClientAPI client, string regionDescriptor); + GridRegion GetHyperlinkRegion(ulong handle); + ulong FindRegionHandle(ulong handle); + + bool SendUserInformation(GridRegion region, AgentCircuitData aCircuit); + void AdjustUserInformation(AgentCircuitData aCircuit); + + bool CheckUserAtEntry(UUID userID, UUID sessionID, out bool comingHome); + void AcceptUser(ForeignUserProfileData user, GridRegion home); + + bool IsLocalUser(UUID userID); + } +} -- cgit v1.1 From 689eea3bad7a7dd7fa8dfdacacd891e1d390e51e Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 27 Sep 2009 15:06:44 -0700 Subject: Guarding the methods under if (m_Enabled) --- .../CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs index c8062d7..1eb481e 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs @@ -135,7 +135,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid public void PostInitialise() { - ((ISharedRegionModule)m_GridServiceConnector).PostInitialise(); + if (m_Enabled) + ((ISharedRegionModule)m_GridServiceConnector).PostInitialise(); } public void Close() @@ -157,8 +158,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid public void RemoveRegion(Scene scene) { - m_LocalScenes.Remove(scene.RegionInfo.RegionHandle); - ((ISharedRegionModule)m_GridServiceConnector).RemoveRegion(scene); + if (m_Enabled) + { + m_LocalScenes.Remove(scene.RegionInfo.RegionHandle); + ((ISharedRegionModule)m_GridServiceConnector).RemoveRegion(scene); + } } public void RegionLoaded(Scene scene) -- cgit v1.1 From e15a9b848413115644d3a6dd920e146b9589b639 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 27 Sep 2009 17:01:30 -0700 Subject: Fixed an issue with the PresenceModule in "gridmode", introduced by my fixing the notifications of the messaging service in standalone. --- OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs | 3 --- 1 file changed, 3 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs index 5a9b452..ad05bab 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs @@ -330,9 +330,6 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage private void NotifyMessageServerOfStartup(Scene scene) { - if (m_Scenes[0].CommsManager.NetworkServersInfo.MessagingURL == string.Empty) - return; - Hashtable xmlrpcdata = new Hashtable(); xmlrpcdata["RegionUUID"] = scene.RegionInfo.RegionID.ToString(); ArrayList SendParams = new ArrayList(); -- cgit v1.1 From 0766b6dc34b972026846360767a20e2f11325c70 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 27 Sep 2009 20:44:43 -0700 Subject: Fixed the connection from User server to GridServer. --- .../Grid/UserServer.Modules/UserLoginService.cs | 62 +++++++++++----------- 1 file changed, 30 insertions(+), 32 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Grid/UserServer.Modules/UserLoginService.cs b/OpenSim/Grid/UserServer.Modules/UserLoginService.cs index 01d5537..2ca5ada 100644 --- a/OpenSim/Grid/UserServer.Modules/UserLoginService.cs +++ b/OpenSim/Grid/UserServer.Modules/UserLoginService.cs @@ -34,6 +34,7 @@ using System.Text.RegularExpressions; using log4net; using Nwc.XmlRpc; using OpenMetaverse; +using Nini.Config; using OpenSim.Data; using OpenSim.Framework; using OpenSim.Framework.Communications; @@ -42,6 +43,9 @@ using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Capabilities; using OpenSim.Framework.Servers; using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Services.Interfaces; +using OpenSim.Services.Connectors; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; namespace OpenSim.Grid.UserServer.Modules { @@ -63,6 +67,8 @@ namespace OpenSim.Grid.UserServer.Modules public UserConfig m_config; private readonly IRegionProfileRouter m_regionProfileService; + private IGridService m_GridService; + protected BaseHttpServer m_httpServer; public UserLoginService( @@ -76,6 +82,8 @@ namespace OpenSim.Grid.UserServer.Modules m_defaultHomeY = m_config.DefaultY; m_interInventoryService = inventoryService; m_regionProfileService = regionProfileService; + + m_GridService = new GridServicesConnector(config.GridServerURL.ToString()); } public void RegisterHandlers(BaseHttpServer httpServer, bool registerLLSDHandler, bool registerOpenIDHandlers) @@ -203,47 +211,37 @@ namespace OpenSim.Grid.UserServer.Modules protected override RegionInfo RequestClosestRegion(string region) { - RegionProfileData profileData = m_regionProfileService.RequestSimProfileData(region, - m_config.GridServerURL, m_config.GridSendKey, m_config.GridRecvKey); - - if (profileData != null) - { - return profileData.ToRegionInfo(); - } - else - { - return null; - } + return GridRegionToRegionInfo(m_GridService.GetRegionByName(UUID.Zero, region)); } protected override RegionInfo GetRegionInfo(ulong homeRegionHandle) { - RegionProfileData profileData = m_regionProfileService.RequestSimProfileData(homeRegionHandle, - m_config.GridServerURL, m_config.GridSendKey, - m_config.GridRecvKey); - if (profileData != null) - { - return profileData.ToRegionInfo(); - } - else - { - return null; - } + uint x = 0, y = 0; + Utils.LongToUInts(homeRegionHandle, out x, out y); + return GridRegionToRegionInfo(m_GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y)); } protected override RegionInfo GetRegionInfo(UUID homeRegionId) { - RegionProfileData profileData = m_regionProfileService.RequestSimProfileData(homeRegionId, - m_config.GridServerURL, m_config.GridSendKey, - m_config.GridRecvKey); - if (profileData != null) - { - return profileData.ToRegionInfo(); - } - else - { + return GridRegionToRegionInfo(m_GridService.GetRegionByUUID(UUID.Zero, homeRegionId)); + } + + private RegionInfo GridRegionToRegionInfo(GridRegion gregion) + { + if (gregion == null) return null; - } + + RegionInfo rinfo = new RegionInfo(); + rinfo.ExternalHostName = gregion.ExternalHostName; + rinfo.HttpPort = gregion.HttpPort; + rinfo.InternalEndPoint = gregion.InternalEndPoint; + rinfo.RegionID = gregion.RegionID; + rinfo.RegionLocX = (uint)(gregion.RegionLocX / Constants.RegionSize); + rinfo.RegionLocY = (uint)(gregion.RegionLocY / Constants.RegionSize); + rinfo.RegionName = gregion.RegionName; + rinfo.ScopeID = gregion.ScopeID; + + return rinfo; } protected override bool PrepareLoginToRegion(RegionInfo regionInfo, UserProfileData user, LoginResponse response, IPEndPoint remoteClient) -- cgit v1.1 From 73a61a8a32f18f4a003cbf0f4d6e876badea69ce Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 27 Sep 2009 21:14:31 -0700 Subject: Fixed small bug in having to deal with RegionInfo's ServerURI, which wasn't being set. --- OpenSim/Grid/UserServer.Modules/UserLoginService.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim') diff --git a/OpenSim/Grid/UserServer.Modules/UserLoginService.cs b/OpenSim/Grid/UserServer.Modules/UserLoginService.cs index 2ca5ada..66fc24e 100644 --- a/OpenSim/Grid/UserServer.Modules/UserLoginService.cs +++ b/OpenSim/Grid/UserServer.Modules/UserLoginService.cs @@ -240,6 +240,7 @@ namespace OpenSim.Grid.UserServer.Modules rinfo.RegionLocY = (uint)(gregion.RegionLocY / Constants.RegionSize); rinfo.RegionName = gregion.RegionName; rinfo.ScopeID = gregion.ScopeID; + rinfo.ServerURI = "http://" + gregion.ExternalHostName + ":" + gregion.HttpPort.ToString(); return rinfo; } -- cgit v1.1 From 0f05bbb4a20224492febf17604fa23ef2486fa1a Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 28 Sep 2009 05:54:37 -0700 Subject: Deleted some files that aren't being used anymore. --- .../CreateCommsManager/CreateCommsManagerPlugin.cs | 1 - OpenSim/Framework/Communications/IGridServices.cs | 92 ---------------------- OpenSim/Framework/Communications/IHyperlink.cs | 38 --------- 3 files changed, 131 deletions(-) delete mode 100644 OpenSim/Framework/Communications/IGridServices.cs delete mode 100644 OpenSim/Framework/Communications/IHyperlink.cs (limited to 'OpenSim') diff --git a/OpenSim/ApplicationPlugins/CreateCommsManager/CreateCommsManagerPlugin.cs b/OpenSim/ApplicationPlugins/CreateCommsManager/CreateCommsManagerPlugin.cs index cd93bea..20cec04 100644 --- a/OpenSim/ApplicationPlugins/CreateCommsManager/CreateCommsManagerPlugin.cs +++ b/OpenSim/ApplicationPlugins/CreateCommsManager/CreateCommsManagerPlugin.cs @@ -69,7 +69,6 @@ namespace OpenSim.ApplicationPlugins.CreateCommsManager protected CommunicationsManager m_commsManager; protected GridInfoService m_gridInfoService; - protected IHyperlink HGServices = null; protected IRegionCreator m_regionCreator; diff --git a/OpenSim/Framework/Communications/IGridServices.cs b/OpenSim/Framework/Communications/IGridServices.cs deleted file mode 100644 index 6365919..0000000 --- a/OpenSim/Framework/Communications/IGridServices.cs +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System.Collections.Generic; -using OpenMetaverse; - -namespace OpenSim.Framework.Communications -{ - public interface IGridServices - { - string gdebugRegionName { get; set; } - - /// - /// If true, then regions will accept logins from the user service. If false, then they will not. - /// - bool RegionLoginsEnabled { get; set; } - - /// - /// Register a region with the grid service. - /// - /// - /// - /// Thrown if region registration failed - RegionCommsListener RegisterRegion(RegionInfo regionInfos); - - /// - /// Deregister a region with the grid service. - /// - /// - /// - /// Thrown if region deregistration failed - bool DeregisterRegion(RegionInfo regionInfo); - - /// - /// Get information about the regions neighbouring the given co-ordinates. - /// - /// - /// - /// - List RequestNeighbours(uint x, uint y); - - RegionInfo RequestNeighbourInfo(ulong regionHandle); - RegionInfo RequestNeighbourInfo(UUID regionID); - RegionInfo RequestNeighbourInfo(string name); - RegionInfo RequestNeighbourInfo(string host, uint port); - - RegionInfo RequestClosestRegion(string regionName); - Dictionary GetGridSettings(); - List RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY); - // not complete yet, only contains the fields needed for ParcelInfoReqeust - LandData RequestLandData(ulong regionHandle, uint x, uint y); - - /// - /// Get information about regions starting with the provided name. - /// - /// - /// The name to match against. - /// - /// - /// The maximum number of results to return. - /// - /// - /// A list of s of regions with matching name. If the - /// grid-server couldn't be contacted or returned an error, return null. - /// - List RequestNamedRegions(string name, int maxNumber); - } -} diff --git a/OpenSim/Framework/Communications/IHyperlink.cs b/OpenSim/Framework/Communications/IHyperlink.cs deleted file mode 100644 index 5057386..0000000 --- a/OpenSim/Framework/Communications/IHyperlink.cs +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -namespace OpenSim.Framework.Communications -{ - public interface IHyperlink - { - bool IsHyperlinkRegion(ulong handle); - RegionInfo GetHyperlinkRegion(ulong handle); - ulong FindRegionHandle(ulong handle); - bool SendUserInformation(RegionInfo region, AgentCircuitData aCircuit); - void AdjustUserInformation(AgentCircuitData aCircuit); - } -} -- cgit v1.1 From 69da82b39fbb9952e29f57ff08f731b14f969f04 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 28 Sep 2009 06:44:57 -0700 Subject: Bug fix in SynchronousRestFormsRequester -- Write instead of WriteLine, which was causing an extra \n to be written into the buffer. --- OpenSim/Framework/Servers/HttpServer/SynchronousRestFormsRequester.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/Servers/HttpServer/SynchronousRestFormsRequester.cs b/OpenSim/Framework/Servers/HttpServer/SynchronousRestFormsRequester.cs index ebb2691..a0d4008 100644 --- a/OpenSim/Framework/Servers/HttpServer/SynchronousRestFormsRequester.cs +++ b/OpenSim/Framework/Servers/HttpServer/SynchronousRestFormsRequester.cs @@ -59,11 +59,11 @@ namespace OpenSim.Framework.Servers.HttpServer int length = 0; using (StreamWriter writer = new StreamWriter(buffer)) { - writer.WriteLine(obj); + writer.Write(obj); writer.Flush(); - length = (int)buffer.Length; } + length = (int)obj.Length; request.ContentLength = length; Stream requestStream = request.GetRequestStream(); -- cgit v1.1 From 500cd3505a4213363e001426f2286c1a958d345c Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 28 Sep 2009 07:20:38 -0700 Subject: Added RegionSecret to GridRegion, and corresponding saving/retrieval from DB layer. This sounds fishy to me, but it's what's used to make external currency modules work, for now. --- OpenSim/Services/Interfaces/IGridService.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs index c5495fb..46a7f09 100644 --- a/OpenSim/Services/Interfaces/IGridService.cs +++ b/OpenSim/Services/Interfaces/IGridService.cs @@ -146,6 +146,7 @@ namespace OpenSim.Services.Interfaces public UUID TerrainImage = UUID.Zero; public byte Access; public int Maturity; + public string RegionSecret; public GridRegion() { @@ -189,6 +190,7 @@ namespace OpenSim.Services.Interfaces TerrainImage = ConvertFrom.RegionSettings.TerrainImageID; Access = ConvertFrom.AccessLevel; Maturity = ConvertFrom.RegionSettings.Maturity; + RegionSecret = ConvertFrom.regionSecret; } public GridRegion(GridRegion ConvertFrom) @@ -204,6 +206,7 @@ namespace OpenSim.Services.Interfaces TerrainImage = ConvertFrom.TerrainImage; Access = ConvertFrom.Access; Maturity = ConvertFrom.Maturity; + RegionSecret = ConvertFrom.RegionSecret; } /// @@ -287,6 +290,7 @@ namespace OpenSim.Services.Interfaces kvp["serverPort"] = InternalEndPoint.Port.ToString(); kvp["regionMapTexture"] = TerrainImage.ToString(); kvp["access"] = Access.ToString(); + kvp["regionSecret"] = RegionSecret; // Maturity doesn't seem to exist in the DB return kvp; } @@ -333,14 +337,14 @@ namespace OpenSim.Services.Interfaces ServerURI = (string)kvp["serverURI"]; if (kvp.ContainsKey("regionMapTexture")) - { UUID.TryParse((string)kvp["regionMapTexture"], out TerrainImage); - } if (kvp.ContainsKey("access")) - { - Access = Byte.Parse((string)kvp["access"]); ; - } + Access = Byte.Parse((string)kvp["access"]); + + if (kvp.ContainsKey("regionSecret")) + RegionSecret =(string)kvp["regionSecret"]; + } } -- cgit v1.1 From 3091e5db9d6d46191d52a21ef5c25feb76ed703a Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 28 Sep 2009 07:53:52 -0700 Subject: Fixed bug in user server related to region's serverURI. --- OpenSim/Grid/UserServer.Modules/UserLoginService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Grid/UserServer.Modules/UserLoginService.cs b/OpenSim/Grid/UserServer.Modules/UserLoginService.cs index 66fc24e..47bbeca 100644 --- a/OpenSim/Grid/UserServer.Modules/UserLoginService.cs +++ b/OpenSim/Grid/UserServer.Modules/UserLoginService.cs @@ -240,7 +240,7 @@ namespace OpenSim.Grid.UserServer.Modules rinfo.RegionLocY = (uint)(gregion.RegionLocY / Constants.RegionSize); rinfo.RegionName = gregion.RegionName; rinfo.ScopeID = gregion.ScopeID; - rinfo.ServerURI = "http://" + gregion.ExternalHostName + ":" + gregion.HttpPort.ToString(); + rinfo.ServerURI = gregion.ServerURI; return rinfo; } -- cgit v1.1 From 9bdb585a93f824223f20f248e1411ba6da760624 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 28 Sep 2009 10:56:05 -0700 Subject: Added Protocol versions back, this time in a range model. --- OpenSim/Server/Base/ProtocolVersions.cs | 56 ++++++++++++++++++++++ .../Server/Handlers/Grid/GridServerPostHandler.cs | 18 +++++++ .../Connectors/Grid/GridServiceConnector.cs | 3 +- 3 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 OpenSim/Server/Base/ProtocolVersions.cs (limited to 'OpenSim') diff --git a/OpenSim/Server/Base/ProtocolVersions.cs b/OpenSim/Server/Base/ProtocolVersions.cs new file mode 100644 index 0000000..6df27b7 --- /dev/null +++ b/OpenSim/Server/Base/ProtocolVersions.cs @@ -0,0 +1,56 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +namespace OpenSim.Server.Base +{ + public class ProtocolVersions + { + /// + /// This is the external protocol versions. It is separate from the OpenSimulator project version. + /// + /// These version numbers should be increased by 1 every time a code + /// change in the Service.Connectors and Server.Handlers, espectively, + /// makes the previous OpenSimulator revision incompatible + /// with the new revision. + /// + /// Changes which are compatible with an older revision (e.g. older revisions experience degraded functionality + /// but not outright failure) do not need a version number increment. + /// + /// Having this version number allows the grid service to reject connections from regions running a version + /// of the code that is too old. + /// + /// + + // The range of acceptable servers for client-side connectors + public readonly static int ClientProtocolVersionMin = 0; + public readonly static int ClientProtocolVersionMax = 0; + + // The range of acceptable clients in server-side handlers + public readonly static int ServerProtocolVersionMin = 0; + public readonly static int ServerProtocolVersionMax = 0; + } +} diff --git a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs index 711639f..3d72fec 100644 --- a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs @@ -118,6 +118,24 @@ namespace OpenSim.Server.Handlers.Grid else m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to register region"); + int versionNumberMin = 0, versionNumberMax = 0; + if (request.ContainsKey("VERSIONMIN")) + Int32.TryParse(request["VERSIONMIN"], out versionNumberMin); + else + m_log.WarnFormat("[GRID HANDLER]: no minimum protocol version in request to register region"); + + if (request.ContainsKey("VERSIONMAX")) + Int32.TryParse(request["VERSIONMAX"], out versionNumberMax); + else + m_log.WarnFormat("[GRID HANDLER]: no maximum protocol version in request to register region"); + + // Check the protocol version + if ((versionNumberMin > ProtocolVersions.ServerProtocolVersionMax && versionNumberMax < ProtocolVersions.ServerProtocolVersionMax)) + { + // Can't do, there is no overlap in the acceptable ranges + FailureResult(); + } + Dictionary rinfoData = new Dictionary(); foreach (KeyValuePair kvp in request) rinfoData[kvp.Key] = kvp.Value; diff --git a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs index 748892a..ba46b0d 100644 --- a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs +++ b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs @@ -94,7 +94,8 @@ namespace OpenSim.Services.Connectors sendData[kvp.Key] = (string)kvp.Value; sendData["SCOPEID"] = scopeID.ToString(); - + sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString(); + sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString(); sendData["METHOD"] = "register"; string reqString = ServerUtils.BuildQueryString(sendData); -- cgit v1.1 From 276b0a0cbe2cec5ff0e937a2d2eda6b48b5691b2 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 28 Sep 2009 11:17:34 -0700 Subject: Forgot a return statement. --- OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs index 3d72fec..e751365 100644 --- a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs @@ -133,7 +133,7 @@ namespace OpenSim.Server.Handlers.Grid if ((versionNumberMin > ProtocolVersions.ServerProtocolVersionMax && versionNumberMax < ProtocolVersions.ServerProtocolVersionMax)) { // Can't do, there is no overlap in the acceptable ranges - FailureResult(); + return FailureResult(); } Dictionary rinfoData = new Dictionary(); -- cgit v1.1