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); RegionSyncListenerInfo info = new RegionSyncListenerInfo(addr, port);
// Register this actor as a endpoint for this quark // remove any cruft from previous runs
// Note that this is wrong in that this module is not an actor m_scene.GridService.CleanUpEndpoint(m_scene.RegionInfo.RegionID.ToString());
// Resolve by figuring out registation of endpoints vs actors // Register the endpoint and quark and persistence actor for this simulator instance
List<GridQuarkInfo> lgqi = new List<GridQuarkInfo>(); GridEndpointInfo gei = new GridEndpointInfo();
GridQuarkInfo gqi = new GridQuarkInfo(); gei.syncServerID = m_scene.RegionInfo.RegionID.ToString();
gqi.locX = m_scene.RegionInfo.SyncQuarkLocationX; gei.address = m_scene.RegionInfo.SyncServerAddress;
gqi.locY = m_scene.RegionInfo.SyncQuarkLocationY; gei.port = (uint)m_scene.RegionInfo.SyncServerPort;
lgqi.Add(gqi); if (!m_scene.GridService.RegisterEndpoint(gei))
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); 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; 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 the address is not specified in the region configuration file, get it from the grid service
if (addr.Equals(IPAddrUnknown)) if (addr.Equals(IPAddrUnknown))
{ {
GridQuarkInfo gqi = new GridQuarkInfo(); List<GridEndpointInfo> lgei = m_scene.GridService.LookupQuark(
gqi.locX = m_scene.RegionInfo.SyncQuarkLocationX; m_scene.RegionInfo.SyncQuarkLocationX, m_scene.RegionInfo.SyncQuarkLocationY, "scene_persistence");
gqi.locY = m_scene.RegionInfo.SyncQuarkLocationY; if (lgei == null || lgei.Count != 1)
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); m_log.ErrorFormat("{0}: Failed to find quark persistence actor", LogHeader);
addr = IPAddrUnknown; addr = IPAddrUnknown;
@ -823,11 +822,12 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
} }
else else
{ {
GridActorInfo gai = lgai[0]; GridEndpointInfo gei = lgei[0];
addr = gai.address; addr = gei.address;
port = gai.port; port = (int)gei.port;
m_log.WarnFormat("{0}: Found quark ({1}/{2}) persistence actor at {3}:{4}", LogHeader, 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 #region SYNC SERVER
// Stubs for actor and quark management. Only implementation is in SimianGridService // 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 #endregion SYNC SERVER

View File

@ -291,25 +291,29 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
#region SYNC SERVER #region SYNC SERVER
// Stubs for actor and quark management. Only implementation is in SimianGridService // 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 #endregion SYNC SERVER
} }

View File

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

View File

@ -434,115 +434,113 @@ namespace OpenSim.Services.Connectors.SimianGrid
} }
#region SYNC SERVER #region SYNC SERVER
/// <summary> public virtual bool RegisterEndpoint(GridEndpointInfo gei)
/// 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)
{ {
NameValueCollection requestArgs = new NameValueCollection NameValueCollection requestArgs = new NameValueCollection
{ {
{ "RequestMethod", "AddActor" }, { "RequestMethod", "AddEndpoint" },
{ "ActorID", gai.actorID }, { "SyncServerID", gei.syncServerID },
{ "ActorType", gai.actorType }, { "Address", gei.address },
{ "Address", gai.address }, { "Port", gei.port.ToString() },
{ "Port", gai.port.ToString() },
}; };
OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs);
if (response["Success"].AsBoolean()) if (response["Success"].AsBoolean())
{ {
m_log.WarnFormat("{0}: Registration of actor {1} at addr={2}:{3} successful", m_log.WarnFormat("{0}: Registration of endpoint {1} at addr={2}:{3} successful",
"[SIMIAN GRID CONNECTOR]", gai.actorID, gai.address, gai.port.ToString()); "[SIMIAN GRID CONNECTOR]", gei.syncServerID, gei.address, gei.port.ToString());
return true; return true;
} }
m_log.ErrorFormat("{0}: Registration of actor {1} at addr={2}:{3} failed: {4}", m_log.ErrorFormat("{0}: Registration of endpoint {1} at addr={2}:{3} failed: {4}",
"[SIMIAN GRID CONNECTOR]", gai.actorID, gai.address, gai.port.ToString(), response["Message"]); "[SIMIAN GRID CONNECTOR]", gei.syncServerID, gei.address, gei.port.ToString(), response["Message"]);
return false; 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 NameValueCollection requestArgs = new NameValueCollection
{ {
{ "RequestMethod", "AddQuark" }, { "RequestMethod", "AddQuark" },
{ "ActorID", actorID }, { "SyncServerID", syncServerID },
{ "LocX", gqi.locX.ToString() }, { "LocX", locX.ToString() },
{ "LocY", gqi.locY.ToString() }, { "LocY", locY.ToString() },
}; };
OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs);
if (response["Success"].AsBoolean()) if (response["Success"].AsBoolean())
{ {
m_log.WarnFormat("{0}: Registration of quark at {1}/{2} successful", 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; return true;
} }
m_log.ErrorFormat("{0}: Registration of quark at {1}/{2} failed: {3}", 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; return false;
} }
public virtual List<GridActorInfo> LookupQuark(GridQuarkInfo gqi) public virtual List<GridEndpointInfo> LookupQuark(uint locX, uint locY)
{ {
NameValueCollection requestArgs = new NameValueCollection NameValueCollection requestArgs = new NameValueCollection
{ {
{ "RequestMethod", "GetQuark" }, { "RequestMethod", "GetQuark" },
{ "LocX", gqi.locX.ToString() }, { "LocX", locX.ToString() },
{ "LocY", gqi.locY.ToString() } { "LocY", locY.ToString() }
}; };
return LookupQuark(requestArgs); 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 NameValueCollection requestArgs = new NameValueCollection
{ {
{ "RequestMethod", "GetQuark" }, { "RequestMethod", "GetQuark" },
{ "LocX", gqi.locX.ToString() }, { "LocX", locX.ToString() },
{ "LocY", gqi.locY.ToString() }, { "LocY", locY.ToString() },
{ "ActorType", actorType } { "ActorType", actorType }
}; };
return LookupQuark(requestArgs); return LookupQuark(requestArgs);
} }
private List<GridActorInfo> LookupQuark(NameValueCollection requestArgs) private List<GridEndpointInfo> LookupQuark(NameValueCollection requestArgs)
{ {
OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs);
if (response["Success"].AsBoolean()) if (response["Success"].AsBoolean())
{ {
List<GridActorInfo> lgai = new List<GridActorInfo>(); List<GridEndpointInfo> lgai = new List<GridEndpointInfo>();
OSDArray gridActors = (OSDArray)response["Actors"]; OSDArray gridEndpoints = (OSDArray)response["Endpoints"];
m_log.WarnFormat("{0}: Lookup of quark successful. {1} addresses", m_log.WarnFormat("{0}: Lookup of quark successful. {1} addresses",
"[SIMIAN GRID CONNECTOR]", gridActors.Count); "[SIMIAN GRID CONNECTOR]", gridEndpoints.Count);
for (int ii = 0; ii < gridActors.Count; ii++) for (int ii = 0; ii < gridEndpoints.Count; ii++)
{ {
OSDMap thisGridActor = (OSDMap)gridActors[ii]; OSDMap thisEndpoint = (OSDMap)gridEndpoints[ii];
GridActorInfo gai = new GridActorInfo(); GridEndpointInfo gai = new GridEndpointInfo();
gai.actorID = thisGridActor["ActorID"].AsString(); gai.syncServerID = thisEndpoint["SyncServerID"].AsString();
gai.actorType = thisGridActor["ActorType"].AsString(); gai.actorType = thisEndpoint["ActorType"].AsString();
gai.address = thisGridActor["Address"].AsString(); gai.address = thisEndpoint["Address"].AsString();
gai.port = thisGridActor["Port"].AsInteger(); gai.port = (uint)thisEndpoint["Port"].AsInteger();
lgai.Add(gai); lgai.Add(gai);
} }
return lgai; return lgai;
@ -551,6 +549,40 @@ namespace OpenSim.Services.Connectors.SimianGrid
"[SIMIAN GRID CONNECTOR]", response["Message"]); "[SIMIAN GRID CONNECTOR]", response["Message"]);
return null; 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 #endregion SYNC SERVER
} }
} }

View File

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

View File

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