aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2009-08-11 16:45:16 +0100
committerJustin Clark-Casey (justincc)2009-08-11 16:45:16 +0100
commit226c082ed417f4a5f2295595e45eca2fcb1e42c9 (patch)
tree4bbe2f59176589e497a2f4fd16b3adfe3989c5cd /OpenSim/Framework
parentAdded some needed comments to SceneSetupHelper (actually just retriggering pa... (diff)
downloadopensim-SC-226c082ed417f4a5f2295595e45eca2fcb1e42c9.zip
opensim-SC-226c082ed417f4a5f2295595e45eca2fcb1e42c9.tar.gz
opensim-SC-226c082ed417f4a5f2295595e45eca2fcb1e42c9.tar.bz2
opensim-SC-226c082ed417f4a5f2295595e45eca2fcb1e42c9.tar.xz
Establish CachedUserInfo.OnInventoryReceived event so that region/test inventory code can be written with the async inventory fetch
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Communications/Cache/CachedUserInfo.cs19
-rw-r--r--OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs96
2 files changed, 68 insertions, 47 deletions
diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs
index 10aff42..8ee1b1a 100644
--- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs
+++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs
@@ -49,16 +49,24 @@ namespace OpenSim.Framework.Communications.Cache
49 IClientAPI client, UUID folderID, bool fetchFolders, bool fetchItems); 49 IClientAPI client, UUID folderID, bool fetchFolders, bool fetchItems);
50 50
51 public delegate void OnItemReceivedDelegate(UUID itemID); 51 public delegate void OnItemReceivedDelegate(UUID itemID);
52 public delegate void OnInventoryReceivedDelegate(UUID userID);
52 53
53 /// <summary> 54 /// <summary>
54 /// Stores user profile and inventory data received from backend services for a particular user. 55 /// Stores user profile and inventory data received from backend services for a particular user.
55 /// </summary> 56 /// </summary>
56 public class CachedUserInfo 57 public class CachedUserInfo
57 { 58 {
59 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
60
61 //// <value>
62 /// Fired when a particular item has been received from the inventory service
63 /// </value>
58 public event OnItemReceivedDelegate OnItemReceived; 64 public event OnItemReceivedDelegate OnItemReceived;
59 65
60 private static readonly ILog m_log 66 /// <value>
61 = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 67 /// Fired once the entire inventory has been received for the user
68 /// </value>
69 public event OnInventoryReceivedDelegate OnInventoryReceived;
62 70
63 /// <summary> 71 /// <summary>
64 /// The comms manager holds references to services (user, grid, inventory, etc.) 72 /// The comms manager holds references to services (user, grid, inventory, etc.)
@@ -133,7 +141,9 @@ namespace OpenSim.Framework.Communications.Cache
133 UUID parentFolderId = folder.ParentID; 141 UUID parentFolderId = folder.ParentID;
134 142
135 if (dictionary.ContainsKey(parentFolderId)) 143 if (dictionary.ContainsKey(parentFolderId))
144 {
136 dictionary[parentFolderId].Add(folder); 145 dictionary[parentFolderId].Add(folder);
146 }
137 else 147 else
138 { 148 {
139 IList<InventoryFolderImpl> folders = new List<InventoryFolderImpl>(); 149 IList<InventoryFolderImpl> folders = new List<InventoryFolderImpl>();
@@ -299,6 +309,9 @@ namespace OpenSim.Framework.Communications.Cache
299 request.Execute(); 309 request.Execute();
300 } 310 }
301 } 311 }
312
313 if (OnInventoryReceived != null)
314 OnInventoryReceived(UserProfile.ID);
302 } 315 }
303 316
304 /// <summary> 317 /// <summary>
diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs
index 0402883..fe88cf5 100644
--- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs
+++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs
@@ -43,6 +43,18 @@ namespace OpenSim.Framework.Communications.Tests
43 [TestFixture] 43 [TestFixture]
44 public class UserProfileCacheServiceTests 44 public class UserProfileCacheServiceTests
45 { 45 {
46 /// <value>Used by tests to indicate whether an async operation timed out</value>
47 private bool timedOut;
48
49 private void InventoryReceived(UUID userId)
50 {
51 lock (this)
52 {
53 timedOut = false;
54 Monitor.PulseAll(this);
55 }
56 }
57
46 [Test] 58 [Test]
47 public void TestGetUserDetails() 59 public void TestGetUserDetails()
48 { 60 {
@@ -118,14 +130,15 @@ namespace OpenSim.Framework.Communications.Tests
118 TestHelper.InMethod(); 130 TestHelper.InMethod();
119 131
120 Scene myScene = SceneSetupHelpers.SetupScene("inventory"); 132 Scene myScene = SceneSetupHelpers.SetupScene("inventory");
121 CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager); 133
122 for (int i = 0 ; i < 50 ; i++) 134 timedOut = true;
123 { 135 lock (this)
124 if (userInfo.HasReceivedInventory == true) 136 {
125 break; 137 UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived);
126 Thread.Sleep(200); 138 Monitor.Wait(this, 60000);
127 } 139 }
128 Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)"); 140
141 Assert.That(timedOut, Is.False, "Timed out");
129 } 142 }
130 143
131 [Test] 144 [Test]
@@ -134,14 +147,13 @@ namespace OpenSim.Framework.Communications.Tests
134 TestHelper.InMethod(); 147 TestHelper.InMethod();
135 148
136 Scene myScene = SceneSetupHelpers.SetupScene("inventory"); 149 Scene myScene = SceneSetupHelpers.SetupScene("inventory");
137 CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager); 150 CachedUserInfo userInfo;
138 for (int i = 0 ; i < 50 ; i++) 151
139 { 152 lock (this)
140 if (userInfo.HasReceivedInventory == true) 153 {
141 break; 154 userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived);
142 Thread.Sleep(200); 155 Monitor.Wait(this, 60000);
143 } 156 }
144 Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)");
145 157
146 UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000011"); 158 UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000011");
147 Assert.That(userInfo.RootFolder.GetChildFolder(folderId), Is.Null); 159 Assert.That(userInfo.RootFolder.GetChildFolder(folderId), Is.Null);
@@ -156,14 +168,13 @@ namespace OpenSim.Framework.Communications.Tests
156 TestHelper.InMethod(); 168 TestHelper.InMethod();
157 169
158 Scene myScene = SceneSetupHelpers.SetupScene("inventory"); 170 Scene myScene = SceneSetupHelpers.SetupScene("inventory");
159 CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager); 171 CachedUserInfo userInfo;
160 for (int i = 0 ; i < 50 ; i++) 172
161 { 173 lock (this)
162 if (userInfo.HasReceivedInventory == true) 174 {
163 break; 175 userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived);
164 Thread.Sleep(200); 176 Monitor.Wait(this, 60000);
165 } 177 }
166 Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)");
167 178
168 UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000010"); 179 UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000010");
169 Assert.That(userInfo.RootFolder.ContainsChildFolder(folderId), Is.False); 180 Assert.That(userInfo.RootFolder.ContainsChildFolder(folderId), Is.False);
@@ -192,14 +203,13 @@ namespace OpenSim.Framework.Communications.Tests
192 TestHelper.InMethod(); 203 TestHelper.InMethod();
193 204
194 Scene myScene = SceneSetupHelpers.SetupScene("inventory"); 205 Scene myScene = SceneSetupHelpers.SetupScene("inventory");
195 CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager); 206 CachedUserInfo userInfo;
196 for (int i = 0 ; i < 50 ; i++) 207
197 { 208 lock (this)
198 if (userInfo.HasReceivedInventory == true) 209 {
199 break; 210 userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived);
200 Thread.Sleep(200); 211 Monitor.Wait(this, 60000);
201 } 212 }
202 Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)");
203 213
204 UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); 214 UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
205 InventoryFolderImpl rootFolder = userInfo.RootFolder; 215 InventoryFolderImpl rootFolder = userInfo.RootFolder;
@@ -258,14 +268,13 @@ namespace OpenSim.Framework.Communications.Tests
258 TestHelper.InMethod(); 268 TestHelper.InMethod();
259 269
260 Scene myScene = SceneSetupHelpers.SetupScene("inventory"); 270 Scene myScene = SceneSetupHelpers.SetupScene("inventory");
261 CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager); 271 CachedUserInfo userInfo;
262 for (int i = 0 ; i < 50 ; i++) 272
263 { 273 lock (this)
264 if (userInfo.HasReceivedInventory == true) 274 {
265 break; 275 userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived);
266 Thread.Sleep(200); 276 Monitor.Wait(this, 60000);
267 } 277 }
268 Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)");
269 278
270 UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000020"); 279 UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000020");
271 UUID folder2Id = UUID.Parse("00000000-0000-0000-0000-000000000021"); 280 UUID folder2Id = UUID.Parse("00000000-0000-0000-0000-000000000021");
@@ -299,14 +308,13 @@ namespace OpenSim.Framework.Communications.Tests
299 //log4net.Config.XmlConfigurator.Configure(); 308 //log4net.Config.XmlConfigurator.Configure();
300 309
301 Scene myScene = SceneSetupHelpers.SetupScene("inventory"); 310 Scene myScene = SceneSetupHelpers.SetupScene("inventory");
302 CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager); 311 CachedUserInfo userInfo;
303 for (int i = 0 ; i < 50 ; i++) 312
304 { 313 lock (this)
305 if (userInfo.HasReceivedInventory == true) 314 {
306 break; 315 userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived);
307 Thread.Sleep(200); 316 Monitor.Wait(this, 60000);
308 } 317 }
309 Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)");
310 318
311 UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000070"); 319 UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000070");
312 InventoryFolderImpl rootFolder = userInfo.RootFolder; 320 InventoryFolderImpl rootFolder = userInfo.RootFolder;
@@ -323,4 +331,4 @@ namespace OpenSim.Framework.Communications.Tests
323 Assert.That(myScene.InventoryService.QueryFolder(myFolder), Is.Null); 331 Assert.That(myScene.InventoryService.QueryFolder(myFolder), Is.Null);
324 } 332 }
325 } 333 }
326} 334} \ No newline at end of file