From dbd2b4523319758c8c0e093a89be8bcb9b2e4ee1 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 23 Jan 2009 20:38:44 +0000 Subject: * Write a simple archive loading test which doesn't actually do any testing yet apart from not blow up --- .../Framework/Communications/Cache/AssetCache.cs | 10 +++------ .../Modules/World/Archiver/ArchiveReadRequest.cs | 11 +++++++++ .../World/Archiver/ArchiveWriteRequestExecution.cs | 6 ++--- .../Modules/World/Archiver/TarArchiveWriter.cs | 2 +- .../Modules/World/Archiver/Tests/ArchiverTests.cs | 26 +++++++++++++++++++++- 5 files changed, 43 insertions(+), 12 deletions(-) diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 436f175..653597b 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -41,16 +41,12 @@ namespace OpenSim.Framework.Communications.Cache /// /// Manages local cache of assets and their sending to viewers. - /// + /// + /// /// This class actually encapsulates two largely separate mechanisms. One mechanism fetches assets either /// synchronously or async and passes the data back to the requester. The second mechanism fetches assets and /// sends packetised data directly back to the client. The only point where they meet is AssetReceived() and - /// AssetNotFound(), which means they do share the same asset and texture caches. - /// - /// TODO: Assets in this cache are effectively immortal (they are never disposed of through old age). - /// This is not a huge problem at the moment since other memory use usually dwarfs that used by assets - /// but it's something to bear in mind. - /// + /// AssetNotFound(), which means they do share the same asset and texture caches.I agr public class AssetCache : IAssetReceiver { protected ICache m_memcache = new SimpleMemoryCache(); diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs index bd58e7c..ce293e4 100644 --- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs @@ -276,6 +276,17 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver asset.Data = data; m_scene.AssetCache.AddAsset(asset); + + /** + * Create layers on decode for image assets. This is likely to significantly increase the time to load archives so + * it might be best done when dearchive takes place on a separate thread + if (asset.Type=AssetType.Texture) + { + IJ2KDecoder cacheLayerDecode = scene.RequestModuleInterface(); + if (cacheLayerDecode != null) + cacheLayerDecode.syncdecode(asset.FullID, asset.Data); + } + */ return true; } diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestExecution.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestExecution.cs index 0c75951..bade121 100644 --- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestExecution.cs +++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestExecution.cs @@ -88,7 +88,7 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver TarArchiveWriter archive = new TarArchiveWriter(); // Write out control file - archive.AddFile(ArchiveConstants.CONTROL_FILE_PATH, CreateControlFile()); + archive.AddFile(ArchiveConstants.CONTROL_FILE_PATH, Create0p2ControlFile()); // Write out region settings string settingsPath = String.Format("{0}{1}.xml", ArchiveConstants.SETTINGS_PATH, m_regionInfo.RegionName); @@ -129,10 +129,10 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver } /// - /// Create the control file for this archive + /// Create the control file for a 0.2 version archive /// /// - protected string CreateControlFile() + public static string Create0p2ControlFile() { StringWriter sw = new StringWriter(); XmlTextWriter xtw = new XmlTextWriter(sw); diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveWriter.cs b/OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveWriter.cs index d4a8a46..55edec0 100644 --- a/OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveWriter.cs +++ b/OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveWriter.cs @@ -32,7 +32,7 @@ using System.Text; //using System.Reflection; //using log4net; -namespace OpenSim.Region.Environment +namespace OpenSim.Region.Environment.Modules.World.Archiver { /// /// Temporary code to produce a tar archive in tar v7 format diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/Environment/Modules/World/Archiver/Tests/ArchiverTests.cs index db296b0..4f4f53c 100644 --- a/OpenSim/Region/Environment/Modules/World/Archiver/Tests/ArchiverTests.cs +++ b/OpenSim/Region/Environment/Modules/World/Archiver/Tests/ArchiverTests.cs @@ -40,7 +40,7 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver.Tests public class ArchiverTests { /// - /// Test saving a V0.2 OpenSim Region Archive. Does not yet do what it says on the tin + /// Test saving a V0.2 OpenSim Region Archive. /// [Test] public void TestSaveOarV0p2() @@ -76,5 +76,29 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver.Tests // TODO: Test presence of more files and contents of files. } + + /// + /// Test loading a V0.2 OpenSim Region Archive. Does not yet do what it says on the tin. + /// + [Test] + public void TestLoadOarV0p2() + { + MemoryStream archiveWriteStream = new MemoryStream(); + TarArchiveWriter tar = new TarArchiveWriter(); + + tar.AddFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestExecution.Create0p2ControlFile()); + tar.WriteTar(archiveWriteStream); + + MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); + + ArchiverModule archiverModule = new ArchiverModule(); + + Scene scene = SceneSetupHelpers.SetupScene(); + SceneSetupHelpers.SetupSceneModules(scene, archiverModule); + + archiverModule.DearchiveRegion(archiveReadStream); + + // TODO: Okay, so nothing is tested yet apart from the fact that it doesn't blow up + } } } \ No newline at end of file -- cgit v1.1