* Add direct stream loading and saving methods to the archive module.
* The async stream method does not yet signal completion to interested calling code0.6.3-post-fixes
parent
74df9f9c81
commit
ddff7ab20e
|
@ -25,6 +25,8 @@
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace OpenSim.Region.Environment.Interfaces
|
namespace OpenSim.Region.Environment.Interfaces
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -38,10 +40,27 @@ namespace OpenSim.Region.Environment.Interfaces
|
||||||
/// <param name="savePath"></param>
|
/// <param name="savePath"></param>
|
||||||
void ArchiveRegion(string savePath);
|
void ArchiveRegion(string savePath);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Archive the region to a stream.
|
||||||
|
/// </summary>
|
||||||
|
///
|
||||||
|
/// This may be a little problematic to use right now since saves happen asynchronously and there is not yet
|
||||||
|
/// a mechanism to signal completion to the caller (possibly other than continually checking whether the
|
||||||
|
/// stream has any data in it). TODO: Address this.
|
||||||
|
///
|
||||||
|
/// <param name="saveStream"></param>
|
||||||
|
void ArchiveRegion(Stream saveStream);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Dearchive the given region archive into the scene
|
/// Dearchive the given region archive into the scene
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="loadPath"></param>
|
/// <param name="loadPath"></param>
|
||||||
void DearchiveRegion(string loadPath);
|
void DearchiveRegion(string loadPath);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Dearchive a region from a stream
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="loadStream"></param>
|
||||||
|
void DearchiveRegion(Stream loadStream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
|
||||||
private static System.Text.ASCIIEncoding m_asciiEncoding = new System.Text.ASCIIEncoding();
|
private static System.Text.ASCIIEncoding m_asciiEncoding = new System.Text.ASCIIEncoding();
|
||||||
|
|
||||||
private Scene m_scene;
|
private Scene m_scene;
|
||||||
private string m_loadPath;
|
private Stream m_loadStream;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Used to cache lookups for valid uuids.
|
/// Used to cache lookups for valid uuids.
|
||||||
|
@ -62,12 +62,19 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
|
||||||
public ArchiveReadRequest(Scene scene, string loadPath)
|
public ArchiveReadRequest(Scene scene, string loadPath)
|
||||||
{
|
{
|
||||||
m_scene = scene;
|
m_scene = scene;
|
||||||
m_loadPath = loadPath;
|
m_loadStream = new GZipStream(GetStream(loadPath), CompressionMode.Decompress);
|
||||||
|
|
||||||
DearchiveRegion();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DearchiveRegion()
|
public ArchiveReadRequest(Scene scene, Stream loadStream)
|
||||||
|
{
|
||||||
|
m_scene = scene;
|
||||||
|
m_loadStream = loadStream;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Dearchive the region embodied in this request.
|
||||||
|
/// </summary>
|
||||||
|
public void DearchiveRegion()
|
||||||
{
|
{
|
||||||
// The same code can handle dearchiving 0.1 and 0.2 OpenSim Archive versions
|
// The same code can handle dearchiving 0.1 and 0.2 OpenSim Archive versions
|
||||||
DearchiveRegion0DotStar();
|
DearchiveRegion0DotStar();
|
||||||
|
@ -75,9 +82,7 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
|
||||||
|
|
||||||
private void DearchiveRegion0DotStar()
|
private void DearchiveRegion0DotStar()
|
||||||
{
|
{
|
||||||
TarArchiveReader archive
|
TarArchiveReader archive = new TarArchiveReader(m_loadStream);
|
||||||
= new TarArchiveReader(
|
|
||||||
new GZipStream(GetStream(m_loadPath), CompressionMode.Decompress));
|
|
||||||
|
|
||||||
//AssetsDearchiver dearchiver = new AssetsDearchiver(m_scene.AssetCache);
|
//AssetsDearchiver dearchiver = new AssetsDearchiver(m_scene.AssetCache);
|
||||||
|
|
||||||
|
@ -368,7 +373,6 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Resolve path to a working FileStream
|
/// Resolve path to a working FileStream
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
private Stream GetStream(string path)
|
private Stream GetStream(string path)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -392,7 +396,6 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
|
||||||
// OK, now we know we have an HTTP URI to work with
|
// OK, now we know we have an HTTP URI to work with
|
||||||
|
|
||||||
return URIFetch(uri);
|
return URIFetch(uri);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.IO.Compression;
|
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
|
@ -57,20 +56,20 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
|
||||||
protected IRegionSerialiserModule m_serialiser;
|
protected IRegionSerialiserModule m_serialiser;
|
||||||
protected List<SceneObjectGroup> m_sceneObjects;
|
protected List<SceneObjectGroup> m_sceneObjects;
|
||||||
protected RegionInfo m_regionInfo;
|
protected RegionInfo m_regionInfo;
|
||||||
protected string m_savePath;
|
protected Stream m_saveStream;
|
||||||
|
|
||||||
public ArchiveWriteRequestExecution(
|
public ArchiveWriteRequestExecution(
|
||||||
List<SceneObjectGroup> sceneObjects,
|
List<SceneObjectGroup> sceneObjects,
|
||||||
ITerrainModule terrainModule,
|
ITerrainModule terrainModule,
|
||||||
IRegionSerialiserModule serialiser,
|
IRegionSerialiserModule serialiser,
|
||||||
RegionInfo regionInfo,
|
RegionInfo regionInfo,
|
||||||
string savePath)
|
Stream saveStream)
|
||||||
{
|
{
|
||||||
m_sceneObjects = sceneObjects;
|
m_sceneObjects = sceneObjects;
|
||||||
m_terrainModule = terrainModule;
|
m_terrainModule = terrainModule;
|
||||||
m_serialiser = serialiser;
|
m_serialiser = serialiser;
|
||||||
m_regionInfo = regionInfo;
|
m_regionInfo = regionInfo;
|
||||||
m_savePath = savePath;
|
m_saveStream = saveStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected internal void ReceivedAllAssets(IDictionary<UUID, AssetBase> assetsFound, ICollection<UUID> assetsNotFoundUuids)
|
protected internal void ReceivedAllAssets(IDictionary<UUID, AssetBase> assetsFound, ICollection<UUID> assetsNotFoundUuids)
|
||||||
|
@ -124,9 +123,10 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
|
||||||
AssetsArchiver assetsArchiver = new AssetsArchiver(assetsFound);
|
AssetsArchiver assetsArchiver = new AssetsArchiver(assetsFound);
|
||||||
assetsArchiver.Archive(archive);
|
assetsArchiver.Archive(archive);
|
||||||
|
|
||||||
archive.WriteTar(new GZipStream(new FileStream(m_savePath, FileMode.Create), CompressionMode.Compress));
|
archive.WriteTar(m_saveStream);
|
||||||
|
|
||||||
m_log.InfoFormat("[ARCHIVER]: Wrote out OpenSimulator archive {0}", m_savePath);
|
// m_log.InfoFormat("[ARCHIVER]: Wrote out OpenSimulator archive for {0}", m_regionInfo.RegionName);
|
||||||
|
m_log.InfoFormat("[ARCHIVER]: Wrote out OpenSimulator archive for {0}", m_saveStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -33,8 +33,9 @@ using OpenSim.Region.Environment.Modules.World.Terrain;
|
||||||
using OpenSim.Region.Environment.Scenes;
|
using OpenSim.Region.Environment.Scenes;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.IO.Compression;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
//using System.Text;
|
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
|
@ -51,7 +52,7 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
protected Scene m_scene;
|
protected Scene m_scene;
|
||||||
protected string m_savePath;
|
protected Stream m_saveStream;
|
||||||
|
|
||||||
/// <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
|
||||||
|
@ -70,7 +71,18 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
|
||||||
public ArchiveWriteRequestPreparation(Scene scene, string savePath)
|
public ArchiveWriteRequestPreparation(Scene scene, string savePath)
|
||||||
{
|
{
|
||||||
m_scene = scene;
|
m_scene = scene;
|
||||||
m_savePath = savePath;
|
m_saveStream = new GZipStream(new FileStream(savePath, FileMode.Create), CompressionMode.Compress);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="scene"></param>
|
||||||
|
/// <param name="saveStream">The stream to which to save data.</param>
|
||||||
|
public ArchiveWriteRequestPreparation(Scene scene, Stream saveStream)
|
||||||
|
{
|
||||||
|
m_scene = scene;
|
||||||
|
m_saveStream = saveStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -257,6 +269,10 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Archive the region requested.
|
||||||
|
/// </summary>
|
||||||
|
/// <exception cref="System.IO.IOException">if there was an io problem with creating the file</exception>
|
||||||
public void ArchiveRegion()
|
public void ArchiveRegion()
|
||||||
{
|
{
|
||||||
Dictionary<UUID, int> assetUuids = new Dictionary<UUID, int>();
|
Dictionary<UUID, int> assetUuids = new Dictionary<UUID, int>();
|
||||||
|
@ -309,7 +325,7 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
|
||||||
m_scene.RequestModuleInterface<ITerrainModule>(),
|
m_scene.RequestModuleInterface<ITerrainModule>(),
|
||||||
m_scene.RequestModuleInterface<IRegionSerialiserModule>(),
|
m_scene.RequestModuleInterface<IRegionSerialiserModule>(),
|
||||||
m_scene.RegionInfo,
|
m_scene.RegionInfo,
|
||||||
m_savePath);
|
m_saveStream);
|
||||||
|
|
||||||
new AssetsRequest(assetUuids.Keys, m_scene.AssetCache, awre.ReceivedAllAssets).Execute();
|
new AssetsRequest(assetUuids.Keys, m_scene.AssetCache, awre.ReceivedAllAssets).Execute();
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,15 +25,16 @@
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using OpenSim.Framework.Communications.Cache;
|
|
||||||
using OpenSim.Region.Environment.Interfaces;
|
|
||||||
using OpenSim.Region.Environment.Modules.World.Serialiser;
|
|
||||||
using OpenSim.Region.Environment.Scenes;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
using log4net;
|
using log4net;
|
||||||
using Nini.Config;
|
using Nini.Config;
|
||||||
|
using OpenSim.Framework.Communications.Cache;
|
||||||
|
using OpenSim.Region.Environment.Interfaces;
|
||||||
|
using OpenSim.Region.Environment.Modules.World.Serialiser;
|
||||||
|
using OpenSim.Region.Environment.Scenes;
|
||||||
|
|
||||||
namespace OpenSim.Region.Environment.Modules.World.Archiver
|
namespace OpenSim.Region.Environment.Modules.World.Archiver
|
||||||
{
|
{
|
||||||
|
@ -44,14 +45,9 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
|
||||||
{
|
{
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Scene to which this module belongs
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="scene"></param>
|
|
||||||
/// <param name="source"></param>
|
|
||||||
private Scene m_scene;
|
private Scene m_scene;
|
||||||
|
|
||||||
public string Name { get { return "ArchiverModule"; } }
|
public string Name { get { return "Archiver Module"; } }
|
||||||
|
|
||||||
public bool IsSharedModule { get { return false; } }
|
public bool IsSharedModule { get { return false; } }
|
||||||
|
|
||||||
|
@ -76,11 +72,21 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
|
||||||
new ArchiveWriteRequestPreparation(m_scene, savePath).ArchiveRegion();
|
new ArchiveWriteRequestPreparation(m_scene, savePath).ArchiveRegion();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ArchiveRegion(Stream saveStream)
|
||||||
|
{
|
||||||
|
new ArchiveWriteRequestPreparation(m_scene, saveStream).ArchiveRegion();
|
||||||
|
}
|
||||||
|
|
||||||
public void DearchiveRegion(string loadPath)
|
public void DearchiveRegion(string loadPath)
|
||||||
{
|
{
|
||||||
m_log.InfoFormat("[SCENE]: Loading archive to region {0} from {1}", m_scene.RegionInfo.RegionName, loadPath);
|
m_log.InfoFormat("[SCENE]: Loading archive to region {0} from {1}", m_scene.RegionInfo.RegionName, loadPath);
|
||||||
|
|
||||||
new ArchiveReadRequest(m_scene, loadPath);
|
new ArchiveReadRequest(m_scene, loadPath).DearchiveRegion();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DearchiveRegion(Stream loadStream)
|
||||||
|
{
|
||||||
|
new ArchiveReadRequest(m_scene, loadStream).DearchiveRegion();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,18 +26,22 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
using OpenSim.Region.Environment.Modules.World.Archiver;
|
||||||
|
|
||||||
namespace OpenSim.Region.Environment.Modules.World.Archiver
|
namespace OpenSim.Region.Environment.Modules.World.Archiver.Tests
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class ArchiverTests
|
public class ArchiverTests
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Test loading a V0.2 OpenSim Region Archive. Does not yet do what it says on the tin
|
/// Test saving a V0.2 OpenSim Region Archive. Does not yet do what it says on the tin
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Test]
|
[Test]
|
||||||
public void TestLoadOarV0p2()
|
public void TestSaveOarV0p2()
|
||||||
{
|
{
|
||||||
|
// Create an archive containing only a terrain
|
||||||
|
//TarArchiveWriter taw = new TarArchiveWriter();
|
||||||
|
|
||||||
//System.Console.WriteLine("wibble");
|
//System.Console.WriteLine("wibble");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
@ -117,8 +118,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
m_localID = localID;
|
m_localID = localID;
|
||||||
m_itemID = itemID;
|
m_itemID = itemID;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false))
|
if (m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false))
|
||||||
m_OSFunctionsEnabled = true;
|
m_OSFunctionsEnabled = true;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue