diff options
author | Justin Clarke Casey | 2008-06-21 23:45:22 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2008-06-21 23:45:22 +0000 |
commit | ca88e3580b8ef94cd882d1b6723c37815601e54e (patch) | |
tree | f3e2fcb35fff62a3af70e7dae9ff88b69d2db627 /OpenSim | |
parent | Mantis#1580. Thank you kindly, Dmiles for a patch that: (diff) | |
download | opensim-SC-ca88e3580b8ef94cd882d1b6723c37815601e54e.zip opensim-SC-ca88e3580b8ef94cd882d1b6723c37815601e54e.tar.gz opensim-SC-ca88e3580b8ef94cd882d1b6723c37815601e54e.tar.bz2 opensim-SC-ca88e3580b8ef94cd882d1b6723c37815601e54e.tar.xz |
* 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
Diffstat (limited to 'OpenSim')
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 | |||
50 | /// <summary> | 50 | /// <summary> |
51 | /// Path for the prims file | 51 | /// Path for the prims file |
52 | /// </summary> | 52 | /// </summary> |
53 | public static readonly string PRIMS_PATH = "objects/prims.xml"; | 53 | public static readonly string OBJECTS_PATH = "objects/"; |
54 | } | 54 | } |
55 | } | 55 | } |
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; | |||
29 | using OpenSim.Region.Environment.Scenes; | 29 | using OpenSim.Region.Environment.Scenes; |
30 | using OpenSim.Region.Environment.Modules.World.Serialiser; | 30 | using OpenSim.Region.Environment.Modules.World.Serialiser; |
31 | using System; | 31 | using System; |
32 | using System.Collections.Generic; | ||
32 | using System.IO; | 33 | using System.IO; |
33 | using System.Reflection; | 34 | using System.Reflection; |
34 | using System.Xml; | 35 | using System.Xml; |
@@ -62,9 +63,7 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
62 | TarArchiveReader archive = new TarArchiveReader(m_loadPath); | 63 | TarArchiveReader archive = new TarArchiveReader(m_loadPath); |
63 | AssetsDearchiver dearchiver = new AssetsDearchiver(m_scene.AssetCache); | 64 | AssetsDearchiver dearchiver = new AssetsDearchiver(m_scene.AssetCache); |
64 | 65 | ||
65 | string serializedPrims = string.Empty; | 66 | List<string> serialisedSceneObjects = new List<string>(); |
66 | |||
67 | // Just test for now by reading first file | ||
68 | string filePath = "ERROR"; | 67 | string filePath = "ERROR"; |
69 | 68 | ||
70 | byte[] data; | 69 | byte[] data; |
@@ -73,9 +72,9 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
73 | m_log.DebugFormat( | 72 | m_log.DebugFormat( |
74 | "[ARCHIVER]: Successfully read {0} ({1} bytes) from archive {2}", filePath, data.Length, m_loadPath); | 73 | "[ARCHIVER]: Successfully read {0} ({1} bytes) from archive {2}", filePath, data.Length, m_loadPath); |
75 | 74 | ||
76 | if (filePath.Equals(ArchiveConstants.PRIMS_PATH)) | 75 | if (filePath.StartsWith(ArchiveConstants.OBJECTS_PATH)) |
77 | { | 76 | { |
78 | serializedPrims = m_asciiEncoding.GetString(data); | 77 | serialisedSceneObjects.Add(m_asciiEncoding.GetString(data)); |
79 | } | 78 | } |
80 | else if (filePath.Equals(ArchiveConstants.ASSETS_METADATA_PATH)) | 79 | else if (filePath.Equals(ArchiveConstants.ASSETS_METADATA_PATH)) |
81 | { | 80 | { |
@@ -92,35 +91,17 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
92 | 91 | ||
93 | archive.Close(); | 92 | archive.Close(); |
94 | 93 | ||
95 | if (serializedPrims.Equals(string.Empty)) | ||
96 | { | ||
97 | m_log.ErrorFormat("[ARCHIVER]: Archive did not contain a {0} file", ArchiveConstants.PRIMS_PATH); | ||
98 | return; | ||
99 | } | ||
100 | |||
101 | // Reload serialized prims | 94 | // Reload serialized prims |
102 | m_log.InfoFormat("[ARCHIVER]: Loading scene objects"); | 95 | m_log.InfoFormat("[ARCHIVER]: Loading {0} scene objects", serialisedSceneObjects.Count); |
103 | 96 | ||
104 | IRegionSerialiser serialiser = m_scene.RequestModuleInterface<IRegionSerialiser>(); | 97 | IRegionSerialiser serialiser = m_scene.RequestModuleInterface<IRegionSerialiser>(); |
105 | |||
106 | // Temporary code to read each sog in the file separately, pending actually having these in separate files | ||
107 | XmlTextReader xtr = new XmlTextReader(new StringReader(serializedPrims)); | ||
108 | XmlDocument doc = new XmlDocument(); | ||
109 | xtr.WhitespaceHandling = WhitespaceHandling.None; | ||
110 | doc.Load(xtr); | ||
111 | xtr.Close(); | ||
112 | XmlNode sceneNode = doc.FirstChild; | ||
113 | int count = 0; | ||
114 | 98 | ||
115 | foreach (XmlNode objectNode in sceneNode.ChildNodes) | 99 | foreach (string serialisedSceneObject in serialisedSceneObjects) |
116 | { | 100 | { |
117 | serialiser.LoadGroupFromXml2(m_scene, objectNode.OuterXml.ToString()); | 101 | serialiser.LoadGroupFromXml2(m_scene, serialisedSceneObject); |
118 | count++; | ||
119 | } | 102 | } |
120 | 103 | ||
121 | //serialiser.LoadPrimsFromXml2(m_scene, new StringReader(serializedPrims)); | 104 | m_log.InfoFormat("[ARCHIVER]: Successfully loaded archive"); |
122 | |||
123 | m_log.DebugFormat("[ARCHIVER]: Loaded {0} scene objects", count); | ||
124 | } | 105 | } |
125 | } | 106 | } |
126 | } | 107 | } |
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 @@ | |||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | ||
28 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
29 | using System.Reflection; | 30 | using System.Reflection; |
30 | using libsecondlife; | 31 | using libsecondlife; |
31 | using log4net; | 32 | using log4net; |
32 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
34 | using OpenSim.Region.Environment.Interfaces; | ||
35 | using OpenSim.Region.Environment.Modules.World.Serialiser; | ||
36 | using OpenSim.Region.Environment.Scenes; | ||
33 | 37 | ||
34 | namespace OpenSim.Region.Environment.Modules.World.Archiver | 38 | namespace OpenSim.Region.Environment.Modules.World.Archiver |
35 | { | 39 | { |
@@ -45,12 +49,15 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
45 | { | 49 | { |
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
47 | 51 | ||
52 | protected IRegionSerialiser m_serialiser; | ||
53 | protected List<EntityBase> m_sceneObjects; | ||
48 | protected string m_savePath; | 54 | protected string m_savePath; |
49 | protected string m_serializedEntities; | ||
50 | 55 | ||
51 | public ArchiveWriteRequestExecution(string serializedEntities, string savePath) | 56 | public ArchiveWriteRequestExecution( |
57 | List<EntityBase> sceneObjects, IRegionSerialiser serialiser, string savePath) | ||
52 | { | 58 | { |
53 | m_serializedEntities = serializedEntities; | 59 | m_sceneObjects = sceneObjects; |
60 | m_serialiser = serialiser; | ||
54 | m_savePath = savePath; | 61 | m_savePath = savePath; |
55 | } | 62 | } |
56 | 63 | ||
@@ -59,8 +66,23 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
59 | m_log.DebugFormat("[ARCHIVER]: Received all {0} assets required", assets.Count); | 66 | m_log.DebugFormat("[ARCHIVER]: Received all {0} assets required", assets.Count); |
60 | 67 | ||
61 | TarArchiveWriter archive = new TarArchiveWriter(); | 68 | TarArchiveWriter archive = new TarArchiveWriter(); |
62 | 69 | ||
63 | archive.AddFile(ArchiveConstants.PRIMS_PATH, m_serializedEntities); | 70 | foreach (EntityBase entity in m_sceneObjects) |
71 | { | ||
72 | // FIXME: I'm fairly sure that all entities are in fact SceneObjectGroups... must fix this | ||
73 | SceneObjectGroup sceneObject = (SceneObjectGroup)entity; | ||
74 | LLVector3 position = sceneObject.AbsolutePosition; | ||
75 | |||
76 | string serializedObject = m_serialiser.SaveGroupToXml2(sceneObject); | ||
77 | string filename | ||
78 | = string.Format( | ||
79 | "{0}{1}_{2:000}-{3:000}-{4:000}__{5}.xml", | ||
80 | ArchiveConstants.OBJECTS_PATH, sceneObject.Name, | ||
81 | Math.Round(position.X), Math.Round(position.Y), Math.Round(position.Z), | ||
82 | sceneObject.UUID); | ||
83 | |||
84 | archive.AddFile(filename, serializedObject); | ||
85 | } | ||
64 | 86 | ||
65 | AssetsArchiver assetsArchiver = new AssetsArchiver(assets); | 87 | AssetsArchiver assetsArchiver = new AssetsArchiver(assets); |
66 | assetsArchiver.Archive(archive); | 88 | assetsArchiver.Archive(archive); |
@@ -68,6 +90,6 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
68 | archive.WriteTar(m_savePath); | 90 | archive.WriteTar(m_savePath); |
69 | 91 | ||
70 | m_log.InfoFormat("[ARCHIVER]: Wrote out OpenSimulator archive {0}", m_savePath); | 92 | m_log.InfoFormat("[ARCHIVER]: Wrote out OpenSimulator archive {0}", m_savePath); |
71 | } | 93 | } |
72 | } | 94 | } |
73 | } | 95 | } |
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 | |||
172 | } | 172 | } |
173 | } | 173 | } |
174 | 174 | ||
175 | string serializedEntities = SerializeObjects(entities); | 175 | if (entities.Count > 0) |
176 | |||
177 | if (serializedEntities != null && serializedEntities.Length > 0) | ||
178 | { | 176 | { |
179 | m_log.DebugFormat("[ARCHIVER]: Successfully got serialization for {0} entities", entities.Count); | 177 | m_log.DebugFormat("[ARCHIVER]: Successfully got serialization for {0} entities", entities.Count); |
180 | m_log.DebugFormat("[ARCHIVER]: Requiring save of {0} assets", assetUuids.Count); | 178 | m_log.DebugFormat("[ARCHIVER]: Requiring save of {0} assets", assetUuids.Count); |
181 | 179 | ||
182 | // Asynchronously request all the assets required to perform this archive operation | 180 | // Asynchronously request all the assets required to perform this archive operation |
183 | ArchiveWriteRequestExecution awre = new ArchiveWriteRequestExecution(serializedEntities, m_savePath); | 181 | ArchiveWriteRequestExecution awre |
182 | = new ArchiveWriteRequestExecution( | ||
183 | entities, m_scene.RequestModuleInterface<IRegionSerialiser>(), m_savePath); | ||
184 | new AssetsRequest(assetUuids.Keys, m_scene.AssetCache, awre.ReceivedAllAssets).Execute(); | 184 | new AssetsRequest(assetUuids.Keys, m_scene.AssetCache, awre.ReceivedAllAssets).Execute(); |
185 | } | 185 | } |
186 | } | 186 | } |
187 | |||
188 | /// <summary> | ||
189 | /// Get an xml representation of the given scene objects. | ||
190 | /// </summary> | ||
191 | /// <param name="scene"></param> | ||
192 | /// <returns></returns> | ||
193 | protected static string SerializeObjects(List<EntityBase> entities) | ||
194 | { | ||
195 | string serialization = "<scene>"; | ||
196 | |||
197 | List<string> serObjects = new List<string>(); | ||
198 | |||
199 | foreach (EntityBase ent in entities) | ||
200 | { | ||
201 | if (ent is SceneObjectGroup) | ||
202 | { | ||
203 | serObjects.Add(((SceneObjectGroup) ent).ToXmlString2()); | ||
204 | } | ||
205 | } | ||
206 | |||
207 | foreach (string serObject in serObjects) | ||
208 | serialization += serObject; | ||
209 | |||
210 | serialization += "</scene>"; | ||
211 | |||
212 | return serialization; | ||
213 | } | ||
214 | } | 187 | } |
215 | } | 188 | } |
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 | |||
146 | } | 146 | } |
147 | 147 | ||
148 | /// <summary> | 148 | /// <summary> |
149 | /// | 149 | /// Number of prims in this group |
150 | /// </summary> | 150 | /// </summary> |
151 | public int PrimCount | 151 | public int PrimCount |
152 | { | 152 | { |
@@ -164,14 +164,6 @@ namespace OpenSim.Region.Environment.Scenes | |||
164 | set { m_rootPart.GroupID = value; } | 164 | set { m_rootPart.GroupID = value; } |
165 | } | 165 | } |
166 | 166 | ||
167 | /// <summary> | ||
168 | /// | ||
169 | /// </summary> | ||
170 | public LLVector3 GroupCentrePoint | ||
171 | { | ||
172 | get { return new LLVector3(0, 0, 0); } | ||
173 | } | ||
174 | |||
175 | public Dictionary<LLUUID, SceneObjectPart> Children | 167 | public Dictionary<LLUUID, SceneObjectPart> Children |
176 | { | 168 | { |
177 | get { return m_parts; } | 169 | get { return m_parts; } |