Actor/Quark registration for Simian backend
parent
f5870a1e23
commit
4fe0bd32d4
|
@ -902,7 +902,7 @@ namespace OpenSim.Framework
|
|||
|
||||
string quarkLocation = config.GetString("SyncQuarkLocation", "1000,1000");
|
||||
|
||||
string[] quarkLocElements = location.Split(new char[] { ',' });
|
||||
string[] quarkLocElements = quarkLocation.Split(new char[] { ',' });
|
||||
|
||||
m_quarkLocX = Convert.ToUInt32(quarkLocElements[0]);
|
||||
m_quarkLocY = Convert.ToUInt32(quarkLocElements[1]);
|
||||
|
|
|
@ -36,6 +36,7 @@ using OpenSim.Region.CoreModules.Framework.InterfaceCommander;
|
|||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using OpenSim.Region.Physics.Manager;
|
||||
using OpenSim.Services.Interfaces;
|
||||
using log4net;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
|
@ -105,11 +106,6 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
|
|||
|
||||
m_log.Debug(LogHeader + " Init PEToSceneConnectorModule, for local scene " + scene.RegionInfo.RegionName);
|
||||
|
||||
// string configString = scene.RegionInfo.RegionName + "_SceneToPESyncServerIP";
|
||||
// m_serveraddr = syncConfig.GetString(configString, "127.0.0.1");
|
||||
// configString = scene.RegionInfo.RegionName + "_SceneToPESyncServerPort";
|
||||
// m_serverport = syncConfig.GetInt(configString, 13000);
|
||||
|
||||
m_scene = scene;
|
||||
m_scene.RegisterModuleInterface<IPhysEngineToSceneConnectorModule>(this);
|
||||
m_syncConfig = syncConfig;
|
||||
|
|
|
@ -13,6 +13,7 @@ using OpenSim.Region.CoreModules.Framework.InterfaceCommander;
|
|||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using OpenSim.Region.Framework.Scenes.Serialization;
|
||||
using OpenSim.Services.Interfaces;
|
||||
using log4net;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
|
@ -764,6 +765,28 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
|
|||
if (!addr.Equals(IPAddrUnknown) && port != PortUnknown)
|
||||
{
|
||||
RegionSyncListenerInfo info = new RegionSyncListenerInfo(addr, port);
|
||||
|
||||
// Register this actor as a endpoint for this quark
|
||||
// Note that this is wrong in that this module is not an actor
|
||||
// Resolve by figuring out registation of endpoints vs actors
|
||||
List<GridQuarkInfo> lgqi = new List<GridQuarkInfo>();
|
||||
GridQuarkInfo gqi = new GridQuarkInfo();
|
||||
gqi.locX = m_scene.RegionInfo.SyncQuarkLocationX;
|
||||
gqi.locY = m_scene.RegionInfo.SyncQuarkLocationY;
|
||||
lgqi.Add(gqi);
|
||||
GridActorInfo gai = new GridActorInfo();
|
||||
// gai.actorID = m_actorID;
|
||||
// gai.actorID = m_scene.RegionInfo.RegionName;
|
||||
gai.actorID = m_scene.RegionInfo.RegionID.ToString();
|
||||
gai.address = addr;
|
||||
gai.port = port;
|
||||
// the actor really doesn't belong here -- the sync server is actor agnostic
|
||||
// the registration should be of just the endpoint with a separate registration for the actor
|
||||
gai.actorType = "scene_persistence";
|
||||
if (!m_scene.GridService.RegisterActor(gai, lgqi))
|
||||
{
|
||||
m_log.ErrorFormat("{0}: Failure registering actor endpoint", LogHeader);
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
|
@ -785,6 +808,29 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
|
|||
string addr = m_scene.RegionInfo.SyncServerAddress;
|
||||
int port = m_scene.RegionInfo.SyncServerPort;
|
||||
|
||||
// if the address is not specified in the region configuration file, get it from the grid service
|
||||
if (addr.Equals(IPAddrUnknown))
|
||||
{
|
||||
GridQuarkInfo gqi = new GridQuarkInfo();
|
||||
gqi.locX = m_scene.RegionInfo.SyncQuarkLocationX;
|
||||
gqi.locY = m_scene.RegionInfo.SyncQuarkLocationY;
|
||||
List<GridActorInfo> lgai = m_scene.GridService.LookupQuark(gqi, "scene_persistence");
|
||||
if (lgai == null || lgai.Count != 1)
|
||||
{
|
||||
m_log.ErrorFormat("{0}: Failed to find quark persistence actor", LogHeader);
|
||||
addr = IPAddrUnknown;
|
||||
port = PortUnknown;
|
||||
}
|
||||
else
|
||||
{
|
||||
GridActorInfo gai = lgai[0];
|
||||
addr = gai.address;
|
||||
port = gai.port;
|
||||
m_log.WarnFormat("{0}: Found quark ({1}/{2}) persistence actor at {3}:{4}", LogHeader,
|
||||
gqi.locX.ToString(), gqi.locY.ToString(), addr, port.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
if (!addr.Equals(IPAddrUnknown) && port != PortUnknown)
|
||||
{
|
||||
RegionSyncListenerInfo info = new RegionSyncListenerInfo(addr, port);
|
||||
|
|
|
@ -262,9 +262,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
|
|||
{
|
||||
return m_GridService.RegisterActor(gai, lgqi);
|
||||
}
|
||||
public virtual bool RegisterActor(GridActorInfo gai, GridQuarkInfo gqi)
|
||||
public virtual bool RegisterActor(GridActorInfo gai)
|
||||
{
|
||||
return m_GridService.RegisterActor(gai, gqi);
|
||||
return m_GridService.RegisterActor(gai);
|
||||
}
|
||||
public virtual bool RegisterQuark(string actorID, GridQuarkInfo gqi)
|
||||
{
|
||||
return m_GridService.RegisterQuark(actorID, gqi);
|
||||
}
|
||||
public virtual List<GridActorInfo> LookupQuark(GridQuarkInfo gqi)
|
||||
{
|
||||
|
|
|
@ -295,17 +295,21 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
|
|||
{
|
||||
return m_RemoteGridService.RegisterActor(gai, lgqi);
|
||||
}
|
||||
public virtual bool RegisterActor(GridActorInfo gai, GridQuarkInfo gqi)
|
||||
public virtual bool RegisterActor(GridActorInfo gai)
|
||||
{
|
||||
return m_RemoteGridService.RegisterActor(gai, gqi);
|
||||
return m_RemoteGridService.RegisterActor(gai);
|
||||
}
|
||||
public virtual bool RegisterQuark(string actorID, GridQuarkInfo gqi)
|
||||
{
|
||||
return m_RemoteGridService.RegisterQuark(actorID, gqi);
|
||||
}
|
||||
public virtual List<GridActorInfo> LookupQuark(GridQuarkInfo gqi)
|
||||
{
|
||||
return LookupQuark(gqi);
|
||||
return m_RemoteGridService.LookupQuark(gqi);
|
||||
}
|
||||
public virtual List<GridActorInfo> LookupQuark(GridQuarkInfo gqi, string actorType)
|
||||
{
|
||||
return LookupQuark(gqi, actorType);
|
||||
return m_RemoteGridService.LookupQuark(gqi, actorType);
|
||||
}
|
||||
#endregion SYNC SERVER
|
||||
}
|
||||
|
|
|
@ -659,7 +659,11 @@ namespace OpenSim.Services.Connectors
|
|||
{
|
||||
return false;
|
||||
}
|
||||
public virtual bool RegisterActor(GridActorInfo gai, GridQuarkInfo gqi)
|
||||
public virtual bool RegisterActor(GridActorInfo gai)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
public virtual bool RegisterQuark(string actorID, GridQuarkInfo gqi)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -434,51 +434,82 @@ namespace OpenSim.Services.Connectors.SimianGrid
|
|||
}
|
||||
|
||||
#region SYNC SERVER
|
||||
// Stubs for actor and quark management. Only implementation is in SimianGridService
|
||||
/// <summary>
|
||||
/// Register an actor and it's associated quarks
|
||||
/// </summary>
|
||||
/// <param name="gai"></param>
|
||||
/// <param name="lgqi"></param>
|
||||
/// <returns></returns>
|
||||
public virtual bool RegisterActor(GridActorInfo gai, List<GridQuarkInfo> lgqi)
|
||||
{
|
||||
OSDArray quarks = new OSDArray();
|
||||
foreach (GridQuarkInfo gqi in lgqi)
|
||||
if (RegisterActor(gai))
|
||||
{
|
||||
OSDMap quarkMap = new OSDMap
|
||||
bool success = true;
|
||||
foreach (GridQuarkInfo gqi in lgqi)
|
||||
{
|
||||
{ "locX", OSD.FromInteger(gqi.locX) },
|
||||
{ "locY", OSD.FromInteger(gqi.locY) }
|
||||
};
|
||||
quarks.Add(quarkMap);
|
||||
if (!RegisterQuark(gai.actorID, gqi))
|
||||
{
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return success;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool RegisterActor(GridActorInfo gai)
|
||||
{
|
||||
NameValueCollection requestArgs = new NameValueCollection
|
||||
{
|
||||
{ "RequestMethod", "RegisterActor" },
|
||||
{ "actorID", gai.actorID },
|
||||
{ "type", gai.type },
|
||||
{ "address", gai.address },
|
||||
{ "port", gai.port.ToString() },
|
||||
{ "quarks", OSDParser.SerializeJsonString(quarks) }
|
||||
{ "RequestMethod", "AddActor" },
|
||||
{ "ActorID", gai.actorID },
|
||||
{ "ActorType", gai.actorType },
|
||||
{ "Address", gai.address },
|
||||
{ "Port", gai.port.ToString() },
|
||||
};
|
||||
|
||||
OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs);
|
||||
if (response["Success"].AsBoolean())
|
||||
{
|
||||
m_log.WarnFormat("{0}: Registration of actor {1} at addr={2}:{3} successful",
|
||||
"[SIMIAN GRID CONNECTOR]", gai.actorID, gai.address, gai.port.ToString());
|
||||
return true;
|
||||
}
|
||||
m_log.ErrorFormat("{0}: Registration of actor {1} at addr={2}:{3} failed: {4}",
|
||||
"[SIMIAN GRID CONNECTOR]", gai.actorID, gai.address, gai.port.ToString(), response["Message"]);
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool RegisterActor(GridActorInfo gai, GridQuarkInfo gqi)
|
||||
public virtual bool RegisterQuark(string actorID, GridQuarkInfo gqi)
|
||||
{
|
||||
List<GridActorInfo> lgqi = new List<GridActorInfo>();
|
||||
lgqi.Add(gqi);
|
||||
return RegisterActor(gai, lgqi);
|
||||
NameValueCollection requestArgs = new NameValueCollection
|
||||
{
|
||||
{ "RequestMethod", "AddQuark" },
|
||||
{ "ActorID", actorID },
|
||||
{ "LocX", gqi.locX.ToString() },
|
||||
{ "LocY", gqi.locY.ToString() },
|
||||
};
|
||||
|
||||
OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs);
|
||||
if (response["Success"].AsBoolean())
|
||||
{
|
||||
m_log.WarnFormat("{0}: Registration of quark at {1}/{2} successful",
|
||||
"[SIMIAN GRID CONNECTOR]", gqi.locX.ToString(), gqi.locY.ToString());
|
||||
return true;
|
||||
}
|
||||
m_log.ErrorFormat("{0}: Registration of quark at {1}/{2} failed: {3}",
|
||||
"[SIMIAN GRID CONNECTOR]", gqi.locX.ToString(), gqi.locY.ToString(), response["Message"]);
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual List<GridActorInfo> LookupQuark(GridQuarkInfo gqi)
|
||||
{
|
||||
NameValueCollection requestArgs = new NameValueCollection
|
||||
{
|
||||
{ "RequestMethod", "LookupQuark" },
|
||||
{ "locX", gqi.locX.ToString() },
|
||||
{ "locY", gqi.locY.ToString() }
|
||||
{ "RequestMethod", "GetQuark" },
|
||||
{ "LocX", gqi.locX.ToString() },
|
||||
{ "LocY", gqi.locY.ToString() }
|
||||
};
|
||||
return LookupQuark(requestArgs);
|
||||
}
|
||||
|
@ -487,10 +518,10 @@ namespace OpenSim.Services.Connectors.SimianGrid
|
|||
{
|
||||
NameValueCollection requestArgs = new NameValueCollection
|
||||
{
|
||||
{ "RequestMethod", "LookupQuark" },
|
||||
{ "locX", gqi.locX.ToString() },
|
||||
{ "locY", gqi.locY.ToString() },
|
||||
{ "actorType", actorType }
|
||||
{ "RequestMethod", "GetQuark" },
|
||||
{ "LocX", gqi.locX.ToString() },
|
||||
{ "LocY", gqi.locY.ToString() },
|
||||
{ "ActorType", actorType }
|
||||
};
|
||||
return LookupQuark(requestArgs);
|
||||
}
|
||||
|
@ -501,19 +532,23 @@ namespace OpenSim.Services.Connectors.SimianGrid
|
|||
if (response["Success"].AsBoolean())
|
||||
{
|
||||
List<GridActorInfo> lgai = new List<GridActorInfo>();
|
||||
OSDArray gridActors = (OSDArray)response["actors"];
|
||||
OSDArray gridActors = (OSDArray)response["Actors"];
|
||||
m_log.WarnFormat("{0}: Lookup of quark successful. {1} addresses",
|
||||
"[SIMIAN GRID CONNECTOR]", gridActors.Count);
|
||||
for (int ii = 0; ii < gridActors.Count; ii++)
|
||||
{
|
||||
OSDMap thisGridActor = (OSDMap)gridActors[ii];
|
||||
GridActorInfo gai = new GridActorInfo();
|
||||
gai.actorID = thisGridActor["actorID"].AsString();
|
||||
gai.type = thisGridActor["actorType"].AsString();
|
||||
gai.address = thisGridActor["address"].AsString();
|
||||
gai.port = thisGridActor["port"].AsInteger();
|
||||
gai.actorID = thisGridActor["ActorID"].AsString();
|
||||
gai.actorType = thisGridActor["ActorType"].AsString();
|
||||
gai.address = thisGridActor["Address"].AsString();
|
||||
gai.port = thisGridActor["Port"].AsInteger();
|
||||
lgai.Add(gai);
|
||||
}
|
||||
return lgai;
|
||||
}
|
||||
m_log.ErrorFormat("{0}: Lookup of quark failed: {1}",
|
||||
"[SIMIAN GRID CONNECTOR]", response["Message"]);
|
||||
return null;
|
||||
}
|
||||
#endregion SYNC SERVER
|
||||
|
|
|
@ -555,7 +555,11 @@ namespace OpenSim.Services.GridService
|
|||
{
|
||||
return false;
|
||||
}
|
||||
public virtual bool RegisterActor(GridActorInfo gai, GridQuarkInfo gqi)
|
||||
public virtual bool RegisterActor(GridActorInfo gai)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
public virtual bool RegisterQuark(string actorID, GridQuarkInfo gqi)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -96,24 +96,29 @@ namespace OpenSim.Services.Interfaces
|
|||
|
||||
int GetRegionFlags(UUID scopeID, UUID regionID);
|
||||
|
||||
// SYNC SERVER
|
||||
bool RegisterActor(GridActorInfo gai, List<GridQuarkInfo> lgqi);
|
||||
bool RegisterActor(GridActorInfo gai, GridQuarkInfo gqi);
|
||||
bool RegisterActor(GridActorInfo gai);
|
||||
bool RegisterQuark(string actorID, GridQuarkInfo gqi);
|
||||
List<GridActorInfo> LookupQuark(GridQuarkInfo gqi);
|
||||
List<GridActorInfo> LookupQuark(GridQuarkInfo gqi, string actorType);
|
||||
// END SYNC SERVER
|
||||
}
|
||||
|
||||
// SYNC SERVER
|
||||
public class GridQuarkInfo
|
||||
{
|
||||
public int locX;
|
||||
public int locY;
|
||||
public uint locX;
|
||||
public uint locY;
|
||||
}
|
||||
public class GridActorInfo
|
||||
{
|
||||
public string address;
|
||||
public int port;
|
||||
public string type;
|
||||
public string actorType;
|
||||
public string actorID;
|
||||
}
|
||||
// END SYNC SERVER
|
||||
|
||||
public class GridRegion : Object
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue