diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs index 8892996394..9914a64e17 100644 --- a/OpenSim/Framework/RegionInfo.cs +++ b/OpenSim/Framework/RegionInfo.cs @@ -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]); diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/PhysEngineToSceneConnectorModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/PhysEngineToSceneConnectorModule.cs index 0b77ea898b..0e7d94276c 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/PhysEngineToSceneConnectorModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/PhysEngineToSceneConnectorModule.cs @@ -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(this); m_syncConfig = syncConfig; diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/PhysicsEngineSyncModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/PhysicsEngineSyncModule.cs index 757d6eb23f..addb52e041 100755 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/PhysicsEngineSyncModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/PhysicsEngineSyncModule.cs @@ -77,6 +77,13 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule //register the module with SceneGraph. If needed, SceneGraph checks the module's ActorType to know what type of module it is. m_scene.RegisterModuleInterface(this); + // register actor + if (!scene.GridService.RegisterActor(scene.RegionInfo.RegionID.ToString(), + "physics_engine", scene.RegionInfo.RegionID.ToString())) + { + m_log.ErrorFormat("{0}: Failure registering actor", LogHeader); + } + // Setup the command line interface //m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole; //InstallInterfaces(); diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs index 0d92ecf313..247af727da 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs @@ -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; @@ -876,6 +877,24 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule if (!addr.Equals(IPAddrUnknown) && port != PortUnknown) { RegionSyncListenerInfo info = new RegionSyncListenerInfo(addr, port); + + // 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 endpoint", 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; } @@ -897,6 +916,28 @@ 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)) + { + 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; + port = PortUnknown; + } + else + { + 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, + m_scene.RegionInfo.SyncQuarkLocationX, m_scene.RegionInfo.SyncQuarkLocationY, + addr, port.ToString()); + } + } + if (!addr.Equals(IPAddrUnknown) && port != PortUnknown) { RegionSyncListenerInfo info = new RegionSyncListenerInfo(addr, port); diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/ScenePersistenceSyncModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/ScenePersistenceSyncModule.cs index 69b3472728..5d6512b359 100755 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/ScenePersistenceSyncModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/ScenePersistenceSyncModule.cs @@ -74,6 +74,13 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule //register the module with SceneGraph. If needed, SceneGraph checks the module's ActorType to know what type of module it is. m_scene.RegisterModuleInterface(this); + // register actor + if (!scene.GridService.RegisterActor(scene.RegionInfo.RegionID.ToString(), + "scene_persistence", scene.RegionInfo.RegionID.ToString())) + { + m_log.ErrorFormat("{0}: Failure registering actor", LogHeader); + } + // Setup the command line interface //m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole; //InstallInterfaces(); diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs index 023a44c601..9315c1449a 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs @@ -256,5 +256,33 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid } } + #region SYNC SERVER + // Stubs for actor and quark management. Only implementation is in SimianGridService + public bool RegisterEndpoint(GridEndpointInfo gei) + { + return m_GridService.RegisterEndpoint(gei); + } + public bool RegisterActor(string actorID, string actorType, string syncServerID) + { + return m_GridService.RegisterActor(actorID, actorType, syncServerID); + } + public bool RegisterQuark(string syncServerID, uint locX, uint locY) + { + return m_GridService.RegisterQuark(syncServerID, locX, locY); + } + public List LookupQuark(uint locX, uint locY) + { + return m_GridService.LookupQuark(locX, locY); + } + public List LookupQuark(uint locX, uint locY, string 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 33cc838322..4797a7c3d7 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs @@ -288,5 +288,33 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid return flags; } #endregion + + #region SYNC SERVER + // Stubs for actor and quark management. Only implementation is in SimianGridService + public bool RegisterEndpoint(GridEndpointInfo gei) + { + return m_RemoteGridService.RegisterEndpoint(gei); + } + public bool RegisterActor(string actorID, string actorType, string syncServerID) + { + return m_RemoteGridService.RegisterActor(actorID, actorType, syncServerID); + } + public bool RegisterQuark(string syncServerID, uint locX, uint locY) + { + return m_RemoteGridService.RegisterQuark(syncServerID, locX, locY); + } + public List LookupQuark(uint locX, uint locY) + { + return m_RemoteGridService.LookupQuark(locX, locY); + } + public List LookupQuark(uint locX, uint locY, string 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 5092d741e6..10b28e0baf 100644 --- a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs +++ b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs @@ -653,5 +653,33 @@ namespace OpenSim.Services.Connectors #endregion + #region SYNC SERVER + // Stubs for actor and quark management. Only implementation is in SimianGridService + public bool RegisterEndpoint(GridEndpointInfo gei) + { + return false; + } + public bool RegisterActor(string actorID, string actorType, string syncServerID) + { + return false; + } + public bool RegisterQuark(string syncServerID, uint locX, uint locY) + { + return false; + } + public List LookupQuark(uint locX, uint locY) + { + return null; + } + 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 918544f1f6..d535bb4754 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs @@ -432,5 +432,157 @@ namespace OpenSim.Services.Connectors.SimianGrid return region; } + + #region SYNC SERVER + public virtual bool RegisterEndpoint(GridEndpointInfo gei) + { + NameValueCollection requestArgs = new NameValueCollection + { + { "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 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 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 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" }, + { "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]", locX.ToString(), locY.ToString()); + return true; + } + m_log.ErrorFormat("{0}: Registration of quark at {1}/{2} failed: {3}", + "[SIMIAN GRID CONNECTOR]", locX.ToString(), locY.ToString(), response["Message"]); + return false; + } + + public virtual List LookupQuark(uint locX, uint locY) + { + NameValueCollection requestArgs = new NameValueCollection + { + { "RequestMethod", "GetQuark" }, + { "LocX", locX.ToString() }, + { "LocY", locY.ToString() } + }; + return LookupQuark(requestArgs); + } + + public virtual List LookupQuark(uint locX, uint locY, string actorType) + { + NameValueCollection requestArgs = new NameValueCollection + { + { "RequestMethod", "GetQuark" }, + { "LocX", locX.ToString() }, + { "LocY", locY.ToString() }, + { "ActorType", actorType } + }; + return LookupQuark(requestArgs); + } + + private List LookupQuark(NameValueCollection requestArgs) + { + OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); + if (response["Success"].AsBoolean()) + { + List lgai = new List(); + OSDArray gridEndpoints = (OSDArray)response["Endpoints"]; + m_log.WarnFormat("{0}: Lookup of quark successful. {1} addresses", + "[SIMIAN GRID CONNECTOR]", gridEndpoints.Count); + for (int ii = 0; ii < gridEndpoints.Count; ii++) + { + 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; + } + m_log.ErrorFormat("{0}: Lookup of quark failed: {1}", + "[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 125c2be8cf..fe5ef489e1 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -548,5 +548,33 @@ namespace OpenSim.Services.GridService m_Database.Store(r); } } + + #region SYNC SERVER + // Stubs for actor and quark management. Only implementation is in SimianGridService + public bool RegisterEndpoint(GridEndpointInfo gei) + { + return false; + } + public bool RegisterActor(string actorID, string actorType, string syncServerID) + { + return false; + } + public bool RegisterQuark(string syncServerID, uint locX, uint locY) + { + return false; + } + public List LookupQuark(uint locX, uint locY) + { + return null; + } + 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 a34f0bebf6..56823954bc 100644 --- a/OpenSim/Services/Interfaces/IGridService.cs +++ b/OpenSim/Services/Interfaces/IGridService.cs @@ -95,8 +95,29 @@ namespace OpenSim.Services.Interfaces List GetHyperlinks(UUID scopeID); int GetRegionFlags(UUID scopeID, UUID regionID); + + // SYNC SERVER + 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 GridEndpointInfo + { + public string syncServerID; + public string address; + public uint port; + public string internalAddress; + public uint internalPort; + public string actorType; + } + // END SYNC SERVER + public class GridRegion : Object {