* Make it possible to add a request id to load and save oar requests
* This allows specific requests to be identified.0.6.5-rc1
parent
3c338e4e56
commit
63936d442c
|
@ -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;
|
||||
|
||||
/// <value>
|
||||
|
@ -67,19 +68,21 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
|||
/// </summary>
|
||||
private IDictionary<UUID, bool> m_validUserUuids = new Dictionary<UUID, bool>();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -165,7 +168,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
|||
IRegionSerialiserModule serialiser = m_scene.RequestModuleInterface<IRegionSerialiserModule>();
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -58,19 +58,22 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
|||
protected List<SceneObjectGroup> m_sceneObjects;
|
||||
protected Scene m_scene;
|
||||
protected Stream m_saveStream;
|
||||
protected Guid m_requestId;
|
||||
|
||||
public ArchiveWriteRequestExecution(
|
||||
List<SceneObjectGroup> 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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -50,14 +50,16 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
|||
|
||||
protected Scene m_scene;
|
||||
protected Stream m_saveStream;
|
||||
protected Guid m_requestId;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
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_requestId = requestId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -65,10 +67,12 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
|||
/// </summary>
|
||||
/// <param name="scene"></param>
|
||||
/// <param name="saveStream">The stream to which to save data.</param>
|
||||
public ArchiveWriteRequestPreparation(Scene scene, Stream saveStream)
|
||||
/// <param name="requestId">The id associated with this request</param>
|
||||
public ArchiveWriteRequestPreparation(Scene scene, Stream saveStream, Guid requestId)
|
||||
{
|
||||
m_scene = scene;
|
||||
m_saveStream = saveStream;
|
||||
m_requestId = requestId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -129,7 +133,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
|||
m_scene.RequestModuleInterface<ITerrainModule>(),
|
||||
m_scene.RequestModuleInterface<IRegionSerialiserModule>(),
|
||||
m_scene,
|
||||
m_saveStream);
|
||||
m_saveStream,
|
||||
m_requestId);
|
||||
|
||||
new AssetsRequest(assetUuids.Keys, m_scene.CommsManager.AssetCache, awre.ReceivedAllAssets).Execute();
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using log4net;
|
||||
|
@ -62,39 +63,49 @@ 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,9 +115,11 @@ 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();
|
||||
|
@ -122,6 +127,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
|
|||
Monitor.Wait(this, 60000);
|
||||
}
|
||||
|
||||
Assert.That(m_lastRequestId, Is.EqualTo(requestId));
|
||||
|
||||
byte[] archive = archiveWriteStream.ToArray();
|
||||
MemoryStream archiveReadStream = new MemoryStream(archive);
|
||||
TarArchiveReader tar = new TarArchiveReader(archiveReadStream);
|
||||
|
@ -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");
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace OpenSim.Region.Framework.Interfaces
|
||||
|
@ -44,6 +45,17 @@ namespace OpenSim.Region.Framework.Interfaces
|
|||
/// <param name="savePath"></param>
|
||||
void ArchiveRegion(string savePath);
|
||||
|
||||
/// <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>
|
||||
/// <param name="requestId">If supplied, this request Id is later returned in the saved event</param>
|
||||
void ArchiveRegion(string savePath, Guid requestId);
|
||||
|
||||
/// <summary>
|
||||
/// Archive the region to a stream.
|
||||
/// </summary>
|
||||
|
@ -52,7 +64,8 @@ namespace OpenSim.Region.Framework.Interfaces
|
|||
/// the EventManager.OnOarFileSaved event.
|
||||
///
|
||||
/// <param name="saveStream"></param>
|
||||
void ArchiveRegion(Stream saveStream);
|
||||
/// <param name="requestId">If supplied, this request Id is later returned in the saved event</param>
|
||||
void ArchiveRegion(Stream saveStream, Guid requestId);
|
||||
|
||||
/// <summary>
|
||||
/// Dearchive the given region archive. This replaces the existing scene.
|
||||
|
@ -74,7 +87,8 @@ namespace OpenSim.Region.Framework.Interfaces
|
|||
/// If true, the loaded region merges with the existing one rather than replacing it. Any terrain or region
|
||||
/// settings in the archive will be ignored.
|
||||
/// </param>
|
||||
void DearchiveRegion(string loadPath, bool merge);
|
||||
/// <param name="requestId">If supplied, this request Id is later returned in the saved event</param>
|
||||
void DearchiveRegion(string loadPath, bool merge, Guid requestId);
|
||||
|
||||
/// <summary>
|
||||
/// Dearchive a region from a stream. This replaces the existing scene.
|
||||
|
@ -96,6 +110,7 @@ namespace OpenSim.Region.Framework.Interfaces
|
|||
/// If true, the loaded region merges with the existing one rather than replacing it. Any terrain or region
|
||||
/// settings in the archive will be ignored.
|
||||
/// </param>
|
||||
void DearchiveRegion(Stream loadStream, bool merge);
|
||||
/// <param name="requestId">If supplied, this request Id is later returned in the saved event</param>
|
||||
void DearchiveRegion(Stream loadStream, bool merge, Guid requestId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -279,14 +279,16 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
/// the scripts may not have started yet
|
||||
/// Message is non empty string if there were problems loading the oar file
|
||||
/// </summary>
|
||||
public delegate void OarFileLoaded(string message);
|
||||
public delegate void OarFileLoaded(Guid guid, 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
|
||||
/// If a guid was supplied on the original call to identify, the request, this is returned. Otherwise
|
||||
/// Guid.Empty is returned.
|
||||
/// </summary>
|
||||
public delegate void OarFileSaved(string message);
|
||||
public delegate void OarFileSaved(Guid guid, string message);
|
||||
public event OarFileSaved OnOarFileSaved;
|
||||
|
||||
/// <summary>
|
||||
|
@ -968,18 +970,18 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
return 6;
|
||||
}
|
||||
|
||||
public void TriggerOarFileLoaded(string message)
|
||||
public void TriggerOarFileLoaded(Guid requestId, string message)
|
||||
{
|
||||
handlerOarFileLoaded = OnOarFileLoaded;
|
||||
if (handlerOarFileLoaded != null)
|
||||
handlerOarFileLoaded(message);
|
||||
handlerOarFileLoaded(requestId, message);
|
||||
}
|
||||
|
||||
public void TriggerOarFileSaved(string message)
|
||||
public void TriggerOarFileSaved(Guid requestId, string message)
|
||||
{
|
||||
handlerOarFileSaved = OnOarFileSaved;
|
||||
if (handlerOarFileSaved != null)
|
||||
handlerOarFileSaved(message);
|
||||
handlerOarFileSaved(requestId, message);
|
||||
}
|
||||
|
||||
public void TriggerEmptyScriptCompileQueue(int numScriptsFailed, string message)
|
||||
|
|
|
@ -76,13 +76,13 @@ namespace OpenSim.Region.CoreModules.Scripting.RegionReady
|
|||
{
|
||||
if (m_enabled)
|
||||
{
|
||||
m_log.Info("[RegionReady] Enabled");
|
||||
m_log.Info("[RegionReady]: Enabled");
|
||||
m_scene.EventManager.OnEmptyScriptCompileQueue += new EventManager.EmptyScriptCompileQueue(OnEmptyScriptCompileQueue);
|
||||
m_scene.EventManager.OnOarFileLoaded += new EventManager.OarFileLoaded(OnOarFileLoaded);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.Info("[RegionReady] Disabled");
|
||||
m_log.Info("[RegionReady]: Disabled");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -129,20 +129,20 @@ namespace OpenSim.Region.CoreModules.Scripting.RegionReady
|
|||
c.Sender = null;
|
||||
c.SenderUUID = UUID.Zero;
|
||||
|
||||
m_log.InfoFormat("[RegionReady] Region \"{0}\" is ready: \"{1}\" on channel {2}",
|
||||
m_log.InfoFormat("[RegionReady]: Region \"{0}\" is ready: \"{1}\" on channel {2}",
|
||||
m_scene.RegionInfo.RegionName, c.Message, m_channelNotify);
|
||||
m_scene.EventManager.TriggerOnChatBroadcast(this, c);
|
||||
}
|
||||
}
|
||||
|
||||
void OnOarFileLoaded(string message)
|
||||
void OnOarFileLoaded(Guid requestId, string message)
|
||||
{
|
||||
m_oarFileLoading = true;
|
||||
if (message==String.Empty)
|
||||
{
|
||||
m_lastOarLoadedOk = true;
|
||||
} else {
|
||||
m_log.InfoFormat("[RegionReady] Oar file load errors: {0}", message);
|
||||
m_log.InfoFormat("[RegionReady]: Oar file load errors: {0}", message);
|
||||
m_lastOarLoadedOk = false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue