* Resolve http://opensimulator.org/mantis/view.php?id=3509 by putting some service initialization into CommsManager

* What is really needed is a plugin and interface request system as being done for region modules
0.6.5-rc1
Justin Clarke Casey 2009-04-22 22:19:43 +00:00
parent 4254733e8a
commit 342126b7b9
14 changed files with 148 additions and 98 deletions

View File

@ -181,21 +181,14 @@ namespace OpenSim.ApplicationPlugins.CreateCommsManager
inventoryService.AddPlugin(m_openSim.ConfigurationSettings.StandaloneInventoryPlugin,
m_openSim.ConfigurationSettings.StandaloneInventorySource);
LocalUserServices userService =
new LocalUserServices(
m_openSim.NetServersInfo.DefaultHomeLocX, m_openSim.NetServersInfo.DefaultHomeLocY, inventoryService);
userService.AddPlugin(m_openSim.ConfigurationSettings.StandaloneUserPlugin,
m_openSim.ConfigurationSettings.StandaloneUserSource);
LocalBackEndServices backendService = new LocalBackEndServices();
//LocalLoginService loginService = CreateLoginService(libraryRootFolder, inventoryService, userService, backendService);
m_commsManager
= new CommunicationsLocal(
m_openSim.NetServersInfo, m_httpServer, m_openSim.AssetCache, userService, userService,
inventoryService, backendService, userService,
libraryRootFolder, m_openSim.ConfigurationSettings.DumpAssetsToFile);
m_openSim.ConfigurationSettings, m_openSim.NetServersInfo, m_httpServer, m_openSim.AssetCache,
inventoryService, backendService, libraryRootFolder, m_openSim.ConfigurationSettings.DumpAssetsToFile);
CreateGridInfoService();
}
@ -207,7 +200,6 @@ namespace OpenSim.ApplicationPlugins.CreateCommsManager
m_httpServer.AddStreamHandler(new OpenSim.SimStatusHandler());
m_httpServer.AddStreamHandler(new OpenSim.XSimStatusHandler(m_openSim));
}
protected virtual void InitialiseHGStandaloneServices(LibraryRootFolder libraryRootFolder)
@ -217,28 +209,18 @@ namespace OpenSim.ApplicationPlugins.CreateCommsManager
HGInventoryServiceClient inventoryService = new HGInventoryServiceClient(m_openSim.NetServersInfo.InventoryURL, null, false);
inventoryService.AddPlugin(m_openSim.ConfigurationSettings.StandaloneInventoryPlugin, m_openSim.ConfigurationSettings.StandaloneInventorySource);
LocalUserServices localuserService =
new LocalUserServices(
m_openSim.NetServersInfo.DefaultHomeLocX, m_openSim.NetServersInfo.DefaultHomeLocY,
inventoryService);
localuserService.AddPlugin(
m_openSim.ConfigurationSettings.StandaloneUserPlugin,
m_openSim.ConfigurationSettings.StandaloneUserSource);
HGUserServices userService = new HGUserServices(m_commsManager, localuserService);
// This plugin arrangement could eventually be configurable rather than hardcoded here.
userService.AddPlugin(new OGS1UserDataPlugin(m_commsManager));
HGGridServicesStandalone gridService
= new HGGridServicesStandalone(
m_openSim.NetServersInfo, m_httpServer, m_openSim.AssetCache, m_openSim.SceneManager);
m_commsManager = new HGCommunicationsStandalone(m_openSim.NetServersInfo, m_httpServer, m_openSim.AssetCache,
userService, localuserService, inventoryService, gridService, userService, libraryRootFolder, m_openSim.ConfigurationSettings.DumpAssetsToFile);
m_commsManager
= new HGCommunicationsStandalone(
m_openSim.ConfigurationSettings, m_openSim.NetServersInfo, m_httpServer, m_openSim.AssetCache,
inventoryService, gridService,
libraryRootFolder, m_openSim.ConfigurationSettings.DumpAssetsToFile);
inventoryService.UserProfileCache = m_commsManager.UserProfileCacheService;
HGServices = gridService;
userService.SetCommunicationsManager(m_commsManager);
CreateGridInfoService();
}

View File

@ -64,7 +64,7 @@ namespace OpenSim.Data
/// </summary>
/// <param name="queryID">ID associated with the user's query. This must match what the client sent</param>
/// <param name="query">The filtered contents of the search box when the user hit search.</param>
/// <returns>A list of user details. If there are no results than either an empty list or null can be returned</returns>
/// <returns>A list of user details. If there are no results than either an empty list or null</returns>
List<AvatarPickerAvatar> GeneratePickerResults(UUID queryID, string query);
/// <summary>
@ -140,6 +140,7 @@ namespace OpenSim.Data
/// Returns a list of FriendsListItems that describe the friends and permissions in the friend relationship for UUID friendslistowner
/// </summary>
/// <param name="friendlistowner">The agent that we're retreiving the friends Data.</param>
/// <returns>The user's friends. If there are no results than either an empty list or null</returns>
List<FriendListItem> GetUserFriendList(UUID friendlistowner);
/// <summary>

View File

@ -36,6 +36,12 @@ namespace OpenSim.Framework.Communications
/// <summary>
/// This class manages references to OpenSim non-region services (asset, inventory, user, etc.)
/// </summary>
///
/// TODO: Service retrieval needs to be managed via plugin and interfaces requests, as happens for region
/// modules from scene. Among other things, this will allow this class to be used in many different contexts
/// (from a grid service executable, to provide services on a region) without lots of messy nulls and confusion.
/// Also, a post initialize step on the plugins will be needed so that we don't get tortuous problems with
/// circular dependencies between plugins.
public class CommunicationsManager
{
//private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);

View File

@ -117,7 +117,12 @@ namespace OpenSim.Framework.Communications
/// Returns a list of FriendsListItems that describe the friends and permissions in the friend relationship
/// for UUID friendslistowner
/// </summary>
/// <param name="friendlistowner">The agent that we're retreiving the friends Data.</param>
///
/// <param name="friendlistowner">The agent for whom we're retreiving the friends Data.</param>
/// <returns>
/// A List of FriendListItems that contains info about the user's friends.
/// Always returns a list even if the user has no friends
/// </returns>
List<FriendListItem> GetUserFriendList(UUID friendlistowner);
// This probably shouldn't be here, it belongs to IAuthentication

View File

@ -35,6 +35,7 @@ using Nwc.XmlRpc;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
using OpenSim.Data;
using OpenSim.Framework.Communications;
using OpenSim.Framework.Statistics;
namespace OpenSim.Framework.Communications
@ -52,15 +53,15 @@ namespace OpenSim.Framework.Communications
/// </value>
private List<IUserDataPlugin> m_plugins = new List<IUserDataPlugin>();
protected IInterServiceInventoryServices m_interServiceInventoryService;
protected CommunicationsManager m_commsManager;
/// <summary>
/// Constructor
/// </summary>
/// <param name="interServiceInventoryService"></param>
public UserManagerBase(IInterServiceInventoryServices interServiceInventoryService)
/// <param name="commsManager"></param>
public UserManagerBase(CommunicationsManager commsManager)
{
m_interServiceInventoryService = interServiceInventoryService;
m_commsManager = commsManager;
}
/// <summary>
@ -296,48 +297,48 @@ namespace OpenSim.Framework.Communications
return null;
}
/// <summary>
/// Loads a user's friend list
/// </summary>
/// <param name="name">the UUID of the friend list owner</param>
/// <returns>A List of FriendListItems that contains info about the user's friends</returns>
public virtual List<FriendListItem> GetUserFriendList(UUID ownerID)
{
List<FriendListItem> allFriends = new List<FriendListItem>();
foreach (IUserDataPlugin plugin in m_plugins)
{
try
{
List<FriendListItem> result = plugin.GetUserFriendList(ownerID);
List<FriendListItem> friends = plugin.GetUserFriendList(ownerID);
if (result != null)
return result;
if (friends != null)
allFriends.AddRange(friends);
}
catch (Exception e)
{
m_log.Info("[USERSTORAGE]: Unable to GetUserFriendList via " + plugin.Name + "(" + e.ToString() + ")");
m_log.Error("[USERSTORAGE]: Unable to GetUserFriendList via " + plugin.Name + "(" + e.ToString() + ")");
}
}
return null;
return allFriends;
}
public virtual Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos (List<UUID> uuids)
{
//Dictionary<UUID, FriendRegionInfo> allFriendRegions = new Dictionary<UUID, FriendRegionInfo>();
foreach (IUserDataPlugin plugin in m_plugins)
{
try
{
Dictionary<UUID, FriendRegionInfo> result = plugin.GetFriendRegionInfos(uuids);
Dictionary<UUID, FriendRegionInfo> friendRegions = plugin.GetFriendRegionInfos(uuids);
if (result != null)
return result;
if (friendRegions != null)
return friendRegions;
}
catch (Exception e)
{
m_log.Info("[USERSTORAGE]: Unable to GetFriendRegionInfos via " + plugin.Name + "(" + e.ToString() + ")");
}
}
return null;
return new Dictionary<UUID, FriendRegionInfo>();
}
public void StoreWebLoginKey(UUID agentID, UUID webLoginKey)
@ -662,7 +663,7 @@ namespace OpenSim.Framework.Communications
}
else
{
m_interServiceInventoryService.CreateNewUserInventory(userProf.ID);
m_commsManager.InterServiceInventoryService.CreateNewUserInventory(userProf.ID);
return userProf.ID;
}
@ -731,13 +732,17 @@ namespace OpenSim.Framework.Communications
{
try
{
return plugin.GetUserAppearance(user);
AvatarAppearance appearance = plugin.GetUserAppearance(user);
if (appearance != null)
return appearance;
}
catch (Exception e)
{
m_log.InfoFormat("[USERSTORAGE]: Unable to find user appearance {0} via {1} ({2})", user.ToString(), plugin.Name, e.ToString());
}
}
return null;
}

View File

@ -43,13 +43,8 @@ namespace OpenSim.Grid.UserServer.Modules
{
protected IGridServiceCore m_core;
public UserDataBaseService()
: base(null)
{
}
public UserDataBaseService(IInterServiceInventoryServices interServiceInventoryService)
: base(interServiceInventoryService)
public UserDataBaseService(CommunicationsManager commsManager)
: base(commsManager)
{
}
@ -57,13 +52,6 @@ namespace OpenSim.Grid.UserServer.Modules
{
m_core = core;
//we only need core components so we can request them from here
IInterServiceInventoryServices inventoryService;
if (m_core.TryGet<IInterServiceInventoryServices>(out inventoryService))
{
m_interServiceInventoryService = inventoryService;
}
UserConfig cfg;
if (m_core.TryGet<UserConfig>(out cfg))
{

View File

@ -146,8 +146,15 @@ namespace OpenSim.Grid.UserServer
protected virtual void StartupUserServerModules()
{
m_log.Info("[STARTUP]: Establishing data connection");
//we only need core components so we can request them from here
IInterServiceInventoryServices inventoryService;
TryGet<IInterServiceInventoryServices>(out inventoryService);
CommunicationsManager commsManager = new UserServerCommsManager(inventoryService);
//setup database access service, for now this has to be created before the other modules.
m_userDataBaseService = new UserDataBaseService();
m_userDataBaseService = new UserDataBaseService(commsManager);
m_userDataBaseService.Initialise(this);
//TODO: change these modules so they fetch the databaseService class in the PostInitialise method

View File

@ -0,0 +1,40 @@
/*
* 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 OpenSim.Framework.Communications;
namespace OpenSim.Grid.UserServer
{
public class UserServerCommsManager : CommunicationsManager
{
public UserServerCommsManager(IInterServiceInventoryServices interServiceInventoryService)
: base(null, null, null, false, null)
{
m_interServiceInventoryService = interServiceInventoryService;
}
}
}

View File

@ -25,32 +25,53 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using OpenSim.Framework;
using OpenSim.Framework.Communications;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Servers;
using OpenSim.Region.Communications.Local;
using OpenSim.Region.Communications.OGS1;
namespace OpenSim.Region.Communications.Hypergrid
{
public class HGCommunicationsStandalone : CommunicationsLocal
public class HGCommunicationsStandalone : CommunicationsManager
{
public HGCommunicationsStandalone(
ConfigSettings configSettings,
NetworkServersInfo serversInfo,
BaseHttpServer httpServer,
IAssetCache assetCache,
IUserService userService,
IUserAdminService userServiceAdmin,
LocalInventoryService inventoryService,
HGGridServices gridService, IMessagingService messageService, LibraryRootFolder libraryRootFolder, bool dumpAssetsToFile)
: base(serversInfo, httpServer, assetCache, userService, userServiceAdmin, inventoryService, gridService, messageService, libraryRootFolder, dumpAssetsToFile)
HGGridServices gridService,
LibraryRootFolder libraryRootFolder,
bool dumpAssetsToFile)
: base(serversInfo, httpServer, assetCache, dumpAssetsToFile, libraryRootFolder)
{
gridService.UserProfileCache = m_userProfileCacheService;
LocalUserServices localUserService =
new LocalUserServices(
serversInfo.DefaultHomeLocX, serversInfo.DefaultHomeLocY, this);
localUserService.AddPlugin(configSettings.StandaloneUserPlugin, configSettings.StandaloneUserSource);
AddInventoryService(inventoryService);
m_defaultInventoryHost = inventoryService.Host;
m_interServiceInventoryService = inventoryService;
m_assetCache = assetCache;
// Let's swap to always be secure access to inventory
AddSecureInventoryService((ISecureInventoryService)inventoryService);
m_inventoryServices = null;
HGUserServices hgUserService = new HGUserServices(this, localUserService);
// This plugin arrangement could eventually be configurable rather than hardcoded here.
hgUserService.AddPlugin(new OGS1UserDataPlugin(this));
m_userService = hgUserService;
m_userAdminService = hgUserService;
m_avatarService = hgUserService;
m_messageService = hgUserService;
gridService.UserProfileCache = m_userProfileCacheService;
m_gridService = gridService;
}
}
}

View File

@ -47,7 +47,6 @@ namespace OpenSim.Region.Communications.Hypergrid
{
//private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
//private CommunicationsManager m_parent;
//private OGS1UserServices m_remoteUserServices;
private LocalUserServices m_localUserServices;
@ -64,12 +63,6 @@ namespace OpenSim.Region.Communications.Hypergrid
m_localUserServices = local;
}
// Called for standalone mode only, to set up the communications manager
public void SetCommunicationsManager(CommunicationsManager parent)
{
m_commsManager = parent;
}
/// <summary>
/// Get a user agent from the user server
/// </summary>
@ -84,7 +77,6 @@ namespace OpenSim.Region.Communications.Hypergrid
return base.GetAgentByUUID(userId);
}
/// <summary>
/// Logs off a user on the user server
/// </summary>

View File

@ -35,24 +35,30 @@ namespace OpenSim.Region.Communications.Local
public class CommunicationsLocal : CommunicationsManager
{
public CommunicationsLocal(
ConfigSettings configSettings,
NetworkServersInfo serversInfo,
BaseHttpServer httpServer,
IAssetCache assetCache,
IUserService userService,
IUserAdminService userServiceAdmin,
LocalInventoryService inventoryService,
IGridServices gridService, IMessagingService messageService,
LibraryRootFolder libraryRootFolder, bool dumpAssetsToFile)
IGridServices gridService,
LibraryRootFolder libraryRootFolder,
bool dumpAssetsToFile)
: base(serversInfo, httpServer, assetCache, dumpAssetsToFile, libraryRootFolder)
{
AddInventoryService(inventoryService);
m_defaultInventoryHost = inventoryService.Host;
m_interServiceInventoryService = inventoryService;
m_userService = userService;
m_userAdminService = userServiceAdmin;
m_avatarService = (IAvatarService)userService;
LocalUserServices lus
= new LocalUserServices(
serversInfo.DefaultHomeLocX, serversInfo.DefaultHomeLocY, this);
lus.AddPlugin(configSettings.StandaloneUserPlugin, configSettings.StandaloneUserSource);
m_userService = lus;
m_userAdminService = lus;
m_avatarService = lus;
m_messageService = lus;
m_gridService = gridService;
m_messageService = messageService;
}
}
}

View File

@ -45,10 +45,10 @@ namespace OpenSim.Region.Communications.Local
/// </summary>
/// <param name="defaultHomeLocX"></param>
/// <param name="defaultHomeLocY"></param>
/// <param name="inventoryService"></param>
/// <param name="commsManager"></param>
public LocalUserServices(
uint defaultHomeLocX, uint defaultHomeLocY, IInterServiceInventoryServices interServiceInventoryService)
: base(interServiceInventoryService)
uint defaultHomeLocX, uint defaultHomeLocY, CommunicationsManager commsManager)
: base(commsManager)
{
m_defaultHomeX = defaultHomeLocX;
m_defaultHomeY = defaultHomeLocY;

View File

@ -46,12 +46,9 @@ namespace OpenSim.Region.Communications.OGS1
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
protected CommunicationsManager m_commsManager;
public OGS1UserServices(CommunicationsManager commsManager)
: base(commsManager.InterServiceInventoryService)
: base(commsManager)
{
m_commsManager = commsManager;
}
public override void ClearUserAgent(UUID avatarID)

View File

@ -67,7 +67,7 @@ namespace OpenSim.Tests.Common.Mock
m_interServiceInventoryService = lis;
AddInventoryService(lis);
LocalUserServices lus = new LocalUserServices(991, 992, lis);
LocalUserServices lus = new LocalUserServices(991, 992, this);
lus.AddPlugin(m_userDataPlugin);
m_userService = lus;
m_userAdminService = lus;