From 33330297d603a66cc157baa21c81328edc893e51 Mon Sep 17 00:00:00 2001 From: diva Date: Fri, 20 Feb 2009 03:39:50 +0000 Subject: THE BIG ANTI-REMOTING SCHLEP -- StartRemoting is no more. Sims in older versions will have a hard time communicating with sims on this release and later, especially if they haven't transitioned to RESTComms at all. There's still some cleanup to do on assorted data structures, but the main functional change here is that sims no longer listen on remoting ports. --- .../Hypergrid/HGCommunicationsGridMode.cs | 1 - .../Hypergrid/HGCommunicationsStandalone.cs | 3 +- .../Communications/Hypergrid/HGGridServices.cs | 330 +------- .../Hypergrid/HGGridServicesGridMode.cs | 122 --- .../Hypergrid/HGGridServicesStandalone.cs | 679 --------------- .../Communications/Local/CommunicationsLocal.cs | 2 - .../Communications/Local/LocalBackEndServices.cs | 217 +---- .../Communications/OGS1/CommunicationsOGS1.cs | 1 - .../Region/Communications/OGS1/OGS1GridServices.cs | 913 +-------------------- .../Communications/OGS1/OGS1InterSimComms.cs | 263 ------ 10 files changed, 4 insertions(+), 2527 deletions(-) delete mode 100644 OpenSim/Region/Communications/OGS1/OGS1InterSimComms.cs (limited to 'OpenSim/Region/Communications') diff --git a/OpenSim/Region/Communications/Hypergrid/HGCommunicationsGridMode.cs b/OpenSim/Region/Communications/Hypergrid/HGCommunicationsGridMode.cs index c8a540b..8b7c3d1 100644 --- a/OpenSim/Region/Communications/Hypergrid/HGCommunicationsGridMode.cs +++ b/OpenSim/Region/Communications/Hypergrid/HGCommunicationsGridMode.cs @@ -56,7 +56,6 @@ namespace OpenSim.Region.Communications.Hypergrid // From constructor at CommunicationsOGS1 HGGridServices gridInterComms = new HGGridServicesGridMode(serversInfo, httpServer, assetCache, sman, m_userProfileCacheService); m_gridService = gridInterComms; - m_interRegion = gridInterComms; m_osw = gridInterComms; // The HG InventoryService always uses secure handlers diff --git a/OpenSim/Region/Communications/Hypergrid/HGCommunicationsStandalone.cs b/OpenSim/Region/Communications/Hypergrid/HGCommunicationsStandalone.cs index 5feea4d..21e651d 100644 --- a/OpenSim/Region/Communications/Hypergrid/HGCommunicationsStandalone.cs +++ b/OpenSim/Region/Communications/Hypergrid/HGCommunicationsStandalone.cs @@ -44,9 +44,8 @@ namespace OpenSim.Region.Communications.Hypergrid IUserService userService, IUserAdminService userServiceAdmin, LocalInventoryService inventoryService, - IInterRegionCommunications interRegionService, HGGridServices gridService, IMessagingService messageService, LibraryRootFolder libraryRootFolder, bool dumpAssetsToFile) - : base(serversInfo, httpServer, assetCache, userService, userServiceAdmin, inventoryService, interRegionService, gridService, messageService, libraryRootFolder, dumpAssetsToFile) + : base(serversInfo, httpServer, assetCache, userService, userServiceAdmin, inventoryService, gridService, messageService, libraryRootFolder, dumpAssetsToFile) { gridService.UserProfileCache = m_userProfileCacheService; m_assetCache = assetCache; diff --git a/OpenSim/Region/Communications/Hypergrid/HGGridServices.cs b/OpenSim/Region/Communications/Hypergrid/HGGridServices.cs index 24db63e..08d74f3 100644 --- a/OpenSim/Region/Communications/Hypergrid/HGGridServices.cs +++ b/OpenSim/Region/Communications/Hypergrid/HGGridServices.cs @@ -55,7 +55,7 @@ namespace OpenSim.Region.Communications.Hypergrid /// hyperlinks, as well as processing all the inter-region comms between a region and /// an hyperlinked region. /// - public class HGGridServices : IGridServices, IInterRegionCommunications, IHyperlink + public class HGGridServices : IGridServices, IHyperlink { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -777,80 +777,6 @@ namespace OpenSim.Region.Communications.Hypergrid return resp; } - #region IInterRegionCommunications interface - - public virtual bool AcknowledgeAgentCrossed(ulong regionHandle, UUID agentId) { return false; } - public virtual bool AcknowledgePrimCrossed(ulong regionHandle, UUID primID) { return false; } - public virtual bool CheckRegion(string address, uint port) { return false; } - public virtual bool ChildAgentUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentData) { return false; } - - public virtual bool ExpectAvatarCrossing(ulong regionHandle, UUID agentID, Vector3 position, bool isFlying) { - // Remote region - RegionInfo regInfo = null; - ulong remoteHandle = 0; - try - { - regInfo = RequestNeighbourInfo(regionHandle); - if (regInfo != null) - { - try - { - remoteHandle = Convert.ToUInt64(regInfo.regionSecret); - } - catch - { - m_log.Warn("[HGrid]: Invalid remote region with handle " + regInfo.regionSecret); - return false; - } - //Console.WriteLine("XXX---- Sending Expectavatarcrossing into : " + remoteHandle); - - bool retValue = false; - OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting)Activator.GetObject( - typeof(OGS1InterRegionRemoting), - "tcp://" + regInfo.RemotingAddress + - ":" + regInfo.RemotingPort + - "/InterRegions"); - - if (remObject != null) - { - retValue = - remObject.ExpectAvatarCrossing(remoteHandle, agentID.Guid, new sLLVector3(position), - isFlying); - } - else - { - m_log.Warn("[HGrid]: Remoting object not found"); - } - remObject = null; - - return retValue; - } - //TODO need to see if we know about where this region is and use .net remoting - // to inform it. - //NoteDeadRegion(regionHandle); - return false; - } - catch (RemotingException e) - { -// NoteDeadRegion(regionHandle); - - m_log.WarnFormat( - "[HGrid]: Remoting Error: Unable to connect to adjacent region: {0} {1},{2}", - regInfo.RegionName, regInfo.RegionLocX, regInfo.RegionLocY); - m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); - - return false; - } - catch - { -// NoteDeadRegion(regionHandle); - return false; - } - - } - - public virtual bool ExpectPrimCrossing(ulong regionHandle, UUID primID, Vector3 position, bool isFlying) { return false; } - public bool SendUserInformation(RegionInfo regInfo, AgentCircuitData agentData) { CachedUserInfo uinfo = m_userProfileCache.GetUserDetails(agentData.AgentID); @@ -887,260 +813,6 @@ namespace OpenSim.Region.Communications.Hypergrid return true; } - public virtual bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData) - { - // If we're here, it's because regionHandle is a remote, non-grided region - m_log.Info("[HGrid]: InformRegionOfChildAgent for " + regionHandle); - - RegionInfo regInfo = GetHyperlinkRegion(regionHandle); - if (regInfo == null) - return false; - - //ulong realHandle = regionHandle; - - if (!SendUserInformation(regInfo, agentData)) - { - m_log.Warn("[HGrid]: Failed to inform remote region of user."); - //return false; - } - - try - { - // ... and then - - m_log.Debug("[HGrid]: Region is hyperlink."); - bool retValue = false; - try - { - regionHandle = Convert.ToUInt64(regInfo.regionSecret); - } - catch (Exception) - { - m_log.Warn("[HGrid]: Invalid hyperlink region."); - return false; - } - - OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting)Activator.GetObject( - typeof(OGS1InterRegionRemoting), - "tcp://" + regInfo.RemotingAddress + - ":" + regInfo.RemotingPort + - "/InterRegions"); - - if (remObject != null) - { - sAgentCircuitData sag = new sAgentCircuitData(agentData); - //CachedUserInfo uinfo = m_userProfileCache.GetUserDetails(agentData.AgentID); - - //// May need to change agent's name - //if (IsLocalUser(uinfo)) - //{ - // sag.firstname = agentData.firstname + "." + agentData.lastname; - // sag.lastname = serversInfo.UserURL; //HGNetworkServersInfo.Singleton.LocalUserServerURI; - //} - retValue = remObject.InformRegionOfChildAgent(regionHandle, sag); - } - else - { - m_log.Warn("[HGrid]: remoting object not found"); - } - remObject = null; - m_log.Info("[HGrid]: tried to InformRegionOfChildAgent for " + - agentData.firstname + " " + agentData.lastname + " and got " + - retValue.ToString()); - - // Remove the info from this region - //if (m_knownRegions.ContainsKey(uinfo.UserProfile.ID)) - // m_knownRegions.Remove(uinfo.UserProfile.ID); - - return retValue; - } - catch (RemotingException e) - { - //NoteDeadRegion(regionHandle); - - m_log.WarnFormat( - "[HGrid]: Remoting Error: Unable to connect to adjacent region: {0} {1},{2}", - regInfo.RegionName, regInfo.RegionLocX, regInfo.RegionLocY); - m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); - - return false; - } - catch (SocketException e) - { - //NoteDeadRegion(regionHandle); - - m_log.WarnFormat( - "[HGrid]: Remoting Error: Unable to connect to adjacent region: {0} {1},{2}", - regInfo.RegionName, regInfo.RegionLocX, regInfo.RegionLocY); - m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); - - return false; - } - catch (InvalidCredentialException e) - { - //NoteDeadRegion(regionHandle); - - m_log.WarnFormat( - "[HGrid]: Remoting Error: Unable to connect to adjacent region: {0} {1},{2}", - regInfo.RegionName, regInfo.RegionLocX, regInfo.RegionLocY); - m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); - - return false; - } - catch (AuthenticationException e) - { - //NoteDeadRegion(regionHandle); - - m_log.WarnFormat( - "[HGrid]: Remoting Error: Unable to connect to adjacent region: {0} {1},{2}", - regInfo.RegionName, regInfo.RegionLocX, regInfo.RegionLocY); - m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); - - return false; - } - catch (Exception e) - { - //NoteDeadRegion(regionHandle); - - if (regInfo != null) - { - m_log.WarnFormat( - "[HGrid]: Remoting Error: Unable to connect to adjacent region: {0} {1},{2}", - regInfo.RegionName, regInfo.RegionLocX, regInfo.RegionLocY); - } - m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); - - return false; - } - - - } - - public virtual bool InformRegionOfPrimCrossing(ulong regionHandle, UUID primID, string objData, int XMLMethod) { return false; } - - public virtual bool RegionUp(SerializableRegionInfo region, ulong regionhandle) { - - ulong realHandle = FindRegionHandle(regionhandle); - - if (realHandle == regionhandle) // something wrong, not remote region - return false; - - SerializableRegionInfo regInfo = null; - try - { - // You may ask why this is in here... - // The region asking the grid services about itself.. - // And, surprisingly, the reason is.. it doesn't know - // it's own remoting port! How special. - RegionUpData regiondata = new RegionUpData(region.RegionLocX, region.RegionLocY, region.ExternalHostName, region.InternalEndPoint.Port); - - region = new SerializableRegionInfo(RequestNeighbourInfo(realHandle)); - region.RemotingAddress = region.ExternalHostName; - region.RemotingPort = NetworkServersInfo.RemotingListenerPort; - region.HttpPort = serversInfo.HttpListenerPort; - - regInfo = new SerializableRegionInfo(RequestNeighbourInfo(regionhandle)); - if (regInfo != null) - { - // If we're not trying to remote to ourselves. - if (regInfo.RemotingAddress != region.RemotingAddress && region.RemotingAddress != null) - { - //don't want to be creating a new link to the remote instance every time like we are here - bool retValue = false; - - OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting)Activator.GetObject( - typeof(OGS1InterRegionRemoting), - "tcp://" + - regInfo.RemotingAddress + - ":" + regInfo.RemotingPort + - "/InterRegions"); - - if (remObject != null) - { - retValue = remObject.RegionUp(regiondata, realHandle); - } - else - { - m_log.Warn("[HGrid]: remoting object not found"); - } - remObject = null; - - m_log.Info( - "[HGrid]: tried to inform region I'm up"); - - return retValue; - } - else - { - // We're trying to inform ourselves via remoting. - // This is here because we're looping over the listeners before we get here. - // Odd but it should work. - return true; - } - } - - return false; - } - catch (RemotingException e) - { - m_log.Warn("[HGrid]: Remoting Error: Unable to connect to adjacent region using tcp://" + - regInfo.RemotingAddress + - ":" + regInfo.RemotingPort + - "/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY + - " - Is this neighbor up?"); - m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); - return false; - } - catch (SocketException e) - { - m_log.Warn("[HGrid]: Socket Error: Unable to connect to adjacent region using tcp://" + - regInfo.RemotingAddress + - ":" + regInfo.RemotingPort + - "/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY + - " - Is this neighbor up?"); - m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); - return false; - } - catch (InvalidCredentialException e) - { - m_log.Warn("[HGrid]: Invalid Credentials: Unable to connect to adjacent region using tcp://" + - regInfo.RemotingAddress + - ":" + regInfo.RemotingPort + - "/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY); - m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); - return false; - } - catch (AuthenticationException e) - { - m_log.Warn("[HGrid]: Authentication exception: Unable to connect to adjacent region using tcp://" + - regInfo.RemotingAddress + - ":" + regInfo.RemotingPort + - "/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY); - m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); - return false; - } - catch (Exception e) - { - m_log.Debug(e.ToString()); - return false; - } - - } - - public virtual bool TellRegionToCloseChildConnection(ulong regionHandle, UUID agentID) { return false; } - - public virtual List InformFriendsInOtherRegion(UUID agentId, ulong destRegionHandle, List friends, bool online) - { - return new List(); - } - - public virtual bool TriggerTerminateFriend(ulong regionHandle, UUID agentID, UUID exFriendID) - { - return true; - } - - - #endregion #region Methods triggered by calls from external instances diff --git a/OpenSim/Region/Communications/Hypergrid/HGGridServicesGridMode.cs b/OpenSim/Region/Communications/Hypergrid/HGGridServicesGridMode.cs index 94646d2..85fb4b7 100644 --- a/OpenSim/Region/Communications/Hypergrid/HGGridServicesGridMode.cs +++ b/OpenSim/Region/Communications/Hypergrid/HGGridServicesGridMode.cs @@ -71,9 +71,6 @@ namespace OpenSim.Region.Communications.Hypergrid : base(servers_info, httpServe, asscache, sman) { m_remoteBackend = new OGS1GridServices(servers_info, httpServe); - // Let's deregister this, so we can handle it here first - InterRegionSingleton.Instance.OnChildAgent -= m_remoteBackend.IncomingChildAgent; - InterRegionSingleton.Instance.OnChildAgent += IncomingChildAgent; m_userProfileCache = userv; } @@ -158,125 +155,6 @@ namespace OpenSim.Region.Communications.Hypergrid #endregion - #region IInterRegionCommunications interface - - public override bool AcknowledgeAgentCrossed(ulong regionHandle, UUID agentId) - { - return m_remoteBackend.AcknowledgeAgentCrossed(regionHandle, agentId); - } - - public override bool AcknowledgePrimCrossed(ulong regionHandle, UUID primID) - { - return m_remoteBackend.AcknowledgePrimCrossed(regionHandle, primID); - } - - public override bool CheckRegion(string address, uint port) - { - return m_remoteBackend.CheckRegion(address, port); - } - - public override bool ChildAgentUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentData) - { - return m_remoteBackend.ChildAgentUpdate(regionHandle, cAgentData); - } - - public override bool ExpectAvatarCrossing(ulong regionHandle, UUID agentID, Vector3 position, bool isFlying) - { - if (base.ExpectAvatarCrossing(regionHandle, agentID, position, isFlying)) - return true; - return m_remoteBackend.ExpectAvatarCrossing(regionHandle, agentID, position, isFlying); - } - - public override bool ExpectPrimCrossing(ulong regionHandle, UUID primID, Vector3 position, bool isFlying) - { - return m_remoteBackend.ExpectPrimCrossing(regionHandle, primID, position, isFlying); - } - - public override bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData) - { - CachedUserInfo user = m_userProfileCache.GetUserDetails(agentData.AgentID); - - if (IsLocalUser(user)) - { - Console.WriteLine("XXX Home User XXX"); - if (IsHyperlinkRegion(regionHandle)) - { - Console.WriteLine("XXX Going Hyperlink XXX"); - return base.InformRegionOfChildAgent(regionHandle, agentData); - } - else - { - // non-hypergrid case - Console.WriteLine("XXX Going local-grid region XXX"); - return m_remoteBackend.InformRegionOfChildAgent(regionHandle, agentData); - } - } - - // Foregin users - Console.WriteLine("XXX Foreign User XXX"); - if (IsLocalRegion(regionHandle)) // regions on the same instance - { - Console.WriteLine("XXX Going onInstance region XXX"); - return m_remoteBackend.InformRegionOfChildAgent(regionHandle, agentData); - } - - if (IsHyperlinkRegion(regionHandle)) // hyperlinked regions - { - Console.WriteLine("XXX Going Hyperlink XXX"); - return base.InformRegionOfChildAgent(regionHandle, agentData); - } - else - { - // foreign user going to a non-local region on the same grid - // We need to inform that region about this user before - // proceeding to the normal backend process. - Console.WriteLine("XXX Going local-grid region XXX"); - RegionInfo regInfo = RequestNeighbourInfo(regionHandle); - if (regInfo != null) - // For now, don't test if this succeeds/fails; until someone complains, this is a feature :-) - InformRegionOfUser(regInfo, agentData); - return m_remoteBackend.InformRegionOfChildAgent(regionHandle, agentData); - } - - } - - public override bool InformRegionOfPrimCrossing(ulong regionHandle, UUID primID, string objData, int XMLMethod) - { - return m_remoteBackend.InformRegionOfPrimCrossing(regionHandle, primID, objData, XMLMethod); - } - - public override bool RegionUp(SerializableRegionInfo region, ulong regionhandle) - { - if (m_remoteBackend.RegionUp(region, regionhandle)) - return true; - return base.RegionUp(region, regionhandle); - } - - public override bool TellRegionToCloseChildConnection(ulong regionHandle, UUID agentID) - { - return m_remoteBackend.TellRegionToCloseChildConnection(regionHandle, agentID); - } - - - #endregion - - #region Methods triggered by calls from external instances - - /// - /// - /// - /// - /// - /// - public bool IncomingChildAgent(ulong regionHandle, AgentCircuitData agentData) - { - AdjustUserInformation(agentData); - - m_log.Info("[HGrid]: Incoming HGrid Agent " + agentData.firstname + " " + agentData.lastname); - - return m_remoteBackend.IncomingChildAgent(regionHandle, agentData); - } - #endregion } } diff --git a/OpenSim/Region/Communications/Hypergrid/HGGridServicesStandalone.cs b/OpenSim/Region/Communications/Hypergrid/HGGridServicesStandalone.cs index ea8ac2e..36d4b99 100644 --- a/OpenSim/Region/Communications/Hypergrid/HGGridServicesStandalone.cs +++ b/OpenSim/Region/Communications/Hypergrid/HGGridServicesStandalone.cs @@ -84,7 +84,6 @@ namespace OpenSim.Region.Communications.Hypergrid httpServer.AddXmlRPCHandler("check", PingCheckReply); httpServer.AddXmlRPCHandler("land_data", LandData); - StartRemoting(); } #region IGridServices interface @@ -256,683 +255,5 @@ namespace OpenSim.Region.Communications.Hypergrid #endregion - #region Remoting - - /// - /// Start listening for .net remoting calls from other regions. - /// - private void StartRemoting() - { - m_log.Info("[HGrid]: Start remoting..."); - TcpChannel ch; - try - { - ch = new TcpChannel((int)NetworkServersInfo.RemotingListenerPort); - ChannelServices.RegisterChannel(ch, false); // Disabled security as Mono doesn't support this. - } - catch (Exception ex) - { - m_log.Error("[HGrid]: Exception while attempting to listen on TCP port " + (int)NetworkServersInfo.RemotingListenerPort + "."); - throw (ex); - } - - WellKnownServiceTypeEntry wellType = - new WellKnownServiceTypeEntry(typeof(OGS1InterRegionRemoting), "InterRegions", - WellKnownObjectMode.Singleton); - RemotingConfiguration.RegisterWellKnownServiceType(wellType); - InterRegionSingleton.Instance.OnArrival += TriggerExpectAvatarCrossing; - InterRegionSingleton.Instance.OnChildAgent += IncomingChildAgent; - InterRegionSingleton.Instance.OnPrimGroupArrival += IncomingPrim; - InterRegionSingleton.Instance.OnPrimGroupNear += TriggerExpectPrimCrossing; - InterRegionSingleton.Instance.OnRegionUp += TriggerRegionUp; - InterRegionSingleton.Instance.OnChildAgentUpdate += TriggerChildAgentUpdate; - InterRegionSingleton.Instance.OnTellRegionToCloseChildConnection += TriggerTellRegionToCloseChildConnection; - } - - - #endregion - - #region IInterRegionCommunications interface (Methods called by regions in this instance) - - public override bool ChildAgentUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentData) - { - int failures = 0; - lock (m_deadRegionCache) - { - if (m_deadRegionCache.ContainsKey(regionHandle)) - { - failures = m_deadRegionCache[regionHandle]; - } - } - if (failures <= 3) - { - RegionInfo regInfo = null; - try - { - if (m_localBackend.ChildAgentUpdate(regionHandle, cAgentData)) - { - return true; - } - - regInfo = RequestNeighbourInfo(regionHandle); - if (regInfo != null) - { - //don't want to be creating a new link to the remote instance every time like we are here - bool retValue = false; - - - OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting)Activator.GetObject( - typeof(OGS1InterRegionRemoting), - "tcp://" + regInfo.RemotingAddress + - ":" + regInfo.RemotingPort + - "/InterRegions"); - - if (remObject != null) - { - retValue = remObject.ChildAgentUpdate(regionHandle, cAgentData); - } - else - { - m_log.Warn("[HGrid]: remoting object not found"); - } - remObject = null; - - return retValue; - } - NoteDeadRegion(regionHandle); - - return false; - } - catch (RemotingException e) - { - NoteDeadRegion(regionHandle); - - m_log.WarnFormat( - "[HGrid]: Remoting Error: Unable to connect to adjacent region: {0} {1},{2}", - regInfo.RegionName, regInfo.RegionLocX, regInfo.RegionLocY); - m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); - - return false; - } - catch (SocketException e) - { - NoteDeadRegion(regionHandle); - - m_log.WarnFormat( - "[HGrid]: Remoting Error: Unable to connect to adjacent region: {0} {1},{2}", - regInfo.RegionName, regInfo.RegionLocX, regInfo.RegionLocY); - m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); - - return false; - } - catch (InvalidCredentialException e) - { - NoteDeadRegion(regionHandle); - - m_log.WarnFormat( - "[HGrid]: Remoting Error: Unable to connect to adjacent region: {0} {1},{2}", - regInfo.RegionName, regInfo.RegionLocX, regInfo.RegionLocY); - m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); - - return false; - } - catch (AuthenticationException e) - { - NoteDeadRegion(regionHandle); - - m_log.WarnFormat( - "[HGrid]: Remoting Error: Unable to connect to adjacent region: {0} {1},{2}", - regInfo.RegionName, regInfo.RegionLocX, regInfo.RegionLocY); - m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); - - return false; - } - catch (Exception e) - { - NoteDeadRegion(regionHandle); - - m_log.WarnFormat("[HGrid]: Unable to connect to adjacent region: {0} {1},{2}", - regInfo.RegionName, regInfo.RegionLocX, regInfo.RegionLocY); - m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); - - return false; - } - } - else - { - //m_log.Info("[INTERREGION]: Skipped Sending Child Update to a region because it failed too many times:" + regionHandle.ToString()); - return false; - } - } - - /// - /// Inform a region that a child agent will be on the way from a client. - /// - /// - /// - /// - public override bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData) - { - - if (m_localBackend.InformRegionOfChildAgent(regionHandle, agentData)) - { - return true; - } - return base.InformRegionOfChildAgent(regionHandle, agentData); - } - - // UGLY! - public override bool RegionUp(SerializableRegionInfo region, ulong regionhandle) - { - if (m_localBackend.RegionUp(region, regionhandle)) - return true; - return base.RegionUp(region, regionhandle); - } - - /// - /// - /// - /// - /// - /// - public override bool InformRegionOfPrimCrossing(ulong regionHandle, UUID primID, string objData, int XMLMethod) - { - int failures = 0; - lock (m_deadRegionCache) - { - if (m_deadRegionCache.ContainsKey(regionHandle)) - { - failures = m_deadRegionCache[regionHandle]; - } - } - if (failures <= 1) - { - RegionInfo regInfo = null; - try - { - if (m_localBackend.InformRegionOfPrimCrossing(regionHandle, primID, objData, XMLMethod)) - { - return true; - } - - regInfo = RequestNeighbourInfo(regionHandle); - if (regInfo != null) - { - try - { - regionHandle = Convert.ToUInt64(regInfo.regionSecret); - } - catch (Exception) - { - m_log.Warn("[HGrid]: Invalid hyperlink region."); - return false; - } - - //don't want to be creating a new link to the remote instance every time like we are here - bool retValue = false; - - OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting)Activator.GetObject( - typeof(OGS1InterRegionRemoting), - "tcp://" + regInfo.RemotingAddress + - ":" + regInfo.RemotingPort + - "/InterRegions"); - - if (remObject != null) - { - m_log.Debug("[HGrid]: Inform region of prim crossing: " + regInfo.RemotingAddress + ":" + regInfo.RemotingPort); - retValue = remObject.InformRegionOfPrimCrossing(regionHandle, primID.Guid, objData, XMLMethod); - } - else - { - m_log.Warn("[HGrid]: Remoting object not found"); - } - remObject = null; - - return retValue; - } - NoteDeadRegion(regionHandle); - return false; - } - catch (RemotingException e) - { - NoteDeadRegion(regionHandle); - m_log.Warn("[HGrid]: Remoting Error: Unable to connect to adjacent region: " + regionHandle); - m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); - return false; - } - catch (SocketException e) - { - NoteDeadRegion(regionHandle); - m_log.Warn("[HGrid]: Remoting Error: Unable to connect to adjacent region: " + regionHandle); - m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); - return false; - } - catch (InvalidCredentialException e) - { - NoteDeadRegion(regionHandle); - m_log.Warn("[HGrid]: Invalid Credential Exception: Invalid Credentials : " + regionHandle); - m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); - return false; - } - catch (AuthenticationException e) - { - NoteDeadRegion(regionHandle); - m_log.Warn("[HGrid]: Authentication exception: Unable to connect to adjacent region: " + regionHandle); - m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); - return false; - } - catch (Exception e) - { - NoteDeadRegion(regionHandle); - m_log.Warn("[HGrid]: Unknown exception: Unable to connect to adjacent region: " + regionHandle); - m_log.DebugFormat("[HGrid]: {0}", e); - return false; - } - } - else - { - return false; - } - } - - /// - /// - /// - /// - /// - /// - /// - public override bool ExpectAvatarCrossing(ulong regionHandle, UUID agentID, Vector3 position, bool isFlying) - { - - RegionInfo[] regions = m_regionsOnInstance.ToArray(); - bool banned = false; - bool localregion = false; - - for (int i = 0; i < regions.Length; i++) - { - if (regions[i] != null) - { - if (regions[i].RegionHandle == regionHandle) - { - localregion = true; - if (regions[i].EstateSettings.IsBanned(agentID)) - { - banned = true; - break; - } - } - } - } - - if (banned) - return false; - if (localregion) - return m_localBackend.ExpectAvatarCrossing(regionHandle, agentID, position, isFlying); - - return base.ExpectAvatarCrossing(regionHandle, agentID, position, isFlying); - - } - - public override bool ExpectPrimCrossing(ulong regionHandle, UUID agentID, Vector3 position, bool isPhysical) - { - RegionInfo regInfo = null; - try - { - if (m_localBackend.TriggerExpectPrimCrossing(regionHandle, agentID, position, isPhysical)) - { - return true; - } - - regInfo = RequestNeighbourInfo(regionHandle); - if (regInfo != null) - { - bool retValue = false; - OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting)Activator.GetObject( - typeof(OGS1InterRegionRemoting), - "tcp://" + regInfo.RemotingAddress + - ":" + regInfo.RemotingPort + - "/InterRegions"); - - if (remObject != null) - { - retValue = - remObject.ExpectAvatarCrossing(regionHandle, agentID.Guid, new sLLVector3(position), - isPhysical); - } - else - { - m_log.Warn("[HGrid]: Remoting object not found"); - } - remObject = null; - - return retValue; - } - //TODO need to see if we know about where this region is and use .net remoting - // to inform it. - NoteDeadRegion(regionHandle); - return false; - } - catch (RemotingException e) - { - NoteDeadRegion(regionHandle); - m_log.Warn("[HGrid]: Remoting Error: Unable to connect to adjacent region: " + regionHandle); - m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); - return false; - } - catch (SocketException e) - { - NoteDeadRegion(regionHandle); - m_log.Warn("[HGrid]: Remoting Error: Unable to connect to adjacent region: " + regionHandle); - m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); - return false; - } - catch (InvalidCredentialException e) - { - NoteDeadRegion(regionHandle); - m_log.Warn("[HGrid]: Invalid Credential Exception: Invalid Credentials : " + regionHandle); - m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); - return false; - } - catch (AuthenticationException e) - { - NoteDeadRegion(regionHandle); - m_log.Warn("[HGrid]: Authentication exception: Unable to connect to adjacent region: " + regionHandle); - m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); - return false; - } - catch (Exception e) - { - NoteDeadRegion(regionHandle); - m_log.Warn("[HGrid]: Unknown exception: Unable to connect to adjacent region: " + regionHandle); - m_log.DebugFormat("[HGrid]: {0}", e); - return false; - } - } - - public override bool TellRegionToCloseChildConnection(ulong regionHandle, UUID agentID) - { - m_log.Debug("[HGrid]: TellRegion " + regionHandle + " ToCloseChildConnection for " + agentID); - RegionInfo regInfo = null; - try - { - if (m_localBackend.TriggerTellRegionToCloseChildConnection(regionHandle, agentID)) - { - return true; - } - - regInfo = RequestNeighbourInfo(regionHandle); - if (regInfo != null) - { - // bool retValue = false; - OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting)Activator.GetObject( - typeof(OGS1InterRegionRemoting), - "tcp://" + regInfo.RemotingAddress + - ":" + regInfo.RemotingPort + - "/InterRegions"); - - if (remObject != null) - { - // retValue = - remObject.TellRegionToCloseChildConnection(regionHandle, agentID.Guid); - } - else - { - m_log.Warn("[HGrid]: Remoting object not found"); - } - remObject = null; - - return true; - } - //TODO need to see if we know about where this region is and use .net remoting - // to inform it. - NoteDeadRegion(regionHandle); - return false; - } - catch (RemotingException) - { - NoteDeadRegion(regionHandle); - m_log.Warn("[HGrid]: Remoting Error: Unable to connect to adjacent region to tell it to close child agents: " + regInfo.RegionName + - " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); - //m_log.Debug(e.ToString()); - return false; - } - catch (SocketException e) - { - NoteDeadRegion(regionHandle); - m_log.Warn("[HGridS]: Socket Error: Unable to connect to adjacent region using tcp://" + - regInfo.RemotingAddress + - ":" + regInfo.RemotingPort + - "/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY + - " - Is this neighbor up?"); - m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); - return false; - } - catch (InvalidCredentialException e) - { - NoteDeadRegion(regionHandle); - m_log.Warn("[HGrid]: Invalid Credentials: Unable to connect to adjacent region using tcp://" + - regInfo.RemotingAddress + - ":" + regInfo.RemotingPort + - "/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY); - m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); - return false; - } - catch (AuthenticationException e) - { - NoteDeadRegion(regionHandle); - m_log.Warn("[HGrid]: Authentication exception: Unable to connect to adjacent region using tcp://" + - regInfo.RemotingAddress + - ":" + regInfo.RemotingPort + - "/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY); - m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); - return false; - } - catch (WebException e) - { - NoteDeadRegion(regionHandle); - m_log.Warn("[HGrid]: WebException exception: Unable to connect to adjacent region using tcp://" + - regInfo.RemotingAddress + - ":" + regInfo.RemotingPort + - "/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY); - m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); - return false; - } - catch (Exception e) - { - NoteDeadRegion(regionHandle); - // This line errors with a Null Reference Exception.. Why? @.@ - //m_log.Warn("Unknown exception: Unable to connect to adjacent region using tcp://" + regInfo.RemotingAddress + - // ":" + regInfo.RemotingPort + - //"/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY + " - This is likely caused by an incompatibility in the protocol between this sim and that one"); - m_log.DebugFormat("[HGrid]: {0}", e); - return false; - } - } - - public override bool AcknowledgeAgentCrossed(ulong regionHandle, UUID agentId) - { - return m_localBackend.AcknowledgeAgentCrossed(regionHandle, agentId); - } - - public override bool AcknowledgePrimCrossed(ulong regionHandle, UUID primId) - { - return m_localBackend.AcknowledgePrimCrossed(regionHandle, primId); - } - - #endregion - - #region Methods triggered by calls from external instances - - /// - /// - /// - /// - /// - /// - public bool IncomingChildAgent(ulong regionHandle, AgentCircuitData agentData) - { - AdjustUserInformation(agentData); - - m_log.Info("[HGrid]: " + gdebugRegionName + ": Incoming HGrid Agent " + agentData.firstname + " " + agentData.lastname); - - return m_localBackend.IncomingChildAgent(regionHandle, agentData); - } - - public bool TriggerRegionUp(RegionUpData regionData, ulong regionhandle) - { - m_log.Info( - "[HGrid]: " + - m_localBackend._gdebugRegionName + "Incoming HGrid RegionUpReport: " + "(" + regionData.X + - "," + regionData.Y + "). Giving this region a fresh set of 'dead' tries"); - - RegionInfo nRegionInfo = new RegionInfo(); - nRegionInfo.SetEndPoint("127.0.0.1", regionData.PORT); - nRegionInfo.ExternalHostName = regionData.IPADDR; - nRegionInfo.RegionLocX = regionData.X; - nRegionInfo.RegionLocY = regionData.Y; - - lock (m_deadRegionCache) - { - if (m_deadRegionCache.ContainsKey(nRegionInfo.RegionHandle)) - { - m_deadRegionCache.Remove(nRegionInfo.RegionHandle); - } - } - - return m_localBackend.TriggerRegionUp(nRegionInfo, regionhandle); - } - - public bool TriggerChildAgentUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentData) - { - //m_log.Info("[INTER]: Incoming HGrid Child Agent Data Update"); - - return m_localBackend.TriggerChildAgentUpdate(regionHandle, cAgentData); - } - - /// - /// - /// - /// - /// - /// - public bool IncomingPrim(ulong regionHandle, UUID primID, string objData, int XMLMethod) - { - m_log.Debug("[HGrid]: Incoming Prim"); - m_localBackend.TriggerExpectPrim(regionHandle, primID, objData, XMLMethod); - - return true; - } - - /// - /// - /// - /// - /// - /// - /// - public bool TriggerExpectAvatarCrossing(ulong regionHandle, UUID agentID, Vector3 position, bool isFlying) - { - return m_localBackend.TriggerExpectAvatarCrossing(regionHandle, agentID, position, isFlying); - } - - public bool TriggerExpectPrimCrossing(ulong regionHandle, UUID agentID, Vector3 position, bool isPhysical) - { - return m_localBackend.TriggerExpectPrimCrossing(regionHandle, agentID, position, isPhysical); - } - - public bool TriggerTellRegionToCloseChildConnection(ulong regionHandle, UUID agentID) - { - return m_localBackend.TriggerTellRegionToCloseChildConnection(regionHandle, agentID); - } - - int timeOut = 10; //10 seconds - /// - /// Check that a region is available for TCP comms. This is necessary for .NET remoting between regions. - /// - /// - /// - /// - /// - public bool CheckRegion(string address, uint port, bool retry) - { - bool available = false; - bool timed_out = true; - - IPAddress ia; - IPAddress.TryParse(address, out ia); - IPEndPoint m_EndPoint = new IPEndPoint(ia, (int)port); - - AsyncCallback callback = delegate(IAsyncResult iar) - { - Socket s = (Socket)iar.AsyncState; - try - { - s.EndConnect(iar); - available = true; - timed_out = false; - } - catch (Exception e) - { - m_log.DebugFormat( - "[HGrid]: Callback EndConnect exception: {0}:{1}", e.Message, e.StackTrace); - } - - s.Close(); - }; - - try - { - Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); - IAsyncResult ar = socket.BeginConnect(m_EndPoint, callback, socket); - ar.AsyncWaitHandle.WaitOne(timeOut * 1000, false); - } - catch (Exception e) - { - m_log.DebugFormat( - "[HGrid]: CheckRegion Socket Setup exception: {0}:{1}", e.Message, e.StackTrace); - - return false; - } - - if (timed_out) - { - m_log.DebugFormat( - "[HGrid]: socket [{0}] timed out ({1}) waiting to obtain a connection.", - m_EndPoint, timeOut * 1000); - - if (retry) - { - return CheckRegion(address, port, false); - } - } - - return available; - } - - public override bool CheckRegion(string address, uint port) - { - return CheckRegion(address, port, true); - } - - public void NoteDeadRegion(ulong regionhandle) - { - lock (m_deadRegionCache) - { - if (m_deadRegionCache.ContainsKey(regionhandle)) - { - m_deadRegionCache[regionhandle] = m_deadRegionCache[regionhandle] + 1; - } - else - { - m_deadRegionCache.Add(regionhandle, 1); - } - } - - } - - #endregion - - } } diff --git a/OpenSim/Region/Communications/Local/CommunicationsLocal.cs b/OpenSim/Region/Communications/Local/CommunicationsLocal.cs index 3a5c33e..59a1293 100644 --- a/OpenSim/Region/Communications/Local/CommunicationsLocal.cs +++ b/OpenSim/Region/Communications/Local/CommunicationsLocal.cs @@ -41,7 +41,6 @@ namespace OpenSim.Region.Communications.Local IUserService userService, IUserAdminService userServiceAdmin, LocalInventoryService inventoryService, - IInterRegionCommunications interRegionService, IGridServices gridService, IMessagingService messageService, LibraryRootFolder libraryRootFolder, bool dumpAssetsToFile) : base(serversInfo, httpServer, assetCache, dumpAssetsToFile, libraryRootFolder) @@ -53,7 +52,6 @@ namespace OpenSim.Region.Communications.Local m_userAdminService = userServiceAdmin; m_avatarService = (IAvatarService)userService; m_gridService = gridService; - m_interRegion = interRegionService; m_messageService = messageService; } } diff --git a/OpenSim/Region/Communications/Local/LocalBackEndServices.cs b/OpenSim/Region/Communications/Local/LocalBackEndServices.cs index fc2f422..306ea27 100644 --- a/OpenSim/Region/Communications/Local/LocalBackEndServices.cs +++ b/OpenSim/Region/Communications/Local/LocalBackEndServices.cs @@ -36,7 +36,7 @@ using OpenSim.Framework.Communications; namespace OpenSim.Region.Communications.Local { - public class LocalBackEndServices : IGridServices, IInterRegionCommunications + public class LocalBackEndServices : IGridServices { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -244,46 +244,6 @@ namespace OpenSim.Region.Communications.Local return mapBlocks; } - public bool TellRegionToCloseChildConnection(ulong regionHandle, UUID agentID) - { - if (m_regionListeners.ContainsKey(regionHandle)) - { - return m_regionListeners[regionHandle].TriggerTellRegionToCloseChildConnection(agentID); - } - - return false; - } - - public virtual bool RegionUp(SerializableRegionInfo sregion, ulong regionhandle) - { - RegionInfo region = new RegionInfo(sregion); - - //region.RegionLocX = sregion.X; - //region.RegionLocY = sregion.Y; - //region.SetEndPoint(sregion.IPADDR, sregion.PORT); - - //sregion); - if (m_regionListeners.ContainsKey(regionhandle)) - { - return m_regionListeners[regionhandle].TriggerRegionUp(region); - } - - return false; - } - - public virtual bool ChildAgentUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentData) - { - if (m_regionListeners.ContainsKey(regionHandle)) - { - // Console.WriteLine("CommsManager- Informing a region to expect child agent"); - m_regionListeners[regionHandle].TriggerChildAgentUpdate(cAgentData); - //m_log.Info("[INTER]: " + rdebugRegionName + ":Local BackEnd: Got Listener trigginering local event: " + agentData.firstname + " " + agentData.lastname); - - return true; - } - return false; - } - // This function is only here to keep this class in line with the Grid Interface. // It never gets called. public virtual Dictionary GetGridSettings() @@ -303,124 +263,6 @@ namespace OpenSim.Region.Communications.Local m_queuedGridSettings.Add("allow_forceful_banlines", "FALSE"); } - public bool TriggerRegionUp(RegionInfo region, ulong regionhandle) - { - if (m_regionListeners.ContainsKey(regionhandle)) - { - return m_regionListeners[regionhandle].TriggerRegionUp(region); - } - - return false; - } - - public bool TriggerChildAgentUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentData) - { - if (m_regionListeners.ContainsKey(regionHandle)) - { - return m_regionListeners[regionHandle].TriggerChildAgentUpdate(cAgentData); - } - - return false; - } - - public bool TriggerTellRegionToCloseChildConnection(ulong regionHandle, UUID agentID) - { - if (m_regionListeners.ContainsKey(regionHandle)) - { - return m_regionListeners[regionHandle].TriggerTellRegionToCloseChildConnection(agentID); - } - - return false; - } - - /// - /// Tell a region to expect a new client connection. - /// - /// - /// - /// - public bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData) - // TODO: should change from agentCircuitData - { - //Console.WriteLine("CommsManager- Trying to Inform a region to expect child agent"); - //m_log.Info("[INTER]: " + rdebugRegionName + ":Local BackEnd: Trying to inform region of child agent: " + agentData.firstname + " " + agentData.lastname); - - if (m_regionListeners.ContainsKey(regionHandle)) - { - // Console.WriteLine("CommsManager- Informing a region to expect child agent"); - m_regionListeners[regionHandle].TriggerExpectUser(agentData); - //m_log.Info("[INTER]: " + rdebugRegionName + ":Local BackEnd: Got Listener trigginering local event: " + agentData.firstname + " " + agentData.lastname); - - return true; - } - return false; - } - - /// - /// Tell a region to expect the crossing in of a new prim. - /// - /// - /// - /// - /// - /// - public bool InformRegionOfPrimCrossing(ulong regionHandle, UUID primID, string objData, int XMLMethod) - { - if (m_regionListeners.ContainsKey(regionHandle)) - { - m_regionListeners[regionHandle].TriggerExpectPrim(primID, objData, XMLMethod); - return true; - } - - return false; - } - - /// - /// Tell a region to get prepare for an avatar to cross into it. - /// - /// - /// - /// - /// - public bool ExpectAvatarCrossing(ulong regionHandle, UUID agentID, Vector3 position, bool isFlying) - { - if (m_regionListeners.ContainsKey(regionHandle)) - { - // Console.WriteLine("CommsManager- Informing a region to expect avatar crossing"); - m_regionListeners[regionHandle].TriggerExpectAvatarCrossing(agentID, position, isFlying); - return true; - } - return false; - } - - public bool ExpectPrimCrossing(ulong regionHandle, UUID primID, Vector3 position, bool isPhysical) - { - if (m_regionListeners.ContainsKey(regionHandle)) - { - m_regionListeners[regionHandle].TriggerExpectPrimCrossing(primID, position, isPhysical); - return true; - } - - return false; - } - - public bool AcknowledgeAgentCrossed(ulong regionHandle, UUID agentId) - { - if (m_regionListeners.ContainsKey(regionHandle)) - { - return true; - } - return false; - } - - public bool AcknowledgePrimCrossed(ulong regionHandle, UUID primID) - { - if (m_regionListeners.ContainsKey(regionHandle)) - { - return true; - } - return false; - } /// /// Is a Sandbox mode method, used by the local Login server to inform a region of a connection user/session @@ -474,14 +316,6 @@ namespace OpenSim.Region.Communications.Local } } - public void TriggerExpectPrim(ulong regionHandle, UUID primID, string objData, int XMLMethod) - { - if (m_regionListeners.ContainsKey(regionHandle)) - { - m_regionListeners[regionHandle].TriggerExpectPrim(primID, objData, XMLMethod); - } - } - public void PingCheckReply(Hashtable respData) { foreach (ulong region in m_regions.Keys) @@ -495,40 +329,6 @@ namespace OpenSim.Region.Communications.Local } } - public bool TriggerExpectAvatarCrossing(ulong regionHandle, UUID agentID, Vector3 position, bool isFlying) - { - if (m_regionListeners.ContainsKey(regionHandle)) - { - return m_regionListeners[regionHandle].TriggerExpectAvatarCrossing(agentID, position, isFlying); - } - - return false; - } - - public bool TriggerExpectPrimCrossing(ulong regionHandle, UUID primID, Vector3 position, bool isPhysical) - { - if (m_regionListeners.ContainsKey(regionHandle)) - { - return - m_regionListeners[regionHandle].TriggerExpectPrimCrossing(primID, position, isPhysical); - } - return false; - } - - public bool IncomingChildAgent(ulong regionHandle, AgentCircuitData agentData) - { - // m_log.Info("[INTER]: " + rdebugRegionName + ":Local BackEnd: Other local region is sending child agent our way: " + agentData.firstname + " " + agentData.lastname); - - if (m_regionListeners.ContainsKey(regionHandle)) - { - //m_log.Info("[INTER]: " + rdebugRegionName + ":Local BackEnd: found local region to trigger event on: " + agentData.firstname + " " + agentData.lastname); - - TriggerExpectUser(regionHandle, agentData); - return true; - } - - return false; - } public LandData RequestLandData (ulong regionHandle, uint x, uint y) { @@ -560,20 +360,5 @@ namespace OpenSim.Region.Communications.Local return regions; } - public List InformFriendsInOtherRegion(UUID agentId, ulong destRegionHandle, List friends, bool online) - { - // if we get to here, something is wrong: We are in standalone mode, but have users that are not on our server? - m_log.WarnFormat("[INTERREGION STANDALONE] Did find {0} users on a region not on our server: {1} ???", - friends.Count, destRegionHandle); - return new List(); - } - - public bool TriggerTerminateFriend (ulong regionHandle, UUID agentID, UUID exFriendID) - { - // if we get to here, something is wrong: We are in standalone mode, but have users that are not on our server? - m_log.WarnFormat("[INTERREGION STANDALONE] Did find user {0} on a region not on our server: {1} ???", - agentID, regionHandle); - return true; - } } } diff --git a/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs b/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs index c506dd0..f32b160 100644 --- a/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs +++ b/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs @@ -41,7 +41,6 @@ namespace OpenSim.Region.Communications.OGS1 { OGS1GridServices gridInterComms = new OGS1GridServices(serversInfo, httpServer); m_gridService = gridInterComms; - m_interRegion = gridInterComms; if (serversInfo.secureInventoryServer) { diff --git a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs index 660e684..66da986 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs @@ -31,9 +31,6 @@ using System.Collections.Generic; using System.Net; using System.Net.Sockets; using System.Reflection; -using System.Runtime.Remoting; -using System.Runtime.Remoting.Channels; -using System.Runtime.Remoting.Channels.Tcp; using System.Security.Authentication; using log4net; using Nwc.XmlRpc; @@ -45,7 +42,7 @@ using OpenSim.Region.Communications.Local; namespace OpenSim.Region.Communications.OGS1 { - public class OGS1GridServices : IGridServices, IInterRegionCommunications + public class OGS1GridServices : IGridServices { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -99,7 +96,6 @@ namespace OpenSim.Region.Communications.OGS1 httpServer.AddXmlRPCHandler("check", PingCheckReply); httpServer.AddXmlRPCHandler("land_data", LandData); - StartRemoting(); } // see IGridServices @@ -716,913 +712,6 @@ namespace OpenSim.Region.Communications.OGS1 return new XmlRpcResponse(); } - #region m_interRegion Comms - - /// - /// Start listening for .net remoting calls from other regions. - /// - private void StartRemoting() - { - TcpChannel ch; - try - { - ch = new TcpChannel((int)NetworkServersInfo.RemotingListenerPort); - ChannelServices.RegisterChannel(ch, false); // Disabled security as Mono doesn't support this. - } - catch (Exception ex) - { - m_log.Error("[OGS1 GRID SERVICES]: Exception while attempting to listen on TCP port " + (int)NetworkServersInfo.RemotingListenerPort + "."); - throw (ex); - } - - WellKnownServiceTypeEntry wellType = - new WellKnownServiceTypeEntry(typeof (OGS1InterRegionRemoting), "InterRegions", - WellKnownObjectMode.Singleton); - RemotingConfiguration.RegisterWellKnownServiceType(wellType); - InterRegionSingleton.Instance.OnArrival += TriggerExpectAvatarCrossing; - InterRegionSingleton.Instance.OnChildAgent += IncomingChildAgent; - InterRegionSingleton.Instance.OnPrimGroupArrival += IncomingPrim; - InterRegionSingleton.Instance.OnPrimGroupNear += TriggerExpectPrimCrossing; - InterRegionSingleton.Instance.OnRegionUp += TriggerRegionUp; - InterRegionSingleton.Instance.OnChildAgentUpdate += TriggerChildAgentUpdate; - InterRegionSingleton.Instance.OnTellRegionToCloseChildConnection += TriggerTellRegionToCloseChildConnection; - } - - #region Methods called by regions in this instance - - public bool ChildAgentUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentData) - { - int failures = 0; - lock (m_deadRegionCache) - { - if (m_deadRegionCache.ContainsKey(regionHandle)) - { - failures = m_deadRegionCache[regionHandle]; - } - } - if (failures <= 3) - { - RegionInfo regInfo = null; - try - { - if (m_localBackend.ChildAgentUpdate(regionHandle, cAgentData)) - { - return true; - } - - regInfo = RequestNeighbourInfo(regionHandle); - if (regInfo != null) - { - //don't want to be creating a new link to the remote instance every time like we are here - bool retValue = false; - - - OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting)Activator.GetObject( - typeof(OGS1InterRegionRemoting), - "tcp://" + regInfo.RemotingAddress + - ":" + regInfo.RemotingPort + - "/InterRegions"); - - if (remObject != null) - { - retValue = remObject.ChildAgentUpdate(regionHandle, cAgentData); - } - else - { - m_log.Warn("[OGS1 GRID SERVICES]: remoting object not found"); - } - remObject = null; -// m_log.Info("[INTER]: " + -// gdebugRegionName + -// ": OGS1 tried to Update Child Agent data on outside region and got " + -// retValue.ToString()); - - return retValue; - } - NoteDeadRegion(regionHandle); - - return false; - } - catch (RemotingException e) - { - NoteDeadRegion(regionHandle); - - m_log.WarnFormat( - "[OGS1 GRID SERVICES]: Remoting Error: Unable to connect to adjacent region: {0} {1},{2}", - regInfo.RegionName, regInfo.RegionLocX, regInfo.RegionLocY); - m_log.DebugFormat("[OGS1 GRID SERVICES]: {0} {1}", e.Source, e.Message); - - return false; - } - catch (SocketException e) - { - NoteDeadRegion(regionHandle); - - m_log.WarnFormat( - "[OGS1 GRID SERVICES]: Remoting Error: Unable to connect to adjacent region: {0} {1},{2}", - regInfo.RegionName, regInfo.RegionLocX, regInfo.RegionLocY); - m_log.DebugFormat("[OGS1 GRID SERVICES]: {0} {1}", e.Source, e.Message); - - return false; - } - catch (InvalidCredentialException e) - { - NoteDeadRegion(regionHandle); - - m_log.WarnFormat( - "[OGS1 GRID SERVICES]: Remoting Error: Unable to connect to adjacent region: {0} {1},{2}", - regInfo.RegionName, regInfo.RegionLocX, regInfo.RegionLocY); - m_log.DebugFormat("[OGS1 GRID SERVICES]: {0} {1}", e.Source, e.Message); - - return false; - } - catch (AuthenticationException e) - { - NoteDeadRegion(regionHandle); - - m_log.WarnFormat( - "[OGS1 GRID SERVICES]: Remoting Error: Unable to connect to adjacent region: {0} {1},{2}", - regInfo.RegionName, regInfo.RegionLocX, regInfo.RegionLocY); - m_log.DebugFormat("[OGS1 GRID SERVICES]: {0} {1}", e.Source, e.Message); - - return false; - } - catch (Exception e) - { - NoteDeadRegion(regionHandle); - - m_log.WarnFormat("[OGS1 GRID SERVICES]: Unable to connect to adjacent region: {0} {1},{2}", - regInfo.RegionName, regInfo.RegionLocX, regInfo.RegionLocY); - m_log.DebugFormat("[OGS1 GRID SERVICES]: {0} {1}", e.Source, e.Message); - - return false; - } - } - else - { - //m_log.Info("[INTERREGION]: Skipped Sending Child Update to a region because it failed too many times:" + regionHandle.ToString()); - return false; - } - } - - /// - /// Inform a region that a child agent will be on the way from a client. - /// - /// - /// - /// - public bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData) - { - RegionInfo regInfo = null; - try - { - if (m_localBackend.InformRegionOfChildAgent(regionHandle, agentData)) - { - return true; - } - - regInfo = RequestNeighbourInfo(regionHandle); - if (regInfo != null) - { - //don't want to be creating a new link to the remote instance every time like we are here - bool retValue = false; - - OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting)Activator.GetObject( - typeof(OGS1InterRegionRemoting), - "tcp://" + regInfo.RemotingAddress + - ":" + regInfo.RemotingPort + - "/InterRegions"); - - if (remObject != null) - { - retValue = remObject.InformRegionOfChildAgent(regionHandle, new sAgentCircuitData(agentData)); - } - else - { - m_log.Warn("[OGS1 GRID SERVICES]: remoting object not found"); - } - remObject = null; - m_log.Info("[OGS1 GRID SERVICES]: " + - m_localBackend._gdebugRegionName + ": OGS1 tried to InformRegionOfChildAgent for " + - agentData.firstname + " " + agentData.lastname + " and got " + - retValue.ToString()); - - return retValue; - } - NoteDeadRegion(regionHandle); - return false; - } - catch (RemotingException e) - { - NoteDeadRegion(regionHandle); - - m_log.WarnFormat( - "[OGS1 GRID SERVICES]: Remoting Error: Unable to connect to adjacent region: {0} {1},{2}", - regInfo.RegionName, regInfo.RegionLocX, regInfo.RegionLocY); - m_log.DebugFormat("[OGS1 GRID SERVICES]: {0} {1}", e.Source, e.Message); - - return false; - } - catch (SocketException e) - { - NoteDeadRegion(regionHandle); - - m_log.WarnFormat( - "[OGS1 GRID SERVICES]: Remoting Error: Unable to connect to adjacent region: {0} {1},{2}", - regInfo.RegionName, regInfo.RegionLocX, regInfo.RegionLocY); - m_log.DebugFormat("[OGS1 GRID SERVICES]: {0} {1}", e.Source, e.Message); - - return false; - } - catch (InvalidCredentialException e) - { - NoteDeadRegion(regionHandle); - - m_log.WarnFormat( - "[OGS1 GRID SERVICES]: Remoting Error: Unable to connect to adjacent region: {0} {1},{2}", - regInfo.RegionName, regInfo.RegionLocX, regInfo.RegionLocY); - m_log.DebugFormat("[OGS1 GRID SERVICES]: {0} {1}", e.Source, e.Message); - - return false; - } - catch (AuthenticationException e) - { - NoteDeadRegion(regionHandle); - - m_log.WarnFormat( - "[OGS1 GRID SERVICES]: Remoting Error: Unable to connect to adjacent region: {0} {1},{2}", - regInfo.RegionName, regInfo.RegionLocX, regInfo.RegionLocY); - m_log.DebugFormat("[OGS1 GRID SERVICES]: {0} {1}", e.Source, e.Message); - - return false; - } - catch (Exception e) - { - NoteDeadRegion(regionHandle); - - if (regInfo != null) - { - m_log.WarnFormat( - "[OGS1 GRID SERVICES]: Remoting Error: Unable to connect to adjacent region: {0} {1},{2}", - regInfo.RegionName, regInfo.RegionLocX, regInfo.RegionLocY); - } - m_log.DebugFormat("[OGS1 GRID SERVICES]: {0} {1}", e.Source, e.Message); - - return false; - } - } - - // UGLY! - public bool RegionUp(SerializableRegionInfo region, ulong regionhandle) - { - SerializableRegionInfo regInfo = null; - try - { - // You may ask why this is in here... - // The region asking the grid services about itself.. - // And, surprisingly, the reason is.. it doesn't know - // it's own remoting port! How special. - RegionUpData regiondata = new RegionUpData(region.RegionLocX, region.RegionLocY, region.ExternalHostName, region.InternalEndPoint.Port); - - region = new SerializableRegionInfo(RequestNeighbourInfo(region.RegionHandle)); - region.RemotingAddress = region.ExternalHostName; - region.RemotingPort = NetworkServersInfo.RemotingListenerPort; - region.HttpPort = serversInfo.HttpListenerPort; - - if (m_localBackend.RegionUp(region, regionhandle)) - { - return true; - } - - regInfo = new SerializableRegionInfo(RequestNeighbourInfo(regionhandle)); - if (regInfo != null) - { - // If we're not trying to remote to ourselves. - if (regInfo.RemotingAddress != region.RemotingAddress && region.RemotingAddress != null) - { - //don't want to be creating a new link to the remote instance every time like we are here - bool retValue = false; - - OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting) Activator.GetObject( - typeof(OGS1InterRegionRemoting), - "tcp://" + - regInfo.RemotingAddress + - ":" + regInfo.RemotingPort + - "/InterRegions"); - - if (remObject != null) - { - retValue = remObject.RegionUp(regiondata, regionhandle); - } - else - { - m_log.Warn("[OGS1 GRID SERVICES]: remoting object not found"); - } - remObject = null; - - m_log.Info( - "[INTER]: " + m_localBackend._gdebugRegionName + ": OGS1 tried to inform region I'm up"); - - return retValue; - } - else - { - // We're trying to inform ourselves via remoting. - // This is here because we're looping over the listeners before we get here. - // Odd but it should work. - return true; - } - } - - return false; - } - catch (RemotingException e) - { - m_log.Warn("[OGS1 GRID SERVICES]: Remoting Error: Unable to connect to adjacent region using tcp://" + - regInfo.RemotingAddress + - ":" + regInfo.RemotingPort + - "/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY + - " - Is this neighbor up?"); - m_log.DebugFormat("[OGS1 GRID SERVICES]: {0} {1}", e.Source, e.Message); - return false; - } - catch (SocketException e) - { - m_log.Warn("[OGS1 GRID SERVICES]: Socket Error: Unable to connect to adjacent region using tcp://" + - regInfo.RemotingAddress + - ":" + regInfo.RemotingPort + - "/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY + - " - Is this neighbor up?"); - m_log.DebugFormat("[OGS1 GRID SERVICES]: {0} {1}", e.Source, e.Message); - return false; - } - catch (InvalidCredentialException e) - { - m_log.Warn("[OGS1 GRID SERVICES]: Invalid Credentials: Unable to connect to adjacent region using tcp://" + - regInfo.RemotingAddress + - ":" + regInfo.RemotingPort + - "/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY); - m_log.DebugFormat("[OGS1 GRID SERVICES]: {0} {1}", e.Source, e.Message); - return false; - } - catch (AuthenticationException e) - { - m_log.Warn("[OGS1 GRID SERVICES]: Authentication exception: Unable to connect to adjacent region using tcp://" + - regInfo.RemotingAddress + - ":" + regInfo.RemotingPort + - "/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY); - m_log.DebugFormat("[OGS1 GRID SERVICES]: {0} {1}", e.Source, e.Message); - return false; - } - catch (Exception e) - { - // This line errors with a Null Reference Exception.. Why? @.@ - //m_log.Warn("Unknown exception: Unable to connect to adjacent region using tcp://" + regInfo.RemotingAddress + - // ":" + regInfo.RemotingPort + - //"/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY + " - This is likely caused by an incompatibility in the protocol between this sim and that one"); - m_log.Debug(e.ToString()); - return false; - } - } - - /// - /// - /// - /// - /// - /// - public bool InformRegionOfPrimCrossing(ulong regionHandle, UUID primID, string objData, int XMLMethod) - { - int failures = 0; - lock (m_deadRegionCache) - { - if (m_deadRegionCache.ContainsKey(regionHandle)) - { - failures = m_deadRegionCache[regionHandle]; - } - } - if (failures <= 1) - { - RegionInfo regInfo = null; - try - { - if (m_localBackend.InformRegionOfPrimCrossing(regionHandle, primID, objData, XMLMethod)) - { - return true; - } - - regInfo = RequestNeighbourInfo(regionHandle); - if (regInfo != null) - { - //don't want to be creating a new link to the remote instance every time like we are here - bool retValue = false; - - OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting)Activator.GetObject( - typeof(OGS1InterRegionRemoting), - "tcp://" + regInfo.RemotingAddress + - ":" + regInfo.RemotingPort + - "/InterRegions"); - - if (remObject != null) - { - m_log.DebugFormat("[INTERREGION]: Sending prim crossing message for prim {0}", primID.ToString()); - retValue = remObject.InformRegionOfPrimCrossing(regionHandle, primID.Guid, objData, XMLMethod); - m_log.DebugFormat("[INTERREGION]: Return from prim crossing message for prim {0}: {1}", primID.ToString(), retValue.ToString()); - } - else - { - m_log.Warn("[OGS1 GRID SERVICES]: Remoting object not found"); - } - remObject = null; - - return retValue; - } - NoteDeadRegion(regionHandle); - return false; - } - catch (RemotingException e) - { - NoteDeadRegion(regionHandle); - m_log.Warn("[OGS1 GRID SERVICES]: Remoting Error: Unable to connect to adjacent region: " + regionHandle); - m_log.DebugFormat("[OGS1 GRID SERVICES]: {0} {1}", e.Source, e.Message); - return false; - } - catch (SocketException e) - { - NoteDeadRegion(regionHandle); - m_log.Warn("[OGS1 GRID SERVICES]: Remoting Error: Unable to connect to adjacent region: " + regionHandle); - m_log.DebugFormat("[OGS1 GRID SERVICES]: {0} {1}", e.Source, e.Message); - return false; - } - catch (InvalidCredentialException e) - { - NoteDeadRegion(regionHandle); - m_log.Warn("[OGS1 GRID SERVICES]: Invalid Credential Exception: Invalid Credentials : " + regionHandle); - m_log.DebugFormat("[OGS1 GRID SERVICES]: {0} {1}", e.Source, e.Message); - return false; - } - catch (AuthenticationException e) - { - NoteDeadRegion(regionHandle); - m_log.Warn("[OGS1 GRID SERVICES]: Authentication exception: Unable to connect to adjacent region: " + regionHandle); - m_log.DebugFormat("[OGS1 GRID SERVICES]: {0} {1}", e.Source, e.Message); - return false; - } - catch (Exception e) - { - NoteDeadRegion(regionHandle); - m_log.Warn("[OGS1 GRID SERVICES]: Unknown exception: Unable to connect to adjacent region: " + regionHandle); - m_log.DebugFormat("[OGS1 GRID SERVICES]: {0}", e); - return false; - } - } - else - { - return false; - } - } - - /// - /// - /// - /// - /// - /// - /// - public bool ExpectAvatarCrossing(ulong regionHandle, UUID agentID, Vector3 position, bool isFlying) - { - RegionInfo[] regions = m_regionsOnInstance.ToArray(); - bool banned = false; - - for (int i = 0; i < regions.Length; i++) - { - if (regions[i] != null) - { - if (regions[i].RegionHandle == regionHandle) - { - if (regions[i].EstateSettings.IsBanned(agentID)) - { - banned = true; - break; - } - } - } - } - - if (banned) - return false; - - RegionInfo regInfo = null; - try - { - if (m_localBackend.TriggerExpectAvatarCrossing(regionHandle, agentID, position, isFlying)) - { - return true; - } - - regInfo = RequestNeighbourInfo(regionHandle); - if (regInfo != null) - { - bool retValue = false; - OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting) Activator.GetObject( - typeof (OGS1InterRegionRemoting), - "tcp://" + regInfo.RemotingAddress + - ":" + regInfo.RemotingPort + - "/InterRegions"); - - if (remObject != null) - { - retValue = - remObject.ExpectAvatarCrossing(regionHandle, agentID.Guid, new sLLVector3(position), - isFlying); - } - else - { - m_log.Warn("[OGS1 GRID SERVICES]: Remoting object not found"); - } - remObject = null; - - return retValue; - } - //TODO need to see if we know about where this region is and use .net remoting - // to inform it. - NoteDeadRegion(regionHandle); - return false; - } - catch (RemotingException e) - { - NoteDeadRegion(regionHandle); - - m_log.WarnFormat( - "[OGS1 GRID SERVICES]: Remoting Error: Unable to connect to adjacent region: {0} {1},{2}", - regInfo.RegionName, regInfo.RegionLocX, regInfo.RegionLocY); - m_log.DebugFormat("[OGS1 GRID SERVICES]: {0} {1}", e.Source, e.Message); - - return false; - } - catch - { - NoteDeadRegion(regionHandle); - return false; - } - } - - public bool ExpectPrimCrossing(ulong regionHandle, UUID agentID, Vector3 position, bool isPhysical) - { - RegionInfo regInfo = null; - try - { - if (m_localBackend.TriggerExpectPrimCrossing(regionHandle, agentID, position, isPhysical)) - { - return true; - } - - regInfo = RequestNeighbourInfo(regionHandle); - if (regInfo != null) - { - bool retValue = false; - OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting) Activator.GetObject( - typeof (OGS1InterRegionRemoting), - "tcp://" + regInfo.RemotingAddress + - ":" + regInfo.RemotingPort + - "/InterRegions"); - - if (remObject != null) - { - retValue = - remObject.ExpectAvatarCrossing(regionHandle, agentID.Guid, new sLLVector3(position), - isPhysical); - } - else - { - m_log.Warn("[OGS1 GRID SERVICES]: Remoting object not found"); - } - remObject = null; - - return retValue; - } - //TODO need to see if we know about where this region is and use .net remoting - // to inform it. - NoteDeadRegion(regionHandle); - return false; - } - catch (RemotingException e) - { - NoteDeadRegion(regionHandle); - m_log.Warn("[OGS1 GRID SERVICES]: Remoting Error: Unable to connect to adjacent region: " + regionHandle); - m_log.DebugFormat("[OGS1 GRID SERVICES]: {0} {1}", e.Source, e.Message); - return false; - } - catch (SocketException e) - { - NoteDeadRegion(regionHandle); - m_log.Warn("[OGS1 GRID SERVICES]: Remoting Error: Unable to connect to adjacent region: " + regionHandle); - m_log.DebugFormat("[OGS1 GRID SERVICES]: {0} {1}", e.Source, e.Message); - return false; - } - catch (InvalidCredentialException e) - { - NoteDeadRegion(regionHandle); - m_log.Warn("[OGS1 GRID SERVICES]: Invalid Credential Exception: Invalid Credentials : " + regionHandle); - m_log.DebugFormat("[OGS1 GRID SERVICES]: {0} {1}", e.Source, e.Message); - return false; - } - catch (AuthenticationException e) - { - NoteDeadRegion(regionHandle); - m_log.Warn("[OGS1 GRID SERVICES]: Authentication exception: Unable to connect to adjacent region: " + regionHandle); - m_log.DebugFormat("[OGS1 GRID SERVICES]: {0} {1}", e.Source, e.Message); - return false; - } - catch (Exception e) - { - NoteDeadRegion(regionHandle); - m_log.Warn("[OGS1 GRID SERVICES]: Unknown exception: Unable to connect to adjacent region: " + regionHandle); - m_log.DebugFormat("[OGS1 GRID SERVICES]: {0}", e); - return false; - } - } - - public bool TellRegionToCloseChildConnection(ulong regionHandle, UUID agentID) - { - RegionInfo regInfo = null; - try - { - if (m_localBackend.TriggerTellRegionToCloseChildConnection(regionHandle, agentID)) - { - return true; - } - - regInfo = RequestNeighbourInfo(regionHandle); - if (regInfo != null) - { - // bool retValue = false; - OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting)Activator.GetObject( - typeof(OGS1InterRegionRemoting), - "tcp://" + regInfo.RemotingAddress + - ":" + regInfo.RemotingPort + - "/InterRegions"); - - if (remObject != null) - { - // retValue = - remObject.TellRegionToCloseChildConnection(regionHandle, agentID.Guid); - } - else - { - m_log.Warn("[OGS1 GRID SERVICES]: Remoting object not found"); - } - remObject = null; - - return true; - } - //TODO need to see if we know about where this region is and use .net remoting - // to inform it. - NoteDeadRegion(regionHandle); - return false; - } - catch (RemotingException) - { - NoteDeadRegion(regionHandle); - m_log.Warn("[OGS1 GRID SERVICES]: Remoting Error: Unable to connect to adjacent region to tell it to close child agents: " + regInfo.RegionName + - " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); - //m_log.Debug(e.ToString()); - return false; - } - catch (SocketException e) - { - NoteDeadRegion(regionHandle); - m_log.Warn("[OGS1 GRID SERVICES]: Socket Error: Unable to connect to adjacent region using tcp://" + - regInfo.RemotingAddress + - ":" + regInfo.RemotingPort + - "/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY + - " - Is this neighbor up?"); - m_log.DebugFormat("[OGS1 GRID SERVICES]: {0} {1}", e.Source, e.Message); - return false; - } - catch (InvalidCredentialException e) - { - NoteDeadRegion(regionHandle); - m_log.Warn("[OGS1 GRID SERVICES]: Invalid Credentials: Unable to connect to adjacent region using tcp://" + - regInfo.RemotingAddress + - ":" + regInfo.RemotingPort + - "/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY); - m_log.DebugFormat("[OGS1 GRID SERVICES]: {0} {1}", e.Source, e.Message); - return false; - } - catch (AuthenticationException e) - { - NoteDeadRegion(regionHandle); - m_log.Warn("[OGS1 GRID SERVICES]: Authentication exception: Unable to connect to adjacent region using tcp://" + - regInfo.RemotingAddress + - ":" + regInfo.RemotingPort + - "/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY); - m_log.DebugFormat("[OGS1 GRID SERVICES]: {0} {1}", e.Source, e.Message); - return false; - } - catch (WebException e) - { - NoteDeadRegion(regionHandle); - m_log.Warn("[OGS1 GRID SERVICES]: WebException exception: Unable to connect to adjacent region using tcp://" + - regInfo.RemotingAddress + - ":" + regInfo.RemotingPort + - "/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY); - m_log.DebugFormat("[OGS1 GRID SERVICES]: {0} {1}", e.Source, e.Message); - return false; - } - catch (Exception e) - { - NoteDeadRegion(regionHandle); - // This line errors with a Null Reference Exception.. Why? @.@ - //m_log.Warn("Unknown exception: Unable to connect to adjacent region using tcp://" + regInfo.RemotingAddress + - // ":" + regInfo.RemotingPort + - //"/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY + " - This is likely caused by an incompatibility in the protocol between this sim and that one"); - m_log.DebugFormat("[OGS1 GRID SERVICES]: {0}", e); - return false; - } - } - - public bool AcknowledgeAgentCrossed(ulong regionHandle, UUID agentId) - { - return m_localBackend.AcknowledgeAgentCrossed(regionHandle, agentId); - } - - public bool AcknowledgePrimCrossed(ulong regionHandle, UUID primId) - { - return m_localBackend.AcknowledgePrimCrossed(regionHandle, primId); - } - - #endregion - - #region Methods triggered by calls from external instances - - /// - /// - /// - /// - /// - /// - public bool IncomingChildAgent(ulong regionHandle, AgentCircuitData agentData) - { - //m_log.Info("[INTER]: " + gdebugRegionName + ": Incoming OGS1 Agent " + agentData.firstname + " " + agentData.lastname); - - return m_localBackend.IncomingChildAgent(regionHandle, agentData); - } - - public bool TriggerRegionUp(RegionUpData regionData, ulong regionhandle) - { - m_log.Info( - "[OGS1 GRID SERVICES]: " + - m_localBackend._gdebugRegionName + "Incoming OGS1 RegionUpReport: " + "(" + regionData.X + - "," + regionData.Y + "). Giving this region a fresh set of 'dead' tries"); - - RegionInfo nRegionInfo = new RegionInfo(); - nRegionInfo.SetEndPoint("127.0.0.1", regionData.PORT); - nRegionInfo.ExternalHostName = regionData.IPADDR; - nRegionInfo.RegionLocX = regionData.X; - nRegionInfo.RegionLocY = regionData.Y; - - lock (m_deadRegionCache) - { - if (m_deadRegionCache.ContainsKey(nRegionInfo.RegionHandle)) - { - m_deadRegionCache.Remove(nRegionInfo.RegionHandle); - } - } - - return m_localBackend.TriggerRegionUp(nRegionInfo, regionhandle); - } - - public bool TriggerChildAgentUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentData) - { - //m_log.Info("[INTER]: Incoming OGS1 Child Agent Data Update"); - - return m_localBackend.TriggerChildAgentUpdate(regionHandle, cAgentData); - } - - /// - /// - /// - /// - /// - /// - public bool IncomingPrim(ulong regionHandle, UUID primID, string objData, int XMLMethod) - { - m_log.DebugFormat("[INTERREGION]: Got prim crosssing request for {0}", primID); - m_localBackend.TriggerExpectPrim(regionHandle, primID, objData, XMLMethod); - - return true; - } - - /// - /// - /// - /// - /// - /// - /// - public bool TriggerExpectAvatarCrossing(ulong regionHandle, UUID agentID, Vector3 position, bool isFlying) - { - return m_localBackend.TriggerExpectAvatarCrossing(regionHandle, agentID, position, isFlying); - } - - public bool TriggerExpectPrimCrossing(ulong regionHandle, UUID agentID, Vector3 position, bool isPhysical) - { - return m_localBackend.TriggerExpectPrimCrossing(regionHandle, agentID, position, isPhysical); - } - - public bool TriggerTellRegionToCloseChildConnection(ulong regionHandle, UUID agentID) - { - return m_localBackend.TriggerTellRegionToCloseChildConnection(regionHandle, agentID); - } - - #endregion - - #endregion - - int timeOut = 10; //10 seconds - - /// - /// Check that a region is available for TCP comms. This is necessary for .NET remoting between regions. - /// - /// - /// - /// - /// - public bool CheckRegion(string address, uint port, bool retry) - { - bool available = false; - bool timed_out = true; - - IPAddress ia = Util.GetHostFromDNS(address); - IPEndPoint m_EndPoint; - try - { - m_EndPoint = new IPEndPoint(ia, (int)port); - } - catch (Exception) - { - m_log.Debug("[OGS1 GRID SERVICES]: Invalid remoting address: " + address); - return false; - } - - AsyncCallback callback = delegate(IAsyncResult iar) - { - timed_out = false; - - Socket s = (Socket)iar.AsyncState; - try - { - s.EndConnect(iar); - available = true; - } - catch (Exception e) - { - m_log.DebugFormat( - "[OGS1 GRID SERVICES]: Callback EndConnect exception: {0}:{1}", e.Message, e.StackTrace); - } - - s.Close(); - }; - - IAsyncResult ar; - - try - { - Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); - ar = socket.BeginConnect(m_EndPoint, callback, socket); - ar.AsyncWaitHandle.WaitOne(timeOut * 1000, false); - } - catch (Exception e) - { - m_log.DebugFormat( - "[OGS1 GRID SERVICES]: CheckRegion Socket Setup exception: {0}:{1}", e.Message, e.StackTrace); - - return false; - } - - if (timed_out) - { - ar.AsyncWaitHandle.Close(); - - m_log.DebugFormat( - "[OGS1 GRID SERVICES]: socket [{0}] timed out ({1}) waiting to obtain a connection.", - m_EndPoint, timeOut * 1000); - - if (retry) - { - return CheckRegion(address, port, false); - } - } - - return available; - } - - public bool CheckRegion(string address, uint port) - { - return CheckRegion(address, port, true); - } - public void NoteDeadRegion(ulong regionhandle) { lock (m_deadRegionCache) diff --git a/OpenSim/Region/Communications/OGS1/OGS1InterSimComms.cs b/OpenSim/Region/Communications/OGS1/OGS1InterSimComms.cs deleted file mode 100644 index dd4d0aa..0000000 --- a/OpenSim/Region/Communications/OGS1/OGS1InterSimComms.cs +++ /dev/null @@ -1,263 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSim Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Reflection; -using System.Runtime.Remoting; -using log4net; -using OpenMetaverse; -using OpenSim.Framework; - -namespace OpenSim.Region.Communications.OGS1 -{ - public delegate bool InformRegionChild(ulong regionHandle, AgentCircuitData agentData); - - public delegate bool ExpectArrival(ulong regionHandle, UUID agentID, Vector3 position, bool isFlying); - - public delegate bool InformRegionPrimGroup(ulong regionHandle, UUID primID, Vector3 Positon, bool isPhysical); - - public delegate bool PrimGroupArrival(ulong regionHandle, UUID primID, string objData, int XMLMethod); - - public delegate bool RegionUp(RegionUpData region, ulong regionhandle); - - public delegate bool ChildAgentUpdate(ulong regionHandle, ChildAgentDataUpdate childUpdate); - - public delegate bool TellRegionToCloseChildConnection(ulong regionHandle, UUID agentID); - - public sealed class InterRegionSingleton - { - private static readonly InterRegionSingleton instance = new InterRegionSingleton(); - - public event InformRegionChild OnChildAgent; - public event ExpectArrival OnArrival; - public event InformRegionPrimGroup OnPrimGroupNear; - public event PrimGroupArrival OnPrimGroupArrival; - public event RegionUp OnRegionUp; - public event ChildAgentUpdate OnChildAgentUpdate; - public event TellRegionToCloseChildConnection OnTellRegionToCloseChildConnection; - - private InformRegionChild handlerChildAgent = null; // OnChildAgent; - private ExpectArrival handlerArrival = null; // OnArrival; - private InformRegionPrimGroup handlerPrimGroupNear = null; // OnPrimGroupNear; - private PrimGroupArrival handlerPrimGroupArrival = null; // OnPrimGroupArrival; - private RegionUp handlerRegionUp = null; // OnRegionUp; - private ChildAgentUpdate handlerChildAgentUpdate = null; // OnChildAgentUpdate; - private TellRegionToCloseChildConnection handlerTellRegionToCloseChildConnection = null; // OnTellRegionToCloseChildConnection; - - - static InterRegionSingleton() - { - } - - private InterRegionSingleton() - { - } - - public static InterRegionSingleton Instance - { - get { return instance; } - } - - public bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData) - { - handlerChildAgent = OnChildAgent; - if (handlerChildAgent != null) - { - return handlerChildAgent(regionHandle, agentData); - } - return false; - } - - public bool RegionUp(RegionUpData sregion, ulong regionhandle) - { - handlerRegionUp = OnRegionUp; - if (handlerRegionUp != null) - { - return handlerRegionUp(sregion, regionhandle); - } - return false; - } - - public bool ChildAgentUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentUpdate) - { - handlerChildAgentUpdate = OnChildAgentUpdate; - if (handlerChildAgentUpdate != null) - { - return handlerChildAgentUpdate(regionHandle, cAgentUpdate); - } - return false; - } - - public bool ExpectAvatarCrossing(ulong regionHandle, UUID agentID, Vector3 position, bool isFlying) - { - handlerArrival = OnArrival; - if (handlerArrival != null) - { - return handlerArrival(regionHandle, agentID, position, isFlying); - } - return false; - } - - public bool InformRegionPrim(ulong regionHandle, UUID primID, Vector3 position, bool isPhysical) - { - handlerPrimGroupNear = OnPrimGroupNear; - if (handlerPrimGroupNear != null) - { - return handlerPrimGroupNear(regionHandle, primID, position, isPhysical); - } - return false; - } - - public bool ExpectPrimCrossing(ulong regionHandle, UUID primID, string objData, int XMLMethod) - { - handlerPrimGroupArrival = OnPrimGroupArrival; - if (handlerPrimGroupArrival != null) - { - return handlerPrimGroupArrival(regionHandle, primID, objData, XMLMethod); - } - return false; - } - - public bool TellRegionToCloseChildConnection(ulong regionHandle, UUID agentID) - { - handlerTellRegionToCloseChildConnection = OnTellRegionToCloseChildConnection; - if (handlerTellRegionToCloseChildConnection != null) - { - return handlerTellRegionToCloseChildConnection(regionHandle, agentID); - } - return false; - } - } - - public class OGS1InterRegionRemoting : MarshalByRefObject - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - public OGS1InterRegionRemoting() - { - } - - public bool InformRegionOfChildAgent(ulong regionHandle, sAgentCircuitData agentData) - { - try - { - return - InterRegionSingleton.Instance.InformRegionOfChildAgent(regionHandle, new AgentCircuitData(agentData)); - } - catch (RemotingException e) - { - Console.WriteLine("Remoting Error: Unable to connect to remote region.\n" + e.ToString()); - return false; - } - } - - public bool RegionUp(RegionUpData region, ulong regionhandle) - { - try - { - return InterRegionSingleton.Instance.RegionUp(region, regionhandle); - } - catch (RemotingException e) - { - Console.WriteLine("Remoting Error: Unable to connect to remote region.\n" + e.ToString()); - return false; - } - } - - public bool ChildAgentUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentData) - { - try - { - return InterRegionSingleton.Instance.ChildAgentUpdate(regionHandle, cAgentData); - } - catch (RemotingException e) - { - Console.WriteLine("Remoting Error: Unable to send Child agent update to remote region.\n" + e.ToString()); - return false; - } - } - - - public bool ExpectAvatarCrossing(ulong regionHandle, Guid agentID, sLLVector3 position, bool isFlying) - { - try - { - return - InterRegionSingleton.Instance.ExpectAvatarCrossing(regionHandle, new UUID(agentID), - new Vector3(position.x, position.y, position.z), - isFlying); - } - catch (RemotingException e) - { - Console.WriteLine("Remoting Error: Unable to connect to remote region.\n" + e.ToString()); - return false; - } - } - - public bool InformRegionPrim(ulong regionHandle, Guid SceneObjectGroupID, sLLVector3 position, bool isPhysical) - { - try - { - return - InterRegionSingleton.Instance.InformRegionPrim(regionHandle, new UUID(SceneObjectGroupID), - new Vector3(position.x, position.y, position.z), - isPhysical); - } - catch (RemotingException e) - { - Console.WriteLine("Remoting Error: Unable to connect to remote region.\n" + e.ToString()); - return false; - } - } - - public bool InformRegionOfPrimCrossing(ulong regionHandle, Guid primID, string objData, int XMLMethod) - { - try - { - return InterRegionSingleton.Instance.ExpectPrimCrossing(regionHandle, new UUID(primID), objData, XMLMethod); - } - catch (RemotingException e) - { - Console.WriteLine("Remoting Error: Unable to connect to remote region.\n" + e.ToString()); - return false; - } - } - - public bool TellRegionToCloseChildConnection(ulong regionHandle, Guid agentID) - { - try - { - return InterRegionSingleton.Instance.TellRegionToCloseChildConnection(regionHandle, new UUID(agentID)); - } - catch (RemotingException) - { - m_log.Info("[INTERREGION]: Remoting Error: Unable to connect to remote region: " + regionHandle.ToString()); - return false; - } - } - } -} -- cgit v1.1