aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/World/Archiver
diff options
context:
space:
mode:
authorMelanie2010-11-21 23:47:28 +0000
committerMelanie2010-11-21 23:47:28 +0000
commit8d7b181b58d89b109b522d1b1401ea72cf16e694 (patch)
tree69d7ae271383933e82be070d652dc7979f54a09b /OpenSim/Region/CoreModules/World/Archiver
parentAdd the remote connector for freeswitch config retrieval (diff)
parentAdd the remote connector for freeswitch config retrieval (diff)
downloadopensim-SC_OLD-8d7b181b58d89b109b522d1b1401ea72cf16e694.zip
opensim-SC_OLD-8d7b181b58d89b109b522d1b1401ea72cf16e694.tar.gz
opensim-SC_OLD-8d7b181b58d89b109b522d1b1401ea72cf16e694.tar.bz2
opensim-SC_OLD-8d7b181b58d89b109b522d1b1401ea72cf16e694.tar.xz
Merge branch 'master' into careminster-presence-refactor
Diffstat (limited to 'OpenSim/Region/CoreModules/World/Archiver')
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs2
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs203
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs22
3 files changed, 132 insertions, 95 deletions
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
index 1f85278..702eab9 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
@@ -56,7 +56,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
56 /// The maximum major version of OAR that we can read. Minor versions shouldn't need a max number since version 56 /// The maximum major version of OAR that we can read. Minor versions shouldn't need a max number since version
57 /// bumps here should be compatible. 57 /// bumps here should be compatible.
58 /// </summary> 58 /// </summary>
59 public static int MAX_MAJOR_VERSION = 0; 59 public static int MAX_MAJOR_VERSION = 1;
60 60
61 protected Scene m_scene; 61 protected Scene m_scene;
62 protected Stream m_loadStream; 62 protected Stream m_loadStream;
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs
index 0567a82..b987b5a 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs
@@ -49,7 +49,17 @@ namespace OpenSim.Region.CoreModules.World.Archiver
49 public class ArchiveWriteRequestPreparation 49 public class ArchiveWriteRequestPreparation
50 { 50 {
51 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 51 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
52 52
53 /// <summary>
54 /// The minimum major version of OAR that we can write.
55 /// </summary>
56 public static int MIN_MAJOR_VERSION = 0;
57
58 /// <summary>
59 /// The maximum major version of OAR that we can write.
60 /// </summary>
61 public static int MAX_MAJOR_VERSION = 1;
62
53 protected Scene m_scene; 63 protected Scene m_scene;
54 protected Stream m_saveStream; 64 protected Stream m_saveStream;
55 protected Guid m_requestId; 65 protected Guid m_requestId;
@@ -101,110 +111,137 @@ namespace OpenSim.Region.CoreModules.World.Archiver
101 /// <exception cref="System.IO.IOException">if there was an io problem with creating the file</exception> 111 /// <exception cref="System.IO.IOException">if there was an io problem with creating the file</exception>
102 public void ArchiveRegion(Dictionary<string, object> options) 112 public void ArchiveRegion(Dictionary<string, object> options)
103 { 113 {
104 Dictionary<UUID, AssetType> assetUuids = new Dictionary<UUID, AssetType>(); 114 try
105 115 {
106 EntityBase[] entities = m_scene.GetEntities(); 116 Dictionary<UUID, AssetType> assetUuids = new Dictionary<UUID, AssetType>();
107 List<SceneObjectGroup> sceneObjects = new List<SceneObjectGroup>(); 117
108 118 EntityBase[] entities = m_scene.GetEntities();
109 /* 119 List<SceneObjectGroup> sceneObjects = new List<SceneObjectGroup>();
110 foreach (ILandObject lo in m_scene.LandChannel.AllParcels()) 120
121 /*
122 foreach (ILandObject lo in m_scene.LandChannel.AllParcels())
123 {
124 if (name == lo.LandData.Name)
125 {
126 // This is the parcel we want
127 }
128 }
129 */
130
131 // Filter entities so that we only have scene objects.
132 // FIXME: Would be nicer to have this as a proper list in SceneGraph, since lots of methods
133 // end up having to do this
134 foreach (EntityBase entity in entities)
111 { 135 {
112 if (name == lo.LandData.Name) 136 if (entity is SceneObjectGroup)
113 { 137 {
114 // This is the parcel we want 138 SceneObjectGroup sceneObject = (SceneObjectGroup)entity;
139
140 if (!sceneObject.IsDeleted && !sceneObject.IsAttachment)
141 sceneObjects.Add((SceneObjectGroup)entity);
115 } 142 }
116 } 143 }
117 */ 144
118 145 UuidGatherer assetGatherer = new UuidGatherer(m_scene.AssetService);
119 // Filter entities so that we only have scene objects. 146
120 // FIXME: Would be nicer to have this as a proper list in SceneGraph, since lots of methods 147 foreach (SceneObjectGroup sceneObject in sceneObjects)
121 // end up having to do this
122 foreach (EntityBase entity in entities)
123 {
124 if (entity is SceneObjectGroup)
125 { 148 {
126 SceneObjectGroup sceneObject = (SceneObjectGroup)entity; 149 assetGatherer.GatherAssetUuids(sceneObject, assetUuids);
127
128 if (!sceneObject.IsDeleted && !sceneObject.IsAttachment)
129 sceneObjects.Add((SceneObjectGroup)entity);
130 } 150 }
151
152 m_log.DebugFormat(
153 "[ARCHIVER]: {0} scene objects to serialize requiring save of {1} assets",
154 sceneObjects.Count, assetUuids.Count);
155
156 // Make sure that we also request terrain texture assets
157 RegionSettings regionSettings = m_scene.RegionInfo.RegionSettings;
158
159 if (regionSettings.TerrainTexture1 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_1)
160 assetUuids[regionSettings.TerrainTexture1] = AssetType.Texture;
161
162 if (regionSettings.TerrainTexture2 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_2)
163 assetUuids[regionSettings.TerrainTexture2] = AssetType.Texture;
164
165 if (regionSettings.TerrainTexture3 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_3)
166 assetUuids[regionSettings.TerrainTexture3] = AssetType.Texture;
167
168 if (regionSettings.TerrainTexture4 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_4)
169 assetUuids[regionSettings.TerrainTexture4] = AssetType.Texture;
170
171 TarArchiveWriter archiveWriter = new TarArchiveWriter(m_saveStream);
172
173 // Asynchronously request all the assets required to perform this archive operation
174 ArchiveWriteRequestExecution awre
175 = new ArchiveWriteRequestExecution(
176 sceneObjects,
177 m_scene.RequestModuleInterface<ITerrainModule>(),
178 m_scene.RequestModuleInterface<IRegionSerialiserModule>(),
179 m_scene,
180 archiveWriter,
181 m_requestId,
182 options);
183
184 m_log.InfoFormat("[ARCHIVER]: Creating archive file. This may take some time.");
185
186 // Write out control file. This has to be done first so that subsequent loaders will see this file first
187 // XXX: I know this is a weak way of doing it since external non-OAR aware tar executables will not do this
188 archiveWriter.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, CreateControlFile(options));
189 m_log.InfoFormat("[ARCHIVER]: Added control file to archive.");
190
191 new AssetsRequest(
192 new AssetsArchiver(archiveWriter), assetUuids,
193 m_scene.AssetService, awre.ReceivedAllAssets).Execute();
131 } 194 }
132 195 catch (Exception)
133 UuidGatherer assetGatherer = new UuidGatherer(m_scene.AssetService);
134
135 foreach (SceneObjectGroup sceneObject in sceneObjects)
136 { 196 {
137 assetGatherer.GatherAssetUuids(sceneObject, assetUuids); 197 m_saveStream.Close();
138 } 198 throw;
139 199 }
140 m_log.DebugFormat(
141 "[ARCHIVER]: {0} scene objects to serialize requiring save of {1} assets",
142 sceneObjects.Count, assetUuids.Count);
143
144 // Make sure that we also request terrain texture assets
145 RegionSettings regionSettings = m_scene.RegionInfo.RegionSettings;
146
147 if (regionSettings.TerrainTexture1 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_1)
148 assetUuids[regionSettings.TerrainTexture1] = AssetType.Texture;
149
150 if (regionSettings.TerrainTexture2 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_2)
151 assetUuids[regionSettings.TerrainTexture2] = AssetType.Texture;
152
153 if (regionSettings.TerrainTexture3 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_3)
154 assetUuids[regionSettings.TerrainTexture3] = AssetType.Texture;
155
156 if (regionSettings.TerrainTexture4 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_4)
157 assetUuids[regionSettings.TerrainTexture4] = AssetType.Texture;
158
159 TarArchiveWriter archiveWriter = new TarArchiveWriter(m_saveStream);
160
161 // Asynchronously request all the assets required to perform this archive operation
162 ArchiveWriteRequestExecution awre
163 = new ArchiveWriteRequestExecution(
164 sceneObjects,
165 m_scene.RequestModuleInterface<ITerrainModule>(),
166 m_scene.RequestModuleInterface<IRegionSerialiserModule>(),
167 m_scene,
168 archiveWriter,
169 m_requestId,
170 options);
171
172 m_log.InfoFormat("[ARCHIVER]: Creating archive file. This may take some time.");
173
174 // Write out control file. This has to be done first so that subsequent loaders will see this file first
175 // XXX: I know this is a weak way of doing it since external non-OAR aware tar executables will not do this
176 archiveWriter.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, Create0p2ControlFile(options));
177 m_log.InfoFormat("[ARCHIVER]: Added control file to archive.");
178
179 new AssetsRequest(
180 new AssetsArchiver(archiveWriter), assetUuids,
181 m_scene.AssetService, awre.ReceivedAllAssets).Execute();
182 } 200 }
183 201
184 /// <summary> 202 /// <summary>
185 /// Create the control file for the most up to date archive 203 /// Create the control file for the most up to date archive
186 /// </summary> 204 /// </summary>
187 /// <returns></returns> 205 /// <returns></returns>
188 public static string Create0p2ControlFile(Dictionary<string, object> options) 206 public static string CreateControlFile(Dictionary<string, object> options)
189 { 207 {
190 int majorVersion = 0, minorVersion = 5; 208 int majorVersion = MAX_MAJOR_VERSION, minorVersion = 0;
191 209
192 if (options.ContainsKey("version")) 210 if (options.ContainsKey("version"))
193 { 211 {
194 minorVersion = 0;
195 string[] parts = options["version"].ToString().Split('.'); 212 string[] parts = options["version"].ToString().Split('.');
196 if (parts.Length >= 1) 213 if (parts.Length >= 1)
197 majorVersion = Int32.Parse(parts[0]); 214 {
198 if (parts.Length >= 2) 215 majorVersion = Int32.Parse(parts[0]);
199 minorVersion = Int32.Parse(parts[1]); 216
217 if (parts.Length >= 2)
218 minorVersion = Int32.Parse(parts[1]);
219 }
200 } 220 }
201 221
202 m_log.InfoFormat("[ARCHIVER]: Creating version {0}.{1} OAR", majorVersion, minorVersion); 222 if (majorVersion < MIN_MAJOR_VERSION || majorVersion > MAX_MAJOR_VERSION)
203// if (majorVersion == 1) 223 {
204// { 224 throw new Exception(
205// m_log.WarnFormat("[ARCHIVER]: Please be aware that version 1.0 OARs are not compatible with OpenSim 0.7.0.2 and earlier. Please use the --version=0 option if you want to produce a compatible OAR"); 225 string.Format(
206// } 226 "OAR version number for save must be between {0} and {1}",
227 MIN_MAJOR_VERSION, MAX_MAJOR_VERSION));
228 }
229 else if (majorVersion == MAX_MAJOR_VERSION)
230 {
231 // Force 1.0
232 minorVersion = 0;
233 }
234 else if (majorVersion == MIN_MAJOR_VERSION)
235 {
236 // Force 0.4
237 minorVersion = 4;
238 }
207 239
240 m_log.InfoFormat("[ARCHIVER]: Creating version {0}.{1} OAR", majorVersion, minorVersion);
241 if (majorVersion == 1)
242 {
243 m_log.WarnFormat("[ARCHIVER]: Please be aware that version 1.0 OARs are not compatible with OpenSim 0.7.0.2 and earlier. Please use the --version=0 option if you want to produce a compatible OAR");
244 }
208 245
209 StringWriter sw = new StringWriter(); 246 StringWriter sw = new StringWriter();
210 XmlTextWriter xtw = new XmlTextWriter(sw); 247 XmlTextWriter xtw = new XmlTextWriter(sw);
diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
index 04bdc4f..04b6e3d 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
@@ -122,13 +122,13 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
122 } 122 }
123 123
124 /// <summary> 124 /// <summary>
125 /// Test saving a V0.2 OpenSim Region Archive. 125 /// Test saving an OpenSim Region Archive.
126 /// </summary> 126 /// </summary>
127 [Test] 127 [Test]
128 public void TestSaveOarV0_2() 128 public void TestSaveOar()
129 { 129 {
130 TestHelper.InMethod(); 130 TestHelper.InMethod();
131 //log4net.Config.XmlConfigurator.Configure(); 131// log4net.Config.XmlConfigurator.Configure();
132 132
133 SceneObjectPart part1 = CreateSceneObjectPart1(); 133 SceneObjectPart part1 = CreateSceneObjectPart1();
134 SceneObjectGroup sog1 = new SceneObjectGroup(part1); 134 SceneObjectGroup sog1 = new SceneObjectGroup(part1);
@@ -212,10 +212,10 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
212 } 212 }
213 213
214 /// <summary> 214 /// <summary>
215 /// Test loading a V0.2 OpenSim Region Archive. 215 /// Test loading an OpenSim Region Archive.
216 /// </summary> 216 /// </summary>
217 [Test] 217 [Test]
218 public void TestLoadOarV0_2() 218 public void TestLoadOar()
219 { 219 {
220 TestHelper.InMethod(); 220 TestHelper.InMethod();
221// log4net.Config.XmlConfigurator.Configure(); 221// log4net.Config.XmlConfigurator.Configure();
@@ -230,7 +230,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
230 // upset load 230 // upset load
231 tar.WriteDir(ArchiveConstants.TERRAINS_PATH); 231 tar.WriteDir(ArchiveConstants.TERRAINS_PATH);
232 232
233 tar.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestPreparation.Create0p2ControlFile(new Dictionary<string, Object>())); 233 tar.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestPreparation.CreateControlFile(new Dictionary<string, Object>()));
234 234
235 SceneObjectPart part1 = CreateSceneObjectPart1(); 235 SceneObjectPart part1 = CreateSceneObjectPart1();
236 SceneObjectGroup object1 = new SceneObjectGroup(part1); 236 SceneObjectGroup object1 = new SceneObjectGroup(part1);
@@ -317,10 +317,10 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
317 } 317 }
318 318
319 /// <summary> 319 /// <summary>
320 /// Test loading the region settings of a V0.2 OpenSim Region Archive. 320 /// Test loading the region settings of an OpenSim Region Archive.
321 /// </summary> 321 /// </summary>
322 [Test] 322 [Test]
323 public void TestLoadOarV0_2RegionSettings() 323 public void TestLoadOarRegionSettings()
324 { 324 {
325 TestHelper.InMethod(); 325 TestHelper.InMethod();
326 //log4net.Config.XmlConfigurator.Configure(); 326 //log4net.Config.XmlConfigurator.Configure();
@@ -329,7 +329,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
329 TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream); 329 TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);
330 330
331 tar.WriteDir(ArchiveConstants.TERRAINS_PATH); 331 tar.WriteDir(ArchiveConstants.TERRAINS_PATH);
332 tar.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestPreparation.Create0p2ControlFile(new Dictionary<string, Object>())); 332 tar.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestPreparation.CreateControlFile(new Dictionary<string, Object>()));
333 333
334 RegionSettings rs = new RegionSettings(); 334 RegionSettings rs = new RegionSettings();
335 rs.AgentLimit = 17; 335 rs.AgentLimit = 17;
@@ -409,10 +409,10 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
409 } 409 }
410 410
411 /// <summary> 411 /// <summary>
412 /// Test merging a V0.2 OpenSim Region Archive into an existing scene 412 /// Test merging an OpenSim Region Archive into an existing scene
413 /// </summary> 413 /// </summary>
414 //[Test] 414 //[Test]
415 public void TestMergeOarV0_2() 415 public void TestMergeOar()
416 { 416 {
417 TestHelper.InMethod(); 417 TestHelper.InMethod();
418 //XmlConfigurator.Configure(); 418 //XmlConfigurator.Configure();