aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services
diff options
context:
space:
mode:
authorDiva Canto2015-05-07 19:24:08 -0700
committerDiva Canto2015-05-07 19:24:08 -0700
commitc74cef0f4261191962959e42c7e349adafd42a04 (patch)
tree95ad098d2606b7d37a6b287816d9f6a02311860d /OpenSim/Services
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff)
downloadopensim-SC-c74cef0f4261191962959e42c7e349adafd42a04.zip
opensim-SC-c74cef0f4261191962959e42c7e349adafd42a04.tar.gz
opensim-SC-c74cef0f4261191962959e42c7e349adafd42a04.tar.bz2
opensim-SC-c74cef0f4261191962959e42c7e349adafd42a04.tar.xz
Major change in the way inventory is downloaded: added a method throughout IIventoryService that fetches sets of folders at once. Also added folder id in the InventoryCollection data structure, so that we don't need to go to inventory server again just for that. This reduces the chatter between sims and inventory server by... a lot. On my tests, this reduces initial inventory download down to 30% of what it currently is.
Diffstat (limited to '')
-rw-r--r--OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs81
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs16
-rw-r--r--OpenSim/Services/HypergridService/HGInventoryService.cs9
-rw-r--r--OpenSim/Services/Interfaces/IInventoryService.cs8
-rw-r--r--OpenSim/Services/InventoryService/XInventoryService.cs21
5 files changed, 130 insertions, 5 deletions
diff --git a/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs b/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs
index 574de89..c694d27 100644
--- a/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs
@@ -205,7 +205,7 @@ namespace OpenSim.Services.Connectors
205 InventoryCollection inventory = new InventoryCollection(); 205 InventoryCollection inventory = new InventoryCollection();
206 inventory.Folders = new List<InventoryFolderBase>(); 206 inventory.Folders = new List<InventoryFolderBase>();
207 inventory.Items = new List<InventoryItemBase>(); 207 inventory.Items = new List<InventoryItemBase>();
208 inventory.UserID = principalID; 208 inventory.OwnerID = principalID;
209 209
210 try 210 try
211 { 211 {
@@ -235,7 +235,86 @@ namespace OpenSim.Services.Connectors
235 235
236 return inventory; 236 return inventory;
237 } 237 }
238
239 public virtual InventoryCollection[] GetMultipleFoldersContent(UUID principalID, UUID[] folderIDs)
240 {
241 InventoryCollection[] inventoryArr = new InventoryCollection[folderIDs.Length];
242 //m_log.DebugFormat("[XXX]: In GetMultipleFoldersContent {0}", folderIDs.Length);
243 try
244 {
245 Dictionary<string, object> resultSet = MakeRequest("GETMULTIPLEFOLDERSCONTENT",
246 new Dictionary<string, object> {
247 { "PRINCIPAL", principalID.ToString() },
248 { "FOLDERS", String.Join(",", folderIDs) },
249 { "COUNT", folderIDs.Length.ToString() }
250 });
251
252 if (!CheckReturn(resultSet))
253 return null;
238 254
255 int i = 0;
256 foreach (KeyValuePair<string, object> kvp in resultSet)
257 {
258 InventoryCollection inventory = new InventoryCollection();
259 if (kvp.Key.StartsWith("F_"))
260 {
261 UUID fid = UUID.Zero;
262 if (UUID.TryParse(kvp.Key.Substring(2), out fid) && fid == folderIDs[i])
263 {
264 inventory.Folders = new List<InventoryFolderBase>();
265 inventory.Items = new List<InventoryItemBase>();
266
267 Dictionary<string, object> ret = (Dictionary<string, object>)kvp.Value;
268
269 if (ret.ContainsKey("FID"))
270 {
271 if (!UUID.TryParse(ret["FID"].ToString(), out inventory.FolderID))
272 m_log.WarnFormat("[XINVENTORY SERVICES CONNECTOR]: Could not parse folder id {0}", ret["FID"].ToString());
273 }
274 else
275 m_log.WarnFormat("[XINVENTORY SERVICES CONNECTOR]: FID key not present in response");
276
277 inventory.Version = -1;
278 if (ret.ContainsKey("VERSION"))
279 Int32.TryParse(ret["VERSION"].ToString(), out inventory.Version);
280 if (ret.ContainsKey("OWNER"))
281 UUID.TryParse(ret["OWNER"].ToString(), out inventory.OwnerID);
282
283 //m_log.DebugFormat("[XXX]: Received {0} ({1}) {2} {3}", inventory.FolderID, fid, inventory.Version, inventory.OwnerID);
284
285 Dictionary<string, object> folders =
286 (Dictionary<string, object>)ret["FOLDERS"];
287 Dictionary<string, object> items =
288 (Dictionary<string, object>)ret["ITEMS"];
289
290 foreach (Object o in folders.Values) // getting the values directly, we don't care about the keys folder_i
291 {
292 inventory.Folders.Add(BuildFolder((Dictionary<string, object>)o));
293 }
294 foreach (Object o in items.Values) // getting the values directly, we don't care about the keys item_i
295 {
296 inventory.Items.Add(BuildItem((Dictionary<string, object>)o));
297 }
298
299 inventoryArr[i] = inventory;
300 }
301 else
302 {
303 m_log.WarnFormat("[XINVENTORY SERVICES CONNECTOR]: Folder id does not match. Expected {0} got {1}",
304 folderIDs[i], fid);
305 }
306
307 i += 1;
308 }
309 }
310 }
311 catch (Exception e)
312 {
313 m_log.WarnFormat("[XINVENTORY SERVICES CONNECTOR]: Exception in GetMultipleFoldersContent: {0}", e.Message);
314 }
315
316 return inventoryArr;
317 }
239 public List<InventoryItemBase> GetFolderItems(UUID principalID, UUID folderID) 318 public List<InventoryItemBase> GetFolderItems(UUID principalID, UUID folderID)
240 { 319 {
241 Dictionary<string,object> ret = MakeRequest("GETFOLDERITEMS", 320 Dictionary<string,object> ret = MakeRequest("GETFOLDERITEMS",
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs
index 9ded1c4..0331c66 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs
@@ -340,7 +340,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
340 public InventoryCollection GetFolderContent(UUID userID, UUID folderID) 340 public InventoryCollection GetFolderContent(UUID userID, UUID folderID)
341 { 341 {
342 InventoryCollection inventory = new InventoryCollection(); 342 InventoryCollection inventory = new InventoryCollection();
343 inventory.UserID = userID; 343 inventory.OwnerID = userID;
344 344
345 NameValueCollection requestArgs = new NameValueCollection 345 NameValueCollection requestArgs = new NameValueCollection
346 { 346 {
@@ -371,6 +371,18 @@ namespace OpenSim.Services.Connectors.SimianGrid
371 return inventory; 371 return inventory;
372 } 372 }
373 373
374 public virtual InventoryCollection[] GetMultipleFoldersContent(UUID principalID, UUID[] folderIDs)
375 {
376 InventoryCollection[] invColl = new InventoryCollection[folderIDs.Length];
377 int i = 0;
378 foreach (UUID fid in folderIDs)
379 {
380 invColl[i++] = GetFolderContent(principalID, fid);
381 }
382
383 return invColl;
384 }
385
374 /// <summary> 386 /// <summary>
375 /// Gets the items inside a folder 387 /// Gets the items inside a folder
376 /// </summary> 388 /// </summary>
@@ -380,7 +392,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
380 public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID) 392 public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID)
381 { 393 {
382 InventoryCollection inventory = new InventoryCollection(); 394 InventoryCollection inventory = new InventoryCollection();
383 inventory.UserID = userID; 395 inventory.OwnerID = userID;
384 396
385 NameValueCollection requestArgs = new NameValueCollection 397 NameValueCollection requestArgs = new NameValueCollection
386 { 398 {
diff --git a/OpenSim/Services/HypergridService/HGInventoryService.cs b/OpenSim/Services/HypergridService/HGInventoryService.cs
index 2c63240..5f245e4 100644
--- a/OpenSim/Services/HypergridService/HGInventoryService.cs
+++ b/OpenSim/Services/HypergridService/HGInventoryService.cs
@@ -153,7 +153,14 @@ namespace OpenSim.Services.HypergridService
153 //public InventoryCollection GetFolderContent(UUID principalID, UUID folderID) 153 //public InventoryCollection GetFolderContent(UUID principalID, UUID folderID)
154 //{ 154 //{
155 //} 155 //}
156 156
157 // NOGO
158 //
159 public override InventoryCollection[] GetMultipleFoldersContent(UUID principalID, UUID[] folderID)
160 {
161 return new InventoryCollection[0];
162 }
163
157 //public List<InventoryItemBase> GetFolderItems(UUID principalID, UUID folderID) 164 //public List<InventoryItemBase> GetFolderItems(UUID principalID, UUID folderID)
158 //{ 165 //{
159 //} 166 //}
diff --git a/OpenSim/Services/Interfaces/IInventoryService.cs b/OpenSim/Services/Interfaces/IInventoryService.cs
index 2805356..829f169 100644
--- a/OpenSim/Services/Interfaces/IInventoryService.cs
+++ b/OpenSim/Services/Interfaces/IInventoryService.cs
@@ -76,6 +76,14 @@ namespace OpenSim.Services.Interfaces
76 /// <param name="folderID"></param> 76 /// <param name="folderID"></param>
77 /// <returns>Inventory content. null if the request failed.</returns> 77 /// <returns>Inventory content. null if the request failed.</returns>
78 InventoryCollection GetFolderContent(UUID userID, UUID folderID); 78 InventoryCollection GetFolderContent(UUID userID, UUID folderID);
79
80 /// <summary>
81 /// Gets everything (folders and items) inside a folder
82 /// </summary>
83 /// <param name="userId"></param>
84 /// <param name="folderIDs"></param>
85 /// <returns>Inventory content. null if the request failed.</returns>
86 InventoryCollection[] GetMultipleFoldersContent(UUID userID, UUID[] folderIDs);
79 87
80 /// <summary> 88 /// <summary>
81 /// Gets the items inside a folder 89 /// Gets the items inside a folder
diff --git a/OpenSim/Services/InventoryService/XInventoryService.cs b/OpenSim/Services/InventoryService/XInventoryService.cs
index 362ff8f..6582b75 100644
--- a/OpenSim/Services/InventoryService/XInventoryService.cs
+++ b/OpenSim/Services/InventoryService/XInventoryService.cs
@@ -291,7 +291,7 @@ namespace OpenSim.Services.InventoryService
291 // 291 //
292 //m_log.DebugFormat("[XINVENTORY SERVICE]: Fetch contents for folder {0}", folderID.ToString()); 292 //m_log.DebugFormat("[XINVENTORY SERVICE]: Fetch contents for folder {0}", folderID.ToString());
293 InventoryCollection inventory = new InventoryCollection(); 293 InventoryCollection inventory = new InventoryCollection();
294 inventory.UserID = principalID; 294 inventory.OwnerID = principalID;
295 inventory.Folders = new List<InventoryFolderBase>(); 295 inventory.Folders = new List<InventoryFolderBase>();
296 inventory.Items = new List<InventoryItemBase>(); 296 inventory.Items = new List<InventoryItemBase>();
297 297
@@ -315,8 +315,27 @@ namespace OpenSim.Services.InventoryService
315 inventory.Items.Add(ConvertToOpenSim(i)); 315 inventory.Items.Add(ConvertToOpenSim(i));
316 } 316 }
317 317
318 InventoryFolderBase f = new InventoryFolderBase(folderID, principalID);
319 f = GetFolder(f);
320 if (f != null)
321 {
322 inventory.Version = f.Version;
323 inventory.OwnerID = f.Owner;
324 }
325 inventory.FolderID = folderID;
326
318 return inventory; 327 return inventory;
319 } 328 }
329
330 public virtual InventoryCollection[] GetMultipleFoldersContent(UUID principalID, UUID[] folderIDs)
331 {
332 InventoryCollection[] multiple = new InventoryCollection[folderIDs.Length];
333 int i = 0;
334 foreach (UUID fid in folderIDs)
335 multiple[i++] = GetFolderContent(principalID, fid);
336
337 return multiple;
338 }
320 339
321 public virtual List<InventoryItemBase> GetFolderItems(UUID principalID, UUID folderID) 340 public virtual List<InventoryItemBase> GetFolderItems(UUID principalID, UUID folderID)
322 { 341 {