From 9970677ed8271c8779544547d239b84f2a396f2b Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Fri, 11 Feb 2011 15:50:25 -0800 Subject: [PATCH] Quark/Endpoint registration and lookup for three table database --- .../SymmetricSync/RegionSyncModule.cs | 56 +++---- .../Grid/LocalGridServiceConnector.cs | 24 +-- .../Grid/RemoteGridServiceConnector.cs | 24 +-- .../Connectors/Grid/GridServiceConnector.cs | 14 +- .../SimianGrid/SimianGridServiceConnector.cs | 146 +++++++++++------- OpenSim/Services/GridService/GridService.cs | 14 +- OpenSim/Services/Interfaces/IGridService.cs | 24 ++- 7 files changed, 174 insertions(+), 128 deletions(-) diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs index 2a34e4a2d6..0a9ad781ac 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs @@ -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 lgqi = new List(); - 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 lgai = m_scene.GridService.LookupQuark(gqi, "scene_persistence"); - if (lgai == null || lgai.Count != 1) + List 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()); } } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs index 276130feeb..9315c1449a 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs @@ -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 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 LookupQuark(GridQuarkInfo gqi) + public List LookupQuark(uint locX, uint locY) { - return m_GridService.LookupQuark(gqi); + return m_GridService.LookupQuark(locX, locY); } - public virtual List LookupQuark(GridQuarkInfo gqi, string actorType) + public List 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 diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs index b45f4c81fb..4797a7c3d7 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs @@ -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 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 LookupQuark(GridQuarkInfo gqi) + public List LookupQuark(uint locX, uint locY) { - return m_RemoteGridService.LookupQuark(gqi); + return m_RemoteGridService.LookupQuark(locX, locY); } - public virtual List LookupQuark(GridQuarkInfo gqi, string actorType) + public List 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 } diff --git a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs index 849b83b9e7..10b28e0baf 100644 --- a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs +++ b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs @@ -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 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 LookupQuark(GridQuarkInfo gqi) + public List LookupQuark(uint locX, uint locY) { return null; } - public virtual List LookupQuark(GridQuarkInfo gqi, string actorType) + public List LookupQuark(uint locX, uint locY, string actorType) { return null; } + public bool CleanUpEndpoint(string syncServerID) + { + return false; + } #endregion SYNC SERVER } diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs index 561ee4a89a..d535bb4754 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs @@ -434,115 +434,113 @@ namespace OpenSim.Services.Connectors.SimianGrid } #region SYNC SERVER - /// - /// Register an actor and it's associated quarks - /// - /// - /// - /// - public virtual bool RegisterActor(GridActorInfo gai, List 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 LookupQuark(GridQuarkInfo gqi) + public virtual List 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 LookupQuark(GridQuarkInfo gqi, string actorType) + public virtual List 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 LookupQuark(NameValueCollection requestArgs) + private List LookupQuark(NameValueCollection requestArgs) { OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); if (response["Success"].AsBoolean()) { - List lgai = new List(); - OSDArray gridActors = (OSDArray)response["Actors"]; + List lgai = new List(); + 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 } } diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index acd0475487..fe5ef489e1 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -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 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 LookupQuark(GridQuarkInfo gqi) + public List LookupQuark(uint locX, uint locY) { return null; } - public virtual List LookupQuark(GridQuarkInfo gqi, string actorType) + public List LookupQuark(uint locX, uint locY, string actorType) { return null; } + public bool CleanUpEndpoint(string syncServerID) + { + return false; + } #endregion SYNC SERVER } } diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs index db3dc1a5fa..56823954bc 100644 --- a/OpenSim/Services/Interfaces/IGridService.cs +++ b/OpenSim/Services/Interfaces/IGridService.cs @@ -97,26 +97,24 @@ namespace OpenSim.Services.Interfaces int GetRegionFlags(UUID scopeID, UUID regionID); // SYNC SERVER - bool RegisterActor(GridActorInfo gai, List lgqi); - bool RegisterActor(GridActorInfo gai); - bool RegisterQuark(string actorID, GridQuarkInfo gqi); - List LookupQuark(GridQuarkInfo gqi); - List 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 LookupQuark(uint locX, uint locY); + List 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