aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorMelanie Thielker2009-05-10 12:27:05 +0000
committerMelanie Thielker2009-05-10 12:27:05 +0000
commitd8e1842d2507b2c18b21671ed01496b3a2c59e18 (patch)
tree2ae57cf45dd1b22fe48b72b85c952258d87f60b6 /OpenSim/Region
parentFix the build break (diff)
downloadopensim-SC-d8e1842d2507b2c18b21671ed01496b3a2c59e18.zip
opensim-SC-d8e1842d2507b2c18b21671ed01496b3a2c59e18.tar.gz
opensim-SC-d8e1842d2507b2c18b21671ed01496b3a2c59e18.tar.bz2
opensim-SC-d8e1842d2507b2c18b21671ed01496b3a2c59e18.tar.xz
Add some asset cache plumbing. Change the generic cache from UUID to string
keys to allow caching the new crop of URI identified objects.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs32
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs16
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectors/Asset/LocalAssetServiceConnector.cs23
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectors/Asset/RemoteAssetServiceConnector.cs19
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs4
-rw-r--r--OpenSim/Region/Framework/Interfaces/IImprovedAssetCache.cs (renamed from OpenSim/Region/Framework/Interfaces/IAssetCache.cs)6
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs6
7 files changed, 83 insertions, 23 deletions
diff --git a/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs b/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs
index 957b04f..c4cc007 100644
--- a/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs
+++ b/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs
@@ -45,8 +45,6 @@ namespace OpenSim.Region.CoreModules.Asset
45 MethodBase.GetCurrentMethod().DeclaringType); 45 MethodBase.GetCurrentMethod().DeclaringType);
46 46
47 private bool m_Enabled = false; 47 private bool m_Enabled = false;
48 private Dictionary<Scene, IAssetService> m_AssetService =
49 new Dictionary<Scene, IAssetService>();
50 48
51 public string Name 49 public string Name
52 { 50 {
@@ -85,10 +83,6 @@ namespace OpenSim.Region.CoreModules.Asset
85 83
86 public void AddRegion(Scene scene) 84 public void AddRegion(Scene scene)
87 { 85 {
88 if (!m_Enabled)
89 return;
90
91 scene.RegisterModuleInterface<IImprovedAssetCache>(this);
92 } 86 }
93 87
94 public void RemoveRegion(Scene scene) 88 public void RemoveRegion(Scene scene)
@@ -97,15 +91,27 @@ namespace OpenSim.Region.CoreModules.Asset
97 91
98 public void RegionLoaded(Scene scene) 92 public void RegionLoaded(Scene scene)
99 { 93 {
100 if (!m_Enabled) 94 }
101 return; 95
96 ////////////////////////////////////////////////////////////
97 // IImprovedAssetCache
98 //
99
100 public void Cache(AssetBase asset)
101 {
102 }
103
104 public AssetBase Get(string id)
105 {
106 return null;
107 }
102 108
103 m_AssetService[scene] = 109 public void Expire(string id)
104 scene.RequestModuleInterface<IAssetService>(); 110 {
111 }
105 112
106 if (m_AssetService[scene] != null) 113 public void Clear()
107 m_log.InfoFormat("[ASSET CACHE]: Enabled for region {0}", 114 {
108 scene.RegionInfo.RegionName);
109 } 115 }
110 } 116 }
111} 117}
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
index 246cf55..e46545c 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
@@ -624,8 +624,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
624 // a new friend was added in the initiator's and friend's data, so the cache entries are wrong now. 624 // a new friend was added in the initiator's and friend's data, so the cache entries are wrong now.
625 lock (m_friendLists) 625 lock (m_friendLists)
626 { 626 {
627 m_friendLists.Invalidate(fromAgentID); 627 m_friendLists.Invalidate(fromAgentID.ToString());
628 m_friendLists.Invalidate(toAgentID); 628 m_friendLists.Invalidate(toAgentID.ToString());
629 } 629 }
630 630
631 // now send presence update and add a calling card for the new friend 631 // now send presence update and add a calling card for the new friend
@@ -664,8 +664,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
664 // The cache entries aren't valid anymore either, as we just added a friend to both sides. 664 // The cache entries aren't valid anymore either, as we just added a friend to both sides.
665 lock (m_friendLists) 665 lock (m_friendLists)
666 { 666 {
667 m_friendLists.Invalidate(agentID); 667 m_friendLists.Invalidate(agentID.ToString());
668 m_friendLists.Invalidate(friendID); 668 m_friendLists.Invalidate(friendID.ToString());
669 } 669 }
670 670
671 // if it's a local friend, we don't have to do the lookup 671 // if it's a local friend, we don't have to do the lookup
@@ -782,8 +782,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
782 // clean up cache: FriendList is wrong now... 782 // clean up cache: FriendList is wrong now...
783 lock (m_friendLists) 783 lock (m_friendLists)
784 { 784 {
785 m_friendLists.Invalidate(agentID); 785 m_friendLists.Invalidate(agentID.ToString());
786 m_friendLists.Invalidate(exfriendID); 786 m_friendLists.Invalidate(exfriendID.ToString());
787 } 787 }
788 } 788 }
789 789
@@ -1070,7 +1070,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
1070 List<FriendListItem> fl; 1070 List<FriendListItem> fl;
1071 lock (m_friendLists) 1071 lock (m_friendLists)
1072 { 1072 {
1073 fl = (List<FriendListItem>)m_friendLists.Get(agent.ControllingClient.AgentId, 1073 fl = (List<FriendListItem>)m_friendLists.Get(agent.ControllingClient.AgentId.ToString(),
1074 m_initialScene.GetFriendList); 1074 m_initialScene.GetFriendList);
1075 } 1075 }
1076 1076
@@ -1083,7 +1083,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
1083 List<FriendListItem> fl; 1083 List<FriendListItem> fl;
1084 lock (m_friendLists) 1084 lock (m_friendLists)
1085 { 1085 {
1086 fl = (List<FriendListItem>)m_friendLists.Get(remoteClient.AgentId, 1086 fl = (List<FriendListItem>)m_friendLists.Get(remoteClient.AgentId.ToString(),
1087 m_initialScene.GetFriendList); 1087 m_initialScene.GetFriendList);
1088 } 1088 }
1089 1089
diff --git a/OpenSim/Region/CoreModules/ServiceConnectors/Asset/LocalAssetServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectors/Asset/LocalAssetServiceConnector.cs
index 24ac8be..0a0f634 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectors/Asset/LocalAssetServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectors/Asset/LocalAssetServiceConnector.cs
@@ -28,6 +28,7 @@
28using log4net; 28using log4net;
29using Nini.Config; 29using Nini.Config;
30using System; 30using System;
31using System.Collections.Generic;
31using System.Reflection; 32using System.Reflection;
32using OpenSim.Servers.Base; 33using OpenSim.Servers.Base;
33using OpenSim.Region.Framework.Interfaces; 34using OpenSim.Region.Framework.Interfaces;
@@ -42,6 +43,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Asset
42 LogManager.GetLogger( 43 LogManager.GetLogger(
43 MethodBase.GetCurrentMethod().DeclaringType); 44 MethodBase.GetCurrentMethod().DeclaringType);
44 45
46 private Dictionary<Scene, IImprovedAssetCache> m_AssetCache =
47 new Dictionary<Scene, IImprovedAssetCache>();
48
45 private IAssetService m_AssetService; 49 private IAssetService m_AssetService;
46 50
47 private bool m_Enabled = false; 51 private bool m_Enabled = false;
@@ -109,10 +113,29 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Asset
109 113
110 public void RemoveRegion(Scene scene) 114 public void RemoveRegion(Scene scene)
111 { 115 {
116 if (!m_Enabled)
117 return;
118
119 m_AssetCache.Remove(scene);
112 } 120 }
113 121
114 public void RegionLoaded(Scene scene) 122 public void RegionLoaded(Scene scene)
115 { 123 {
124 if (!m_Enabled)
125 return;
126
127 m_AssetCache[scene] =
128 scene.RequestModuleInterface<IImprovedAssetCache>();
129
130 m_log.InfoFormat("[ASSET CONNECTOR]: Enabled local assets for region {0}", scene.RegionInfo.RegionName);
131
132 m_AssetCache[scene] =
133 scene.RequestModuleInterface<IImprovedAssetCache>();
134
135 if (m_AssetCache[scene] != null)
136 {
137 m_log.InfoFormat("[ASSET CONNECTOR]: Enabled asset caching for region {0}", scene.RegionInfo.RegionName);
138 }
116 } 139 }
117 } 140 }
118} 141}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectors/Asset/RemoteAssetServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectors/Asset/RemoteAssetServiceConnector.cs
index 2cc2962..835678d 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectors/Asset/RemoteAssetServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectors/Asset/RemoteAssetServiceConnector.cs
@@ -27,6 +27,7 @@
27 27
28using log4net; 28using log4net;
29using System; 29using System;
30using System.Collections.Generic;
30using System.IO; 31using System.IO;
31using System.Reflection; 32using System.Reflection;
32using Nini.Config; 33using Nini.Config;
@@ -48,6 +49,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Asset
48 49
49 private bool m_Enabled = false; 50 private bool m_Enabled = false;
50 private string m_ServerURI = String.Empty; 51 private string m_ServerURI = String.Empty;
52 private Dictionary<Scene, IImprovedAssetCache> m_AssetCache =
53 new Dictionary<Scene, IImprovedAssetCache>();
51 54
52 public string Name 55 public string Name
53 { 56 {
@@ -103,10 +106,26 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Asset
103 106
104 public void RemoveRegion(Scene scene) 107 public void RemoveRegion(Scene scene)
105 { 108 {
109 if (!m_Enabled)
110 return;
111
112 m_AssetCache.Remove(scene);
106 } 113 }
107 114
108 public void RegionLoaded(Scene scene) 115 public void RegionLoaded(Scene scene)
109 { 116 {
117 if (!m_Enabled)
118 return;
119
120 m_AssetCache[scene] =
121 scene.RequestModuleInterface<IImprovedAssetCache>();
122
123 m_log.InfoFormat("[ASSET CONNECTOR]: Enabled remote assets for region {0}", scene.RegionInfo.RegionName);
124
125 if (m_AssetCache[scene] != null)
126 {
127 m_log.InfoFormat("[ASSET CONNECTOR]: Enabled asset caching for region {0}", scene.RegionInfo.RegionName);
128 }
110 } 129 }
111 130
112 public AssetBase Get(string id) 131 public AssetBase Get(string id)
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
index ce54261..1dc33e1 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
@@ -1302,7 +1302,9 @@ namespace OpenSim.Region.CoreModules.World.Land
1302 if (parcelID == UUID.Zero) 1302 if (parcelID == UUID.Zero)
1303 return; 1303 return;
1304 1304
1305 ExtendedLandData data = (ExtendedLandData)parcelInfoCache.Get(parcelID, delegate(UUID parcel) { 1305 ExtendedLandData data = (ExtendedLandData)parcelInfoCache.Get(parcelID.ToString(), delegate(string id) {
1306 UUID parcel = UUID.Zero;
1307 UUID.TryParse(id, out parcel);
1306 // assume we've got the parcelID we just computed in RemoteParcelRequest 1308 // assume we've got the parcelID we just computed in RemoteParcelRequest
1307 ExtendedLandData extLandData = new ExtendedLandData(); 1309 ExtendedLandData extLandData = new ExtendedLandData();
1308 Util.ParseFakeParcelID(parcel, out extLandData.regionHandle, out extLandData.x, out extLandData.y); 1310 Util.ParseFakeParcelID(parcel, out extLandData.regionHandle, out extLandData.x, out extLandData.y);
diff --git a/OpenSim/Region/Framework/Interfaces/IAssetCache.cs b/OpenSim/Region/Framework/Interfaces/IImprovedAssetCache.cs
index bd43ce5..b213284 100644
--- a/OpenSim/Region/Framework/Interfaces/IAssetCache.cs
+++ b/OpenSim/Region/Framework/Interfaces/IImprovedAssetCache.cs
@@ -25,9 +25,15 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using OpenSim.Framework;
29
28namespace OpenSim.Region.Framework.Interfaces 30namespace OpenSim.Region.Framework.Interfaces
29{ 31{
30 public interface IImprovedAssetCache 32 public interface IImprovedAssetCache
31 { 33 {
34 void Cache(AssetBase asset);
35 AssetBase Get(string id);
36 void Expire(string id);
37 void Clear();
32 } 38 }
33} 39}
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index d1260d4..7cb66a0 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -2825,8 +2825,12 @@ namespace OpenSim.Region.Framework.Scenes
2825 objectCapacity = objects; 2825 objectCapacity = objects;
2826 } 2826 }
2827 2827
2828 public List<FriendListItem> GetFriendList(UUID avatarID) 2828 public List<FriendListItem> GetFriendList(string id)
2829 { 2829 {
2830 UUID avatarID;
2831 if (!UUID.TryParse(id, out avatarID))
2832 return new List<FriendListItem>();
2833
2830 return CommsManager.GetUserFriendList(avatarID); 2834 return CommsManager.GetUserFriendList(avatarID);
2831 } 2835 }
2832 2836