Pull out distinct cache system folders and drop cache methods in InventoryCache
parent
7f8df4242b
commit
7ff4c2e50b
|
@ -45,6 +45,7 @@ using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver;
|
|||
using OpenSim.Region.CoreModules.World.Serialiser;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using OpenSim.Region.Framework.Scenes.Serialization;
|
||||
using OpenSim.Services.Interfaces;
|
||||
using OpenSim.Tests.Common;
|
||||
using OpenSim.Tests.Common.Mock;
|
||||
using OpenSim.Tests.Common.Setup;
|
||||
|
@ -102,6 +103,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
|
|||
Monitor.Wait(this, 60000);
|
||||
}
|
||||
|
||||
Console.WriteLine("here");
|
||||
|
||||
// Create asset
|
||||
SceneObjectGroup object1;
|
||||
SceneObjectPart part1;
|
||||
|
@ -135,8 +138,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
|
|||
item1.AssetID = asset1.FullID;
|
||||
item1.ID = item1Id;
|
||||
//userInfo.RootFolder.FindFolderByPath("Objects").ID;
|
||||
InventoryFolderBase objsFolder = scene.InventoryService.GetFolderForType(userId, AssetType.Object);
|
||||
//InventoryFolderBase rootFolder = scene.InventoryService.GetRootFolder(userId);
|
||||
//InventoryFolderBase objsFolder = scene.InventoryService.GetFolderForType(userId, AssetType.Object);
|
||||
Console.WriteLine("here2");
|
||||
IInventoryService inventoryService = scene.InventoryService;
|
||||
InventoryFolderBase rootFolder = inventoryService.GetRootFolder(userId);
|
||||
InventoryCollection rootContents = inventoryService.GetFolderContent(userId, rootFolder.ID);
|
||||
InventoryFolderBase objsFolder = null;
|
||||
foreach (InventoryFolderBase folder in rootContents.Folders)
|
||||
if (folder.Name == "Objects")
|
||||
objsFolder = folder;
|
||||
item1.Folder = objsFolder.ID;
|
||||
scene.AddInventoryItem(userId, item1);
|
||||
|
||||
|
|
|
@ -88,13 +88,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
|
|||
}
|
||||
|
||||
// If not, go get them and place them in the cache
|
||||
Dictionary<AssetType, InventoryFolderBase> folders = m_Connector.GetSystemFolders(presence.UUID);
|
||||
Dictionary<AssetType, InventoryFolderBase> folders = CacheSystemFolders(presence.UUID);
|
||||
m_log.DebugFormat("[INVENTORY CACHE]: OnMakeRootAgent in {0}, fetched system folders for {1} {2}: count {3}",
|
||||
presence.Scene.RegionInfo.RegionName, presence.Firstname, presence.Lastname, folders.Count);
|
||||
|
||||
if (folders.Count > 0)
|
||||
lock (m_InventoryCache)
|
||||
m_InventoryCache.Add(presence.UUID, folders);
|
||||
}
|
||||
|
||||
void OnClientClosed(UUID clientID, Scene scene)
|
||||
|
@ -113,26 +109,51 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
|
|||
}
|
||||
}
|
||||
|
||||
// Drop system folders
|
||||
lock (m_InventoryCache)
|
||||
if (m_InventoryCache.ContainsKey(clientID))
|
||||
{
|
||||
m_log.DebugFormat("[INVENTORY CACHE]: OnClientClosed in {0}, user {1} out of sim. Dropping system folders",
|
||||
scene.RegionInfo.RegionName, clientID);
|
||||
|
||||
m_InventoryCache.Remove(clientID);
|
||||
}
|
||||
m_log.DebugFormat(
|
||||
"[INVENTORY CACHE]: OnClientClosed in {0}, user {1} out of sim. Dropping system folders",
|
||||
scene.RegionInfo.RegionName, clientID);
|
||||
DropCachedSystemFolders(clientID);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cache a user's 'system' folders.
|
||||
/// </summary>
|
||||
/// <param name="userID"></param>
|
||||
/// <returns>Folders cached</returns>
|
||||
protected Dictionary<AssetType, InventoryFolderBase> CacheSystemFolders(UUID userID)
|
||||
{
|
||||
// If not, go get them and place them in the cache
|
||||
Dictionary<AssetType, InventoryFolderBase> folders = m_Connector.GetSystemFolders(userID);
|
||||
|
||||
if (folders.Count > 0)
|
||||
lock (m_InventoryCache)
|
||||
m_InventoryCache.Add(userID, folders);
|
||||
|
||||
return folders;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Drop a user's cached 'system' folders
|
||||
/// </summary>
|
||||
/// <param name="userID"></param>
|
||||
protected void DropCachedSystemFolders(UUID userID)
|
||||
{
|
||||
// Drop system folders
|
||||
lock (m_InventoryCache)
|
||||
if (m_InventoryCache.ContainsKey(userID))
|
||||
m_InventoryCache.Remove(userID);
|
||||
}
|
||||
|
||||
public InventoryFolderBase GetFolderForType(UUID userID, AssetType type)
|
||||
{
|
||||
Dictionary<AssetType, InventoryFolderBase> folders = null;
|
||||
|
||||
lock (m_InventoryCache)
|
||||
{
|
||||
m_InventoryCache.TryGetValue(userID, out folders);
|
||||
}
|
||||
|
||||
if ((folders != null) && folders.ContainsKey(type))
|
||||
{
|
||||
return folders[type];
|
||||
|
|
|
@ -88,6 +88,8 @@ namespace OpenSim.Services.InventoryService
|
|||
// See IInventoryServices
|
||||
public virtual InventoryFolderBase GetRootFolder(UUID userID)
|
||||
{
|
||||
//m_log.DebugFormat("[INVENTORY SERVICE]: Getting root folder for {0}", userID);
|
||||
|
||||
// Retrieve the first root folder we get from the DB.
|
||||
InventoryFolderBase rootFolder = m_Database.getUserRootFolder(userID);
|
||||
if (rootFolder != null)
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using log4net;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Data;
|
||||
|
@ -39,7 +41,9 @@ namespace OpenSim.Tests.Common.Mock
|
|||
/// tests are single threaded.
|
||||
/// </summary>
|
||||
public class TestInventoryDataPlugin : IInventoryDataPlugin
|
||||
{
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
/// <value>
|
||||
/// Inventory folders
|
||||
/// </value>
|
||||
|
@ -87,6 +91,8 @@ namespace OpenSim.Tests.Common.Mock
|
|||
|
||||
public InventoryFolderBase getUserRootFolder(UUID user)
|
||||
{
|
||||
m_log.DebugFormat("[MOCK INV DB]: Looking for root folder for {0}", user);
|
||||
|
||||
InventoryFolderBase folder = null;
|
||||
m_rootFolders.TryGetValue(user, out folder);
|
||||
|
||||
|
@ -124,7 +130,11 @@ namespace OpenSim.Tests.Common.Mock
|
|||
m_folders[folder.ID] = folder;
|
||||
|
||||
if (folder.ParentID == UUID.Zero)
|
||||
{
|
||||
m_log.DebugFormat(
|
||||
"[MOCK INV DB]: Adding root folder {0} {1} for {2}", folder.Name, folder.ID, folder.Owner);
|
||||
m_rootFolders[folder.Owner] = folder;
|
||||
}
|
||||
}
|
||||
|
||||
public void updateInventoryFolder(InventoryFolderBase folder)
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
|
||||
</configSections>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="nunit.framework" publicKeyToken="96d09a1eb7f44a77" culture="Neutral" />
|
||||
<bindingRedirect oldVersion="2.0.6.0" newVersion="2.4.6.0" />
|
||||
<bindingRedirect oldVersion="2.1.4.0" newVersion="2.4.6.0" />
|
||||
<bindingRedirect oldVersion="2.2.8.0" newVersion="2.4.6.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
<log4net>
|
||||
<!-- A1 is set to be a ConsoleAppender -->
|
||||
<appender name="A1" type="log4net.Appender.ConsoleAppender">
|
||||
|
||||
<!-- A1 uses PatternLayout -->
|
||||
<layout type="log4net.Layout.PatternLayout">
|
||||
<!-- Print the date in ISO 8601 format -->
|
||||
<conversionPattern value="%date [%thread] %-5level %logger %ndc - %message%newline" />
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<!-- Set root logger level to DEBUG and its only appender to A1 -->
|
||||
<root>
|
||||
<level value="DEBUG" />
|
||||
<appender-ref ref="A1" />
|
||||
</root>
|
||||
</log4net>
|
||||
</configuration>
|
|
@ -1,33 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
|
||||
</configSections>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="nunit.framework" publicKeyToken="96d09a1eb7f44a77" culture="Neutral" />
|
||||
<bindingRedirect oldVersion="2.0.6.0" newVersion="2.4.6.0" />
|
||||
<bindingRedirect oldVersion="2.1.4.0" newVersion="2.4.6.0" />
|
||||
<bindingRedirect oldVersion="2.2.8.0" newVersion="2.4.6.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
<log4net>
|
||||
<!-- A1 is set to be a ConsoleAppender -->
|
||||
<appender name="A1" type="log4net.Appender.ConsoleAppender">
|
||||
|
||||
<!-- A1 uses PatternLayout -->
|
||||
<layout type="log4net.Layout.PatternLayout">
|
||||
<!-- Print the date in ISO 8601 format -->
|
||||
<conversionPattern value="%date [%thread] %-5level %logger %ndc - %message%newline" />
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<!-- Set root logger level to DEBUG and its only appender to A1 -->
|
||||
<root>
|
||||
<level value="Info" />
|
||||
<appender-ref ref="A1" />
|
||||
</root>
|
||||
</log4net>
|
||||
</configuration>
|
|
@ -1,33 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
|
||||
</configSections>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="nunit.framework" publicKeyToken="96d09a1eb7f44a77" culture="Neutral" />
|
||||
<bindingRedirect oldVersion="2.0.6.0" newVersion="2.4.6.0" />
|
||||
<bindingRedirect oldVersion="2.1.4.0" newVersion="2.4.6.0" />
|
||||
<bindingRedirect oldVersion="2.2.8.0" newVersion="2.4.6.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
<log4net>
|
||||
<!-- A1 is set to be a ConsoleAppender -->
|
||||
<appender name="A1" type="log4net.Appender.ConsoleAppender">
|
||||
|
||||
<!-- A1 uses PatternLayout -->
|
||||
<layout type="log4net.Layout.PatternLayout">
|
||||
<!-- Print the date in ISO 8601 format -->
|
||||
<conversionPattern value="%date [%thread] %-5level %logger %ndc - %message%newline" />
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<!-- Set root logger level to DEBUG and its only appender to A1 -->
|
||||
<root>
|
||||
<level value="DEBUG" />
|
||||
<appender-ref ref="A1" />
|
||||
</root>
|
||||
</log4net>
|
||||
</configuration>
|
|
@ -1,33 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
|
||||
</configSections>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="nunit.framework" publicKeyToken="96d09a1eb7f44a77" culture="Neutral" />
|
||||
<bindingRedirect oldVersion="2.0.6.0" newVersion="2.4.6.0" />
|
||||
<bindingRedirect oldVersion="2.1.4.0" newVersion="2.4.6.0" />
|
||||
<bindingRedirect oldVersion="2.2.8.0" newVersion="2.4.6.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
<log4net>
|
||||
<!-- A1 is set to be a ConsoleAppender -->
|
||||
<appender name="A1" type="log4net.Appender.ConsoleAppender">
|
||||
|
||||
<!-- A1 uses PatternLayout -->
|
||||
<layout type="log4net.Layout.PatternLayout">
|
||||
<!-- Print the date in ISO 8601 format -->
|
||||
<conversionPattern value="%date [%thread] %-5level %logger %ndc - %message%newline" />
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<!-- Set root logger level to DEBUG and its only appender to A1 -->
|
||||
<root>
|
||||
<level value="DEBUG" />
|
||||
<appender-ref ref="A1" />
|
||||
</root>
|
||||
</log4net>
|
||||
</configuration>
|
Loading…
Reference in New Issue