From ca88e3580b8ef94cd882d1b6723c37815601e54e Mon Sep 17 00:00:00 2001
From: Justin Clarke Casey
Date: Sat, 21 Jun 2008 23:45:22 +0000
Subject: * archive each object as a separate xml file rather than put them all
in one single large file * this is being done for reasons of compositionality
---
.../Modules/World/Archiver/ArchiveConstants.cs | 2 +-
.../Modules/World/Archiver/ArchiveReadRequest.cs | 35 +++++-----------------
.../World/Archiver/ArchiveWriteRequestExecution.cs | 34 +++++++++++++++++----
.../Archiver/ArchiveWriteRequestPreparation.cs | 35 +++-------------------
.../Region/Environment/Scenes/SceneObjectGroup.cs | 10 +------
5 files changed, 42 insertions(+), 74 deletions(-)
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveConstants.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveConstants.cs
index a96325f..388c541 100644
--- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveConstants.cs
+++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveConstants.cs
@@ -50,6 +50,6 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
///
/// Path for the prims file
///
- public static readonly string PRIMS_PATH = "objects/prims.xml";
+ public static readonly string OBJECTS_PATH = "objects/";
}
}
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs
index 26fc1a6..8d882ea 100644
--- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs
+++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs
@@ -29,6 +29,7 @@ using OpenSim.Framework;
using OpenSim.Region.Environment.Scenes;
using OpenSim.Region.Environment.Modules.World.Serialiser;
using System;
+using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Xml;
@@ -62,9 +63,7 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
TarArchiveReader archive = new TarArchiveReader(m_loadPath);
AssetsDearchiver dearchiver = new AssetsDearchiver(m_scene.AssetCache);
- string serializedPrims = string.Empty;
-
- // Just test for now by reading first file
+ List serialisedSceneObjects = new List();
string filePath = "ERROR";
byte[] data;
@@ -73,9 +72,9 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
m_log.DebugFormat(
"[ARCHIVER]: Successfully read {0} ({1} bytes) from archive {2}", filePath, data.Length, m_loadPath);
- if (filePath.Equals(ArchiveConstants.PRIMS_PATH))
+ if (filePath.StartsWith(ArchiveConstants.OBJECTS_PATH))
{
- serializedPrims = m_asciiEncoding.GetString(data);
+ serialisedSceneObjects.Add(m_asciiEncoding.GetString(data));
}
else if (filePath.Equals(ArchiveConstants.ASSETS_METADATA_PATH))
{
@@ -92,35 +91,17 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
archive.Close();
- if (serializedPrims.Equals(string.Empty))
- {
- m_log.ErrorFormat("[ARCHIVER]: Archive did not contain a {0} file", ArchiveConstants.PRIMS_PATH);
- return;
- }
-
// Reload serialized prims
- m_log.InfoFormat("[ARCHIVER]: Loading scene objects");
+ m_log.InfoFormat("[ARCHIVER]: Loading {0} scene objects", serialisedSceneObjects.Count);
IRegionSerialiser serialiser = m_scene.RequestModuleInterface();
-
- // Temporary code to read each sog in the file separately, pending actually having these in separate files
- XmlTextReader xtr = new XmlTextReader(new StringReader(serializedPrims));
- XmlDocument doc = new XmlDocument();
- xtr.WhitespaceHandling = WhitespaceHandling.None;
- doc.Load(xtr);
- xtr.Close();
- XmlNode sceneNode = doc.FirstChild;
- int count = 0;
- foreach (XmlNode objectNode in sceneNode.ChildNodes)
+ foreach (string serialisedSceneObject in serialisedSceneObjects)
{
- serialiser.LoadGroupFromXml2(m_scene, objectNode.OuterXml.ToString());
- count++;
+ serialiser.LoadGroupFromXml2(m_scene, serialisedSceneObject);
}
- //serialiser.LoadPrimsFromXml2(m_scene, new StringReader(serializedPrims));
-
- m_log.DebugFormat("[ARCHIVER]: Loaded {0} scene objects", count);
+ m_log.InfoFormat("[ARCHIVER]: Successfully loaded archive");
}
}
}
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestExecution.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestExecution.cs
index 199539b..3799c57 100644
--- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestExecution.cs
+++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestExecution.cs
@@ -25,11 +25,15 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+using System;
using System.Collections.Generic;
using System.Reflection;
using libsecondlife;
using log4net;
using OpenSim.Framework;
+using OpenSim.Region.Environment.Interfaces;
+using OpenSim.Region.Environment.Modules.World.Serialiser;
+using OpenSim.Region.Environment.Scenes;
namespace OpenSim.Region.Environment.Modules.World.Archiver
{
@@ -45,12 +49,15 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+ protected IRegionSerialiser m_serialiser;
+ protected List m_sceneObjects;
protected string m_savePath;
- protected string m_serializedEntities;
- public ArchiveWriteRequestExecution(string serializedEntities, string savePath)
+ public ArchiveWriteRequestExecution(
+ List sceneObjects, IRegionSerialiser serialiser, string savePath)
{
- m_serializedEntities = serializedEntities;
+ m_sceneObjects = sceneObjects;
+ m_serialiser = serialiser;
m_savePath = savePath;
}
@@ -59,8 +66,23 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
m_log.DebugFormat("[ARCHIVER]: Received all {0} assets required", assets.Count);
TarArchiveWriter archive = new TarArchiveWriter();
-
- archive.AddFile(ArchiveConstants.PRIMS_PATH, m_serializedEntities);
+
+ foreach (EntityBase entity in m_sceneObjects)
+ {
+ // FIXME: I'm fairly sure that all entities are in fact SceneObjectGroups... must fix this
+ SceneObjectGroup sceneObject = (SceneObjectGroup)entity;
+ LLVector3 position = sceneObject.AbsolutePosition;
+
+ string serializedObject = m_serialiser.SaveGroupToXml2(sceneObject);
+ string filename
+ = string.Format(
+ "{0}{1}_{2:000}-{3:000}-{4:000}__{5}.xml",
+ ArchiveConstants.OBJECTS_PATH, sceneObject.Name,
+ Math.Round(position.X), Math.Round(position.Y), Math.Round(position.Z),
+ sceneObject.UUID);
+
+ archive.AddFile(filename, serializedObject);
+ }
AssetsArchiver assetsArchiver = new AssetsArchiver(assets);
assetsArchiver.Archive(archive);
@@ -68,6 +90,6 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
archive.WriteTar(m_savePath);
m_log.InfoFormat("[ARCHIVER]: Wrote out OpenSimulator archive {0}", m_savePath);
- }
+ }
}
}
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestPreparation.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestPreparation.cs
index a0c6dbf..5d63ce4 100644
--- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestPreparation.cs
+++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestPreparation.cs
@@ -172,44 +172,17 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
}
}
- string serializedEntities = SerializeObjects(entities);
-
- if (serializedEntities != null && serializedEntities.Length > 0)
+ if (entities.Count > 0)
{
m_log.DebugFormat("[ARCHIVER]: Successfully got serialization for {0} entities", entities.Count);
m_log.DebugFormat("[ARCHIVER]: Requiring save of {0} assets", assetUuids.Count);
// Asynchronously request all the assets required to perform this archive operation
- ArchiveWriteRequestExecution awre = new ArchiveWriteRequestExecution(serializedEntities, m_savePath);
+ ArchiveWriteRequestExecution awre
+ = new ArchiveWriteRequestExecution(
+ entities, m_scene.RequestModuleInterface(), m_savePath);
new AssetsRequest(assetUuids.Keys, m_scene.AssetCache, awre.ReceivedAllAssets).Execute();
}
}
-
- ///
- /// Get an xml representation of the given scene objects.
- ///
- ///
- ///
- protected static string SerializeObjects(List entities)
- {
- string serialization = "";
-
- List serObjects = new List();
-
- foreach (EntityBase ent in entities)
- {
- if (ent is SceneObjectGroup)
- {
- serObjects.Add(((SceneObjectGroup) ent).ToXmlString2());
- }
- }
-
- foreach (string serObject in serObjects)
- serialization += serObject;
-
- serialization += "";
-
- return serialization;
- }
}
}
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
index 202e3b8..b8f52ec 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
@@ -146,7 +146,7 @@ namespace OpenSim.Region.Environment.Scenes
}
///
- ///
+ /// Number of prims in this group
///
public int PrimCount
{
@@ -164,14 +164,6 @@ namespace OpenSim.Region.Environment.Scenes
set { m_rootPart.GroupID = value; }
}
- ///
- ///
- ///
- public LLVector3 GroupCentrePoint
- {
- get { return new LLVector3(0, 0, 0); }
- }
-
public Dictionary Children
{
get { return m_parts; }
--
cgit v1.1