First pass at the heart surgery for grid services. Compiles and runs minimally. A few bugs to catch now.

0.6.8-post-fixes
Diva Canto 2009-09-26 07:48:21 -07:00
parent eed8a61559
commit 5757afe766
27 changed files with 441 additions and 980 deletions

View File

@ -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)
{
}

View File

@ -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 <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>]");
m_log.Info("Usage: link-region <Xloc> <Yloc> <HostName> <HttpPort> [<LocalName>]");
m_log.Info("Usage: link-region <URI_of_xml> [<exclude>]");
}
private static void UnlinkRegionCmdUsage()
{
m_log.Info("Usage: unlink-region <HostName>:<HttpPort>");
m_log.Info("Usage: unlink-region <LocalName>");
}
}
}

View File

@ -755,11 +755,6 @@ namespace OpenSim
}
break;
case "link-region":
case "unlink-region":
case "link-mapping":
HGCommands.RunHGCommand(command, cmdparams, m_sceneManager.CurrentOrFirstScene);
break;
}
}

View File

@ -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

View File

@ -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<ulong, Scene> m_scenes = new Dictionary<ulong,Scene>();
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<IMessageTransferModule>();
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<UUID> tpdAway = new List<UUID>();
// 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);

View File

@ -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
/// <param name="reginfo">RegionInfo we pull the data out of to send the request to</param>
/// <param name="xmlrpcdata">The Instant Message data Hashtable</param>
/// <returns>Bool if the message was successfully delivered at the other side.</returns>
protected virtual bool doIMSending(RegionInfo reginfo, Hashtable xmlrpcdata)
protected virtual bool doIMSending(GridRegion reginfo, Hashtable xmlrpcdata)
{
ArrayList SendParams = new ArrayList();

View File

@ -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);

View File

@ -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);
}
/// <summary>
/// Returns an XML RPC response to a simulator profile request
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
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<RegionInfo> 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;
}
}
}

View File

@ -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<MapBlockData> mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks(minX - 4, minY - 4, maxX + 4, maxY + 4);
List<MapBlockData> mapBlocks = new List<MapBlockData>();
List<GridRegion> 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);

View File

@ -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<IGridService>(this);
scene.RegisterModuleInterface<IHyperlinkService>(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
}

View File

@ -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

View File

@ -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<ILandService>(this);
}

View File

@ -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<INeighbourService>(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);
}

View File

@ -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<ILandService>();
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");

View File

@ -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<RegionInfo> regionInfos = m_scene.SceneGridService.RequestNamedRegions(mapName, 20);
List<GridRegion> 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>();
RegionInfo info = m_scene.SceneGridService.RequestClosestRegion(mapName);
regionInfos = new List<GridRegion>();
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<IHyperlinkService>();
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

View File

@ -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<MapBlockData> mapBlocks;
List<MapBlockData> mapBlocks = new List<MapBlockData>(); ;
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<GridRegion> 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<MapBlockData> response = new List<MapBlockData>();
// this should return one mapblock at most. But make sure: Look whether the one we requested is in there
List<MapBlockData> 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<GridRegion> 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<MapBlockData> mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks(minX - 4, minY - 4, maxX + 4, maxY + 4);
List<MapBlockData> mapBlocks = new List<MapBlockData>();
List<GridRegion> 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<MapBlockData> 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<MapBlockData> mapBlocks = new List<MapBlockData>();
List<GridRegion> 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<AssetBase> textures = new List<AssetBase>();
List<Image> bitImages = new List<Image>();
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)

View File

@ -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;
}
}
/// <summary>
/// Cope with this viewer limitation.
/// </summary>
/// <param name="regInfo"></param>
/// <returns></returns>
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;
}
}
}

View File

@ -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;

View File

@ -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)
{

View File

@ -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<IGridService>();
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<INeighbourService>(), RegionInfo);
Dictionary<string, string> dGridSettings = m_sceneGridService.GetGridSettings();
//Dictionary<string, string> 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);
// }
//}
}
/// <summary>
@ -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);
}
/// <summary>
@ -3556,30 +3590,6 @@ namespace OpenSim.Region.Framework.Scenes
m_sceneGridService.EnableNeighbourChildAgents(presence, m_neighbours);
}
/// <summary>
/// Requests information about this region from gridcomms
/// </summary>
/// <param name="regionHandle"></param>
/// <returns></returns>
public RegionInfo RequestNeighbouringRegionInfo(ulong regionHandle)
{
return m_sceneGridService.RequestNeighbouringRegionInfo(regionHandle);
}
/// <summary>
/// Requests textures for map from minimum region to maximum region in world cordinates
/// </summary>
/// <param name="remoteClient"></param>
/// <param name="minX"></param>
/// <param name="minY"></param>
/// <param name="maxX"></param>
/// <param name="maxY"></param>
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);
}
/// <summary>
/// Tries to teleport agent to other region.
/// </summary>
@ -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
/// <param name="position"></param>
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)

View File

@ -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<UUID>();
}
public void SetScene(Scene s)
{
m_scene = s;
m_regionInfo = s.RegionInfo;
m_interregionCommsOut = m_scene.RequestModuleInterface<IInterregionCommsOut>();
}
/// <summary>
/// Register a region with the grid
/// </summary>
@ -138,40 +147,30 @@ namespace OpenSim.Region.Framework.Scenes
/// <exception cref="System.Exception">Thrown if region registration fails.</exception>
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());
//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");
}
}
/// <summary>
/// Returns a region with the name closest to string provided
/// </summary>
/// <param name="name">Partial Region Name for matching</param>
/// <returns>Region Information for the region</returns>
public RegionInfo RequestClosestRegion(string name)
{
return m_commsProvider.GridService.RequestClosestRegion(name);
// 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");
//}
}
/// <summary>
@ -180,30 +179,31 @@ namespace OpenSim.Region.Framework.Scenes
/// </summary>
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
/// <param name="a"></param>
/// <param name="regionHandle"></param>
/// <param name="endPoint"></param>
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<SimpleRegionInfo> 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<SimpleRegionInfo> RequestNeighbors(Scene pScene, uint pRegionLocX, uint pRegionLocY)
public List<GridRegion> 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<eastBorders.Length;i++)
for (int i = 0; i < eastBorders.Length; i++)
{
extent.X = (eastBorders[i].BorderLine.Z > extent.X) ? eastBorders[i].BorderLine.Z : extent.X;
}
for (int i=0;i<northBorders.Length;i++)
for (int i = 0; i < northBorders.Length; i++)
{
extent.Y = (northBorders[i].BorderLine.Z > extent.Y) ? northBorders[i].BorderLine.Z : extent.Y;
}
List<SimpleRegionInfo> neighbourList = new List<SimpleRegionInfo>();
// 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<endX;i++)
{
for (int j=startY;j<endY;j++)
{
// Skip CurrentRegion
if (i == (int)pRegionLocX && j == (int)pRegionLocY)
continue;
List<GridRegion> neighbours = m_scene.GridService.GetRegionRange(m_regionInfo.ScopeID, startX, endX, startY, endY);
neighbours.RemoveAll(delegate(GridRegion r) { return r.RegionID == m_regionInfo.RegionID; });
ulong regionHandle = Util.UIntsToLong((uint)(i * Constants.RegionSize),
(uint)(j * Constants.RegionSize));
RegionInfo neighborreg = m_commsProvider.GridService.RequestNeighbourInfo(regionHandle);
if (neighborreg != null)
{
neighbourList.Add(neighborreg);
}
}
}
return neighbourList;
return neighbours;
//SimpleRegionInfo regionData = m_commsProvider.GridService.RequestNeighbourInfo()
//return m_commsProvider.GridService.RequestNeighbours(pRegionLocX, pRegionLocY);
}
@ -482,23 +461,24 @@ namespace OpenSim.Region.Framework.Scenes
/// </summary>
public void EnableNeighbourChildAgents(ScenePresence avatar, List<RegionInfo> lstneighbours)
{
List<SimpleRegionInfo> neighbours = new List<SimpleRegionInfo>();
//List<SimpleRegionInfo> neighbours = new List<SimpleRegionInfo>();
List<GridRegion> neighbours = new List<GridRegion>();
//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<AgentCircuitData> cagents = new List<AgentCircuitData>();
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.
/// </summary>
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
}
}
/// <summary>
/// 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.
/// </summary>
public void InformNeighborsThatRegionisUp(INeighbourService neighbourService, RegionInfo region)
{
//m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: Sending InterRegion Notification that region is up " + region.RegionName);
List<SimpleRegionInfo> neighbours = new List<SimpleRegionInfo>();
List<GridRegion> neighbours = new List<GridRegion>();
// 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);
/// <summary>
@ -822,41 +802,6 @@ namespace OpenSim.Region.Framework.Scenes
}
}
/// <summary>
/// Helper function to request neighbors from grid-comms
/// </summary>
/// <param name="regionHandle"></param>
/// <returns></returns>
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);
}
/// <summary>
/// Helper function to request neighbors from grid-comms
/// </summary>
/// <param name="regionID"></param>
/// <returns></returns>
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);
}
/// <summary>
/// Requests map blocks in area of minX, maxX, minY, MaxY in world cordinates
/// </summary>
/// <param name="minX"></param>
/// <param name="minY"></param>
/// <param name="maxX"></param>
/// <param name="maxY"></param>
public virtual void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY)
{
List<MapBlockData> mapBlocks;
mapBlocks = m_commsProvider.GridService.RequestNeighbourMapBlocks(minX - 4, minY - 4, minX + 4, minY + 4);
remoteClient.SendMapBlock(mapBlocks, 0);
}
/// <summary>
/// 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<ulong> NeighbourHandles(List<SimpleRegionInfo> neighbours)
private List<ulong> NeighbourHandles(List<GridRegion> neighbours)
{
List<ulong> handles = new List<ulong>();
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<string, string> 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<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY)
{
return m_commsProvider.GridService.RequestNeighbourMapBlocks(minX, minY, maxX, maxY);
}
public List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(UUID queryID, string query)
{
return m_commsProvider.GenerateAgentPickerRequestResponse(queryID, query);
}
public List<RegionInfo> RequestNamedRegions(string name, int maxNumber)
public List<GridRegion> 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<ulong> handles)

View File

@ -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)
{

View File

@ -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<SimpleRegionInfo> neighbors = World.CommsManager.GridService.RequestNeighbours(World.RegionInfo.RegionLocX, World.RegionInfo.RegionLocY);
List<GridRegion> 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)

View File

@ -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<IHyperlinkService>();
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();

View File

@ -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);

View File

@ -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);

View File

@ -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"]); ;
}
}
}