Update SimianGridServicesConnector to work more like
a connector so we can take advantage of the logic in RemoteGridServicesConnector.viewer-2-initial-appearance
parent
6386dfd362
commit
94ed69b1da
|
@ -51,50 +51,20 @@ namespace OpenSim.Services.Connectors.SimianGrid
|
||||||
/// Connects region registration and neighbor lookups to the SimianGrid
|
/// Connects region registration and neighbor lookups to the SimianGrid
|
||||||
/// backend
|
/// backend
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
|
public class SimianGridServiceConnector : IGridService
|
||||||
public class SimianGridServiceConnector : IGridService, ISharedRegionModule
|
|
||||||
{
|
{
|
||||||
private static readonly ILog m_log =
|
private static readonly ILog m_log =
|
||||||
LogManager.GetLogger(
|
LogManager.GetLogger(
|
||||||
MethodBase.GetCurrentMethod().DeclaringType);
|
MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
private string m_serverUrl = String.Empty;
|
private string m_ServerURI = String.Empty;
|
||||||
private Dictionary<UUID, Scene> m_scenes = new Dictionary<UUID, Scene>();
|
|
||||||
private bool m_Enabled = false;
|
private bool m_Enabled = false;
|
||||||
|
|
||||||
#region ISharedRegionModule
|
|
||||||
|
|
||||||
public Type ReplaceableInterface { get { return null; } }
|
|
||||||
public void RegionLoaded(Scene scene) { }
|
|
||||||
public void PostInitialise() { }
|
|
||||||
public void Close() { }
|
|
||||||
|
|
||||||
public SimianGridServiceConnector() { }
|
public SimianGridServiceConnector() { }
|
||||||
public string Name { get { return "SimianGridServiceConnector"; } }
|
public SimianGridServiceConnector(string serverURI)
|
||||||
public void AddRegion(Scene scene)
|
|
||||||
{
|
{
|
||||||
if (!m_Enabled)
|
m_ServerURI = serverURI.TrimEnd('/');
|
||||||
return;
|
|
||||||
|
|
||||||
// Every shared region module has to maintain an indepedent list of
|
|
||||||
// currently running regions
|
|
||||||
lock (m_scenes)
|
|
||||||
m_scenes[scene.RegionInfo.RegionID] = scene;
|
|
||||||
|
|
||||||
scene.RegisterModuleInterface<IGridService>(this);
|
|
||||||
}
|
}
|
||||||
public void RemoveRegion(Scene scene)
|
|
||||||
{
|
|
||||||
if (!m_Enabled)
|
|
||||||
return;
|
|
||||||
|
|
||||||
lock (m_scenes)
|
|
||||||
m_scenes.Remove(scene.RegionInfo.RegionID);
|
|
||||||
|
|
||||||
scene.UnregisterModuleInterface<IGridService>(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion ISharedRegionModule
|
|
||||||
|
|
||||||
public SimianGridServiceConnector(IConfigSource source)
|
public SimianGridServiceConnector(IConfigSource source)
|
||||||
{
|
{
|
||||||
|
@ -103,32 +73,29 @@ namespace OpenSim.Services.Connectors.SimianGrid
|
||||||
|
|
||||||
public void Initialise(IConfigSource source)
|
public void Initialise(IConfigSource source)
|
||||||
{
|
{
|
||||||
IConfig moduleConfig = source.Configs["Modules"];
|
CommonInit(source);
|
||||||
if (moduleConfig != null)
|
|
||||||
{
|
|
||||||
string name = moduleConfig.GetString("GridServices", "");
|
|
||||||
if (name == Name)
|
|
||||||
CommonInit(source);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CommonInit(IConfigSource source)
|
private void CommonInit(IConfigSource source)
|
||||||
{
|
{
|
||||||
IConfig gridConfig = source.Configs["GridService"];
|
IConfig gridConfig = source.Configs["GridService"];
|
||||||
if (gridConfig != null)
|
if (gridConfig == null)
|
||||||
{
|
{
|
||||||
string serviceUrl = gridConfig.GetString("GridServerURI");
|
m_log.Error("[SIMIAN GRID CONNECTOR]: GridService missing from OpenSim.ini");
|
||||||
if (!String.IsNullOrEmpty(serviceUrl))
|
throw new Exception("Grid connector init error");
|
||||||
{
|
|
||||||
if (!serviceUrl.EndsWith("/") && !serviceUrl.EndsWith("="))
|
|
||||||
serviceUrl = serviceUrl + '/';
|
|
||||||
m_serverUrl = serviceUrl;
|
|
||||||
m_Enabled = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (String.IsNullOrEmpty(m_serverUrl))
|
string serviceUrl = gridConfig.GetString("GridServerURI");
|
||||||
m_log.Info("[SIMIAN GRID CONNECTOR]: No GridServerURI specified, disabling connector");
|
if (String.IsNullOrEmpty(serviceUrl))
|
||||||
|
{
|
||||||
|
m_log.Error("[SIMIAN GRID CONNECTOR]: No Server URI named in section GridService");
|
||||||
|
throw new Exception("Grid connector init error");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!serviceUrl.EndsWith("/") && !serviceUrl.EndsWith("="))
|
||||||
|
serviceUrl = serviceUrl + '/';
|
||||||
|
m_ServerURI = serviceUrl;
|
||||||
|
m_Enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region IGridService
|
#region IGridService
|
||||||
|
@ -136,11 +103,11 @@ namespace OpenSim.Services.Connectors.SimianGrid
|
||||||
public string RegisterRegion(UUID scopeID, GridRegion regionInfo)
|
public string RegisterRegion(UUID scopeID, GridRegion regionInfo)
|
||||||
{
|
{
|
||||||
// Generate and upload our map tile in PNG format to the SimianGrid AddMapTile service
|
// Generate and upload our map tile in PNG format to the SimianGrid AddMapTile service
|
||||||
Scene scene;
|
// Scene scene;
|
||||||
if (m_scenes.TryGetValue(regionInfo.RegionID, out scene))
|
// if (m_scenes.TryGetValue(regionInfo.RegionID, out scene))
|
||||||
UploadMapTile(scene);
|
// UploadMapTile(scene);
|
||||||
else
|
// else
|
||||||
m_log.Warn("Registering region " + regionInfo.RegionName + " (" + regionInfo.RegionID + ") that we are not tracking");
|
// m_log.Warn("Registering region " + regionInfo.RegionName + " (" + regionInfo.RegionID + ") that we are not tracking");
|
||||||
|
|
||||||
Vector3d minPosition = new Vector3d(regionInfo.RegionLocX, regionInfo.RegionLocY, 0.0);
|
Vector3d minPosition = new Vector3d(regionInfo.RegionLocX, regionInfo.RegionLocY, 0.0);
|
||||||
Vector3d maxPosition = minPosition + new Vector3d(Constants.RegionSize, Constants.RegionSize, 4096.0);
|
Vector3d maxPosition = minPosition + new Vector3d(Constants.RegionSize, Constants.RegionSize, 4096.0);
|
||||||
|
@ -171,7 +138,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
|
||||||
{ "ExtraData", OSDParser.SerializeJsonString(extraData) }
|
{ "ExtraData", OSDParser.SerializeJsonString(extraData) }
|
||||||
};
|
};
|
||||||
|
|
||||||
OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
|
OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs);
|
||||||
if (response["Success"].AsBoolean())
|
if (response["Success"].AsBoolean())
|
||||||
return String.Empty;
|
return String.Empty;
|
||||||
else
|
else
|
||||||
|
@ -187,7 +154,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
|
||||||
{ "Enabled", "0" }
|
{ "Enabled", "0" }
|
||||||
};
|
};
|
||||||
|
|
||||||
OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
|
OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs);
|
||||||
bool success = response["Success"].AsBoolean();
|
bool success = response["Success"].AsBoolean();
|
||||||
|
|
||||||
if (!success)
|
if (!success)
|
||||||
|
@ -232,9 +199,12 @@ namespace OpenSim.Services.Connectors.SimianGrid
|
||||||
{ "SceneID", regionID.ToString() }
|
{ "SceneID", regionID.ToString() }
|
||||||
};
|
};
|
||||||
|
|
||||||
OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
|
// m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request region with uuid {0}",regionID.ToString());
|
||||||
|
|
||||||
|
OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs);
|
||||||
if (response["Success"].AsBoolean())
|
if (response["Success"].AsBoolean())
|
||||||
{
|
{
|
||||||
|
// m_log.DebugFormat("[SIMIAN GRID CONNECTOR] uuid request successful {0}",response["Name"].AsString());
|
||||||
return ResponseToGridRegion(response);
|
return ResponseToGridRegion(response);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -257,15 +227,18 @@ namespace OpenSim.Services.Connectors.SimianGrid
|
||||||
{ "Enabled", "1" }
|
{ "Enabled", "1" }
|
||||||
};
|
};
|
||||||
|
|
||||||
OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
|
// m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request grid at {0}",position.ToString());
|
||||||
|
|
||||||
|
OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs);
|
||||||
if (response["Success"].AsBoolean())
|
if (response["Success"].AsBoolean())
|
||||||
{
|
{
|
||||||
|
// m_log.DebugFormat("[SIMIAN GRID CONNECTOR] position request successful {0}",response["Name"].AsString());
|
||||||
return ResponseToGridRegion(response);
|
return ResponseToGridRegion(response);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//m_log.InfoFormat("[SIMIAN GRID CONNECTOR]: Grid service did not find a match for region at {0},{1}",
|
// m_log.InfoFormat("[SIMIAN GRID CONNECTOR]: Grid service did not find a match for region at {0},{1}",
|
||||||
// x / Constants.RegionSize, y / Constants.RegionSize);
|
// x / Constants.RegionSize, y / Constants.RegionSize);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -295,9 +268,13 @@ namespace OpenSim.Services.Connectors.SimianGrid
|
||||||
if (maxNumber > 0)
|
if (maxNumber > 0)
|
||||||
requestArgs["MaxNumber"] = maxNumber.ToString();
|
requestArgs["MaxNumber"] = maxNumber.ToString();
|
||||||
|
|
||||||
OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
|
// m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request regions with name {0}",name);
|
||||||
|
|
||||||
|
OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs);
|
||||||
if (response["Success"].AsBoolean())
|
if (response["Success"].AsBoolean())
|
||||||
{
|
{
|
||||||
|
// m_log.DebugFormat("[SIMIAN GRID CONNECTOR] found regions with name {0}",name);
|
||||||
|
|
||||||
OSDArray array = response["Scenes"] as OSDArray;
|
OSDArray array = response["Scenes"] as OSDArray;
|
||||||
if (array != null)
|
if (array != null)
|
||||||
{
|
{
|
||||||
|
@ -328,7 +305,10 @@ namespace OpenSim.Services.Connectors.SimianGrid
|
||||||
{ "Enabled", "1" }
|
{ "Enabled", "1" }
|
||||||
};
|
};
|
||||||
|
|
||||||
OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
|
m_log.WarnFormat("[SIMIAN GRID CONNECTOR] request regions by range {0} to {1}",minPosition.ToString(),maxPosition.ToString());
|
||||||
|
|
||||||
|
|
||||||
|
OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs);
|
||||||
if (response["Success"].AsBoolean())
|
if (response["Success"].AsBoolean())
|
||||||
{
|
{
|
||||||
OSDArray array = response["Scenes"] as OSDArray;
|
OSDArray array = response["Scenes"] as OSDArray;
|
||||||
|
@ -384,7 +364,9 @@ namespace OpenSim.Services.Connectors.SimianGrid
|
||||||
{ "SceneID", regionID.ToString() }
|
{ "SceneID", regionID.ToString() }
|
||||||
};
|
};
|
||||||
|
|
||||||
OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
|
// m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request region flags for {0}",regionID.ToString());
|
||||||
|
|
||||||
|
OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs);
|
||||||
if (response["Success"].AsBoolean())
|
if (response["Success"].AsBoolean())
|
||||||
{
|
{
|
||||||
return response["Enabled"].AsBoolean() ? REGION_ONLINE : 0;
|
return response["Enabled"].AsBoolean() ? REGION_ONLINE : 0;
|
||||||
|
@ -430,7 +412,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
|
||||||
// Make the remote storage request
|
// Make the remote storage request
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(m_serverUrl);
|
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(m_ServerURI);
|
||||||
|
|
||||||
HttpWebResponse response = MultipartForm.Post(request, postParameters);
|
HttpWebResponse response = MultipartForm.Post(request, postParameters);
|
||||||
using (Stream responseStream = response.GetResponseStream())
|
using (Stream responseStream = response.GetResponseStream())
|
||||||
|
@ -486,7 +468,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
|
||||||
if (onlyEnabled)
|
if (onlyEnabled)
|
||||||
requestArgs["Enabled"] = "1";
|
requestArgs["Enabled"] = "1";
|
||||||
|
|
||||||
OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
|
OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs);
|
||||||
if (response["Success"].AsBoolean())
|
if (response["Success"].AsBoolean())
|
||||||
{
|
{
|
||||||
return ResponseToGridRegion(response);
|
return ResponseToGridRegion(response);
|
||||||
|
|
Loading…
Reference in New Issue