From 86defd0a69d53df6d352b7d4b9a5b9d6621c19e8 Mon Sep 17 00:00:00 2001 From: MW Date: Sat, 28 Jun 2008 15:13:17 +0000 Subject: plumbing for multiple inventory servers. Mostly done on the region server side. TODO next is to make the login server read/write a users inventory from the correct server (the inventory url set in a userprofile) On the region side, although not tested with multiple servers it should work if that inventory url was set, and the inventory servers urls have been added to the CommunicationsManager, using CommunicationsManager.AddInventoryService(string hostUrl) --- .../Communications/Cache/CachedUserInfo.cs | 116 +++++++++++++++++---- .../Cache/UserProfileCacheService.cs | 7 +- .../Communications/CommunicationsManager.cs | 72 +++++++++++-- OpenSim/Framework/Communications/IAvatarService.cs | 21 ++++ .../Framework/Communications/IInventoryServices.cs | 4 + OpenSim/Framework/Communications/IUserService.cs | 8 +- .../Communications/InventoryServiceBase.cs | 5 + OpenSim/Region/Application/OpenSimBase.cs | 2 +- .../Communications/Local/CommunicationsLocal.cs | 3 +- .../Communications/OGS1/CommunicationsOGS1.cs | 11 +- .../Communications/OGS1/OGS1InventoryService.cs | 7 ++ .../Scenes/SceneCommunicationService.cs | 1 + .../Modules/AvatarFactory/AvatarFactoryModule.cs | 1 + 13 files changed, 220 insertions(+), 38 deletions(-) create mode 100644 OpenSim/Framework/Communications/IAvatarService.cs (limited to 'OpenSim') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 3127bd6..524f314 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -87,6 +87,24 @@ namespace OpenSim.Framework.Communications.Cache private IDictionary> pendingCategorizationFolders = new Dictionary>(); + private string m_inventoryHost + { + get + { + if (m_userProfile != null) + { + if (m_userProfile.UserInventoryURI != String.Empty) + { + Uri uri = new Uri(m_userProfile.UserInventoryURI); + return uri.Host; + } + } + + return ""; + } + + } + /// /// Constructor /// @@ -325,9 +343,15 @@ namespace OpenSim.Framework.Communications.Cache createdBaseFolder.Type = createdFolder.Type; createdBaseFolder.Version = createdFolder.Version; - m_commsManager.InventoryService.AddFolder(createdBaseFolder); + IInventoryServices invService = GetInventoryService(); + if (invService != null) + { + //m_commsManager.InventoryService + invService.AddFolder(createdBaseFolder); + return true; + } - return true; + return false; } else { @@ -379,14 +403,19 @@ namespace OpenSim.Framework.Communications.Cache baseFolder.Type = (short) type; baseFolder.Version = RootFolder.Version; - m_commsManager.InventoryService.UpdateFolder(baseFolder); - - InventoryFolderImpl folder=RootFolder.FindFolder(folderID); - if(folder != null) - { - folder.Name = name; - folder.ParentID = parentID; - } + IInventoryServices invService = GetInventoryService(); + if (invService != null) + { + //m_commsManager.InventoryService. + invService.UpdateFolder(baseFolder); + + InventoryFolderImpl folder = RootFolder.FindFolder(folderID); + if (folder != null) + { + folder.Name = name; + folder.ParentID = parentID; + } + } } else { @@ -421,13 +450,24 @@ namespace OpenSim.Framework.Communications.Cache baseFolder.ID = folderID; baseFolder.ParentID = parentID; - m_commsManager.InventoryService.MoveFolder(baseFolder); - - InventoryFolderImpl folder=RootFolder.FindFolder(folderID); - if(folder != null) - folder.ParentID = parentID; - - return true; + IInventoryServices invService = GetInventoryService(); + if (invService != null) + { + // m_commsManager.InventoryService + invService.MoveFolder(baseFolder); + + InventoryFolderImpl folder = RootFolder.FindFolder(folderID); + if (folder != null) + { + folder.ParentID = parentID; + } + + return true; + } + else + { + return false; + } } else { @@ -468,11 +508,16 @@ namespace OpenSim.Framework.Communications.Cache purgedBaseFolder.Type = purgedFolder.Type; purgedBaseFolder.Version = purgedFolder.Version; - m_commsManager.InventoryService.PurgeFolder(purgedBaseFolder); + IInventoryServices invService = GetInventoryService(); + if (invService != null) + { + //m_commsManager.InventoryService + invService.PurgeFolder(purgedBaseFolder); - purgedFolder.Purge(); + purgedFolder.Purge(); - return true; + return true; + } } } else @@ -505,7 +550,13 @@ namespace OpenSim.Framework.Communications.Cache item.Folder=RootFolder.ID; } ItemReceive(item); - m_commsManager.InventoryService.AddItem(item); + + IInventoryServices invService = GetInventoryService(); + if (invService != null) + { + //m_commsManager.InventoryService + invService.AddItem(item); + } } else { @@ -525,7 +576,12 @@ namespace OpenSim.Framework.Communications.Cache { if (HasInventory) { - m_commsManager.InventoryService.UpdateItem(item); + IInventoryServices invService = GetInventoryService(); + if (invService != null) + { + //m_commsManager.InventoryService + invService.UpdateItem(item); + } } else { @@ -564,7 +620,14 @@ namespace OpenSim.Framework.Communications.Cache if (RootFolder.DeleteItem(item.ID)) { - return m_commsManager.InventoryService.DeleteItem(item); + IInventoryServices invService = GetInventoryService(); + if (invService != null) + { + //return m_commsManager.InventoryService + return invService.DeleteItem(item); + } + + return false; } } else @@ -641,6 +704,13 @@ namespace OpenSim.Framework.Communications.Cache } return null; } + + public IInventoryServices GetInventoryService() + { + IInventoryServices invService; + m_commsManager.TryGetInventoryService(m_inventoryHost, out invService); + return invService; + } } /// diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index fe61406..37451ab 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -119,7 +119,12 @@ namespace OpenSim.Framework.Communications.Cache CachedUserInfo userInfo = GetUserDetails(userID); if (userInfo != null) { - m_commsManager.InventoryService.RequestInventoryForUser(userID, userInfo.InventoryReceive); + //m_commsManager.InventoryService.RequestInventoryForUser(userID, userInfo.InventoryReceive); + IInventoryServices invService = userInfo.GetInventoryService(); + if (invService != null) + { + invService.RequestInventoryForUser(userID, userInfo.InventoryReceive); + } } else { diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 5de0c71..0410f0e 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -55,12 +55,6 @@ namespace OpenSim.Framework.Communications get { return m_gridService; } } - protected IInventoryServices m_inventoryService; - - public IInventoryServices InventoryService - { - get { return m_inventoryService; } - } protected IInterRegionCommunications m_interRegion; @@ -106,6 +100,70 @@ namespace OpenSim.Framework.Communications // m_transactionsManager = new AgentAssetTransactionsManager(this, dumpAssetsToFile); } + #region Inventory + protected string m_defaultInventoryHost = "default"; + + protected List m_inventoryServices = new List(); + // protected IInventoryServices m_inventoryService; + + public IInventoryServices InventoryService + { + get + { + if (m_inventoryServices.Count > 0) + { + // return m_inventoryServices[0]; + IInventoryServices invService; + if (TryGetInventoryService(m_defaultInventoryHost, out invService)) + { + return invService; + } + + } + + return null; + } + } + + public bool TryGetInventoryService(string host, out IInventoryServices inventoryService) + { + if ((host == string.Empty) | (host == "default")) + { + host = m_defaultInventoryHost; + } + + + lock (m_inventoryServices) + { + foreach (IInventoryServices service in m_inventoryServices) + { + if (service.Host == host) + { + inventoryService = service; + return true; + } + } + } + + inventoryService = null; + return false; + } + + public virtual void AddInventoryService(string hostUrl) + { + + } + + public virtual void AddInventoryService(IInventoryServices service) + { + lock (m_inventoryServices) + { + m_inventoryServices.Add(service); + } + } + + #endregion + public void doCreate(string[] cmmdParams) { switch (cmmdParams[0]) @@ -167,7 +225,7 @@ namespace OpenSim.Framework.Communications } else { - m_inventoryService.CreateNewUserInventory(userProf.ID); + InventoryService.CreateNewUserInventory(userProf.ID); m_log.Info("[USERS]: Created new inventory set for " + firstName + " " + lastName); return userProf.ID; } diff --git a/OpenSim/Framework/Communications/IAvatarService.cs b/OpenSim/Framework/Communications/IAvatarService.cs new file mode 100644 index 0000000..fdac53f --- /dev/null +++ b/OpenSim/Framework/Communications/IAvatarService.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; + +namespace OpenSim.Framework.Communications +{ + public interface IAvatarService + { + /// Get's the User Appearance + AvatarAppearance GetUserAppearance(LLUUID user); + + void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance); + + void AddAttachment(LLUUID user, LLUUID attach); + + void RemoveAttachment(LLUUID user, LLUUID attach); + + List GetAttachments(LLUUID user); + } +} diff --git a/OpenSim/Framework/Communications/IInventoryServices.cs b/OpenSim/Framework/Communications/IInventoryServices.cs index 8dc09bc..3929a4e 100644 --- a/OpenSim/Framework/Communications/IInventoryServices.cs +++ b/OpenSim/Framework/Communications/IInventoryServices.cs @@ -42,6 +42,10 @@ namespace OpenSim.Framework.Communications /// public interface IInventoryServices { + string Host + { + get; + } /// /// Request the inventory for a user. This is an asynchronous operation that will call the callback when the /// inventory has been received diff --git a/OpenSim/Framework/Communications/IUserService.cs b/OpenSim/Framework/Communications/IUserService.cs index a7f19e7..f8ef358 100644 --- a/OpenSim/Framework/Communications/IUserService.cs +++ b/OpenSim/Framework/Communications/IUserService.cs @@ -112,16 +112,16 @@ namespace OpenSim.Framework.Communications List GetUserFriendList(LLUUID friendlistowner); /// - /// Get's the User Appearance - AvatarAppearance GetUserAppearance(LLUUID user); - - /// /// Updates the current region the User is in /// /// User Region the Avatar is IN /// User Region the Avatar is IN void UpdateUserCurrentRegion(LLUUID avatarid, LLUUID regionuuid, ulong regionhandle); + /// + /// Get's the User Appearance + AvatarAppearance GetUserAppearance(LLUUID user); + void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance); void AddAttachment(LLUUID user, LLUUID attach); diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index 89ccf93..d26a3bb 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -81,6 +81,11 @@ namespace OpenSim.Framework.Communications #region IInventoryServices methods + public string Host + { + get { return "default"; } + } + // See IInventoryServices public List GetInventorySkeleton(LLUUID userId) { diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index aecf2df..06b4de7 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs @@ -173,7 +173,7 @@ namespace OpenSim { if (File.Exists("OpenSim.xml")) { - //chech for a xml config file + //check for a xml config file Application.iniFilePath = "OpenSim.xml"; m_config.Source = new XmlConfigSource(); m_config.Source.Merge(new XmlConfigSource(Application.iniFilePath)); diff --git a/OpenSim/Region/Communications/Local/CommunicationsLocal.cs b/OpenSim/Region/Communications/Local/CommunicationsLocal.cs index fb5b17b..2065006 100644 --- a/OpenSim/Region/Communications/Local/CommunicationsLocal.cs +++ b/OpenSim/Region/Communications/Local/CommunicationsLocal.cs @@ -44,7 +44,8 @@ namespace OpenSim.Region.Communications.Local IGridServices gridService, bool dumpAssetsToFile) : base(serversInfo, httpServer, assetCache, dumpAssetsToFile) { - m_inventoryService = inventoryService; + AddInventoryService( inventoryService); + m_defaultInventoryHost = inventoryService.Host; m_userService = userService; m_gridService = gridService; m_interRegion = interRegionService; diff --git a/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs b/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs index d622b7e..b85654d 100644 --- a/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs +++ b/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs @@ -41,8 +41,17 @@ namespace OpenSim.Region.Communications.OGS1 m_gridService = gridInterComms; m_interRegion = gridInterComms; - m_inventoryService = new OGS1InventoryService(serversInfo.InventoryURL); + OGS1InventoryService invService = new OGS1InventoryService(serversInfo.InventoryURL); + AddInventoryService(invService); + m_defaultInventoryHost = invService.Host; + m_userService = new OGS1UserServices(this); } + + public override void AddInventoryService(string hostUrl) + { + OGS1InventoryService invService = new OGS1InventoryService(hostUrl); + AddInventoryService(invService); + } } } diff --git a/OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs b/OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs index dfc741a..4e4bfe8 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs @@ -45,16 +45,23 @@ namespace OpenSim.Region.Communications.OGS1 = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private string _inventoryServerUrl; + private Uri m_Uri; private Dictionary m_RequestingInventory = new Dictionary(); public OGS1InventoryService(string inventoryServerUrl) { _inventoryServerUrl = inventoryServerUrl; + m_Uri = new Uri(_inventoryServerUrl); } #region IInventoryServices Members + public string Host + { + get { return m_Uri.Host; } + } + /// /// /// diff --git a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs index cdd138b..da93890 100644 --- a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs @@ -696,5 +696,6 @@ namespace OpenSim.Region.Environment.Scenes { return m_commsProvider.GenerateAgentPickerRequestResponse(queryID, query); } + } } diff --git a/OpenSim/Region/Modules/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/Modules/AvatarFactory/AvatarFactoryModule.cs index 9c70a04..43b492a 100644 --- a/OpenSim/Region/Modules/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/Modules/AvatarFactory/AvatarFactoryModule.cs @@ -66,6 +66,7 @@ namespace OpenSim.Region.Modules.AvatarFactory appearance = CreateDefault(avatarId); m_log.InfoFormat("[APPEARANCE] appearance not found for {0}, creating default", avatarId.ToString()); return false; + } private AvatarAppearance CreateDefault(LLUUID avatarId) -- cgit v1.1