From 504ae63669e5c57cd89e8213b853c27506012f79 Mon Sep 17 00:00:00 2001
From: Justin Clarke Casey
Date: Mon, 21 Jan 2008 15:06:49 +0000
Subject: * Make object persistence more granular by separating prim and prim
inventory persistence
---
.../Environment/Interfaces/IRegionDataStore.cs | 20 ++++++++++++++++-
.../Scenes/SceneObjectGroup.Inventory.cs | 23 +------------------
.../Region/Environment/Scenes/SceneObjectGroup.cs | 9 ++++++--
.../Scenes/SceneObjectPart.Inventory.cs | 26 +++++++++++++++++++++-
4 files changed, 52 insertions(+), 26 deletions(-)
(limited to 'OpenSim/Region/Environment')
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
/// Temporary switch while this option is immature
void Initialise(string filename, bool persistPrimInventories);
+ ///
+ /// Stores all object's details apart from inventory
+ ///
+ ///
+ ///
void StoreObject(SceneObjectGroup obj, LLUUID regionUUID);
+
+ ///
+ /// Entirely removes the object, including inventory
+ ///
+ ///
+ ///
+ ///
void RemoveObject(LLUUID uuid, LLUUID regionUUID);
+
+ ///
+ /// Store a prim's inventory
+ ///
+ ///
+ void StorePrimInventory(LLUUID primID, IDictionary items);
List LoadObjects(LLUUID regionUUID);
@@ -58,4 +76,4 @@ namespace OpenSim.Region.Environment.Interfaces
void Shutdown();
}
-}
\ No newline at end of file
+}
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
taskItem.InvType = item.invType;
part.AddInventoryItem(taskItem);
- // It might seem somewhat crude to update the whole group for a single prim inventory change,
- // but it's possible that other prim inventory changes will take place before the region
- // persistence thread visits this object. In the future, changes can be signalled at a more
- // granular level, or we could let the datastore worry about whether prims have really
- // changed since they were last persisted.
- HasGroupChanged = true;
-
return true;
}
else
@@ -234,14 +227,7 @@ namespace OpenSim.Region.Environment.Scenes
SceneObjectPart part = GetChildPart(item.ParentPartID);
if (part != null)
{
- part.UpdateInventoryItem(item);
-
- // It might seem somewhat crude to update the whole group for a single prim inventory change,
- // but it's possible that other prim inventory changes will take place before the region
- // persistence thread visits this object. In the future, changes can be signalled at a more
- // granular level, or we could let the datastore worry about whether prims have really
- // changed since they were last persisted.
- HasGroupChanged = true;
+ part.UpdateInventoryItem(item);
return true;
}
@@ -263,13 +249,6 @@ namespace OpenSim.Region.Environment.Scenes
{
int type = part.RemoveInventoryItem(itemID);
- // It might seem somewhat crude to update the whole group for a single prim inventory change,
- // but it's possible that other prim inventory changes will take place before the region
- // persistence thread visits this object. In the future, changes can be signalled at a more
- // granular level, or we could let the datastore worry about whether prims have really
- // changed since they were last persisted.
- HasGroupChanged = true;
-
return type;
}
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
datastore.StoreObject(this, m_scene.RegionInfo.RegionID);
HasGroupChanged = false;
}
+
+ ForEachPart(delegate(SceneObjectPart part) { part.ProcessInventoryBackup(datastore); });
}
#endregion
@@ -1704,9 +1706,12 @@ namespace OpenSim.Region.Environment.Scenes
public void ForEachPart(Action whatToDo)
{
- foreach (SceneObjectPart part in m_parts.Values)
+ lock (m_parts)
{
- whatToDo(part);
+ foreach (SceneObjectPart part in m_parts.Values)
+ {
+ whatToDo(part);
+ }
}
}
}
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
}
///
+ /// Tracks whether inventory has changed since the last persistent backup
+ ///
+ private bool HasInventoryChanged;
+
+ ///
/// Reset LLUUIDs for all the items in the prim's inventory. This involves either generating
/// new ones or setting existing UUIDs to the correct parent UUIDs
///
@@ -207,6 +212,7 @@ namespace OpenSim.Region.Environment.Scenes
}
m_inventorySerial++;
+ HasInventoryChanged = true;
}
///
@@ -224,7 +230,7 @@ namespace OpenSim.Region.Environment.Scenes
TriggerScriptChangedEvent(Changed.INVENTORY);
}
}
-
+
m_inventorySerial++;
}
@@ -268,6 +274,8 @@ namespace OpenSim.Region.Environment.Scenes
m_taskInventory[item.ItemID] = item;
m_inventorySerial++;
TriggerScriptChangedEvent(Changed.INVENTORY);
+
+ HasInventoryChanged = true;
return true;
}
@@ -300,6 +308,8 @@ namespace OpenSim.Region.Environment.Scenes
m_inventorySerial++;
TriggerScriptChangedEvent(Changed.INVENTORY);
+ HasInventoryChanged = true;
+
return type;
}
else
@@ -380,6 +390,20 @@ namespace OpenSim.Region.Environment.Scenes
xferManager.AddNewFile(m_inventoryFileName, fileData);
}
}
+
+ ///
+ /// Process inventory backup
+ ///
+ ///
+ public void ProcessInventoryBackup(IRegionDataStore datastore)
+ {
+ if (HasInventoryChanged)
+ {
+ datastore.StorePrimInventory(UUID, TaskInventory);
+
+ HasInventoryChanged = false;
+ }
+ }
public class InventoryStringBuilder
{
--
cgit v1.1