* 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 day0.6.3-post-fixes
parent
13a5243d76
commit
2c2f10e156
|
@ -26,7 +26,6 @@
|
|||
*/
|
||||
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
|
||||
namespace OpenSim.Region.Environment.Interfaces
|
||||
{
|
||||
|
@ -38,6 +37,10 @@ namespace OpenSim.Region.Environment.Interfaces
|
|||
/// <summary>
|
||||
/// Archive the region to the given path
|
||||
/// </summary>
|
||||
///
|
||||
/// This method occurs asynchronously. If you want notification of when it has completed then subscribe to
|
||||
/// the EventManager.OnOarFileSaved event.
|
||||
///
|
||||
/// <param name="savePath"></param>
|
||||
void ArchiveRegion(string savePath);
|
||||
|
||||
|
@ -45,21 +48,27 @@ namespace OpenSim.Region.Environment.Interfaces
|
|||
/// Archive the region to a stream.
|
||||
/// </summary>
|
||||
///
|
||||
/// This method occurs asynchronously. If you want notification of when it has completed then subscribe to
|
||||
/// the EventManager.OnOarFileSaved event.
|
||||
///
|
||||
/// <param name="saveStream"></param>
|
||||
/// <param name="waitHandle">
|
||||
/// Pass in a wait handle if you want to be signalled when the operation completes.
|
||||
/// </param>
|
||||
void ArchiveRegion(Stream saveStream, EventWaitHandle waitHandle);
|
||||
void ArchiveRegion(Stream saveStream);
|
||||
|
||||
/// <summary>
|
||||
/// Dearchive the given region archive into the scene
|
||||
/// </summary>
|
||||
///
|
||||
/// If you want notification of when it has completed then subscribe to the EventManager.OnOarFileLoaded event.
|
||||
///
|
||||
/// <param name="loadPath"></param>
|
||||
void DearchiveRegion(string loadPath);
|
||||
|
||||
/// <summary>
|
||||
/// Dearchive a region from a stream
|
||||
/// Dearchive a region from a stream.
|
||||
/// </summary>
|
||||
///
|
||||
/// If you want notification of when it has completed then subscribe to the EventManager.OnOarFileLoaded event.
|
||||
///
|
||||
/// <param name="loadStream"></param>
|
||||
void DearchiveRegion(Stream loadStream);
|
||||
}
|
||||
|
|
|
@ -233,8 +233,8 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
|
|||
{
|
||||
sceneObject.CreateScriptInstances(0, true, m_scene.DefaultScriptEngine, 0);
|
||||
}
|
||||
m_scene.EventManager.TriggerOarFileLoaded(m_errorMessage);
|
||||
|
||||
m_scene.EventManager.TriggerOarFileLoaded(m_errorMessage);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -29,7 +29,6 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using System.Xml;
|
||||
using OpenMetaverse;
|
||||
using log4net;
|
||||
|
@ -56,27 +55,25 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
|
|||
protected ITerrainModule m_terrainModule;
|
||||
protected IRegionSerialiserModule m_serialiser;
|
||||
protected List<SceneObjectGroup> m_sceneObjects;
|
||||
protected RegionInfo m_regionInfo;
|
||||
protected Scene m_scene;
|
||||
protected Stream m_saveStream;
|
||||
protected EventWaitHandle m_signalWhenDoneEvent;
|
||||
|
||||
public ArchiveWriteRequestExecution(
|
||||
List<SceneObjectGroup> sceneObjects,
|
||||
ITerrainModule terrainModule,
|
||||
IRegionSerialiserModule serialiser,
|
||||
RegionInfo regionInfo,
|
||||
Stream saveStream,
|
||||
EventWaitHandle signalWhenDoneEvent)
|
||||
Scene scene,
|
||||
Stream saveStream)
|
||||
{
|
||||
m_sceneObjects = sceneObjects;
|
||||
m_terrainModule = terrainModule;
|
||||
m_serialiser = serialiser;
|
||||
m_regionInfo = regionInfo;
|
||||
m_scene = scene;
|
||||
m_saveStream = saveStream;
|
||||
m_signalWhenDoneEvent = signalWhenDoneEvent;
|
||||
}
|
||||
|
||||
protected internal void ReceivedAllAssets(IDictionary<UUID, AssetBase> assetsFound, ICollection<UUID> assetsNotFoundUuids)
|
||||
protected internal void ReceivedAllAssets(
|
||||
IDictionary<UUID, AssetBase> assetsFound, ICollection<UUID> assetsNotFoundUuids)
|
||||
{
|
||||
foreach (UUID uuid in assetsNotFoundUuids)
|
||||
{
|
||||
|
@ -95,11 +92,14 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
|
|||
archive.AddFile(ArchiveConstants.CONTROL_FILE_PATH, Create0p2ControlFile());
|
||||
|
||||
// Write out region settings
|
||||
string settingsPath = String.Format("{0}{1}.xml", ArchiveConstants.SETTINGS_PATH, m_regionInfo.RegionName);
|
||||
archive.AddFile(settingsPath, RegionSettingsSerializer.Serialize(m_regionInfo.RegionSettings));
|
||||
string settingsPath
|
||||
= String.Format("{0}{1}.xml", ArchiveConstants.SETTINGS_PATH, m_scene.RegionInfo.RegionName);
|
||||
archive.AddFile(settingsPath, RegionSettingsSerializer.Serialize(m_scene.RegionInfo.RegionSettings));
|
||||
|
||||
// Write out terrain
|
||||
string terrainPath = String.Format("{0}{1}.r32", ArchiveConstants.TERRAINS_PATH, m_regionInfo.RegionName);
|
||||
string terrainPath
|
||||
= String.Format("{0}{1}.r32", ArchiveConstants.TERRAINS_PATH, m_scene.RegionInfo.RegionName);
|
||||
|
||||
MemoryStream ms = new MemoryStream();
|
||||
m_terrainModule.SaveToStream(terrainPath, ms);
|
||||
archive.AddFile(terrainPath, ms.ToArray());
|
||||
|
@ -129,10 +129,9 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
|
|||
|
||||
archive.WriteTar(m_saveStream);
|
||||
|
||||
m_log.InfoFormat("[ARCHIVER]: Wrote out OpenSimulator archive for {0}", m_regionInfo.RegionName);
|
||||
m_log.InfoFormat("[ARCHIVER]: Wrote out OpenSimulator archive for {0}", m_scene.RegionInfo.RegionName);
|
||||
|
||||
if (m_signalWhenDoneEvent != null)
|
||||
m_signalWhenDoneEvent.Set();
|
||||
m_scene.EventManager.TriggerOarFileSaved(String.Empty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -53,7 +53,6 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
|
|||
|
||||
protected Scene m_scene;
|
||||
protected Stream m_saveStream;
|
||||
protected EventWaitHandle m_signalWhenDoneEvent;
|
||||
|
||||
/// <summary>
|
||||
/// 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
|
|||
/// </summary>
|
||||
/// <param name="scene"></param>
|
||||
/// <param name="saveStream">The stream to which to save data.</param>
|
||||
public ArchiveWriteRequestPreparation(Scene scene, Stream saveStream, EventWaitHandle signalWhenDoneEvent)
|
||||
public ArchiveWriteRequestPreparation(Scene scene, Stream saveStream)
|
||||
{
|
||||
m_scene = scene;
|
||||
m_saveStream = saveStream;
|
||||
m_signalWhenDoneEvent = signalWhenDoneEvent;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -326,9 +324,8 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
|
|||
sceneObjects,
|
||||
m_scene.RequestModuleInterface<ITerrainModule>(),
|
||||
m_scene.RequestModuleInterface<IRegionSerialiserModule>(),
|
||||
m_scene.RegionInfo,
|
||||
m_saveStream,
|
||||
m_signalWhenDoneEvent);
|
||||
m_scene,
|
||||
m_saveStream);
|
||||
|
||||
new AssetsRequest(assetUuids.Keys, m_scene.AssetCache, awre.ReceivedAllAssets).Execute();
|
||||
}
|
||||
|
|
|
@ -73,9 +73,9 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
|
|||
new ArchiveWriteRequestPreparation(m_scene, savePath).ArchiveRegion();
|
||||
}
|
||||
|
||||
public void ArchiveRegion(Stream saveStream, EventWaitHandle waitHandle)
|
||||
public void ArchiveRegion(Stream saveStream)
|
||||
{
|
||||
new ArchiveWriteRequestPreparation(m_scene, saveStream, waitHandle).ArchiveRegion();
|
||||
new ArchiveWriteRequestPreparation(m_scene, saveStream).ArchiveRegion();
|
||||
}
|
||||
|
||||
public void DearchiveRegion(string loadPath)
|
||||
|
|
|
@ -44,13 +44,20 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver.Tests
|
|||
[TestFixture]
|
||||
public class ArchiverTests
|
||||
{
|
||||
private EventWaitHandle m_waitHandle = new AutoResetEvent(false);
|
||||
|
||||
private void SaveCompleted(string errorMessage)
|
||||
{
|
||||
m_waitHandle.Set();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test saving a V0.2 OpenSim Region Archive.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestSaveOarV0p2()
|
||||
{
|
||||
//log4net.Config.XmlConfigurator.Configure();
|
||||
log4net.Config.XmlConfigurator.Configure();
|
||||
|
||||
ArchiverModule archiverModule = new ArchiverModule();
|
||||
SerialiserModule serialiserModule = new SerialiserModule();
|
||||
|
@ -72,10 +79,11 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver.Tests
|
|||
part.Name = partName;
|
||||
|
||||
scene.AddNewSceneObject(new SceneObjectGroup(part), false);
|
||||
EventWaitHandle waitHandle = new ManualResetEvent(false);
|
||||
MemoryStream archiveWriteStream = new MemoryStream();
|
||||
archiverModule.ArchiveRegion(archiveWriteStream, waitHandle);
|
||||
waitHandle.WaitOne(60000, true);
|
||||
|
||||
scene.EventManager.OnOarFileSaved += SaveCompleted;
|
||||
archiverModule.ArchiveRegion(archiveWriteStream);
|
||||
m_waitHandle.WaitOne(60000, true);
|
||||
|
||||
byte[] archive = archiveWriteStream.ToArray();
|
||||
MemoryStream archiveReadStream = new MemoryStream(archive);
|
||||
|
|
|
@ -274,6 +274,13 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
public delegate void OarFileLoaded(string message);
|
||||
public event OarFileLoaded OnOarFileLoaded;
|
||||
|
||||
/// <summary>
|
||||
/// Called when an oar file has finished saving
|
||||
/// Message is non empty string if there were problems saving the oar file
|
||||
/// </summary>
|
||||
public delegate void OarFileSaved(string message);
|
||||
public event OarFileSaved OnOarFileSaved;
|
||||
|
||||
/// <summary>
|
||||
/// Called when the script compile queue becomes empty
|
||||
/// Returns the number of scripts which failed to start
|
||||
|
@ -415,6 +422,8 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
private OnSetRootAgentSceneDelegate handlerSetRootAgentScene = null;
|
||||
|
||||
private OarFileLoaded handlerOarFileLoaded = null;
|
||||
private OarFileSaved handlerOarFileSaved = null;
|
||||
|
||||
private EmptyScriptCompileQueue handlerEmptyScriptCompileQueue = null;
|
||||
|
||||
public void TriggerGetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID)
|
||||
|
@ -926,6 +935,13 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
handlerOarFileLoaded(message);
|
||||
}
|
||||
|
||||
public void TriggerOarFileSaved(string message)
|
||||
{
|
||||
handlerOarFileSaved = OnOarFileSaved;
|
||||
if (handlerOarFileSaved != null)
|
||||
handlerOarFileSaved(message);
|
||||
}
|
||||
|
||||
public void TriggerEmptyScriptCompileQueue(int numScriptsFailed, string message)
|
||||
{
|
||||
handlerEmptyScriptCompileQueue = OnEmptyScriptCompileQueue;
|
||||
|
|
Loading…
Reference in New Issue