diff options
Diffstat (limited to 'OpenSim/Region/Environment/Modules/World')
5 files changed, 65 insertions, 36 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs index 9a0f19a..09776a7 100644 --- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs | |||
@@ -52,7 +52,7 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
52 | private static System.Text.ASCIIEncoding m_asciiEncoding = new System.Text.ASCIIEncoding(); | 52 | private static System.Text.ASCIIEncoding m_asciiEncoding = new System.Text.ASCIIEncoding(); |
53 | 53 | ||
54 | private Scene m_scene; | 54 | private Scene m_scene; |
55 | private string m_loadPath; | 55 | private Stream m_loadStream; |
56 | 56 | ||
57 | /// <summary> | 57 | /// <summary> |
58 | /// Used to cache lookups for valid uuids. | 58 | /// Used to cache lookups for valid uuids. |
@@ -62,12 +62,19 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
62 | public ArchiveReadRequest(Scene scene, string loadPath) | 62 | public ArchiveReadRequest(Scene scene, string loadPath) |
63 | { | 63 | { |
64 | m_scene = scene; | 64 | m_scene = scene; |
65 | m_loadPath = loadPath; | 65 | m_loadStream = new GZipStream(GetStream(loadPath), CompressionMode.Decompress); |
66 | |||
67 | DearchiveRegion(); | ||
68 | } | 66 | } |
67 | |||
68 | public ArchiveReadRequest(Scene scene, Stream loadStream) | ||
69 | { | ||
70 | m_scene = scene; | ||
71 | m_loadStream = loadStream; | ||
72 | } | ||
69 | 73 | ||
70 | private void DearchiveRegion() | 74 | /// <summary> |
75 | /// Dearchive the region embodied in this request. | ||
76 | /// </summary> | ||
77 | public void DearchiveRegion() | ||
71 | { | 78 | { |
72 | // The same code can handle dearchiving 0.1 and 0.2 OpenSim Archive versions | 79 | // The same code can handle dearchiving 0.1 and 0.2 OpenSim Archive versions |
73 | DearchiveRegion0DotStar(); | 80 | DearchiveRegion0DotStar(); |
@@ -75,9 +82,7 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
75 | 82 | ||
76 | private void DearchiveRegion0DotStar() | 83 | private void DearchiveRegion0DotStar() |
77 | { | 84 | { |
78 | TarArchiveReader archive | 85 | TarArchiveReader archive = new TarArchiveReader(m_loadStream); |
79 | = new TarArchiveReader( | ||
80 | new GZipStream(GetStream(m_loadPath), CompressionMode.Decompress)); | ||
81 | 86 | ||
82 | //AssetsDearchiver dearchiver = new AssetsDearchiver(m_scene.AssetCache); | 87 | //AssetsDearchiver dearchiver = new AssetsDearchiver(m_scene.AssetCache); |
83 | 88 | ||
@@ -368,7 +373,6 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
368 | /// <summary> | 373 | /// <summary> |
369 | /// Resolve path to a working FileStream | 374 | /// Resolve path to a working FileStream |
370 | /// </summary> | 375 | /// </summary> |
371 | |||
372 | private Stream GetStream(string path) | 376 | private Stream GetStream(string path) |
373 | { | 377 | { |
374 | try | 378 | try |
@@ -392,7 +396,6 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
392 | // OK, now we know we have an HTTP URI to work with | 396 | // OK, now we know we have an HTTP URI to work with |
393 | 397 | ||
394 | return URIFetch(uri); | 398 | return URIFetch(uri); |
395 | |||
396 | } | 399 | } |
397 | } | 400 | } |
398 | } | 401 | } |
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestExecution.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestExecution.cs index b410e55..36d5eb5 100644 --- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestExecution.cs +++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestExecution.cs | |||
@@ -28,7 +28,6 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.IO; | 30 | using System.IO; |
31 | using System.IO.Compression; | ||
32 | using System.Reflection; | 31 | using System.Reflection; |
33 | using System.Xml; | 32 | using System.Xml; |
34 | using OpenMetaverse; | 33 | using OpenMetaverse; |
@@ -57,20 +56,20 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
57 | protected IRegionSerialiserModule m_serialiser; | 56 | protected IRegionSerialiserModule m_serialiser; |
58 | protected List<SceneObjectGroup> m_sceneObjects; | 57 | protected List<SceneObjectGroup> m_sceneObjects; |
59 | protected RegionInfo m_regionInfo; | 58 | protected RegionInfo m_regionInfo; |
60 | protected string m_savePath; | 59 | protected Stream m_saveStream; |
61 | 60 | ||
62 | public ArchiveWriteRequestExecution( | 61 | public ArchiveWriteRequestExecution( |
63 | List<SceneObjectGroup> sceneObjects, | 62 | List<SceneObjectGroup> sceneObjects, |
64 | ITerrainModule terrainModule, | 63 | ITerrainModule terrainModule, |
65 | IRegionSerialiserModule serialiser, | 64 | IRegionSerialiserModule serialiser, |
66 | RegionInfo regionInfo, | 65 | RegionInfo regionInfo, |
67 | string savePath) | 66 | Stream saveStream) |
68 | { | 67 | { |
69 | m_sceneObjects = sceneObjects; | 68 | m_sceneObjects = sceneObjects; |
70 | m_terrainModule = terrainModule; | 69 | m_terrainModule = terrainModule; |
71 | m_serialiser = serialiser; | 70 | m_serialiser = serialiser; |
72 | m_regionInfo = regionInfo; | 71 | m_regionInfo = regionInfo; |
73 | m_savePath = savePath; | 72 | m_saveStream = saveStream; |
74 | } | 73 | } |
75 | 74 | ||
76 | protected internal void ReceivedAllAssets(IDictionary<UUID, AssetBase> assetsFound, ICollection<UUID> assetsNotFoundUuids) | 75 | protected internal void ReceivedAllAssets(IDictionary<UUID, AssetBase> assetsFound, ICollection<UUID> assetsNotFoundUuids) |
@@ -124,9 +123,10 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
124 | AssetsArchiver assetsArchiver = new AssetsArchiver(assetsFound); | 123 | AssetsArchiver assetsArchiver = new AssetsArchiver(assetsFound); |
125 | assetsArchiver.Archive(archive); | 124 | assetsArchiver.Archive(archive); |
126 | 125 | ||
127 | archive.WriteTar(new GZipStream(new FileStream(m_savePath, FileMode.Create), CompressionMode.Compress)); | 126 | archive.WriteTar(m_saveStream); |
128 | 127 | ||
129 | m_log.InfoFormat("[ARCHIVER]: Wrote out OpenSimulator archive {0}", m_savePath); | 128 | // m_log.InfoFormat("[ARCHIVER]: Wrote out OpenSimulator archive for {0}", m_regionInfo.RegionName); |
129 | m_log.InfoFormat("[ARCHIVER]: Wrote out OpenSimulator archive for {0}", m_saveStream); | ||
130 | } | 130 | } |
131 | 131 | ||
132 | /// <summary> | 132 | /// <summary> |
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestPreparation.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestPreparation.cs index 7c1d015..e9005ae 100644 --- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestPreparation.cs +++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestPreparation.cs | |||
@@ -33,8 +33,9 @@ using OpenSim.Region.Environment.Modules.World.Terrain; | |||
33 | using OpenSim.Region.Environment.Scenes; | 33 | using OpenSim.Region.Environment.Scenes; |
34 | using System; | 34 | using System; |
35 | using System.Collections.Generic; | 35 | using System.Collections.Generic; |
36 | using System.IO; | ||
37 | using System.IO.Compression; | ||
36 | using System.Reflection; | 38 | using System.Reflection; |
37 | //using System.Text; | ||
38 | using System.Text.RegularExpressions; | 39 | using System.Text.RegularExpressions; |
39 | using System.Threading; | 40 | using System.Threading; |
40 | using OpenMetaverse; | 41 | using OpenMetaverse; |
@@ -51,7 +52,7 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
51 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 52 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
52 | 53 | ||
53 | protected Scene m_scene; | 54 | protected Scene m_scene; |
54 | protected string m_savePath; | 55 | protected Stream m_saveStream; |
55 | 56 | ||
56 | /// <summary> | 57 | /// <summary> |
57 | /// Used as a temporary store of an asset which represents an object. This can be a null if no appropriate | 58 | /// Used as a temporary store of an asset which represents an object. This can be a null if no appropriate |
@@ -70,8 +71,19 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
70 | public ArchiveWriteRequestPreparation(Scene scene, string savePath) | 71 | public ArchiveWriteRequestPreparation(Scene scene, string savePath) |
71 | { | 72 | { |
72 | m_scene = scene; | 73 | m_scene = scene; |
73 | m_savePath = savePath; | 74 | m_saveStream = new GZipStream(new FileStream(savePath, FileMode.Create), CompressionMode.Compress); |
74 | } | 75 | } |
76 | |||
77 | /// <summary> | ||
78 | /// Constructor. | ||
79 | /// </summary> | ||
80 | /// <param name="scene"></param> | ||
81 | /// <param name="saveStream">The stream to which to save data.</param> | ||
82 | public ArchiveWriteRequestPreparation(Scene scene, Stream saveStream) | ||
83 | { | ||
84 | m_scene = scene; | ||
85 | m_saveStream = saveStream; | ||
86 | } | ||
75 | 87 | ||
76 | /// <summary> | 88 | /// <summary> |
77 | /// The callback made when we request the asset for an object from the asset service. | 89 | /// The callback made when we request the asset for an object from the asset service. |
@@ -257,8 +269,12 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
257 | } | 269 | } |
258 | } | 270 | } |
259 | 271 | ||
272 | /// <summary> | ||
273 | /// Archive the region requested. | ||
274 | /// </summary> | ||
275 | /// <exception cref="System.IO.IOException">if there was an io problem with creating the file</exception> | ||
260 | public void ArchiveRegion() | 276 | public void ArchiveRegion() |
261 | { | 277 | { |
262 | Dictionary<UUID, int> assetUuids = new Dictionary<UUID, int>(); | 278 | Dictionary<UUID, int> assetUuids = new Dictionary<UUID, int>(); |
263 | 279 | ||
264 | List<EntityBase> entities = m_scene.GetEntities(); | 280 | List<EntityBase> entities = m_scene.GetEntities(); |
@@ -309,7 +325,7 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
309 | m_scene.RequestModuleInterface<ITerrainModule>(), | 325 | m_scene.RequestModuleInterface<ITerrainModule>(), |
310 | m_scene.RequestModuleInterface<IRegionSerialiserModule>(), | 326 | m_scene.RequestModuleInterface<IRegionSerialiserModule>(), |
311 | m_scene.RegionInfo, | 327 | m_scene.RegionInfo, |
312 | m_savePath); | 328 | m_saveStream); |
313 | 329 | ||
314 | new AssetsRequest(assetUuids.Keys, m_scene.AssetCache, awre.ReceivedAllAssets).Execute(); | 330 | new AssetsRequest(assetUuids.Keys, m_scene.AssetCache, awre.ReceivedAllAssets).Execute(); |
315 | } | 331 | } |
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiverModule.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiverModule.cs index de60472..f07185c 100644 --- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiverModule.cs +++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiverModule.cs | |||
@@ -25,15 +25,16 @@ | |||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using OpenSim.Framework.Communications.Cache; | ||
29 | using OpenSim.Region.Environment.Interfaces; | ||
30 | using OpenSim.Region.Environment.Modules.World.Serialiser; | ||
31 | using OpenSim.Region.Environment.Scenes; | ||
32 | using System.Collections.Generic; | 28 | using System.Collections.Generic; |
29 | using System.IO; | ||
33 | using System.Reflection; | 30 | using System.Reflection; |
34 | using OpenMetaverse; | 31 | using OpenMetaverse; |
35 | using log4net; | 32 | using log4net; |
36 | using Nini.Config; | 33 | using Nini.Config; |
34 | using OpenSim.Framework.Communications.Cache; | ||
35 | using OpenSim.Region.Environment.Interfaces; | ||
36 | using OpenSim.Region.Environment.Modules.World.Serialiser; | ||
37 | using OpenSim.Region.Environment.Scenes; | ||
37 | 38 | ||
38 | namespace OpenSim.Region.Environment.Modules.World.Archiver | 39 | namespace OpenSim.Region.Environment.Modules.World.Archiver |
39 | { | 40 | { |
@@ -44,14 +45,9 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
44 | { | 45 | { |
45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
46 | 47 | ||
47 | /// <summary> | ||
48 | /// Scene to which this module belongs | ||
49 | /// </summary> | ||
50 | /// <param name="scene"></param> | ||
51 | /// <param name="source"></param> | ||
52 | private Scene m_scene; | 48 | private Scene m_scene; |
53 | 49 | ||
54 | public string Name { get { return "ArchiverModule"; } } | 50 | public string Name { get { return "Archiver Module"; } } |
55 | 51 | ||
56 | public bool IsSharedModule { get { return false; } } | 52 | public bool IsSharedModule { get { return false; } } |
57 | 53 | ||
@@ -75,12 +71,22 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
75 | 71 | ||
76 | new ArchiveWriteRequestPreparation(m_scene, savePath).ArchiveRegion(); | 72 | new ArchiveWriteRequestPreparation(m_scene, savePath).ArchiveRegion(); |
77 | } | 73 | } |
74 | |||
75 | public void ArchiveRegion(Stream saveStream) | ||
76 | { | ||
77 | new ArchiveWriteRequestPreparation(m_scene, saveStream).ArchiveRegion(); | ||
78 | } | ||
78 | 79 | ||
79 | public void DearchiveRegion(string loadPath) | 80 | public void DearchiveRegion(string loadPath) |
80 | { | 81 | { |
81 | m_log.InfoFormat("[SCENE]: Loading archive to region {0} from {1}", m_scene.RegionInfo.RegionName, loadPath); | 82 | m_log.InfoFormat("[SCENE]: Loading archive to region {0} from {1}", m_scene.RegionInfo.RegionName, loadPath); |
82 | 83 | ||
83 | new ArchiveReadRequest(m_scene, loadPath); | 84 | new ArchiveReadRequest(m_scene, loadPath).DearchiveRegion(); |
85 | } | ||
86 | |||
87 | public void DearchiveRegion(Stream loadStream) | ||
88 | { | ||
89 | new ArchiveReadRequest(m_scene, loadStream).DearchiveRegion(); | ||
84 | } | 90 | } |
85 | } | 91 | } |
86 | } | 92 | } |
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/Environment/Modules/World/Archiver/Tests/ArchiverTests.cs index c2f0d63..149293d 100644 --- a/OpenSim/Region/Environment/Modules/World/Archiver/Tests/ArchiverTests.cs +++ b/OpenSim/Region/Environment/Modules/World/Archiver/Tests/ArchiverTests.cs | |||
@@ -26,18 +26,22 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using NUnit.Framework; | 28 | using NUnit.Framework; |
29 | using OpenSim.Region.Environment.Modules.World.Archiver; | ||
29 | 30 | ||
30 | namespace OpenSim.Region.Environment.Modules.World.Archiver | 31 | namespace OpenSim.Region.Environment.Modules.World.Archiver.Tests |
31 | { | 32 | { |
32 | [TestFixture] | 33 | [TestFixture] |
33 | public class ArchiverTests | 34 | public class ArchiverTests |
34 | { | 35 | { |
35 | /// <summary> | 36 | /// <summary> |
36 | /// Test loading a V0.2 OpenSim Region Archive. Does not yet do what it says on the tin | 37 | /// Test saving a V0.2 OpenSim Region Archive. Does not yet do what it says on the tin |
37 | /// </summary> | 38 | /// </summary> |
38 | [Test] | 39 | [Test] |
39 | public void TestLoadOarV0p2() | 40 | public void TestSaveOarV0p2() |
40 | { | 41 | { |
42 | // Create an archive containing only a terrain | ||
43 | //TarArchiveWriter taw = new TarArchiveWriter(); | ||
44 | |||
41 | //System.Console.WriteLine("wibble"); | 45 | //System.Console.WriteLine("wibble"); |
42 | } | 46 | } |
43 | } | 47 | } |