aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules
diff options
context:
space:
mode:
authorJustin Clarke Casey2009-02-02 20:59:12 +0000
committerJustin Clarke Casey2009-02-02 20:59:12 +0000
commit2c2f10e156c62aa1d95923ff5309f2be7f08faeb (patch)
treec6631296849e076264ce8e034d29ca117750bfa5 /OpenSim/Region/Environment/Modules
parent* As per http://opensimulator.org/mantis/view.php?id=3065 (diff)
downloadopensim-SC_OLD-2c2f10e156c62aa1d95923ff5309f2be7f08faeb.zip
opensim-SC_OLD-2c2f10e156c62aa1d95923ff5309f2be7f08faeb.tar.gz
opensim-SC_OLD-2c2f10e156c62aa1d95923ff5309f2be7f08faeb.tar.bz2
opensim-SC_OLD-2c2f10e156c62aa1d95923ff5309f2be7f08faeb.tar.xz
* Establish OnOarFileSaved EventManager event and subscribe to that instead of passing in a waithandle to the archiver
* This matches the existing OnOarFileLoaded event * This brings up the question of how these things can be made generic so that they don't have to be tied into EventManager, but that's a topic for another day
Diffstat (limited to 'OpenSim/Region/Environment/Modules')
-rw-r--r--OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs2
-rw-r--r--OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestExecution.cs31
-rw-r--r--OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestPreparation.cs9
-rw-r--r--OpenSim/Region/Environment/Modules/World/Archiver/ArchiverModule.cs4
-rw-r--r--OpenSim/Region/Environment/Modules/World/Archiver/Tests/ArchiverTests.cs18
5 files changed, 34 insertions, 30 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs
index ee4323c..4e9fcef 100644
--- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs
+++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs
@@ -233,8 +233,8 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
233 { 233 {
234 sceneObject.CreateScriptInstances(0, true, m_scene.DefaultScriptEngine, 0); 234 sceneObject.CreateScriptInstances(0, true, m_scene.DefaultScriptEngine, 0);
235 } 235 }
236
236 m_scene.EventManager.TriggerOarFileLoaded(m_errorMessage); 237 m_scene.EventManager.TriggerOarFileLoaded(m_errorMessage);
237
238 } 238 }
239 239
240 /// <summary> 240 /// <summary>
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestExecution.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestExecution.cs
index 8eec38d..179b82a 100644
--- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestExecution.cs
+++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestExecution.cs
@@ -29,7 +29,6 @@ using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.IO; 30using System.IO;
31using System.Reflection; 31using System.Reflection;
32using System.Threading;
33using System.Xml; 32using System.Xml;
34using OpenMetaverse; 33using OpenMetaverse;
35using log4net; 34using log4net;
@@ -45,7 +44,7 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
45 /// Method called when all the necessary assets for an archive request have been received. 44 /// Method called when all the necessary assets for an archive request have been received.
46 /// </summary> 45 /// </summary>
47 public delegate void AssetsRequestCallback(IDictionary<UUID, AssetBase> assetsFound, ICollection<UUID> assetsNotFoundUuids); 46 public delegate void AssetsRequestCallback(IDictionary<UUID, AssetBase> assetsFound, ICollection<UUID> assetsNotFoundUuids);
48 47
49 /// <summary> 48 /// <summary>
50 /// Execute the write of an archive once we have received all the necessary data 49 /// Execute the write of an archive once we have received all the necessary data
51 /// </summary> 50 /// </summary>
@@ -56,27 +55,25 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
56 protected ITerrainModule m_terrainModule; 55 protected ITerrainModule m_terrainModule;
57 protected IRegionSerialiserModule m_serialiser; 56 protected IRegionSerialiserModule m_serialiser;
58 protected List<SceneObjectGroup> m_sceneObjects; 57 protected List<SceneObjectGroup> m_sceneObjects;
59 protected RegionInfo m_regionInfo; 58 protected Scene m_scene;
60 protected Stream m_saveStream; 59 protected Stream m_saveStream;
61 protected EventWaitHandle m_signalWhenDoneEvent;
62 60
63 public ArchiveWriteRequestExecution( 61 public ArchiveWriteRequestExecution(
64 List<SceneObjectGroup> sceneObjects, 62 List<SceneObjectGroup> sceneObjects,
65 ITerrainModule terrainModule, 63 ITerrainModule terrainModule,
66 IRegionSerialiserModule serialiser, 64 IRegionSerialiserModule serialiser,
67 RegionInfo regionInfo, 65 Scene scene,
68 Stream saveStream, 66 Stream saveStream)
69 EventWaitHandle signalWhenDoneEvent)
70 { 67 {
71 m_sceneObjects = sceneObjects; 68 m_sceneObjects = sceneObjects;
72 m_terrainModule = terrainModule; 69 m_terrainModule = terrainModule;
73 m_serialiser = serialiser; 70 m_serialiser = serialiser;
74 m_regionInfo = regionInfo; 71 m_scene = scene;
75 m_saveStream = saveStream; 72 m_saveStream = saveStream;
76 m_signalWhenDoneEvent = signalWhenDoneEvent;
77 } 73 }
78 74
79 protected internal void ReceivedAllAssets(IDictionary<UUID, AssetBase> assetsFound, ICollection<UUID> assetsNotFoundUuids) 75 protected internal void ReceivedAllAssets(
76 IDictionary<UUID, AssetBase> assetsFound, ICollection<UUID> assetsNotFoundUuids)
80 { 77 {
81 foreach (UUID uuid in assetsNotFoundUuids) 78 foreach (UUID uuid in assetsNotFoundUuids)
82 { 79 {
@@ -95,11 +92,14 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
95 archive.AddFile(ArchiveConstants.CONTROL_FILE_PATH, Create0p2ControlFile()); 92 archive.AddFile(ArchiveConstants.CONTROL_FILE_PATH, Create0p2ControlFile());
96 93
97 // Write out region settings 94 // Write out region settings
98 string settingsPath = String.Format("{0}{1}.xml", ArchiveConstants.SETTINGS_PATH, m_regionInfo.RegionName); 95 string settingsPath
99 archive.AddFile(settingsPath, RegionSettingsSerializer.Serialize(m_regionInfo.RegionSettings)); 96 = String.Format("{0}{1}.xml", ArchiveConstants.SETTINGS_PATH, m_scene.RegionInfo.RegionName);
97 archive.AddFile(settingsPath, RegionSettingsSerializer.Serialize(m_scene.RegionInfo.RegionSettings));
100 98
101 // Write out terrain 99 // Write out terrain
102 string terrainPath = String.Format("{0}{1}.r32", ArchiveConstants.TERRAINS_PATH, m_regionInfo.RegionName); 100 string terrainPath
101 = String.Format("{0}{1}.r32", ArchiveConstants.TERRAINS_PATH, m_scene.RegionInfo.RegionName);
102
103 MemoryStream ms = new MemoryStream(); 103 MemoryStream ms = new MemoryStream();
104 m_terrainModule.SaveToStream(terrainPath, ms); 104 m_terrainModule.SaveToStream(terrainPath, ms);
105 archive.AddFile(terrainPath, ms.ToArray()); 105 archive.AddFile(terrainPath, ms.ToArray());
@@ -129,10 +129,9 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
129 129
130 archive.WriteTar(m_saveStream); 130 archive.WriteTar(m_saveStream);
131 131
132 m_log.InfoFormat("[ARCHIVER]: Wrote out OpenSimulator archive for {0}", m_regionInfo.RegionName); 132 m_log.InfoFormat("[ARCHIVER]: Wrote out OpenSimulator archive for {0}", m_scene.RegionInfo.RegionName);
133 133
134 if (m_signalWhenDoneEvent != null) 134 m_scene.EventManager.TriggerOarFileSaved(String.Empty);
135 m_signalWhenDoneEvent.Set();
136 } 135 }
137 136
138 /// <summary> 137 /// <summary>
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestPreparation.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestPreparation.cs
index b3c9a91..a5f4770 100644
--- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestPreparation.cs
+++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestPreparation.cs
@@ -53,7 +53,6 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
53 53
54 protected Scene m_scene; 54 protected Scene m_scene;
55 protected Stream m_saveStream; 55 protected Stream m_saveStream;
56 protected EventWaitHandle m_signalWhenDoneEvent;
57 56
58 /// <summary> 57 /// <summary>
59 /// Used as a temporary store of an asset which represents an object. This can be a null if no appropriate 58 /// Used as a temporary store of an asset which represents an object. This can be a null if no appropriate
@@ -80,11 +79,10 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
80 /// </summary> 79 /// </summary>
81 /// <param name="scene"></param> 80 /// <param name="scene"></param>
82 /// <param name="saveStream">The stream to which to save data.</param> 81 /// <param name="saveStream">The stream to which to save data.</param>
83 public ArchiveWriteRequestPreparation(Scene scene, Stream saveStream, EventWaitHandle signalWhenDoneEvent) 82 public ArchiveWriteRequestPreparation(Scene scene, Stream saveStream)
84 { 83 {
85 m_scene = scene; 84 m_scene = scene;
86 m_saveStream = saveStream; 85 m_saveStream = saveStream;
87 m_signalWhenDoneEvent = signalWhenDoneEvent;
88 } 86 }
89 87
90 /// <summary> 88 /// <summary>
@@ -326,9 +324,8 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
326 sceneObjects, 324 sceneObjects,
327 m_scene.RequestModuleInterface<ITerrainModule>(), 325 m_scene.RequestModuleInterface<ITerrainModule>(),
328 m_scene.RequestModuleInterface<IRegionSerialiserModule>(), 326 m_scene.RequestModuleInterface<IRegionSerialiserModule>(),
329 m_scene.RegionInfo, 327 m_scene,
330 m_saveStream, 328 m_saveStream);
331 m_signalWhenDoneEvent);
332 329
333 new AssetsRequest(assetUuids.Keys, m_scene.AssetCache, awre.ReceivedAllAssets).Execute(); 330 new AssetsRequest(assetUuids.Keys, m_scene.AssetCache, awre.ReceivedAllAssets).Execute();
334 } 331 }
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiverModule.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiverModule.cs
index e3dfda2..9d9f81e 100644
--- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiverModule.cs
+++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiverModule.cs
@@ -73,9 +73,9 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
73 new ArchiveWriteRequestPreparation(m_scene, savePath).ArchiveRegion(); 73 new ArchiveWriteRequestPreparation(m_scene, savePath).ArchiveRegion();
74 } 74 }
75 75
76 public void ArchiveRegion(Stream saveStream, EventWaitHandle waitHandle) 76 public void ArchiveRegion(Stream saveStream)
77 { 77 {
78 new ArchiveWriteRequestPreparation(m_scene, saveStream, waitHandle).ArchiveRegion(); 78 new ArchiveWriteRequestPreparation(m_scene, saveStream).ArchiveRegion();
79 } 79 }
80 80
81 public void DearchiveRegion(string loadPath) 81 public void DearchiveRegion(string loadPath)
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/Environment/Modules/World/Archiver/Tests/ArchiverTests.cs
index 95064e2..43df685 100644
--- a/OpenSim/Region/Environment/Modules/World/Archiver/Tests/ArchiverTests.cs
+++ b/OpenSim/Region/Environment/Modules/World/Archiver/Tests/ArchiverTests.cs
@@ -44,13 +44,20 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver.Tests
44 [TestFixture] 44 [TestFixture]
45 public class ArchiverTests 45 public class ArchiverTests
46 { 46 {
47 private EventWaitHandle m_waitHandle = new AutoResetEvent(false);
48
49 private void SaveCompleted(string errorMessage)
50 {
51 m_waitHandle.Set();
52 }
53
47 /// <summary> 54 /// <summary>
48 /// Test saving a V0.2 OpenSim Region Archive. 55 /// Test saving a V0.2 OpenSim Region Archive.
49 /// </summary> 56 /// </summary>
50 [Test] 57 [Test]
51 public void TestSaveOarV0p2() 58 public void TestSaveOarV0p2()
52 { 59 {
53 //log4net.Config.XmlConfigurator.Configure(); 60 log4net.Config.XmlConfigurator.Configure();
54 61
55 ArchiverModule archiverModule = new ArchiverModule(); 62 ArchiverModule archiverModule = new ArchiverModule();
56 SerialiserModule serialiserModule = new SerialiserModule(); 63 SerialiserModule serialiserModule = new SerialiserModule();
@@ -71,11 +78,12 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver.Tests
71 ownerId, shape, groupPosition, rotationOffset, offsetPosition); 78 ownerId, shape, groupPosition, rotationOffset, offsetPosition);
72 part.Name = partName; 79 part.Name = partName;
73 80
74 scene.AddNewSceneObject(new SceneObjectGroup(part), false); 81 scene.AddNewSceneObject(new SceneObjectGroup(part), false);
75 EventWaitHandle waitHandle = new ManualResetEvent(false);
76 MemoryStream archiveWriteStream = new MemoryStream(); 82 MemoryStream archiveWriteStream = new MemoryStream();
77 archiverModule.ArchiveRegion(archiveWriteStream, waitHandle); 83
78 waitHandle.WaitOne(60000, true); 84 scene.EventManager.OnOarFileSaved += SaveCompleted;
85 archiverModule.ArchiveRegion(archiveWriteStream);
86 m_waitHandle.WaitOne(60000, true);
79 87
80 byte[] archive = archiveWriteStream.ToArray(); 88 byte[] archive = archiveWriteStream.ToArray();
81 MemoryStream archiveReadStream = new MemoryStream(archive); 89 MemoryStream archiveReadStream = new MemoryStream(archive);