add gridservice GetOnlineRegions()
This commit is contained in:
@@ -86,6 +86,7 @@ namespace OpenSim.Data
|
||||
List<RegionData> GetDefaultHypergridRegions(UUID scopeID);
|
||||
List<RegionData> GetFallbackRegions(UUID scopeID);
|
||||
List<RegionData> GetHyperlinks(UUID scopeID);
|
||||
List<RegionData> GetOnlineRegions(UUID scopeID);
|
||||
}
|
||||
|
||||
public class RegionDataDistanceCompare : IComparer<RegionData>
|
||||
|
||||
@@ -402,6 +402,11 @@ namespace OpenSim.Data.MySQL
|
||||
return Get((int)RegionFlags.Hyperlink, scopeID);
|
||||
}
|
||||
|
||||
public List<RegionData> GetOnlineRegions(UUID scopeID)
|
||||
{
|
||||
return Get((int)RegionFlags.RegionOnline, scopeID);
|
||||
}
|
||||
|
||||
private List<RegionData> Get(int regionFlags, UUID scopeID)
|
||||
{
|
||||
string command = "select * from `" + m_Realm + "` where (flags & " + regionFlags.ToString() + ") <> 0";
|
||||
|
||||
@@ -273,6 +273,11 @@ namespace OpenSim.Data.Null
|
||||
return Get((int)RegionFlags.Hyperlink, scopeID);
|
||||
}
|
||||
|
||||
public List<RegionData> GetOnlineRegions(UUID scopeID)
|
||||
{
|
||||
return Get((int)RegionFlags.RegionOnline, scopeID);
|
||||
}
|
||||
|
||||
private List<RegionData> Get(int regionFlags, UUID scopeID)
|
||||
{
|
||||
if (Instance != this)
|
||||
|
||||
@@ -431,6 +431,11 @@ namespace OpenSim.Data.PGSQL
|
||||
return Get((int)RegionFlags.Hyperlink, scopeID);
|
||||
}
|
||||
|
||||
public List<RegionData> GetOnlineRegions(UUID scopeID)
|
||||
{
|
||||
return Get((int)RegionFlags.RegionOnline, scopeID);
|
||||
}
|
||||
|
||||
private List<RegionData> Get(int regionFlags, UUID scopeID)
|
||||
{
|
||||
string sql = "SELECT * FROM " + m_Realm + " WHERE (\"flags\" & " + regionFlags.ToString() + ") <> 0";
|
||||
|
||||
@@ -452,7 +452,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
|
||||
{
|
||||
List<GridRegion> rinfo = m_LocalGridService.GetFallbackRegions(scopeID, x, y);
|
||||
//m_log.DebugFormat("[REMOTE GRID CONNECTOR]: Local GetFallbackRegions {0} found {1} regions", name, rinfo.Count);
|
||||
if(m_RemoteGridService != null)
|
||||
if (m_RemoteGridService != null)
|
||||
{
|
||||
List<GridRegion> grinfo = m_RemoteGridService.GetFallbackRegions(scopeID, x, y);
|
||||
|
||||
@@ -462,7 +462,29 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
|
||||
foreach (GridRegion r in grinfo)
|
||||
{
|
||||
m_RegionInfoCache.Cache(r);
|
||||
if (rinfo.Find(delegate(GridRegion gr) { return gr.RegionID == r.RegionID; }) == null)
|
||||
if (rinfo.Find(delegate (GridRegion gr) { return gr.RegionID == r.RegionID; }) == null)
|
||||
rinfo.Add(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
return rinfo;
|
||||
}
|
||||
|
||||
public List<GridRegion> GetOnlineRegions(UUID scopeID, int x, int y, int maxCount)
|
||||
{
|
||||
List<GridRegion> rinfo = m_LocalGridService.GetOnlineRegions(scopeID, x, y, maxCount);
|
||||
//m_log.DebugFormat("[REMOTE GRID CONNECTOR]: Local GetFallbackRegions {0} found {1} regions", name, rinfo.Count);
|
||||
if (m_RemoteGridService != null)
|
||||
{
|
||||
List<GridRegion> grinfo = m_RemoteGridService.GetOnlineRegions(scopeID, x, y, maxCount);
|
||||
|
||||
if (grinfo != null)
|
||||
{
|
||||
//m_log.DebugFormat("[REMOTE GRID CONNECTOR]: Remote GetOnlineRegions {0} found {1} regions", name, grinfo.Count);
|
||||
foreach (GridRegion r in grinfo)
|
||||
{
|
||||
m_RegionInfoCache.Cache(r);
|
||||
if (rinfo.Find(delegate (GridRegion gr) { return gr.RegionID == r.RegionID; }) == null)
|
||||
rinfo.Add(r);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,6 +117,9 @@ namespace OpenSim.Server.Handlers.Grid
|
||||
case "get_fallback_regions":
|
||||
return GetFallbackRegions(request);
|
||||
|
||||
case "get_online_regions":
|
||||
return GetOnlineRegions(request);
|
||||
|
||||
case "get_hyperlinks":
|
||||
return GetHyperlinks(request);
|
||||
|
||||
@@ -543,6 +546,53 @@ namespace OpenSim.Server.Handlers.Grid
|
||||
return Util.UTF8NoBomEncoding.GetBytes(xmlString);
|
||||
}
|
||||
|
||||
byte[] GetOnlineRegions(Dictionary<string, object> request)
|
||||
{
|
||||
UUID scopeID = UUID.Zero;
|
||||
object o;
|
||||
|
||||
if (request.TryGetValue("SCOPEID", out o))
|
||||
UUID.TryParse(o.ToString(), out scopeID);
|
||||
else
|
||||
m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get online regions");
|
||||
|
||||
int x = 0, y = 0, max = 0;
|
||||
if (request.TryGetValue("X", out o))
|
||||
Int32.TryParse(o.ToString(), out x);
|
||||
else
|
||||
m_log.WarnFormat("[GRID HANDLER]: no X in request to get online regions");
|
||||
if (request.TryGetValue("Y", out o))
|
||||
Int32.TryParse(o.ToString(), out y);
|
||||
else
|
||||
m_log.WarnFormat("[GRID HANDLER]: no Y in request to get online regions");
|
||||
if (request.TryGetValue("MC", out o))
|
||||
Int32.TryParse(o.ToString(), out max);
|
||||
else
|
||||
m_log.WarnFormat("[GRID HANDLER]: no Y in request to get online regions");
|
||||
|
||||
List<GridRegion> rinfos = null;
|
||||
if (max > 0)
|
||||
rinfos = m_GridService.GetOnlineRegions(scopeID, x, y, max);
|
||||
|
||||
Dictionary<string, object> result = new Dictionary<string, object>();
|
||||
if ((rinfos == null) || ((rinfos != null) && (rinfos.Count == 0)))
|
||||
result["result"] = "null";
|
||||
else
|
||||
{
|
||||
int i = 0;
|
||||
foreach (GridRegion rinfo in rinfos)
|
||||
{
|
||||
Dictionary<string, object> rinfoDict = rinfo.ToKeyValuePairs();
|
||||
result["region" + i] = rinfoDict;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
string xmlString = ServerUtils.BuildXmlResponse(result);
|
||||
|
||||
//m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
|
||||
return Util.UTF8NoBomEncoding.GetBytes(xmlString);
|
||||
}
|
||||
|
||||
byte[] GetHyperlinks(Dictionary<string, object> request)
|
||||
{
|
||||
//m_log.DebugFormat("[GRID HANDLER]: GetHyperlinks");
|
||||
|
||||
@@ -640,6 +640,58 @@ namespace OpenSim.Services.Connectors
|
||||
return rinfos;
|
||||
}
|
||||
|
||||
public List<GridRegion> GetOnlineRegions(UUID scopeID, int x, int y, int maxCount)
|
||||
{
|
||||
Dictionary<string, object> sendData = new Dictionary<string, object>();
|
||||
|
||||
sendData["SCOPEID"] = scopeID.ToString();
|
||||
sendData["X"] = x.ToString();
|
||||
sendData["Y"] = y.ToString();
|
||||
sendData["MC"] = maxCount.ToString();
|
||||
|
||||
sendData["METHOD"] = "get_online_regions";
|
||||
|
||||
List<GridRegion> rinfos = new List<GridRegion>();
|
||||
string reply = string.Empty;
|
||||
try
|
||||
{
|
||||
reply = SynchronousRestFormsRequester.MakePostRequest(m_ServerURI + "/grid",
|
||||
ServerUtils.BuildQueryString(sendData), m_Auth);
|
||||
|
||||
//m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server at {0}: {1}", m_ServerURI + "/grid", e.Message);
|
||||
return rinfos;
|
||||
}
|
||||
|
||||
if (reply != string.Empty)
|
||||
{
|
||||
Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
|
||||
|
||||
if (replyData != null)
|
||||
{
|
||||
Dictionary<string, object>.ValueCollection rinfosList = replyData.Values;
|
||||
foreach (object r in rinfosList)
|
||||
{
|
||||
if (r is Dictionary<string, object>)
|
||||
{
|
||||
GridRegion rinfo = new GridRegion((Dictionary<string, object>)r);
|
||||
rinfos.Add(rinfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
m_log.DebugFormat("[GRID CONNECTOR]: GetOnlineRegions {0}, {1}-{2} received null response",
|
||||
scopeID, x, y);
|
||||
}
|
||||
else
|
||||
m_log.DebugFormat("[GRID CONNECTOR]: GetOnlineRegions received null reply");
|
||||
|
||||
return rinfos;
|
||||
}
|
||||
|
||||
public List<GridRegion> GetHyperlinks(UUID scopeID)
|
||||
{
|
||||
Dictionary<string, object> sendData = new Dictionary<string, object>();
|
||||
|
||||
@@ -790,8 +790,8 @@ namespace OpenSim.Services.GridService
|
||||
List<GridRegion> ret = new List<GridRegion>();
|
||||
|
||||
List<RegionData> regions = m_Database.GetFallbackRegions(scopeID);
|
||||
if(regions.Count > 0)
|
||||
{
|
||||
if (regions.Count > 0)
|
||||
{
|
||||
if (regions.Count > 1)
|
||||
{
|
||||
regions.Sort(new RegionDataDistanceCompare(x, y));
|
||||
@@ -800,7 +800,7 @@ namespace OpenSim.Services.GridService
|
||||
foreach (RegionData r in regions)
|
||||
{
|
||||
int rflags = Convert.ToInt32(r.Data["flags"]);
|
||||
if((rflags & (int)OpenSim.Framework.RegionFlags.Hyperlink) != 0)
|
||||
if ((rflags & (int)OpenSim.Framework.RegionFlags.Hyperlink) != 0)
|
||||
continue;
|
||||
if ((rflags & (int)OpenSim.Framework.RegionFlags.RegionOnline) != 0)
|
||||
ret.Add(RegionData2RegionInfo(r));
|
||||
@@ -811,6 +811,33 @@ namespace OpenSim.Services.GridService
|
||||
return ret;
|
||||
}
|
||||
|
||||
public List<GridRegion> GetOnlineRegions(UUID scopeID, int x, int y, int maxCount)
|
||||
{
|
||||
List<GridRegion> ret = new List<GridRegion>();
|
||||
|
||||
List<RegionData> regions = m_Database.GetOnlineRegions(scopeID);
|
||||
if (regions.Count > 0)
|
||||
{
|
||||
if (regions.Count > 1)
|
||||
{
|
||||
regions.Sort(new RegionDataDistanceCompare(x, y));
|
||||
}
|
||||
|
||||
foreach (RegionData r in regions)
|
||||
{
|
||||
int rflags = Convert.ToInt32(r.Data["flags"]);
|
||||
if ((rflags & (int)OpenSim.Framework.RegionFlags.Hyperlink) != 0)
|
||||
continue;
|
||||
ret.Add(RegionData2RegionInfo(r));
|
||||
if(ret.Count >= maxCount)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
m_log.DebugFormat("[GRID SERVICE]: online returned {0} regions", ret.Count);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public List<GridRegion> GetHyperlinks(UUID scopeID)
|
||||
{
|
||||
List<GridRegion> ret = new List<GridRegion>();
|
||||
|
||||
@@ -107,6 +107,7 @@ namespace OpenSim.Services.Interfaces
|
||||
List<GridRegion> GetDefaultHypergridRegions(UUID scopeID);
|
||||
List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y);
|
||||
List<GridRegion> GetHyperlinks(UUID scopeID);
|
||||
List<GridRegion> GetOnlineRegions(UUID scopeID, int x, int y, int maxCount);
|
||||
|
||||
/// <summary>
|
||||
/// Get internal OpenSimulator region flags.
|
||||
|
||||
Reference in New Issue
Block a user