* 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.IO;
|
||||||
using System.Threading;
|
|
||||||
|
|
||||||
namespace OpenSim.Region.Environment.Interfaces
|
namespace OpenSim.Region.Environment.Interfaces
|
||||||
{
|
{
|
||||||
|
@ -38,6 +37,10 @@ namespace OpenSim.Region.Environment.Interfaces
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Archive the region to the given path
|
/// Archive the region to the given path
|
||||||
/// </summary>
|
/// </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>
|
/// <param name="savePath"></param>
|
||||||
void ArchiveRegion(string savePath);
|
void ArchiveRegion(string savePath);
|
||||||
|
|
||||||
|
@ -45,21 +48,27 @@ namespace OpenSim.Region.Environment.Interfaces
|
||||||
/// Archive the region to a stream.
|
/// Archive the region to a stream.
|
||||||
/// </summary>
|
/// </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="saveStream"></param>
|
||||||
/// <param name="waitHandle">
|
void ArchiveRegion(Stream saveStream);
|
||||||
/// Pass in a wait handle if you want to be signalled when the operation completes.
|
|
||||||
/// </param>
|
|
||||||
void ArchiveRegion(Stream saveStream, EventWaitHandle waitHandle);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Dearchive the given region archive into the scene
|
/// Dearchive the given region archive into the scene
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
///
|
||||||
|
/// If you want notification of when it has completed then subscribe to the EventManager.OnOarFileLoaded event.
|
||||||
|
///
|
||||||
/// <param name="loadPath"></param>
|
/// <param name="loadPath"></param>
|
||||||
void DearchiveRegion(string loadPath);
|
void DearchiveRegion(string loadPath);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Dearchive a region from a stream
|
/// Dearchive a region from a stream.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
///
|
||||||
|
/// If you want notification of when it has completed then subscribe to the EventManager.OnOarFileLoaded event.
|
||||||
|
///
|
||||||
/// <param name="loadStream"></param>
|
/// <param name="loadStream"></param>
|
||||||
void DearchiveRegion(Stream loadStream);
|
void DearchiveRegion(Stream loadStream);
|
||||||
}
|
}
|
||||||
|
|
|
@ -233,8 +233,8 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
|
||||||
{
|
{
|
||||||
sceneObject.CreateScriptInstances(0, true, m_scene.DefaultScriptEngine, 0);
|
sceneObject.CreateScriptInstances(0, true, m_scene.DefaultScriptEngine, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_scene.EventManager.TriggerOarFileLoaded(m_errorMessage);
|
m_scene.EventManager.TriggerOarFileLoaded(m_errorMessage);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -29,7 +29,6 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Threading;
|
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
using log4net;
|
using log4net;
|
||||||
|
@ -45,7 +44,7 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
|
||||||
/// Method called when all the necessary assets for an archive request have been received.
|
/// Method called when all the necessary assets for an archive request have been received.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public delegate void AssetsRequestCallback(IDictionary<UUID, AssetBase> assetsFound, ICollection<UUID> assetsNotFoundUuids);
|
public delegate void AssetsRequestCallback(IDictionary<UUID, AssetBase> assetsFound, ICollection<UUID> assetsNotFoundUuids);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Execute the write of an archive once we have received all the necessary data
|
/// Execute the write of an archive once we have received all the necessary data
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -56,27 +55,25 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
|
||||||
protected ITerrainModule m_terrainModule;
|
protected ITerrainModule m_terrainModule;
|
||||||
protected IRegionSerialiserModule m_serialiser;
|
protected IRegionSerialiserModule m_serialiser;
|
||||||
protected List<SceneObjectGroup> m_sceneObjects;
|
protected List<SceneObjectGroup> m_sceneObjects;
|
||||||
protected RegionInfo m_regionInfo;
|
protected Scene m_scene;
|
||||||
protected Stream m_saveStream;
|
protected Stream m_saveStream;
|
||||||
protected EventWaitHandle m_signalWhenDoneEvent;
|
|
||||||
|
|
||||||
public ArchiveWriteRequestExecution(
|
public ArchiveWriteRequestExecution(
|
||||||
List<SceneObjectGroup> sceneObjects,
|
List<SceneObjectGroup> sceneObjects,
|
||||||
ITerrainModule terrainModule,
|
ITerrainModule terrainModule,
|
||||||
IRegionSerialiserModule serialiser,
|
IRegionSerialiserModule serialiser,
|
||||||
RegionInfo regionInfo,
|
Scene scene,
|
||||||
Stream saveStream,
|
Stream saveStream)
|
||||||
EventWaitHandle signalWhenDoneEvent)
|
|
||||||
{
|
{
|
||||||
m_sceneObjects = sceneObjects;
|
m_sceneObjects = sceneObjects;
|
||||||
m_terrainModule = terrainModule;
|
m_terrainModule = terrainModule;
|
||||||
m_serialiser = serialiser;
|
m_serialiser = serialiser;
|
||||||
m_regionInfo = regionInfo;
|
m_scene = scene;
|
||||||
m_saveStream = saveStream;
|
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)
|
foreach (UUID uuid in assetsNotFoundUuids)
|
||||||
{
|
{
|
||||||
|
@ -95,11 +92,14 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
|
||||||
archive.AddFile(ArchiveConstants.CONTROL_FILE_PATH, Create0p2ControlFile());
|
archive.AddFile(ArchiveConstants.CONTROL_FILE_PATH, Create0p2ControlFile());
|
||||||
|
|
||||||
// Write out region settings
|
// Write out region settings
|
||||||
string settingsPath = String.Format("{0}{1}.xml", ArchiveConstants.SETTINGS_PATH, m_regionInfo.RegionName);
|
string settingsPath
|
||||||
archive.AddFile(settingsPath, RegionSettingsSerializer.Serialize(m_regionInfo.RegionSettings));
|
= String.Format("{0}{1}.xml", ArchiveConstants.SETTINGS_PATH, m_scene.RegionInfo.RegionName);
|
||||||
|
archive.AddFile(settingsPath, RegionSettingsSerializer.Serialize(m_scene.RegionInfo.RegionSettings));
|
||||||
|
|
||||||
// Write out terrain
|
// 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();
|
MemoryStream ms = new MemoryStream();
|
||||||
m_terrainModule.SaveToStream(terrainPath, ms);
|
m_terrainModule.SaveToStream(terrainPath, ms);
|
||||||
archive.AddFile(terrainPath, ms.ToArray());
|
archive.AddFile(terrainPath, ms.ToArray());
|
||||||
|
@ -129,10 +129,9 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
|
||||||
|
|
||||||
archive.WriteTar(m_saveStream);
|
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_scene.EventManager.TriggerOarFileSaved(String.Empty);
|
||||||
m_signalWhenDoneEvent.Set();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -53,7 +53,6 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
|
||||||
|
|
||||||
protected Scene m_scene;
|
protected Scene m_scene;
|
||||||
protected Stream m_saveStream;
|
protected Stream m_saveStream;
|
||||||
protected EventWaitHandle m_signalWhenDoneEvent;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Used as a temporary store of an asset which represents an object. This can be a null if no appropriate
|
/// 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>
|
/// </summary>
|
||||||
/// <param name="scene"></param>
|
/// <param name="scene"></param>
|
||||||
/// <param name="saveStream">The stream to which to save data.</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_scene = scene;
|
||||||
m_saveStream = saveStream;
|
m_saveStream = saveStream;
|
||||||
m_signalWhenDoneEvent = signalWhenDoneEvent;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -326,9 +324,8 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
|
||||||
sceneObjects,
|
sceneObjects,
|
||||||
m_scene.RequestModuleInterface<ITerrainModule>(),
|
m_scene.RequestModuleInterface<ITerrainModule>(),
|
||||||
m_scene.RequestModuleInterface<IRegionSerialiserModule>(),
|
m_scene.RequestModuleInterface<IRegionSerialiserModule>(),
|
||||||
m_scene.RegionInfo,
|
m_scene,
|
||||||
m_saveStream,
|
m_saveStream);
|
||||||
m_signalWhenDoneEvent);
|
|
||||||
|
|
||||||
new AssetsRequest(assetUuids.Keys, m_scene.AssetCache, awre.ReceivedAllAssets).Execute();
|
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();
|
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)
|
public void DearchiveRegion(string loadPath)
|
||||||
|
|
|
@ -44,13 +44,20 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver.Tests
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class ArchiverTests
|
public class ArchiverTests
|
||||||
{
|
{
|
||||||
|
private EventWaitHandle m_waitHandle = new AutoResetEvent(false);
|
||||||
|
|
||||||
|
private void SaveCompleted(string errorMessage)
|
||||||
|
{
|
||||||
|
m_waitHandle.Set();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Test saving a V0.2 OpenSim Region Archive.
|
/// Test saving a V0.2 OpenSim Region Archive.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Test]
|
[Test]
|
||||||
public void TestSaveOarV0p2()
|
public void TestSaveOarV0p2()
|
||||||
{
|
{
|
||||||
//log4net.Config.XmlConfigurator.Configure();
|
log4net.Config.XmlConfigurator.Configure();
|
||||||
|
|
||||||
ArchiverModule archiverModule = new ArchiverModule();
|
ArchiverModule archiverModule = new ArchiverModule();
|
||||||
SerialiserModule serialiserModule = new SerialiserModule();
|
SerialiserModule serialiserModule = new SerialiserModule();
|
||||||
|
@ -71,11 +78,12 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver.Tests
|
||||||
ownerId, shape, groupPosition, rotationOffset, offsetPosition);
|
ownerId, shape, groupPosition, rotationOffset, offsetPosition);
|
||||||
part.Name = partName;
|
part.Name = partName;
|
||||||
|
|
||||||
scene.AddNewSceneObject(new SceneObjectGroup(part), false);
|
scene.AddNewSceneObject(new SceneObjectGroup(part), false);
|
||||||
EventWaitHandle waitHandle = new ManualResetEvent(false);
|
|
||||||
MemoryStream archiveWriteStream = new MemoryStream();
|
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();
|
byte[] archive = archiveWriteStream.ToArray();
|
||||||
MemoryStream archiveReadStream = new MemoryStream(archive);
|
MemoryStream archiveReadStream = new MemoryStream(archive);
|
||||||
|
|
|
@ -273,6 +273,13 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public delegate void OarFileLoaded(string message);
|
public delegate void OarFileLoaded(string message);
|
||||||
public event OarFileLoaded OnOarFileLoaded;
|
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>
|
/// <summary>
|
||||||
/// Called when the script compile queue becomes empty
|
/// Called when the script compile queue becomes empty
|
||||||
|
@ -415,6 +422,8 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
private OnSetRootAgentSceneDelegate handlerSetRootAgentScene = null;
|
private OnSetRootAgentSceneDelegate handlerSetRootAgentScene = null;
|
||||||
|
|
||||||
private OarFileLoaded handlerOarFileLoaded = null;
|
private OarFileLoaded handlerOarFileLoaded = null;
|
||||||
|
private OarFileSaved handlerOarFileSaved = null;
|
||||||
|
|
||||||
private EmptyScriptCompileQueue handlerEmptyScriptCompileQueue = null;
|
private EmptyScriptCompileQueue handlerEmptyScriptCompileQueue = null;
|
||||||
|
|
||||||
public void TriggerGetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID)
|
public void TriggerGetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID)
|
||||||
|
@ -925,6 +934,13 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
if (handlerOarFileLoaded != null)
|
if (handlerOarFileLoaded != null)
|
||||||
handlerOarFileLoaded(message);
|
handlerOarFileLoaded(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void TriggerOarFileSaved(string message)
|
||||||
|
{
|
||||||
|
handlerOarFileSaved = OnOarFileSaved;
|
||||||
|
if (handlerOarFileSaved != null)
|
||||||
|
handlerOarFileSaved(message);
|
||||||
|
}
|
||||||
|
|
||||||
public void TriggerEmptyScriptCompileQueue(int numScriptsFailed, string message)
|
public void TriggerEmptyScriptCompileQueue(int numScriptsFailed, string message)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue