aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment
diff options
context:
space:
mode:
authorJustin Clarke Casey2009-01-30 20:54:38 +0000
committerJustin Clarke Casey2009-01-30 20:54:38 +0000
commitc307e0e4a7ddf0b07f2b0662fe55adc31b64b393 (patch)
tree3206f4a7aa0d00ad5256599eb457de0ce608fcc6 /OpenSim/Region/Environment
parent* furhter simplify test setups for objects (diff)
downloadopensim-SC_OLD-c307e0e4a7ddf0b07f2b0662fe55adc31b64b393.zip
opensim-SC_OLD-c307e0e4a7ddf0b07f2b0662fe55adc31b64b393.tar.gz
opensim-SC_OLD-c307e0e4a7ddf0b07f2b0662fe55adc31b64b393.tar.bz2
opensim-SC_OLD-c307e0e4a7ddf0b07f2b0662fe55adc31b64b393.tar.xz
* Extend archive save test to check for the presence of the file for the object that was in the scene
* Can now pass in a wait handle to ArchiveRegion() if you want same thread signalling that the save has completed
Diffstat (limited to 'OpenSim/Region/Environment')
-rw-r--r--OpenSim/Region/Environment/Interfaces/IRegionArchiverModule.cs10
-rw-r--r--OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestExecution.cs9
-rw-r--r--OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestPreparation.cs9
-rw-r--r--OpenSim/Region/Environment/Modules/World/Archiver/ArchiverModule.cs5
-rw-r--r--OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveReader.cs5
-rw-r--r--OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveWriter.cs6
-rw-r--r--OpenSim/Region/Environment/Modules/World/Archiver/Tests/ArchiverTests.cs48
7 files changed, 70 insertions, 22 deletions
diff --git a/OpenSim/Region/Environment/Interfaces/IRegionArchiverModule.cs b/OpenSim/Region/Environment/Interfaces/IRegionArchiverModule.cs
index 7db784e..d9f8c08 100644
--- a/OpenSim/Region/Environment/Interfaces/IRegionArchiverModule.cs
+++ b/OpenSim/Region/Environment/Interfaces/IRegionArchiverModule.cs
@@ -26,6 +26,7 @@
26 */ 26 */
27 27
28using System.IO; 28using System.IO;
29using System.Threading;
29 30
30namespace OpenSim.Region.Environment.Interfaces 31namespace OpenSim.Region.Environment.Interfaces
31{ 32{
@@ -44,12 +45,11 @@ namespace OpenSim.Region.Environment.Interfaces
44 /// Archive the region to a stream. 45 /// Archive the region to a stream.
45 /// </summary> 46 /// </summary>
46 /// 47 ///
47 /// This may be a little problematic to use right now since saves happen asynchronously and there is not yet
48 /// a mechanism to signal completion to the caller (possibly other than continually checking whether the
49 /// stream has any data in it). TODO: Address this.
50 ///
51 /// <param name="saveStream"></param> 48 /// <param name="saveStream"></param>
52 void ArchiveRegion(Stream saveStream); 49 /// <param name="waitHandle">
50 /// Pass in a wait handle if you want to be signalled when the operation completes.
51 /// </param>
52 void ArchiveRegion(Stream saveStream, EventWaitHandle waitHandle);
53 53
54 /// <summary> 54 /// <summary>
55 /// Dearchive the given region archive into the scene 55 /// Dearchive the given region archive into the scene
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestExecution.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestExecution.cs
index bade121..8eec38d 100644
--- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestExecution.cs
+++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestExecution.cs
@@ -29,6 +29,7 @@ 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;
32using System.Xml; 33using System.Xml;
33using OpenMetaverse; 34using OpenMetaverse;
34using log4net; 35using log4net;
@@ -57,19 +58,22 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
57 protected List<SceneObjectGroup> m_sceneObjects; 58 protected List<SceneObjectGroup> m_sceneObjects;
58 protected RegionInfo m_regionInfo; 59 protected RegionInfo m_regionInfo;
59 protected Stream m_saveStream; 60 protected Stream m_saveStream;
61 protected EventWaitHandle m_signalWhenDoneEvent;
60 62
61 public ArchiveWriteRequestExecution( 63 public ArchiveWriteRequestExecution(
62 List<SceneObjectGroup> sceneObjects, 64 List<SceneObjectGroup> sceneObjects,
63 ITerrainModule terrainModule, 65 ITerrainModule terrainModule,
64 IRegionSerialiserModule serialiser, 66 IRegionSerialiserModule serialiser,
65 RegionInfo regionInfo, 67 RegionInfo regionInfo,
66 Stream saveStream) 68 Stream saveStream,
69 EventWaitHandle signalWhenDoneEvent)
67 { 70 {
68 m_sceneObjects = sceneObjects; 71 m_sceneObjects = sceneObjects;
69 m_terrainModule = terrainModule; 72 m_terrainModule = terrainModule;
70 m_serialiser = serialiser; 73 m_serialiser = serialiser;
71 m_regionInfo = regionInfo; 74 m_regionInfo = regionInfo;
72 m_saveStream = saveStream; 75 m_saveStream = saveStream;
76 m_signalWhenDoneEvent = signalWhenDoneEvent;
73 } 77 }
74 78
75 protected internal void ReceivedAllAssets(IDictionary<UUID, AssetBase> assetsFound, ICollection<UUID> assetsNotFoundUuids) 79 protected internal void ReceivedAllAssets(IDictionary<UUID, AssetBase> assetsFound, ICollection<UUID> assetsNotFoundUuids)
@@ -126,6 +130,9 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
126 archive.WriteTar(m_saveStream); 130 archive.WriteTar(m_saveStream);
127 131
128 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_regionInfo.RegionName);
133
134 if (m_signalWhenDoneEvent != null)
135 m_signalWhenDoneEvent.Set();
129 } 136 }
130 137
131 /// <summary> 138 /// <summary>
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestPreparation.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestPreparation.cs
index e9005ae..b3c9a91 100644
--- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestPreparation.cs
+++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestPreparation.cs
@@ -53,6 +53,7 @@ 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;
56 57
57 /// <summary> 58 /// <summary>
58 /// Used as a temporary store of an asset which represents an object. This can be a null if no appropriate 59 /// Used as a temporary store of an asset which represents an object. This can be a null if no appropriate
@@ -79,10 +80,11 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
79 /// </summary> 80 /// </summary>
80 /// <param name="scene"></param> 81 /// <param name="scene"></param>
81 /// <param name="saveStream">The stream to which to save data.</param> 82 /// <param name="saveStream">The stream to which to save data.</param>
82 public ArchiveWriteRequestPreparation(Scene scene, Stream saveStream) 83 public ArchiveWriteRequestPreparation(Scene scene, Stream saveStream, EventWaitHandle signalWhenDoneEvent)
83 { 84 {
84 m_scene = scene; 85 m_scene = scene;
85 m_saveStream = saveStream; 86 m_saveStream = saveStream;
87 m_signalWhenDoneEvent = signalWhenDoneEvent;
86 } 88 }
87 89
88 /// <summary> 90 /// <summary>
@@ -325,7 +327,8 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
325 m_scene.RequestModuleInterface<ITerrainModule>(), 327 m_scene.RequestModuleInterface<ITerrainModule>(),
326 m_scene.RequestModuleInterface<IRegionSerialiserModule>(), 328 m_scene.RequestModuleInterface<IRegionSerialiserModule>(),
327 m_scene.RegionInfo, 329 m_scene.RegionInfo,
328 m_saveStream); 330 m_saveStream,
331 m_signalWhenDoneEvent);
329 332
330 new AssetsRequest(assetUuids.Keys, m_scene.AssetCache, awre.ReceivedAllAssets).Execute(); 333 new AssetsRequest(assetUuids.Keys, m_scene.AssetCache, awre.ReceivedAllAssets).Execute();
331 } 334 }
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiverModule.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiverModule.cs
index f07185c..e3dfda2 100644
--- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiverModule.cs
+++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiverModule.cs
@@ -28,6 +28,7 @@
28using System.Collections.Generic; 28using System.Collections.Generic;
29using System.IO; 29using System.IO;
30using System.Reflection; 30using System.Reflection;
31using System.Threading;
31using OpenMetaverse; 32using OpenMetaverse;
32using log4net; 33using log4net;
33using Nini.Config; 34using Nini.Config;
@@ -72,9 +73,9 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
72 new ArchiveWriteRequestPreparation(m_scene, savePath).ArchiveRegion(); 73 new ArchiveWriteRequestPreparation(m_scene, savePath).ArchiveRegion();
73 } 74 }
74 75
75 public void ArchiveRegion(Stream saveStream) 76 public void ArchiveRegion(Stream saveStream, EventWaitHandle waitHandle)
76 { 77 {
77 new ArchiveWriteRequestPreparation(m_scene, saveStream).ArchiveRegion(); 78 new ArchiveWriteRequestPreparation(m_scene, saveStream, waitHandle).ArchiveRegion();
78 } 79 }
79 80
80 public void DearchiveRegion(string loadPath) 81 public void DearchiveRegion(string loadPath)
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveReader.cs b/OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveReader.cs
index 642e03c..c8ae224 100644
--- a/OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveReader.cs
+++ b/OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveReader.cs
@@ -27,9 +27,9 @@
27 27
28using System; 28using System;
29using System.IO; 29using System.IO;
30//using System.Reflection; 30using System.Reflection;
31using System.Text; 31using System.Text;
32//using log4net; 32using log4net;
33 33
34namespace OpenSim.Region.Environment.Modules.World.Archiver 34namespace OpenSim.Region.Environment.Modules.World.Archiver
35{ 35{
@@ -39,6 +39,7 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
39 public class TarArchiveReader 39 public class TarArchiveReader
40 { 40 {
41 //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 41 //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
42
42 public enum TarEntryType 43 public enum TarEntryType
43 { 44 {
44 TYPE_UNKNOWN = 0, 45 TYPE_UNKNOWN = 0,
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveWriter.cs b/OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveWriter.cs
index 55edec0..8fd247c 100644
--- a/OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveWriter.cs
+++ b/OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveWriter.cs
@@ -29,8 +29,8 @@ using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.IO; 30using System.IO;
31using System.Text; 31using System.Text;
32//using System.Reflection; 32using System.Reflection;
33//using log4net; 33using log4net;
34 34
35namespace OpenSim.Region.Environment.Modules.World.Archiver 35namespace OpenSim.Region.Environment.Modules.World.Archiver
36{ 36{
@@ -169,6 +169,8 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
169 } 169 }
170 } 170 }
171 171
172 //m_log.Debug("[TAR ARCHIVE WRITER]: Writing final consecutive 0 blocks");
173
172 // Write two consecutive 0 blocks to end the archive 174 // Write two consecutive 0 blocks to end the archive
173 byte[] finalZeroPadding = new byte[1024]; 175 byte[] finalZeroPadding = new byte[1024];
174 bw.Write(finalZeroPadding); 176 bw.Write(finalZeroPadding);
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/Environment/Modules/World/Archiver/Tests/ArchiverTests.cs
index 6450238..ccd2411 100644
--- a/OpenSim/Region/Environment/Modules/World/Archiver/Tests/ArchiverTests.cs
+++ b/OpenSim/Region/Environment/Modules/World/Archiver/Tests/ArchiverTests.cs
@@ -25,11 +25,16 @@
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
28using System;
28using System.IO; 29using System.IO;
30using System.Threading;
29using NUnit.Framework; 31using NUnit.Framework;
30using NUnit.Framework.SyntaxHelpers; 32using NUnit.Framework.SyntaxHelpers;
33using OpenMetaverse;
34using OpenSim.Framework;
31using OpenSim.Region.Environment.Interfaces; 35using OpenSim.Region.Environment.Interfaces;
32using OpenSim.Region.Environment.Modules.World.Archiver; 36using OpenSim.Region.Environment.Modules.World.Archiver;
37using OpenSim.Region.Environment.Modules.World.Serialiser;
33using OpenSim.Region.Environment.Modules.World.Terrain; 38using OpenSim.Region.Environment.Modules.World.Terrain;
34using OpenSim.Region.Environment.Scenes; 39using OpenSim.Region.Environment.Scenes;
35using OpenSim.Tests.Common.Setup; 40using OpenSim.Tests.Common.Setup;
@@ -48,21 +53,41 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver.Tests
48 //log4net.Config.XmlConfigurator.Configure(); 53 //log4net.Config.XmlConfigurator.Configure();
49 54
50 ArchiverModule archiverModule = new ArchiverModule(); 55 ArchiverModule archiverModule = new ArchiverModule();
56 SerialiserModule serialiserModule = new SerialiserModule();
51 TerrainModule terrainModule = new TerrainModule(); 57 TerrainModule terrainModule = new TerrainModule();
52 58
53 Scene scene = SceneSetupHelpers.SetupScene(); 59 Scene scene = SceneSetupHelpers.SetupScene();
54 SceneSetupHelpers.SetupSceneModules(scene, archiverModule, terrainModule); 60 SceneSetupHelpers.SetupSceneModules(scene, archiverModule, serialiserModule, terrainModule);
55 61
56 62 string partName = "My Little Pony";
63 UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000015");
64 PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere();
65 Vector3 groupPosition = new Vector3(10, 20, 30);
66 Quaternion rotationOffset = new Quaternion(20, 30, 40, 50);
67 Vector3 offsetPosition = new Vector3(5, 10, 15);
68
69 SceneObjectPart part
70 = new SceneObjectPart(
71 ownerId, shape, groupPosition, rotationOffset, offsetPosition);
72 part.Name = partName;
73
74 scene.AddNewSceneObject(new SceneObjectGroup(part), false);
75 EventWaitHandle waitHandle = new ManualResetEvent(false);
57 MemoryStream archiveWriteStream = new MemoryStream(); 76 MemoryStream archiveWriteStream = new MemoryStream();
58 archiverModule.ArchiveRegion(archiveWriteStream); 77 archiverModule.ArchiveRegion(archiveWriteStream, waitHandle);
78 waitHandle.WaitOne();
59 79
60 // If there are no assets to fetch, then the entire archive region code path will execute in this thread, 80 byte[] archive = archiveWriteStream.ToArray();
61 // so no need to worry about signalling. 81 MemoryStream archiveReadStream = new MemoryStream(archive);
62 MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
63 TarArchiveReader tar = new TarArchiveReader(archiveReadStream); 82 TarArchiveReader tar = new TarArchiveReader(archiveReadStream);
64 83
65 bool gotControlFile = false; 84 bool gotControlFile = false;
85 bool gotObjectFile = false;
86 string expectedObjectFileName = string.Format(
87 "{0}_{1:000}-{2:000}-{3:000}__{4}.xml",
88 partName,
89 Math.Round(groupPosition.X), Math.Round(groupPosition.Y), Math.Round(groupPosition.Z),
90 part.UUID);
66 91
67 string filePath; 92 string filePath;
68 TarArchiveReader.TarEntryType tarEntryType; 93 TarArchiveReader.TarEntryType tarEntryType;
@@ -70,10 +95,19 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver.Tests
70 while (tar.ReadEntry(out filePath, out tarEntryType) != null) 95 while (tar.ReadEntry(out filePath, out tarEntryType) != null)
71 { 96 {
72 if (ArchiveConstants.CONTROL_FILE_PATH == filePath) 97 if (ArchiveConstants.CONTROL_FILE_PATH == filePath)
98 {
73 gotControlFile = true; 99 gotControlFile = true;
100 }
101 else if (filePath.StartsWith(ArchiveConstants.OBJECTS_PATH))
102 {
103 string fileName = filePath.Remove(0, ArchiveConstants.OBJECTS_PATH.Length);
104 Assert.That(fileName, Is.EqualTo(expectedObjectFileName));
105 gotObjectFile = true;
106 }
74 } 107 }
75 108
76 Assert.That(gotControlFile, Is.True, "No control file in archive"); 109 Assert.That(gotControlFile, Is.True, "No control file in archive");
110 Assert.That(gotObjectFile, Is.True, "No object file in archive");
77 111
78 // TODO: Test presence of more files and contents of files. 112 // TODO: Test presence of more files and contents of files.
79 } 113 }