diff options
author | Justin Clarke Casey | 2008-01-21 15:06:49 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2008-01-21 15:06:49 +0000 |
commit | 504ae63669e5c57cd89e8213b853c27506012f79 (patch) | |
tree | 0d12e5baa7b7e5ec29676398629e56f3c93b98d5 /OpenSim/Region/Environment | |
parent | Small bug in ResetScript (diff) | |
download | opensim-SC-504ae63669e5c57cd89e8213b853c27506012f79.zip opensim-SC-504ae63669e5c57cd89e8213b853c27506012f79.tar.gz opensim-SC-504ae63669e5c57cd89e8213b853c27506012f79.tar.bz2 opensim-SC-504ae63669e5c57cd89e8213b853c27506012f79.tar.xz |
* Make object persistence more granular by separating prim and prim inventory persistence
Diffstat (limited to '')
4 files changed, 52 insertions, 26 deletions
diff --git a/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs b/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs index 78ad428..47768b7 100644 --- a/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs +++ b/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs | |||
@@ -44,8 +44,26 @@ namespace OpenSim.Region.Environment.Interfaces | |||
44 | /// <param name="persistPrimInventories">Temporary switch while this option is immature</param> | 44 | /// <param name="persistPrimInventories">Temporary switch while this option is immature</param> |
45 | void Initialise(string filename, bool persistPrimInventories); | 45 | void Initialise(string filename, bool persistPrimInventories); |
46 | 46 | ||
47 | /// <summary> | ||
48 | /// Stores all object's details apart from inventory | ||
49 | /// </summary> | ||
50 | /// <param name="obj"></param> | ||
51 | /// <param name="regionUUID"></param> | ||
47 | void StoreObject(SceneObjectGroup obj, LLUUID regionUUID); | 52 | void StoreObject(SceneObjectGroup obj, LLUUID regionUUID); |
53 | |||
54 | /// <summary> | ||
55 | /// Entirely removes the object, including inventory | ||
56 | /// </summary> | ||
57 | /// <param name="uuid"></param> | ||
58 | /// <param name="regionUUID"></param> | ||
59 | /// <returns></returns> | ||
48 | void RemoveObject(LLUUID uuid, LLUUID regionUUID); | 60 | void RemoveObject(LLUUID uuid, LLUUID regionUUID); |
61 | |||
62 | /// <summary> | ||
63 | /// Store a prim's inventory | ||
64 | /// </summary> | ||
65 | /// <returns></returns> | ||
66 | void StorePrimInventory(LLUUID primID, IDictionary<LLUUID, TaskInventoryItem> items); | ||
49 | 67 | ||
50 | List<SceneObjectGroup> LoadObjects(LLUUID regionUUID); | 68 | List<SceneObjectGroup> LoadObjects(LLUUID regionUUID); |
51 | 69 | ||
@@ -58,4 +76,4 @@ namespace OpenSim.Region.Environment.Interfaces | |||
58 | 76 | ||
59 | void Shutdown(); | 77 | void Shutdown(); |
60 | } | 78 | } |
61 | } \ No newline at end of file | 79 | } |
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs index 59ffded..1bddf25 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs | |||
@@ -179,13 +179,6 @@ namespace OpenSim.Region.Environment.Scenes | |||
179 | taskItem.InvType = item.invType; | 179 | taskItem.InvType = item.invType; |
180 | part.AddInventoryItem(taskItem); | 180 | part.AddInventoryItem(taskItem); |
181 | 181 | ||
182 | // It might seem somewhat crude to update the whole group for a single prim inventory change, | ||
183 | // but it's possible that other prim inventory changes will take place before the region | ||
184 | // persistence thread visits this object. In the future, changes can be signalled at a more | ||
185 | // granular level, or we could let the datastore worry about whether prims have really | ||
186 | // changed since they were last persisted. | ||
187 | HasGroupChanged = true; | ||
188 | |||
189 | return true; | 182 | return true; |
190 | } | 183 | } |
191 | else | 184 | else |
@@ -234,14 +227,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
234 | SceneObjectPart part = GetChildPart(item.ParentPartID); | 227 | SceneObjectPart part = GetChildPart(item.ParentPartID); |
235 | if (part != null) | 228 | if (part != null) |
236 | { | 229 | { |
237 | part.UpdateInventoryItem(item); | 230 | part.UpdateInventoryItem(item); |
238 | |||
239 | // It might seem somewhat crude to update the whole group for a single prim inventory change, | ||
240 | // but it's possible that other prim inventory changes will take place before the region | ||
241 | // persistence thread visits this object. In the future, changes can be signalled at a more | ||
242 | // granular level, or we could let the datastore worry about whether prims have really | ||
243 | // changed since they were last persisted. | ||
244 | HasGroupChanged = true; | ||
245 | 231 | ||
246 | return true; | 232 | return true; |
247 | } | 233 | } |
@@ -263,13 +249,6 @@ namespace OpenSim.Region.Environment.Scenes | |||
263 | { | 249 | { |
264 | int type = part.RemoveInventoryItem(itemID); | 250 | int type = part.RemoveInventoryItem(itemID); |
265 | 251 | ||
266 | // It might seem somewhat crude to update the whole group for a single prim inventory change, | ||
267 | // but it's possible that other prim inventory changes will take place before the region | ||
268 | // persistence thread visits this object. In the future, changes can be signalled at a more | ||
269 | // granular level, or we could let the datastore worry about whether prims have really | ||
270 | // changed since they were last persisted. | ||
271 | HasGroupChanged = true; | ||
272 | |||
273 | return type; | 252 | return type; |
274 | } | 253 | } |
275 | 254 | ||
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs index be24f66..12176af 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs | |||
@@ -1492,6 +1492,8 @@ namespace OpenSim.Region.Environment.Scenes | |||
1492 | datastore.StoreObject(this, m_scene.RegionInfo.RegionID); | 1492 | datastore.StoreObject(this, m_scene.RegionInfo.RegionID); |
1493 | HasGroupChanged = false; | 1493 | HasGroupChanged = false; |
1494 | } | 1494 | } |
1495 | |||
1496 | ForEachPart(delegate(SceneObjectPart part) { part.ProcessInventoryBackup(datastore); }); | ||
1495 | } | 1497 | } |
1496 | 1498 | ||
1497 | #endregion | 1499 | #endregion |
@@ -1704,9 +1706,12 @@ namespace OpenSim.Region.Environment.Scenes | |||
1704 | 1706 | ||
1705 | public void ForEachPart(Action<SceneObjectPart> whatToDo) | 1707 | public void ForEachPart(Action<SceneObjectPart> whatToDo) |
1706 | { | 1708 | { |
1707 | foreach (SceneObjectPart part in m_parts.Values) | 1709 | lock (m_parts) |
1708 | { | 1710 | { |
1709 | whatToDo(part); | 1711 | foreach (SceneObjectPart part in m_parts.Values) |
1712 | { | ||
1713 | whatToDo(part); | ||
1714 | } | ||
1710 | } | 1715 | } |
1711 | } | 1716 | } |
1712 | } | 1717 | } |
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs index 1a9e6c4..c0297cf 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs | |||
@@ -82,6 +82,11 @@ namespace OpenSim.Region.Environment.Scenes | |||
82 | } | 82 | } |
83 | 83 | ||
84 | /// <summary> | 84 | /// <summary> |
85 | /// Tracks whether inventory has changed since the last persistent backup | ||
86 | /// </summary> | ||
87 | private bool HasInventoryChanged; | ||
88 | |||
89 | /// <summary> | ||
85 | /// Reset LLUUIDs for all the items in the prim's inventory. This involves either generating | 90 | /// Reset LLUUIDs for all the items in the prim's inventory. This involves either generating |
86 | /// new ones or setting existing UUIDs to the correct parent UUIDs | 91 | /// new ones or setting existing UUIDs to the correct parent UUIDs |
87 | /// </summary> | 92 | /// </summary> |
@@ -207,6 +212,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
207 | } | 212 | } |
208 | 213 | ||
209 | m_inventorySerial++; | 214 | m_inventorySerial++; |
215 | HasInventoryChanged = true; | ||
210 | } | 216 | } |
211 | 217 | ||
212 | /// <summary> | 218 | /// <summary> |
@@ -224,7 +230,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
224 | TriggerScriptChangedEvent(Changed.INVENTORY); | 230 | TriggerScriptChangedEvent(Changed.INVENTORY); |
225 | } | 231 | } |
226 | } | 232 | } |
227 | 233 | ||
228 | m_inventorySerial++; | 234 | m_inventorySerial++; |
229 | } | 235 | } |
230 | 236 | ||
@@ -268,6 +274,8 @@ namespace OpenSim.Region.Environment.Scenes | |||
268 | m_taskInventory[item.ItemID] = item; | 274 | m_taskInventory[item.ItemID] = item; |
269 | m_inventorySerial++; | 275 | m_inventorySerial++; |
270 | TriggerScriptChangedEvent(Changed.INVENTORY); | 276 | TriggerScriptChangedEvent(Changed.INVENTORY); |
277 | |||
278 | HasInventoryChanged = true; | ||
271 | 279 | ||
272 | return true; | 280 | return true; |
273 | } | 281 | } |
@@ -300,6 +308,8 @@ namespace OpenSim.Region.Environment.Scenes | |||
300 | m_inventorySerial++; | 308 | m_inventorySerial++; |
301 | TriggerScriptChangedEvent(Changed.INVENTORY); | 309 | TriggerScriptChangedEvent(Changed.INVENTORY); |
302 | 310 | ||
311 | HasInventoryChanged = true; | ||
312 | |||
303 | return type; | 313 | return type; |
304 | } | 314 | } |
305 | else | 315 | else |
@@ -380,6 +390,20 @@ namespace OpenSim.Region.Environment.Scenes | |||
380 | xferManager.AddNewFile(m_inventoryFileName, fileData); | 390 | xferManager.AddNewFile(m_inventoryFileName, fileData); |
381 | } | 391 | } |
382 | } | 392 | } |
393 | |||
394 | /// <summary> | ||
395 | /// Process inventory backup | ||
396 | /// </summary> | ||
397 | /// <param name="datastore"></param> | ||
398 | public void ProcessInventoryBackup(IRegionDataStore datastore) | ||
399 | { | ||
400 | if (HasInventoryChanged) | ||
401 | { | ||
402 | datastore.StorePrimInventory(UUID, TaskInventory); | ||
403 | |||
404 | HasInventoryChanged = false; | ||
405 | } | ||
406 | } | ||
383 | 407 | ||
384 | public class InventoryStringBuilder | 408 | public class InventoryStringBuilder |
385 | { | 409 | { |