aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorUbitUmarov2015-09-11 04:46:15 +0100
committerUbitUmarov2015-09-11 04:46:15 +0100
commit6a0465b70ad3ef64d6e71aab2e624bf3bfddf9b2 (patch)
treed30b14a253b15436d60d9647c993793066b7c34d
parentadd a few terminating / in LSLhttp uris as core (diff)
downloadopensim-SC-6a0465b70ad3ef64d6e71aab2e624bf3bfddf9b2.zip
opensim-SC-6a0465b70ad3ef64d6e71aab2e624bf3bfddf9b2.tar.gz
opensim-SC-6a0465b70ad3ef64d6e71aab2e624bf3bfddf9b2.tar.bz2
opensim-SC-6a0465b70ad3ef64d6e71aab2e624bf3bfddf9b2.tar.xz
remove diva's inventory cache since it seems to cause mantis 7720, broken items UUID. Guess it doesn't cover all paths
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs44
-rw-r--r--OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs285
2 files changed, 88 insertions, 241 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index edb881f..2f37483 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -898,33 +898,33 @@ namespace OpenSim.Region.Framework.Scenes
898 } 898 }
899 899
900 900
901 if (remoteClient.AgentId == oldAgentID 901 if (remoteClient.AgentId == oldAgentID
902 || (LibraryService != null 902 || (LibraryService != null
903 && LibraryService.LibraryRootFolder != null 903 && LibraryService.LibraryRootFolder != null
904 && oldAgentID == LibraryService.LibraryRootFolder.Owner)) 904 && oldAgentID == LibraryService.LibraryRootFolder.Owner))
905 {
906 CreateNewInventoryItem(
907 remoteClient, item.CreatorId, item.CreatorData, newFolderID,
908 newName, item.Description, item.Flags, callbackID, item.AssetID, (sbyte)item.AssetType, (sbyte)item.InvType,
909 item.BasePermissions, item.CurrentPermissions, item.EveryOnePermissions,
910 item.NextPermissions, item.GroupPermissions, Util.UnixTimeSinceEpoch(), false);
911 }
912 else
913 {
914 // If item is transfer or permissions are off or calling agent is allowed to copy item owner's inventory item.
915 if (((item.CurrentPermissions & (uint)PermissionMask.Transfer) != 0)
916 && (m_permissions.BypassPermissions()
917 || m_permissions.CanCopyUserInventory(remoteClient.AgentId, oldItemID)))
918 { 905 {
919 CreateNewInventoryItem( 906 CreateNewInventoryItem(
920 remoteClient, item.CreatorId, item.CreatorData, newFolderID, newName, item.Description, item.Flags, callbackID, 907 remoteClient, item.CreatorId, item.CreatorData, newFolderID,
921 item.AssetID, (sbyte)item.AssetType, (sbyte) item.InvType, 908 newName, item.Description, item.Flags, callbackID, item.AssetID, (sbyte)item.AssetType, (sbyte)item.InvType,
922 item.NextPermissions, item.NextPermissions, item.EveryOnePermissions & item.NextPermissions, 909 item.BasePermissions, item.CurrentPermissions, item.EveryOnePermissions,
923 item.NextPermissions, item.GroupPermissions, Util.UnixTimeSinceEpoch(), false); 910 item.NextPermissions, item.GroupPermissions, Util.UnixTimeSinceEpoch(), false);
924 } 911 }
912 else
913 {
914 // If item is transfer or permissions are off or calling agent is allowed to copy item owner's inventory item.
915 if (((item.CurrentPermissions & (uint)PermissionMask.Transfer) != 0)
916 && (m_permissions.BypassPermissions()
917 || m_permissions.CanCopyUserInventory(remoteClient.AgentId, oldItemID)))
918 {
919 CreateNewInventoryItem(
920 remoteClient, item.CreatorId, item.CreatorData, newFolderID, newName, item.Description, item.Flags, callbackID,
921 item.AssetID, (sbyte)item.AssetType, (sbyte)item.InvType,
922 item.NextPermissions, item.NextPermissions, item.EveryOnePermissions & item.NextPermissions,
923 item.NextPermissions, item.GroupPermissions, Util.UnixTimeSinceEpoch(), false);
924 }
925 }
925 } 926 }
926 } 927 else
927 else
928 { 928 {
929 m_log.ErrorFormat( 929 m_log.ErrorFormat(
930 "[AGENT INVENTORY]: Could not copy item {0} since asset {1} could not be found", 930 "[AGENT INVENTORY]: Could not copy item {0} since asset {1} could not be found",
diff --git a/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs b/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs
index f235446..36d4ae2 100644
--- a/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs
@@ -33,37 +33,22 @@ using System.Reflection;
33using Nini.Config; 33using Nini.Config;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.Console; 35using OpenSim.Framework.Console;
36 36using OpenSim.Framework.Communications;
37using OpenSim.Framework.Monitoring;
38using OpenSim.Services.Interfaces; 37using OpenSim.Services.Interfaces;
39using OpenSim.Server.Base; 38using OpenSim.Server.Base;
40using OpenMetaverse; 39using OpenMetaverse;
41 40
42namespace OpenSim.Services.Connectors 41namespace OpenSim.Services.Connectors
43{ 42{
44 public class XInventoryServicesConnector : BaseServiceConnector, IInventoryService 43 public class XInventoryServicesConnector : IInventoryService
45 { 44 {
46 private static readonly ILog m_log = 45 private static readonly ILog m_log =
47 LogManager.GetLogger( 46 LogManager.GetLogger(
48 MethodBase.GetCurrentMethod().DeclaringType); 47 MethodBase.GetCurrentMethod().DeclaringType);
49 48
50 /// <summary>
51 /// Number of requests made to the remote inventory service.
52 /// </summary>
53 public int RequestsMade { get; private set; }
54
55 private string m_ServerURI = String.Empty; 49 private string m_ServerURI = String.Empty;
56 50
57 /// <summary> 51 private object m_Lock = new object();
58 /// Timeout for remote requests.
59 /// </summary>
60 /// <remarks>
61 /// In this case, -1 is default timeout (100 seconds), not infinite.
62 /// </remarks>
63 private int m_requestTimeoutSecs = -1;
64
65 private const double CACHE_EXPIRATION_SECONDS = 20.0;
66 private static ExpiringCache<UUID, InventoryItemBase> m_ItemCache = new ExpiringCache<UUID,InventoryItemBase>();
67 52
68 public XInventoryServicesConnector() 53 public XInventoryServicesConnector()
69 { 54 {
@@ -75,21 +60,20 @@ namespace OpenSim.Services.Connectors
75 } 60 }
76 61
77 public XInventoryServicesConnector(IConfigSource source) 62 public XInventoryServicesConnector(IConfigSource source)
78 : base(source, "InventoryService")
79 { 63 {
80 Initialise(source); 64 Initialise(source);
81 } 65 }
82 66
83 public virtual void Initialise(IConfigSource source) 67 public virtual void Initialise(IConfigSource source)
84 { 68 {
85 IConfig config = source.Configs["InventoryService"]; 69 IConfig assetConfig = source.Configs["InventoryService"];
86 if (config == null) 70 if (assetConfig == null)
87 { 71 {
88 m_log.Error("[INVENTORY CONNECTOR]: InventoryService missing from OpenSim.ini"); 72 m_log.Error("[INVENTORY CONNECTOR]: InventoryService missing from OpenSim.ini");
89 throw new Exception("Inventory connector init error"); 73 throw new Exception("Inventory connector init error");
90 } 74 }
91 75
92 string serviceURI = config.GetString("InventoryServerURI", 76 string serviceURI = assetConfig.GetString("InventoryServerURI",
93 String.Empty); 77 String.Empty);
94 78
95 if (serviceURI == String.Empty) 79 if (serviceURI == String.Empty)
@@ -98,21 +82,6 @@ namespace OpenSim.Services.Connectors
98 throw new Exception("Inventory connector init error"); 82 throw new Exception("Inventory connector init error");
99 } 83 }
100 m_ServerURI = serviceURI; 84 m_ServerURI = serviceURI;
101
102 m_requestTimeoutSecs = config.GetInt("RemoteRequestTimeout", m_requestTimeoutSecs);
103
104 StatsManager.RegisterStat(
105 new Stat(
106 "RequestsMade",
107 "Requests made",
108 "Number of requests made to the remove inventory service",
109 "requests",
110 "inventory",
111 serviceURI,
112 StatType.Pull,
113 MeasuresOfInterest.AverageChangeOverTime,
114 s => s.Value = RequestsMade,
115 StatVerbosity.Debug));
116 } 85 }
117 86
118 private bool CheckReturn(Dictionary<string, object> ret) 87 private bool CheckReturn(Dictionary<string, object> ret)
@@ -189,7 +158,7 @@ namespace OpenSim.Services.Connectors
189 return BuildFolder((Dictionary<string, object>)ret["folder"]); 158 return BuildFolder((Dictionary<string, object>)ret["folder"]);
190 } 159 }
191 160
192 public InventoryFolderBase GetFolderForType(UUID principalID, FolderType type) 161 public InventoryFolderBase GetFolderForType(UUID principalID, AssetType type)
193 { 162 {
194 Dictionary<string,object> ret = MakeRequest("GETFOLDERFORTYPE", 163 Dictionary<string,object> ret = MakeRequest("GETFOLDERFORTYPE",
195 new Dictionary<string,object> { 164 new Dictionary<string,object> {
@@ -208,7 +177,7 @@ namespace OpenSim.Services.Connectors
208 InventoryCollection inventory = new InventoryCollection(); 177 InventoryCollection inventory = new InventoryCollection();
209 inventory.Folders = new List<InventoryFolderBase>(); 178 inventory.Folders = new List<InventoryFolderBase>();
210 inventory.Items = new List<InventoryItemBase>(); 179 inventory.Items = new List<InventoryItemBase>();
211 inventory.OwnerID = principalID; 180 inventory.UserID = principalID;
212 181
213 try 182 try
214 { 183 {
@@ -221,17 +190,15 @@ namespace OpenSim.Services.Connectors
221 if (!CheckReturn(ret)) 190 if (!CheckReturn(ret))
222 return null; 191 return null;
223 192
224 Dictionary<string,object> folders = ret.ContainsKey("FOLDERS") ? 193 Dictionary<string,object> folders =
225 (Dictionary<string,object>)ret["FOLDERS"] : null; 194 (Dictionary<string,object>)ret["FOLDERS"];
226 Dictionary<string,object> items = ret.ContainsKey("ITEMS") ? 195 Dictionary<string,object> items =
227 (Dictionary<string, object>)ret["ITEMS"] : null; 196 (Dictionary<string,object>)ret["ITEMS"];
228 197
229 if (folders != null) 198 foreach (Object o in folders.Values) // getting the values directly, we don't care about the keys folder_i
230 foreach (Object o in folders.Values) // getting the values directly, we don't care about the keys folder_i 199 inventory.Folders.Add(BuildFolder((Dictionary<string, object>)o));
231 inventory.Folders.Add(BuildFolder((Dictionary<string, object>)o)); 200 foreach (Object o in items.Values) // getting the values directly, we don't care about the keys item_i
232 if (items != null) 201 inventory.Items.Add(BuildItem((Dictionary<string, object>)o));
233 foreach (Object o in items.Values) // getting the values directly, we don't care about the keys item_i
234 inventory.Items.Add(BuildItem((Dictionary<string, object>)o));
235 } 202 }
236 catch (Exception e) 203 catch (Exception e)
237 { 204 {
@@ -240,87 +207,6 @@ namespace OpenSim.Services.Connectors
240 207
241 return inventory; 208 return inventory;
242 } 209 }
243
244 public virtual InventoryCollection[] GetMultipleFoldersContent(UUID principalID, UUID[] folderIDs)
245 {
246 InventoryCollection[] inventoryArr = new InventoryCollection[folderIDs.Length];
247 // m_log.DebugFormat("[XXX]: In GetMultipleFoldersContent {0}", String.Join(",", folderIDs));
248 try
249 {
250 Dictionary<string, object> resultSet = MakeRequest("GETMULTIPLEFOLDERSCONTENT",
251 new Dictionary<string, object> {
252 { "PRINCIPAL", principalID.ToString() },
253 { "FOLDERS", String.Join(",", folderIDs) },
254 { "COUNT", folderIDs.Length.ToString() }
255 });
256
257 if (!CheckReturn(resultSet))
258 return null;
259
260 int i = 0;
261 foreach (KeyValuePair<string, object> kvp in resultSet)
262 {
263 InventoryCollection inventory = new InventoryCollection();
264 if (kvp.Key.StartsWith("F_"))
265 {
266 UUID fid = UUID.Zero;
267 if (UUID.TryParse(kvp.Key.Substring(2), out fid) && fid == folderIDs[i])
268 {
269 inventory.Folders = new List<InventoryFolderBase>();
270 inventory.Items = new List<InventoryItemBase>();
271
272 Dictionary<string, object> ret = (Dictionary<string, object>)kvp.Value;
273
274 if (ret.ContainsKey("FID"))
275 {
276 if (!UUID.TryParse(ret["FID"].ToString(), out inventory.FolderID))
277 m_log.WarnFormat("[XINVENTORY SERVICES CONNECTOR]: Could not parse folder id {0}", ret["FID"].ToString());
278 }
279 else
280 m_log.WarnFormat("[XINVENTORY SERVICES CONNECTOR]: FID key not present in response");
281
282 inventory.Version = -1;
283 if (ret.ContainsKey("VERSION"))
284 Int32.TryParse(ret["VERSION"].ToString(), out inventory.Version);
285 if (ret.ContainsKey("OWNER"))
286 UUID.TryParse(ret["OWNER"].ToString(), out inventory.OwnerID);
287
288 //m_log.DebugFormat("[XXX]: Received {0} ({1}) {2} {3}", inventory.FolderID, fid, inventory.Version, inventory.OwnerID);
289
290 Dictionary<string, object> folders =
291 (Dictionary<string, object>)ret["FOLDERS"];
292 Dictionary<string, object> items =
293 (Dictionary<string, object>)ret["ITEMS"];
294
295 foreach (Object o in folders.Values) // getting the values directly, we don't care about the keys folder_i
296 {
297 inventory.Folders.Add(BuildFolder((Dictionary<string, object>)o));
298 }
299 foreach (Object o in items.Values) // getting the values directly, we don't care about the keys item_i
300 {
301 inventory.Items.Add(BuildItem((Dictionary<string, object>)o));
302 }
303
304 inventoryArr[i] = inventory;
305 }
306 else
307 {
308 m_log.WarnFormat("[XINVENTORY SERVICES CONNECTOR]: Folder id does not match. Expected {0} got {1}",
309 folderIDs[i], fid);
310 m_log.WarnFormat("[XINVENTORY SERVICES CONNECTOR]: {0} {1}", String.Join(",", folderIDs), String.Join(",", resultSet.Keys));
311 }
312
313 i += 1;
314 }
315 }
316 }
317 catch (Exception e)
318 {
319 m_log.WarnFormat("[XINVENTORY SERVICES CONNECTOR]: Exception in GetMultipleFoldersContent: {0}", e.Message);
320 }
321
322 return inventoryArr;
323 }
324 210
325 public List<InventoryItemBase> GetFolderItems(UUID principalID, UUID folderID) 211 public List<InventoryItemBase> GetFolderItems(UUID principalID, UUID folderID)
326 { 212 {
@@ -411,13 +297,9 @@ namespace OpenSim.Services.Connectors
411 297
412 public bool AddItem(InventoryItemBase item) 298 public bool AddItem(InventoryItemBase item)
413 { 299 {
414 if (item.Description == null)
415 item.Description = String.Empty;
416 if (item.CreatorData == null) 300 if (item.CreatorData == null)
417 item.CreatorData = String.Empty; 301 item.CreatorData = String.Empty;
418 if (item.CreatorId == null) 302 Dictionary<string,object> ret = MakeRequest("ADDITEM",
419 item.CreatorId = String.Empty;
420 Dictionary<string, object> ret = MakeRequest("ADDITEM",
421 new Dictionary<string,object> { 303 new Dictionary<string,object> {
422 { "AssetID", item.AssetID.ToString() }, 304 { "AssetID", item.AssetID.ToString() },
423 { "AssetType", item.AssetType.ToString() }, 305 { "AssetType", item.AssetType.ToString() },
@@ -516,10 +398,6 @@ namespace OpenSim.Services.Connectors
516 398
517 public InventoryItemBase GetItem(InventoryItemBase item) 399 public InventoryItemBase GetItem(InventoryItemBase item)
518 { 400 {
519 InventoryItemBase retrieved = null;
520 if (m_ItemCache.TryGetValue(item.ID, out retrieved))
521 return retrieved;
522
523 try 401 try
524 { 402 {
525 Dictionary<string, object> ret = MakeRequest("GETITEM", 403 Dictionary<string, object> ret = MakeRequest("GETITEM",
@@ -530,78 +408,14 @@ namespace OpenSim.Services.Connectors
530 if (!CheckReturn(ret)) 408 if (!CheckReturn(ret))
531 return null; 409 return null;
532 410
533 retrieved = BuildItem((Dictionary<string, object>)ret["item"]); 411 return BuildItem((Dictionary<string, object>)ret["item"]);
534 } 412 }
535 catch (Exception e) 413 catch (Exception e)
536 { 414 {
537 m_log.Error("[XINVENTORY SERVICES CONNECTOR]: Exception in GetItem: ", e); 415 m_log.Error("[XINVENTORY SERVICES CONNECTOR]: Exception in GetItem: ", e);
538 } 416 }
539 417
540 m_ItemCache.AddOrUpdate(item.ID, retrieved, CACHE_EXPIRATION_SECONDS); 418 return null;
541
542 return retrieved;
543 }
544
545 public virtual InventoryItemBase[] GetMultipleItems(UUID principalID, UUID[] itemIDs)
546 {
547 //m_log.DebugFormat("[XXX]: In GetMultipleItems {0}", String.Join(",", itemIDs));
548
549 InventoryItemBase[] itemArr = new InventoryItemBase[itemIDs.Length];
550 // Try to get them from the cache
551 List<UUID> pending = new List<UUID>();
552 InventoryItemBase item = null;
553 int i = 0;
554 foreach (UUID id in itemIDs)
555 {
556 if (m_ItemCache.TryGetValue(id, out item))
557 itemArr[i++] = item;
558 else
559 pending.Add(id);
560 }
561
562 if (pending.Count == 0) // we're done, everything was in the cache
563 return itemArr;
564
565 try
566 {
567 Dictionary<string, object> resultSet = MakeRequest("GETMULTIPLEITEMS",
568 new Dictionary<string, object> {
569 { "PRINCIPAL", principalID.ToString() },
570 { "ITEMS", String.Join(",", pending.ToArray()) },
571 { "COUNT", pending.Count.ToString() }
572 });
573
574 if (!CheckReturn(resultSet))
575 {
576 if (i == 0)
577 return null;
578 else
579 return itemArr;
580 }
581
582 // carry over index i where we left above
583 foreach (KeyValuePair<string, object> kvp in resultSet)
584 {
585 InventoryCollection inventory = new InventoryCollection();
586 if (kvp.Key.StartsWith("item_"))
587 {
588 if (kvp.Value is Dictionary<string, object>)
589 {
590 item = BuildItem((Dictionary<string, object>)kvp.Value);
591 m_ItemCache.AddOrUpdate(item.ID, item, CACHE_EXPIRATION_SECONDS);
592 itemArr[i++] = item;
593 }
594 else
595 itemArr[i++] = null;
596 }
597 }
598 }
599 catch (Exception e)
600 {
601 m_log.WarnFormat("[XINVENTORY SERVICES CONNECTOR]: Exception in GetMultipleItems: {0}", e.Message);
602 }
603
604 return itemArr;
605 } 419 }
606 420
607 public InventoryFolderBase GetFolder(InventoryFolderBase folder) 421 public InventoryFolderBase GetFolder(InventoryFolderBase folder)
@@ -670,6 +484,45 @@ namespace OpenSim.Services.Connectors
670 return 0; 484 return 0;
671 } 485 }
672 486
487 public InventoryCollection GetUserInventory(UUID principalID)
488 {
489 InventoryCollection inventory = new InventoryCollection();
490 inventory.Folders = new List<InventoryFolderBase>();
491 inventory.Items = new List<InventoryItemBase>();
492 inventory.UserID = principalID;
493
494 try
495 {
496 Dictionary<string, object> ret = MakeRequest("GETUSERINVENTORY",
497 new Dictionary<string, object> {
498 { "PRINCIPAL", principalID.ToString() }
499 });
500
501 if (!CheckReturn(ret))
502 return null;
503
504 Dictionary<string, object> folders =
505 (Dictionary<string, object>)ret["FOLDERS"];
506 Dictionary<string, object> items =
507 (Dictionary<string, object>)ret["ITEMS"];
508
509 foreach (Object o in folders.Values) // getting the values directly, we don't care about the keys folder_i
510 inventory.Folders.Add(BuildFolder((Dictionary<string, object>)o));
511 foreach (Object o in items.Values) // getting the values directly, we don't care about the keys item_i
512 inventory.Items.Add(BuildItem((Dictionary<string, object>)o));
513 }
514 catch (Exception e)
515 {
516 m_log.Error("[XINVENTORY SERVICES CONNECTOR]: Exception in GetUserInventory: ", e);
517 }
518
519 return inventory;
520 }
521
522 public void GetUserInventory(UUID principalID, InventoryReceiptCallback callback)
523 {
524 }
525
673 public bool HasInventoryForUser(UUID principalID) 526 public bool HasInventoryForUser(UUID principalID)
674 { 527 {
675 return false; 528 return false;
@@ -680,19 +533,13 @@ namespace OpenSim.Services.Connectors
680 private Dictionary<string,object> MakeRequest(string method, 533 private Dictionary<string,object> MakeRequest(string method,
681 Dictionary<string,object> sendData) 534 Dictionary<string,object> sendData)
682 { 535 {
683 // Add "METHOD" as the first key in the dictionary. This ensures that it will be 536 sendData["METHOD"] = method;
684 // visible even when using partial logging ("debug http all 5").
685 Dictionary<string, object> temp = sendData;
686 sendData = new Dictionary<string,object>{ { "METHOD", method } };
687 foreach (KeyValuePair<string, object> kvp in temp)
688 sendData.Add(kvp.Key, kvp.Value);
689
690 RequestsMade++;
691 537
692 string reply 538 string reply = string.Empty;
693 = SynchronousRestFormsRequester.MakeRequest( 539 lock (m_Lock)
694 "POST", m_ServerURI + "/xinventory", 540 reply = SynchronousRestFormsRequester.MakeRequest("POST",
695 ServerUtils.BuildQueryString(sendData), m_requestTimeoutSecs, m_Auth); 541 m_ServerURI + "/xinventory",
542 ServerUtils.BuildQueryString(sendData));
696 543
697 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse( 544 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(
698 reply); 545 reply);
@@ -760,4 +607,4 @@ namespace OpenSim.Services.Connectors
760 return item; 607 return item;
761 } 608 }
762 } 609 }
763} 610} \ No newline at end of file