* Make object persistence more granular by separating prim and prim inventory persistence

ThreadPoolClientBranch
Justin Clarke Casey 2008-01-21 15:06:49 +00:00
parent da8923450a
commit 504ae63669
8 changed files with 141 additions and 131 deletions

View File

@ -156,10 +156,10 @@ namespace OpenSim.Framework.Data.MySQL
// MainLog.Instance.Verbose("DATASTORE", "Ignoring Physical obj: " + obj.UUID + " in region: " + regionUUID);
}
}
}
Commit();
}
}
public void RemoveObject(LLUUID obj, LLUUID regionUUID)
{
@ -198,10 +198,10 @@ namespace OpenSim.Framework.Data.MySQL
// Remove prim row
row.Delete();
}
}
Commit();
}
}
/// <summary>
/// Load persisted objects from region storage.
@ -215,8 +215,6 @@ namespace OpenSim.Framework.Data.MySQL
DataTable prims = m_primTable;
DataTable shapes = m_shapeTable;
try
{
string byRegion = "RegionUUID = '" + Util.ToRawUuidString(regionUUID) + "'";
string orderByParent = "ParentID ASC";
@ -230,8 +228,8 @@ namespace OpenSim.Framework.Data.MySQL
{
try
{
string uuid = (string)primRow["UUID"];
string objID = (string)primRow["SceneGroupID"];
string uuid = (string) primRow["UUID"];
string objID = (string) primRow["SceneGroupID"];
SceneObjectPart prim = buildPrim(primRow);
@ -288,11 +286,6 @@ namespace OpenSim.Framework.Data.MySQL
}
}
}
}
catch (Exception ex)
{
MainLog.Instance.Error("DATASTORE", "Exception trying to load prim objects for region " + regionUUID + ": " + ex.ToString());
}
return retvals;
}
@ -416,8 +409,6 @@ namespace OpenSim.Framework.Data.MySQL
public void StoreLandObject(Land parcel, LLUUID regionUUID)
{
MainLog.Instance.Verbose("DATASTORE", "Tedds temp fix: Waiting 3 seconds for stuff to catch up. (Someone please fix! :))");
System.Threading.Thread.Sleep(3000);
lock (m_dataSet)
{
DataTable land = m_landTable;
@ -449,10 +440,10 @@ namespace OpenSim.Framework.Data.MySQL
fillLandAccessRow(newAccessRow, entry, parcel.landData.globalID);
landaccesslist.Rows.Add(newAccessRow);
}
}
Commit();
}
}
public List<LandData> LoadLandObjects(LLUUID regionUUID)
{
@ -519,6 +510,8 @@ namespace OpenSim.Framework.Data.MySQL
m_connection.Open();
}
lock (m_dataSet)
{
// DisplayDataSet(m_dataSet, "Region DataSet");
m_primDataAdapter.Update(m_primTable);
@ -535,14 +528,12 @@ namespace OpenSim.Framework.Data.MySQL
m_dataSet.AcceptChanges();
}
}
public void Shutdown()
{
lock (m_dataSet)
{
Commit();
}
}
/***********************************************************************
*
@ -1202,22 +1193,15 @@ namespace OpenSim.Framework.Data.MySQL
{
fillShapeRow(shapeRow, prim);
}
if (persistPrimInventories)
{
addPrimInventory(prim.UUID, prim.TaskInventory);
}
}
/// <summary>
/// Persist prim inventory. Deletes, updates and inserts rows.
/// </summary>
/// <param name="primID"></param>
/// <param name="items"></param>
/// <returns></returns>
private void addPrimInventory(LLUUID primID, IDictionary<LLUUID, TaskInventoryItem> items)
// see IRegionDatastore
public void StorePrimInventory(LLUUID primID, IDictionary<LLUUID, TaskInventoryItem> items)
{
MainLog.Instance.Verbose("DATASTORE", "Entered addPrimInventory with prim ID {0}", primID);
if (!persistPrimInventories)
return;
MainLog.Instance.Verbose("DATASTORE", "Entered StorePrimInventory with prim ID {0}", primID);
// Find all existing inventory rows for this prim
DataTable dbItems = m_itemsTable;
@ -1587,9 +1571,7 @@ namespace OpenSim.Framework.Data.MySQL
sDa.Fill(tmpDS, "primshapes");
if (persistPrimInventories)
{
iDa.Fill(tmpDS, "primitems");
}
tDa.Fill(tmpDS, "terrain");
lDa.Fill(tmpDS, "land");
@ -1605,9 +1587,7 @@ namespace OpenSim.Framework.Data.MySQL
sDa.Fill(tmpDS, "primshapes");
if (persistPrimInventories)
{
iDa.Fill(tmpDS, "primitems");
}
tDa.Fill(tmpDS, "terrain");
lDa.Fill(tmpDS, "land");

View File

@ -1248,22 +1248,15 @@ namespace OpenSim.Framework.Data.SQLite
{
fillShapeRow(shapeRow, prim);
}
if (persistPrimInventories)
{
addPrimInventory(prim.UUID, prim.TaskInventory);
}
}
/// <summary>
/// Persist prim inventory. Deletes, updates and inserts rows.
/// </summary>
/// <param name="primID"></param>
/// <param name="items"></param>
/// <returns></returns>
private void addPrimInventory(LLUUID primID, IDictionary<LLUUID, TaskInventoryItem> items)
// see IRegionDatastore
public void StorePrimInventory(LLUUID primID, IDictionary<LLUUID, TaskInventoryItem> items)
{
MainLog.Instance.Verbose("DATASTORE", "Entered addPrimInventory with prim ID {0}", primID);
if (!persistPrimInventories)
return;
MainLog.Instance.Verbose("DATASTORE", "Entered StorePrimInventory with prim ID {0}", primID);
// Find all existing inventory rows for this prim
DataTable dbItems = ds.Tables["primitems"];

View File

@ -44,9 +44,27 @@ namespace OpenSim.Region.Environment.Interfaces
/// <param name="persistPrimInventories">Temporary switch while this option is immature</param>
void Initialise(string filename, bool persistPrimInventories);
/// <summary>
/// Stores all object's details apart from inventory
/// </summary>
/// <param name="obj"></param>
/// <param name="regionUUID"></param>
void StoreObject(SceneObjectGroup obj, LLUUID regionUUID);
/// <summary>
/// Entirely removes the object, including inventory
/// </summary>
/// <param name="uuid"></param>
/// <param name="regionUUID"></param>
/// <returns></returns>
void RemoveObject(LLUUID uuid, LLUUID regionUUID);
/// <summary>
/// Store a prim's inventory
/// </summary>
/// <returns></returns>
void StorePrimInventory(LLUUID primID, IDictionary<LLUUID, TaskInventoryItem> items);
List<SceneObjectGroup> LoadObjects(LLUUID regionUUID);
void StoreTerrain(double[,] terrain, LLUUID regionID);

View File

@ -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
@ -236,13 +229,6 @@ namespace OpenSim.Region.Environment.Scenes
{
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;
return true;
}
else
@ -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;
}

View File

@ -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
@ -1703,6 +1705,8 @@ namespace OpenSim.Region.Environment.Scenes
}
public void ForEachPart(Action<SceneObjectPart> whatToDo)
{
lock (m_parts)
{
foreach (SceneObjectPart part in m_parts.Values)
{
@ -1710,4 +1714,5 @@ namespace OpenSim.Region.Environment.Scenes
}
}
}
}
}

View File

@ -81,6 +81,11 @@ namespace OpenSim.Region.Environment.Scenes
set { m_taskInventory = value; }
}
/// <summary>
/// Tracks whether inventory has changed since the last persistent backup
/// </summary>
private bool HasInventoryChanged;
/// <summary>
/// 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;
}
/// <summary>
@ -269,6 +275,8 @@ namespace OpenSim.Region.Environment.Scenes
m_inventorySerial++;
TriggerScriptChangedEvent(Changed.INVENTORY);
HasInventoryChanged = true;
return true;
}
else
@ -300,6 +308,8 @@ namespace OpenSim.Region.Environment.Scenes
m_inventorySerial++;
TriggerScriptChangedEvent(Changed.INVENTORY);
HasInventoryChanged = true;
return type;
}
else
@ -381,6 +391,20 @@ namespace OpenSim.Region.Environment.Scenes
}
}
/// <summary>
/// Process inventory backup
/// </summary>
/// <param name="datastore"></param>
public void ProcessInventoryBackup(IRegionDataStore datastore)
{
if (HasInventoryChanged)
{
datastore.StorePrimInventory(UUID, TaskInventory);
HasInventoryChanged = false;
}
}
public class InventoryStringBuilder
{
public string BuildString = String.Empty;

View File

@ -753,6 +753,12 @@ namespace OpenSim.DataStore.MSSQL
}
}
// see IRegionDatastore
public void StorePrimInventory(LLUUID primID, IDictionary<LLUUID, TaskInventoryItem> items)
{
// No implementation yet
}
/***********************************************************************
*
* SQL Statement Creation Functions

View File

@ -50,6 +50,11 @@ namespace OpenSim.DataStore.NullStorage
{
}
// see IRegionDatastore
public void StorePrimInventory(LLUUID primID, IDictionary<LLUUID, TaskInventoryItem> items)
{
}
public List<SceneObjectGroup> LoadObjects(LLUUID regionUUID)
{
return new List<SceneObjectGroup>();