Quark/Endpoint registration and lookup for three table database

dsg
Robert Adams 2011-02-11 15:50:25 -08:00
parent 4fe0bd32d4
commit 9970677ed8
7 changed files with 174 additions and 128 deletions

View File

@ -766,27 +766,28 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
{
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))
// remove any cruft from previous runs
m_scene.GridService.CleanUpEndpoint(m_scene.RegionInfo.RegionID.ToString());
// Register the endpoint and quark and persistence actor for this simulator instance
GridEndpointInfo gei = new GridEndpointInfo();
gei.syncServerID = m_scene.RegionInfo.RegionID.ToString();
gei.address = m_scene.RegionInfo.SyncServerAddress;
gei.port = (uint)m_scene.RegionInfo.SyncServerPort;
if (!m_scene.GridService.RegisterEndpoint(gei))
{
m_log.ErrorFormat("{0}: Failure registering actor endpoint", LogHeader);
m_log.ErrorFormat("{0}: Failure registering endpoint", LogHeader);
}
if (!m_scene.GridService.RegisterActor(m_scene.RegionInfo.RegionID.ToString(),
"scene_persistence", m_scene.RegionInfo.RegionID.ToString()))
{
m_log.ErrorFormat("{0}: Failure registering actor", LogHeader);
}
if (!m_scene.GridService.RegisterQuark(m_scene.RegionInfo.RegionID.ToString(),
m_scene.RegionInfo.SyncQuarkLocationX, m_scene.RegionInfo.SyncQuarkLocationY))
{
m_log.ErrorFormat("{0}: Failure registering quark", LogHeader);
}
return info;
}
@ -811,11 +812,9 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
// 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)
List<GridEndpointInfo> lgei = m_scene.GridService.LookupQuark(
m_scene.RegionInfo.SyncQuarkLocationX, m_scene.RegionInfo.SyncQuarkLocationY, "scene_persistence");
if (lgei == null || lgei.Count != 1)
{
m_log.ErrorFormat("{0}: Failed to find quark persistence actor", LogHeader);
addr = IPAddrUnknown;
@ -823,11 +822,12 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
}
else
{
GridActorInfo gai = lgai[0];
addr = gai.address;
port = gai.port;
GridEndpointInfo gei = lgei[0];
addr = gei.address;
port = (int)gei.port;
m_log.WarnFormat("{0}: Found quark ({1}/{2}) persistence actor at {3}:{4}", LogHeader,
gqi.locX.ToString(), gqi.locY.ToString(), addr, port.ToString());
m_scene.RegionInfo.SyncQuarkLocationX, m_scene.RegionInfo.SyncQuarkLocationY,
addr, port.ToString());
}
}

View File

@ -258,25 +258,29 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
#region SYNC SERVER
// Stubs for actor and quark management. Only implementation is in SimianGridService
public virtual bool RegisterActor(GridActorInfo gai, List<GridQuarkInfo> lgqi)
public bool RegisterEndpoint(GridEndpointInfo gei)
{
return m_GridService.RegisterActor(gai, lgqi);
return m_GridService.RegisterEndpoint(gei);
}
public virtual bool RegisterActor(GridActorInfo gai)
public bool RegisterActor(string actorID, string actorType, string syncServerID)
{
return m_GridService.RegisterActor(gai);
return m_GridService.RegisterActor(actorID, actorType, syncServerID);
}
public virtual bool RegisterQuark(string actorID, GridQuarkInfo gqi)
public bool RegisterQuark(string syncServerID, uint locX, uint locY)
{
return m_GridService.RegisterQuark(actorID, gqi);
return m_GridService.RegisterQuark(syncServerID, locX, locY);
}
public virtual List<GridActorInfo> LookupQuark(GridQuarkInfo gqi)
public List<GridEndpointInfo> LookupQuark(uint locX, uint locY)
{
return m_GridService.LookupQuark(gqi);
return m_GridService.LookupQuark(locX, locY);
}
public virtual List<GridActorInfo> LookupQuark(GridQuarkInfo gqi, string actorType)
public List<GridEndpointInfo> LookupQuark(uint locX, uint locY, string actorType)
{
return m_GridService.LookupQuark(gqi, actorType);
return m_GridService.LookupQuark(locX, locY, actorType);
}
public bool CleanUpEndpoint(string syncServerID)
{
return m_GridService.CleanUpEndpoint(syncServerID);
}
#endregion SYNC SERVER

View File

@ -291,25 +291,29 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
#region SYNC SERVER
// Stubs for actor and quark management. Only implementation is in SimianGridService
public virtual bool RegisterActor(GridActorInfo gai, List<GridQuarkInfo> lgqi)
public bool RegisterEndpoint(GridEndpointInfo gei)
{
return m_RemoteGridService.RegisterActor(gai, lgqi);
return m_RemoteGridService.RegisterEndpoint(gei);
}
public virtual bool RegisterActor(GridActorInfo gai)
public bool RegisterActor(string actorID, string actorType, string syncServerID)
{
return m_RemoteGridService.RegisterActor(gai);
return m_RemoteGridService.RegisterActor(actorID, actorType, syncServerID);
}
public virtual bool RegisterQuark(string actorID, GridQuarkInfo gqi)
public bool RegisterQuark(string syncServerID, uint locX, uint locY)
{
return m_RemoteGridService.RegisterQuark(actorID, gqi);
return m_RemoteGridService.RegisterQuark(syncServerID, locX, locY);
}
public virtual List<GridActorInfo> LookupQuark(GridQuarkInfo gqi)
public List<GridEndpointInfo> LookupQuark(uint locX, uint locY)
{
return m_RemoteGridService.LookupQuark(gqi);
return m_RemoteGridService.LookupQuark(locX, locY);
}
public virtual List<GridActorInfo> LookupQuark(GridQuarkInfo gqi, string actorType)
public List<GridEndpointInfo> LookupQuark(uint locX, uint locY, string actorType)
{
return m_RemoteGridService.LookupQuark(gqi, actorType);
return m_RemoteGridService.LookupQuark(locX, locY, actorType);
}
public bool CleanUpEndpoint(string syncServerID)
{
return m_RemoteGridService.CleanUpEndpoint(syncServerID);
}
#endregion SYNC SERVER
}

View File

@ -655,26 +655,30 @@ namespace OpenSim.Services.Connectors
#region SYNC SERVER
// Stubs for actor and quark management. Only implementation is in SimianGridService
public virtual bool RegisterActor(GridActorInfo gai, List<GridQuarkInfo> lgqi)
public bool RegisterEndpoint(GridEndpointInfo gei)
{
return false;
}
public virtual bool RegisterActor(GridActorInfo gai)
public bool RegisterActor(string actorID, string actorType, string syncServerID)
{
return false;
}
public virtual bool RegisterQuark(string actorID, GridQuarkInfo gqi)
public bool RegisterQuark(string syncServerID, uint locX, uint locY)
{
return false;
}
public virtual List<GridActorInfo> LookupQuark(GridQuarkInfo gqi)
public List<GridEndpointInfo> LookupQuark(uint locX, uint locY)
{
return null;
}
public virtual List<GridActorInfo> LookupQuark(GridQuarkInfo gqi, string actorType)
public List<GridEndpointInfo> LookupQuark(uint locX, uint locY, string actorType)
{
return null;
}
public bool CleanUpEndpoint(string syncServerID)
{
return false;
}
#endregion SYNC SERVER
}

View File

@ -434,115 +434,113 @@ namespace OpenSim.Services.Connectors.SimianGrid
}
#region SYNC SERVER
/// <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)
{
if (RegisterActor(gai))
{
bool success = true;
foreach (GridQuarkInfo gqi in lgqi)
{
if (!RegisterQuark(gai.actorID, gqi))
{
success = false;
break;
}
}
return success;
}
return false;
}
public virtual bool RegisterActor(GridActorInfo gai)
public virtual bool RegisterEndpoint(GridEndpointInfo gei)
{
NameValueCollection requestArgs = new NameValueCollection
{
{ "RequestMethod", "AddActor" },
{ "ActorID", gai.actorID },
{ "ActorType", gai.actorType },
{ "Address", gai.address },
{ "Port", gai.port.ToString() },
{ "RequestMethod", "AddEndpoint" },
{ "SyncServerID", gei.syncServerID },
{ "Address", gei.address },
{ "Port", gei.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());
m_log.WarnFormat("{0}: Registration of endpoint {1} at addr={2}:{3} successful",
"[SIMIAN GRID CONNECTOR]", gei.syncServerID, gei.address, gei.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"]);
m_log.ErrorFormat("{0}: Registration of endpoint {1} at addr={2}:{3} failed: {4}",
"[SIMIAN GRID CONNECTOR]", gei.syncServerID, gei.address, gei.port.ToString(), response["Message"]);
return false;
}
public virtual bool RegisterQuark(string actorID, GridQuarkInfo gqi)
public virtual bool RegisterActor(string actorID, string actorType, string syncServerID)
{
NameValueCollection requestArgs = new NameValueCollection
{
{ "RequestMethod", "AddActor" },
{ "ActorID", actorID },
{ "ActorType", actorType },
{ "SyncServerID", syncServerID },
};
OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs);
if (response["Success"].AsBoolean())
{
m_log.WarnFormat("{0}: Registration of actor {1} of type {2} successful",
"[SIMIAN GRID CONNECTOR]", actorID, actorType);
return true;
}
m_log.ErrorFormat("{0}: Registration of actor {1} of type {2} failed: {3}",
"[SIMIAN GRID CONNECTOR]", actorID, actorType, response["Message"]);
return false;
return false;
}
public virtual bool RegisterQuark(string syncServerID, uint locX, uint locY)
{
NameValueCollection requestArgs = new NameValueCollection
{
{ "RequestMethod", "AddQuark" },
{ "ActorID", actorID },
{ "LocX", gqi.locX.ToString() },
{ "LocY", gqi.locY.ToString() },
{ "SyncServerID", syncServerID },
{ "LocX", locX.ToString() },
{ "LocY", 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());
"[SIMIAN GRID CONNECTOR]", locX.ToString(), 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"]);
"[SIMIAN GRID CONNECTOR]", locX.ToString(), locY.ToString(), response["Message"]);
return false;
}
public virtual List<GridActorInfo> LookupQuark(GridQuarkInfo gqi)
public virtual List<GridEndpointInfo> LookupQuark(uint locX, uint locY)
{
NameValueCollection requestArgs = new NameValueCollection
{
{ "RequestMethod", "GetQuark" },
{ "LocX", gqi.locX.ToString() },
{ "LocY", gqi.locY.ToString() }
{ "LocX", locX.ToString() },
{ "LocY", locY.ToString() }
};
return LookupQuark(requestArgs);
}
public virtual List<GridActorInfo> LookupQuark(GridQuarkInfo gqi, string actorType)
public virtual List<GridEndpointInfo> LookupQuark(uint locX, uint locY, string actorType)
{
NameValueCollection requestArgs = new NameValueCollection
{
{ "RequestMethod", "GetQuark" },
{ "LocX", gqi.locX.ToString() },
{ "LocY", gqi.locY.ToString() },
{ "LocX", locX.ToString() },
{ "LocY", locY.ToString() },
{ "ActorType", actorType }
};
return LookupQuark(requestArgs);
}
private List<GridActorInfo> LookupQuark(NameValueCollection requestArgs)
private List<GridEndpointInfo> LookupQuark(NameValueCollection requestArgs)
{
OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs);
if (response["Success"].AsBoolean())
{
List<GridActorInfo> lgai = new List<GridActorInfo>();
OSDArray gridActors = (OSDArray)response["Actors"];
List<GridEndpointInfo> lgai = new List<GridEndpointInfo>();
OSDArray gridEndpoints = (OSDArray)response["Endpoints"];
m_log.WarnFormat("{0}: Lookup of quark successful. {1} addresses",
"[SIMIAN GRID CONNECTOR]", gridActors.Count);
for (int ii = 0; ii < gridActors.Count; ii++)
"[SIMIAN GRID CONNECTOR]", gridEndpoints.Count);
for (int ii = 0; ii < gridEndpoints.Count; ii++)
{
OSDMap thisGridActor = (OSDMap)gridActors[ii];
GridActorInfo gai = new GridActorInfo();
gai.actorID = thisGridActor["ActorID"].AsString();
gai.actorType = thisGridActor["ActorType"].AsString();
gai.address = thisGridActor["Address"].AsString();
gai.port = thisGridActor["Port"].AsInteger();
OSDMap thisEndpoint = (OSDMap)gridEndpoints[ii];
GridEndpointInfo gai = new GridEndpointInfo();
gai.syncServerID = thisEndpoint["SyncServerID"].AsString();
gai.actorType = thisEndpoint["ActorType"].AsString();
gai.address = thisEndpoint["Address"].AsString();
gai.port = (uint)thisEndpoint["Port"].AsInteger();
lgai.Add(gai);
}
return lgai;
@ -551,6 +549,40 @@ namespace OpenSim.Services.Connectors.SimianGrid
"[SIMIAN GRID CONNECTOR]", response["Message"]);
return null;
}
// Clean up the information for this endpoint. Removes both the endpoint
// information from the Endpoint table but also removes ALL the quarks associated
// with the endpoint.
public virtual bool CleanUpEndpoint(string syncServerID)
{
NameValueCollection requestArgs = new NameValueCollection
{
{ "RequestMethod", "RemoveEndpoint" },
{ "SyncServerID", syncServerID },
};
OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs);
if (response["Success"].AsBoolean())
{
requestArgs = new NameValueCollection
{
{ "RequestMethod", "RemoveQuark" },
{ "SyncServerID", syncServerID },
};
response = WebUtil.PostToService(m_ServerURI, requestArgs);
if (response["Success"].AsBoolean())
{
return true;
}
m_log.ErrorFormat("{0}: removal of quarks for Endpoint failed: {1}",
"[SIMIAN GRID CONNECTOR]", response["Message"]);
return false;
}
m_log.ErrorFormat("{0}: removal of Endpoint failed: {1}",
"[SIMIAN GRID CONNECTOR]", response["Message"]);
return false;
}
#endregion SYNC SERVER
}
}

View File

@ -551,26 +551,30 @@ namespace OpenSim.Services.GridService
#region SYNC SERVER
// Stubs for actor and quark management. Only implementation is in SimianGridService
public virtual bool RegisterActor(GridActorInfo gai, List<GridQuarkInfo> lgqi)
public bool RegisterEndpoint(GridEndpointInfo gei)
{
return false;
}
public virtual bool RegisterActor(GridActorInfo gai)
public bool RegisterActor(string actorID, string actorType, string syncServerID)
{
return false;
}
public virtual bool RegisterQuark(string actorID, GridQuarkInfo gqi)
public bool RegisterQuark(string syncServerID, uint locX, uint locY)
{
return false;
}
public virtual List<GridActorInfo> LookupQuark(GridQuarkInfo gqi)
public List<GridEndpointInfo> LookupQuark(uint locX, uint locY)
{
return null;
}
public virtual List<GridActorInfo> LookupQuark(GridQuarkInfo gqi, string actorType)
public List<GridEndpointInfo> LookupQuark(uint locX, uint locY, string actorType)
{
return null;
}
public bool CleanUpEndpoint(string syncServerID)
{
return false;
}
#endregion SYNC SERVER
}
}

View File

@ -97,26 +97,24 @@ namespace OpenSim.Services.Interfaces
int GetRegionFlags(UUID scopeID, UUID regionID);
// SYNC SERVER
bool RegisterActor(GridActorInfo gai, List<GridQuarkInfo> lgqi);
bool RegisterActor(GridActorInfo gai);
bool RegisterQuark(string actorID, GridQuarkInfo gqi);
List<GridActorInfo> LookupQuark(GridQuarkInfo gqi);
List<GridActorInfo> LookupQuark(GridQuarkInfo gqi, string actorType);
bool RegisterEndpoint(GridEndpointInfo gei);
bool RegisterActor(string actorID, string actorType, string syncServerID);
bool RegisterQuark(string syncServerID, uint locX, uint locY);
List<GridEndpointInfo> LookupQuark(uint locX, uint locY);
List<GridEndpointInfo> LookupQuark(uint locX, uint locY, string actorType);
bool CleanUpEndpoint(string syncServerID);
// END SYNC SERVER
}
// SYNC SERVER
public class GridQuarkInfo
{
public uint locX;
public uint locY;
}
public class GridActorInfo
public class GridEndpointInfo
{
public string syncServerID;
public string address;
public int port;
public uint port;
public string internalAddress;
public uint internalPort;
public string actorType;
public string actorID;
}
// END SYNC SERVER