Moved RegionName from RegionInfo to SimpleRegionInfo.

remotes/origin/0.6.7-post-fixes
Diva Canto 2009-09-22 14:46:05 -07:00
parent 0fc2b73e7b
commit ffd30b8ac3
6 changed files with 365 additions and 328 deletions

View File

@ -64,6 +64,13 @@ namespace OpenSim.Framework
}
protected string m_serverURI;
public string RegionName
{
get { return m_regionName; }
set { m_regionName = value; }
}
protected string m_regionName = String.Empty;
protected bool Allow_Alternate_Ports;
public bool m_allow_alternate_ports;
protected string m_externalHostName;
@ -284,7 +291,6 @@ namespace OpenSim.Framework
public UUID originRegionID = UUID.Zero;
public string proxyUrl = "";
public int ProxyOffset = 0;
public string RegionName = String.Empty;
public string regionSecret = UUID.Random().ToString();
public string osSecret;

View File

@ -63,6 +63,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
// This is key-ed on agent ID
protected Dictionary<UUID, SimpleRegionInfo> m_knownRegions = new Dictionary<UUID, SimpleRegionInfo>();
protected Dictionary<UUID, ulong> m_HyperlinkHandles = new Dictionary<UUID, ulong>();
#region ISharedRegionModule
public Type ReplaceableInterface
@ -160,10 +162,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
if (regionInfo.RegionID.Equals(UUID.Zero))
{
m_log.Info("[HGrid]: Linking remote region " + regionInfo.ExternalHostName + ":" + regionInfo.HttpPort);
regionInfo.RegionID = m_HypergridServiceConnector.LinkRegion(regionInfo);
ulong regionHandle = 0;
regionInfo.RegionID = m_HypergridServiceConnector.LinkRegion(regionInfo, out regionHandle);
if (!regionInfo.RegionID.Equals(UUID.Zero))
{
m_HyperlinkRegions.Add(regionInfo.RegionID, regionInfo);
AddHyperlinkRegion(regionInfo, regionHandle);
m_log.Info("[HGrid]: Successfully linked to region_uuid " + regionInfo.RegionID);
// Try get the map image
@ -186,15 +189,18 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
// Try the hyperlink collection
if (m_HyperlinkRegions.ContainsKey(regionID))
{
m_HyperlinkRegions.Remove(regionID);
RemoveHyperlinkRegion(regionID);
return true;
}
// Try the foreign users home collection
if (m_knownRegions.ContainsKey(regionID))
{
m_knownRegions.Remove(regionID);
return true;
}
foreach (SimpleRegionInfo r in m_knownRegions.Values)
if (r.RegionID == regionID)
{
RemoveHyperlinkHomeRegion(regionID);
return true;
}
// Finally, try the normal route
return m_GridServiceConnector.DeregisterRegion(regionID);
}
@ -213,8 +219,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
return m_HyperlinkRegions[regionID];
// Try the foreign users home collection
if (m_knownRegions.ContainsKey(regionID))
return m_knownRegions[regionID];
foreach (SimpleRegionInfo r in m_knownRegions.Values)
if (r.RegionID == regionID)
return m_knownRegions[regionID];
// Finally, try the normal route
return m_GridServiceConnector.GetRegionByUUID(scopeID, regionID);
@ -249,20 +256,19 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
if (region != null)
return region;
// !!! Commenting until region name exists
//// Try the hyperlink collection
//foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values)
//{
// if (r.RegionName == regionName)
// return r;
//}
// Try the hyperlink collection
foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values)
{
if (r.RegionName == regionName)
return r;
}
//// Try the foreign users home collection
//foreach (SimpleRegionInfo r in m_knownRegions.Values)
//{
// if (r.RegionName == regionName)
// return r;
//}
// Try the foreign users home collection
foreach (SimpleRegionInfo r in m_knownRegions.Values)
{
if (r.RegionName == regionName)
return r;
}
return null;
}
@ -299,6 +305,35 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
#endregion
private void AddHyperlinkRegion(SimpleRegionInfo regionInfo, ulong regionHandle)
{
m_HyperlinkRegions.Add(regionInfo.RegionID, regionInfo);
m_HyperlinkHandles.Add(regionInfo.RegionID, regionHandle);
}
private void RemoveHyperlinkRegion(UUID regionID)
{
m_HyperlinkRegions.Remove(regionID);
m_HyperlinkHandles.Remove(regionID);
}
private void AddHyperlinkHomeRegion(UUID userID, SimpleRegionInfo regionInfo, ulong regionHandle)
{
m_knownRegions.Add(userID, regionInfo);
m_HyperlinkHandles.Add(regionInfo.RegionID, regionHandle);
}
private void RemoveHyperlinkHomeRegion(UUID regionID)
{
foreach (KeyValuePair<UUID, SimpleRegionInfo> kvp in m_knownRegions)
{
if (kvp.Value.RegionID == regionID)
{
m_knownRegions.Remove(kvp.Key);
}
}
m_HyperlinkHandles.Remove(regionID);
}
}
}

View File

@ -54,67 +54,63 @@ namespace OpenSim.Services.Connectors.Grid
m_AssetService = assService;
}
public UUID LinkRegion(SimpleRegionInfo info)
public UUID LinkRegion(SimpleRegionInfo info, out ulong realHandle)
{
UUID uuid = UUID.Zero;
realHandle = 0;
//Hashtable hash = new Hashtable();
//hash["region_name"] = info.RegionName;
Hashtable hash = new Hashtable();
hash["region_name"] = info.RegionName;
//IList paramList = new ArrayList();
//paramList.Add(hash);
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);
// }
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)
{
realHandle = Convert.ToUInt64((string)hash["handle"]);
m_log.Debug(">> HERE, realHandle: " + realHandle);
}
//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());
}
// }
// catch (Exception e)
// {
// m_log.Error("[HGrid]: Got exception while parsing hyperlink response " + e.StackTrace);
// }
//}
}
catch (Exception e)
{
m_log.Error("[HGrid]: Got exception while parsing hyperlink response " + e.StackTrace);
}
}
return uuid;
}

View File

@ -179,7 +179,7 @@ namespace OpenSim.Services.GridService
rdata.posY = (int)rinfo.RegionLocY;
rdata.RegionID = rinfo.RegionID;
rdata.Data = rinfo.ToKeyValuePairs();
//rdata.RegionName = rinfo.RegionName;
rdata.RegionName = rinfo.RegionName;
return rdata;
}
@ -190,7 +190,7 @@ namespace OpenSim.Services.GridService
rinfo.RegionLocX = (uint)rdata.posX;
rinfo.RegionLocY = (uint)rdata.posY;
rinfo.RegionID = rdata.RegionID;
//rinfo.RegionName = rdata.RegionName;
rinfo.RegionName = rdata.RegionName;
return rinfo;
}