From 63936d442ca7e6bdc0f09a5e974c57b3b5726353 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 15 Apr 2009 19:12:37 +0000 Subject: * Make it possible to add a request id to load and save oar requests * This allows specific requests to be identified. --- .../World/Archiver/ArchiveReadRequest.cs | 14 ++++++----- .../World/Archiver/ArchiveWriteRequestExecution.cs | 7 ++++-- .../Archiver/ArchiveWriteRequestPreparation.cs | 13 +++++++---- .../CoreModules/World/Archiver/ArchiverModule.cs | 27 +++++++++++++++------- .../World/Archiver/Tests/ArchiverTests.cs | 13 ++++++++--- 5 files changed, 51 insertions(+), 23 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index 3f6e822..1e57be0 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs @@ -55,6 +55,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver private Scene m_scene; private Stream m_loadStream; + private Guid m_requestId; private string m_errorMessage; /// @@ -67,19 +68,21 @@ namespace OpenSim.Region.CoreModules.World.Archiver /// private IDictionary m_validUserUuids = new Dictionary(); - public ArchiveReadRequest(Scene scene, string loadPath, bool merge) + public ArchiveReadRequest(Scene scene, string loadPath, bool merge, Guid requestId) { m_scene = scene; m_loadStream = new GZipStream(GetStream(loadPath), CompressionMode.Decompress); m_errorMessage = String.Empty; m_merge = merge; + m_requestId = requestId; } - public ArchiveReadRequest(Scene scene, Stream loadStream, bool merge) + public ArchiveReadRequest(Scene scene, Stream loadStream, bool merge, Guid requestId) { m_scene = scene; m_loadStream = loadStream; m_merge = merge; + m_requestId = requestId; } /// @@ -141,7 +144,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver m_log.ErrorFormat( "[ARCHIVER]: Error loading oar file. Exception was: {0}", e); m_errorMessage += e.ToString(); - m_scene.EventManager.TriggerOarFileLoaded(m_errorMessage); + m_scene.EventManager.TriggerOarFileLoaded(m_requestId, m_errorMessage); return; } @@ -163,8 +166,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver m_log.InfoFormat("[ARCHIVER]: Loading {0} scene objects. Please wait.", serialisedSceneObjects.Count); IRegionSerialiserModule serialiser = m_scene.RequestModuleInterface(); - int sceneObjectsLoadedCount = 0; - + int sceneObjectsLoadedCount = 0; foreach (string serialisedSceneObject in serialisedSceneObjects) { @@ -247,7 +249,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver m_log.InfoFormat("[ARCHIVER]: Successfully loaded archive"); - m_scene.EventManager.TriggerOarFileLoaded(m_errorMessage); + m_scene.EventManager.TriggerOarFileLoaded(m_requestId, m_errorMessage); } /// diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs index 85391b3..943d9d1 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs @@ -58,19 +58,22 @@ namespace OpenSim.Region.CoreModules.World.Archiver protected List m_sceneObjects; protected Scene m_scene; protected Stream m_saveStream; + protected Guid m_requestId; public ArchiveWriteRequestExecution( List sceneObjects, ITerrainModule terrainModule, IRegionSerialiserModule serialiser, Scene scene, - Stream saveStream) + Stream saveStream, + Guid requestId) { m_sceneObjects = sceneObjects; m_terrainModule = terrainModule; m_serialiser = serialiser; m_scene = scene; m_saveStream = saveStream; + m_requestId = requestId; } protected internal void ReceivedAllAssets( @@ -140,7 +143,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver m_log.InfoFormat("[ARCHIVER]: Wrote out OpenSimulator archive for {0}", m_scene.RegionInfo.RegionName); - m_scene.EventManager.TriggerOarFileSaved(String.Empty); + m_scene.EventManager.TriggerOarFileSaved(m_requestId, String.Empty); } /// diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs index accf7e4..a6ad24c 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs @@ -50,14 +50,16 @@ namespace OpenSim.Region.CoreModules.World.Archiver protected Scene m_scene; protected Stream m_saveStream; + protected Guid m_requestId; /// /// Constructor /// - public ArchiveWriteRequestPreparation(Scene scene, string savePath) + public ArchiveWriteRequestPreparation(Scene scene, string savePath, Guid requestId) { m_scene = scene; - m_saveStream = new GZipStream(new FileStream(savePath, FileMode.Create), CompressionMode.Compress); + m_saveStream = new GZipStream(new FileStream(savePath, FileMode.Create), CompressionMode.Compress); + m_requestId = requestId; } /// @@ -65,10 +67,12 @@ namespace OpenSim.Region.CoreModules.World.Archiver /// /// /// The stream to which to save data. - public ArchiveWriteRequestPreparation(Scene scene, Stream saveStream) + /// The id associated with this request + public ArchiveWriteRequestPreparation(Scene scene, Stream saveStream, Guid requestId) { m_scene = scene; m_saveStream = saveStream; + m_requestId = requestId; } /// @@ -129,7 +133,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver m_scene.RequestModuleInterface(), m_scene.RequestModuleInterface(), m_scene, - m_saveStream); + m_saveStream, + m_requestId); new AssetsRequest(assetUuids.Keys, m_scene.CommsManager.AssetCache, awre.ReceivedAllAssets).Execute(); } diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs index dd67027..b6e2d31 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs @@ -25,6 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using System; using System.IO; using System.Reflection; using log4net; @@ -63,38 +64,48 @@ namespace OpenSim.Region.CoreModules.World.Archiver public void ArchiveRegion(string savePath) { + ArchiveRegion(savePath, Guid.Empty); + } + + public void ArchiveRegion(string savePath, Guid requestId) + { m_log.InfoFormat( "[ARCHIVER]: Writing archive for region {0} to {1}", m_scene.RegionInfo.RegionName, savePath); - new ArchiveWriteRequestPreparation(m_scene, savePath).ArchiveRegion(); + new ArchiveWriteRequestPreparation(m_scene, savePath, requestId).ArchiveRegion(); } public void ArchiveRegion(Stream saveStream) { - new ArchiveWriteRequestPreparation(m_scene, saveStream).ArchiveRegion(); + ArchiveRegion(saveStream, Guid.Empty); } + + public void ArchiveRegion(Stream saveStream, Guid requestId) + { + new ArchiveWriteRequestPreparation(m_scene, saveStream, requestId).ArchiveRegion(); + } public void DearchiveRegion(string loadPath) { - DearchiveRegion(loadPath, false); + DearchiveRegion(loadPath, false, Guid.Empty); } - public void DearchiveRegion(string loadPath, bool merge) + public void DearchiveRegion(string loadPath, bool merge, Guid requestId) { m_log.InfoFormat( "[ARCHIVER]: Loading archive to region {0} from {1}", m_scene.RegionInfo.RegionName, loadPath); - new ArchiveReadRequest(m_scene, loadPath, merge).DearchiveRegion(); + new ArchiveReadRequest(m_scene, loadPath, merge, requestId).DearchiveRegion(); } public void DearchiveRegion(Stream loadStream) { - DearchiveRegion(loadStream, false); + DearchiveRegion(loadStream, false, Guid.Empty); } - public void DearchiveRegion(Stream loadStream, bool merge) + public void DearchiveRegion(Stream loadStream, bool merge, Guid requestId) { - new ArchiveReadRequest(m_scene, loadStream, merge).DearchiveRegion(); + new ArchiveReadRequest(m_scene, loadStream, merge, requestId).DearchiveRegion(); } } } diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs index 165a607..3ffabbd 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs @@ -47,10 +47,13 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests [TestFixture, LongRunning] public class ArchiverTests { - private void SaveCompleted(string errorMessage) + private Guid m_lastRequestId; + + private void SaveCompleted(Guid requestId, string errorMessage) { lock (this) { + m_lastRequestId = requestId; System.Console.WriteLine("About to pulse ArchiverTests"); Monitor.PulseAll(this); } @@ -112,15 +115,19 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests MemoryStream archiveWriteStream = new MemoryStream(); scene.EventManager.OnOarFileSaved += SaveCompleted; + Guid requestId = new Guid("00000000-0000-0000-0000-808080808080"); + lock (this) { - archiverModule.ArchiveRegion(archiveWriteStream); + archiverModule.ArchiveRegion(archiveWriteStream, requestId); AssetServerBase assetServer = (AssetServerBase)scene.CommsManager.AssetCache.AssetServer; while (assetServer.HasWaitingRequests()) assetServer.ProcessNextRequest(); Monitor.Wait(this, 60000); } + + Assert.That(m_lastRequestId, Is.EqualTo(requestId)); byte[] archive = archiveWriteStream.ToArray(); MemoryStream archiveReadStream = new MemoryStream(archive); @@ -303,7 +310,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests byte[] archive = archiveWriteStream.ToArray(); MemoryStream archiveReadStream = new MemoryStream(archive); - archiverModule.DearchiveRegion(archiveReadStream, true); + archiverModule.DearchiveRegion(archiveReadStream, true, Guid.Empty); SceneObjectPart object1Existing = scene.GetSceneObjectPart(part1Name); Assert.That(object1Existing, Is.Not.Null, "object1 was not present after merge"); -- cgit v1.1