aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/Connectors/Inventory
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/Connectors/Inventory
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff)
downloadopensim-SC_OLD-c74cef0f4261191962959e42c7e349adafd42a04.zip
opensim-SC_OLD-c74cef0f4261191962959e42c7e349adafd42a04.tar.gz
opensim-SC_OLD-c74cef0f4261191962959e42c7e349adafd42a04.tar.bz2
opensim-SC_OLD-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 'OpenSim/Services/Connectors/Inventory')
-rw-r--r--OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs81
1 files changed, 80 insertions, 1 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",