* Actually persist restored archives to the database - wasn't actually doing this before (doh)

* Not quite perfect yet
0.6.0-stable
Justin Clarke Casey 2008-07-13 00:18:29 +00:00
parent bd9736c9f8
commit eb63b9bbc1
8 changed files with 74 additions and 17 deletions

View File

@ -71,6 +71,9 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
List<string> serialisedSceneObjects = new List<string>();
string filePath = "ERROR";
int successfulAssetRestores = 0;
int failedAssetRestores = 0;
byte[] data;
while ((data = archive.ReadEntry(out filePath)) != null)
@ -89,7 +92,10 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
// }
else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH))
{
LoadAsset(filePath, data);
if (LoadAsset(filePath, data))
successfulAssetRestores++;
else
failedAssetRestores++;
}
else if (filePath.StartsWith(ArchiveConstants.TERRAINS_PATH))
{
@ -100,9 +106,14 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
//m_log.Debug("[ARCHIVER]: Reached end of archive");
archive.Close();
m_log.InfoFormat("[ARCHIVER]: Restored {0} assets", successfulAssetRestores);
if (failedAssetRestores > 0)
m_log.ErrorFormat("[ARCHIVER]: Failed to load {0} assets", failedAssetRestores);
// Reload serialized prims
m_log.InfoFormat("[ARCHIVER]: Loading {0} scene objects", serialisedSceneObjects.Count);
m_log.InfoFormat("[ARCHIVER]: Loading {0} scene objects. Please wait.", serialisedSceneObjects.Count);
IRegionSerialiser serialiser = m_scene.RequestModuleInterface<IRegionSerialiser>();
ICollection<SceneObjectGroup> sceneObjects = new List<SceneObjectGroup>();
@ -115,12 +126,12 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
sceneObjects.Add(sceneObject);
}
m_log.InfoFormat("[ARCHIVER]: Restored {0} objects to the scene", sceneObjects.Count);
m_log.InfoFormat("[ARCHIVER]: Restored {0} scene objects to the scene", sceneObjects.Count);
int ignoredObjects = serialisedSceneObjects.Count - sceneObjects.Count;
if (ignoredObjects > 0)
m_log.WarnFormat("[ARCHIVER]: Ignored {0} objects that already existed in the scene", ignoredObjects);
m_log.WarnFormat("[ARCHIVER]: Ignored {0} scene objects that already existed in the scene", ignoredObjects);
m_log.InfoFormat("[ARCHIVER]: Successfully loaded archive");
@ -149,7 +160,7 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
{
sbyte assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension];
m_log.DebugFormat("[ARCHIVER]: Importing asset {0}, type {1}", uuid, assetType);
//m_log.DebugFormat("[ARCHIVER]: Importing asset {0}, type {1}", uuid, assetType);
AssetBase asset = new AssetBase(new LLUUID(uuid), String.Empty);
asset.Type = assetType;
@ -185,7 +196,7 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
terrainModule.LoadFromStream(terrainPath, ms);
ms.Close();
m_log.DebugFormat("[ARCHIVER]: Successfully loaded terrain {0}", terrainPath);
m_log.DebugFormat("[ARCHIVER]: Restored terrain {0}", terrainPath);
return true;
}

View File

@ -215,7 +215,7 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
// XXX: Not a great way to iterate through face textures, but there's no
// other method available to tell how many faces there actually are
int i = 0;
//int i = 0;
foreach (LLObject.TextureEntryFace texture in textureEntry.FaceTextures)
{
if (texture != null)

View File

@ -185,7 +185,7 @@ namespace OpenSim.Region.Environment.Scenes
{
SceneObjectGroup obj = new SceneObjectGroup(xmlData);
if (scene.AddRestoredSceneObject(obj, true))
if (scene.AddRestoredSceneObject(obj, true, false))
return obj;
else
return null;

View File

@ -196,10 +196,15 @@ namespace OpenSim.Region.Environment.Scenes
/// If true, changes to the object will be reflected in its persisted data
/// If false, the persisted data will not be changed even if the object in the scene is changed
/// </param>
/// <param name="alreadyPersisted">
/// If true, we won't persist this object until it changes
/// If false, we'll persist this object immediately
/// </param>
/// <returns>
/// true if the object was added, false if an object with the same uuid was already in the scene
/// </returns>
protected internal bool AddRestoredSceneObject(SceneObjectGroup sceneObject, bool attachToBackup)
protected internal bool AddRestoredSceneObject(
SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted)
{
sceneObject.RegionHandle = m_regInfo.RegionHandle;
sceneObject.SetScene(m_parentScene);
@ -211,6 +216,12 @@ namespace OpenSim.Region.Environment.Scenes
sceneObject.UpdateParentIDs();
if (!alreadyPersisted)
{
sceneObject.ForceInventoryPersistence();
sceneObject.HasGroupChanged = true;
}
return AddSceneObject(sceneObject, attachToBackup);
}

View File

@ -1485,7 +1485,7 @@ namespace OpenSim.Region.Environment.Scenes
List<SceneObjectGroup> PrimsFromDB = m_storageManager.DataStore.LoadObjects(regionID);
foreach (SceneObjectGroup group in PrimsFromDB)
{
AddRestoredSceneObject(group, true);
AddRestoredSceneObject(group, true, true);
SceneObjectPart rootPart = group.GetChildPart(group.UUID);
rootPart.ObjectFlags &= ~(uint)LLObject.ObjectFlags.Scripted;
rootPart.TrimPermissions();
@ -1665,9 +1665,21 @@ namespace OpenSim.Region.Environment.Scenes
/// Add an object into the scene that has come from storage
/// </summary>
/// <param name="sceneObject"></param>
public bool AddRestoredSceneObject(SceneObjectGroup sceneObject, bool attachToBackup)
/// <param name="attachToBackup">
/// If true, changes to the object will be reflected in its persisted data
/// If false, the persisted data will not be changed even if the object in the scene is changed
/// </param>
/// <param name="alreadyPersisted">
/// If true, we won't persist this object until it changes
/// If false, we'll persist this object immediately
/// </param>
/// <returns>
/// true if the object was added, false if an object with the same uuid was already in the scene
/// </returns>
public bool AddRestoredSceneObject(
SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted)
{
return m_innerScene.AddRestoredSceneObject(sceneObject, attachToBackup);
return m_innerScene.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted);
}
/// <summary>

View File

@ -38,6 +38,20 @@ namespace OpenSim.Region.Environment.Scenes
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// Force all task inventories of prims in the scene object to persist
/// </summary>
public void ForceInventoryPersistence()
{
lock (m_parts)
{
foreach (SceneObjectPart part in m_parts.Values)
{
part.ForceInventoryPersistence();
}
}
}
/// <summary>
/// Start the scripts contained in all the prims in this group.
/// </summary>
@ -53,6 +67,9 @@ namespace OpenSim.Region.Environment.Scenes
}
}
/// <summary>
/// Stop the scripts contained in all the prims in this group
/// </summary>
public void RemoveScriptInstances()
{
lock (m_parts)

View File

@ -1396,7 +1396,7 @@ namespace OpenSim.Region.Environment.Scenes
}
/// <summary>
///
/// Make a copy of the given part.
/// </summary>
/// <param name="part"></param>
/// <param name="cAgentID"></param>

View File

@ -58,7 +58,15 @@ namespace OpenSim.Region.Environment.Scenes
/// <summary>
/// Tracks whether inventory has changed since the last persistent backup
/// </summary>
private bool HasInventoryChanged;
protected bool HasInventoryChanged;
/// <summary>
/// Force the task inventory of this prim to persist at the next update sweep
/// </summary>
public void ForceInventoryPersistence()
{
HasInventoryChanged = true;
}
/// <summary>
/// Reset LLUUIDs for all the items in the prim's inventory. This involves either generating
@ -72,9 +80,7 @@ namespace OpenSim.Region.Environment.Scenes
lock (TaskInventory)
{
if (0 == TaskInventory.Count)
{
return;
}
HasInventoryChanged = true;
ParentGroup.HasGroupChanged = true;
@ -597,7 +603,7 @@ namespace OpenSim.Region.Environment.Scenes
public void ProcessInventoryBackup(IRegionDataStore datastore)
{
if (HasInventoryChanged)
{
{
lock (TaskInventory)
{
datastore.StorePrimInventory(UUID, TaskInventory.Values);