aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment
diff options
context:
space:
mode:
authorJustin Clarke Casey2009-01-23 17:07:37 +0000
committerJustin Clarke Casey2009-01-23 17:07:37 +0000
commitddff7ab20e32664e09f06668f6e6250ea3b3abf7 (patch)
tree6dd80617df340bb3a9cff3d922c8809d7c4413ba /OpenSim/Region/Environment
parent* Adds a synchronous jpeg decode for pre-caching purposes (diff)
downloadopensim-SC-ddff7ab20e32664e09f06668f6e6250ea3b3abf7.zip
opensim-SC-ddff7ab20e32664e09f06668f6e6250ea3b3abf7.tar.gz
opensim-SC-ddff7ab20e32664e09f06668f6e6250ea3b3abf7.tar.bz2
opensim-SC-ddff7ab20e32664e09f06668f6e6250ea3b3abf7.tar.xz
* Add direct stream loading and saving methods to the archive module.
* The async stream method does not yet signal completion to interested calling code
Diffstat (limited to 'OpenSim/Region/Environment')
-rw-r--r--OpenSim/Region/Environment/Interfaces/IRegionArchiverModule.cs19
-rw-r--r--OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs23
-rw-r--r--OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestExecution.cs12
-rw-r--r--OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestPreparation.cs26
-rw-r--r--OpenSim/Region/Environment/Modules/World/Archiver/ArchiverModule.cs28
-rw-r--r--OpenSim/Region/Environment/Modules/World/Archiver/Tests/ArchiverTests.cs12
6 files changed, 84 insertions, 36 deletions
diff --git a/OpenSim/Region/Environment/Interfaces/IRegionArchiverModule.cs b/OpenSim/Region/Environment/Interfaces/IRegionArchiverModule.cs
index 11eea20..7db784e 100644
--- a/OpenSim/Region/Environment/Interfaces/IRegionArchiverModule.cs
+++ b/OpenSim/Region/Environment/Interfaces/IRegionArchiverModule.cs
@@ -25,6 +25,8 @@
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
28using System.IO;
29
28namespace OpenSim.Region.Environment.Interfaces 30namespace OpenSim.Region.Environment.Interfaces
29{ 31{
30 /// <summary> 32 /// <summary>
@@ -39,9 +41,26 @@ namespace OpenSim.Region.Environment.Interfaces
39 void ArchiveRegion(string savePath); 41 void ArchiveRegion(string savePath);
40 42
41 /// <summary> 43 /// <summary>
44 /// Archive the region to a stream.
45 /// </summary>
46 ///
47 /// This may be a little problematic to use right now since saves happen asynchronously and there is not yet
48 /// a mechanism to signal completion to the caller (possibly other than continually checking whether the
49 /// stream has any data in it). TODO: Address this.
50 ///
51 /// <param name="saveStream"></param>
52 void ArchiveRegion(Stream saveStream);
53
54 /// <summary>
42 /// Dearchive the given region archive into the scene 55 /// Dearchive the given region archive into the scene
43 /// </summary> 56 /// </summary>
44 /// <param name="loadPath"></param> 57 /// <param name="loadPath"></param>
45 void DearchiveRegion(string loadPath); 58 void DearchiveRegion(string loadPath);
59
60 /// <summary>
61 /// Dearchive a region from a stream
62 /// </summary>
63 /// <param name="loadStream"></param>
64 void DearchiveRegion(Stream loadStream);
46 } 65 }
47} 66}
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 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.IO; 30using System.IO;
31using System.IO.Compression;
32using System.Reflection; 31using System.Reflection;
33using System.Xml; 32using System.Xml;
34using OpenMetaverse; 33using 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;
33using OpenSim.Region.Environment.Scenes; 33using OpenSim.Region.Environment.Scenes;
34using System; 34using System;
35using System.Collections.Generic; 35using System.Collections.Generic;
36using System.IO;
37using System.IO.Compression;
36using System.Reflection; 38using System.Reflection;
37//using System.Text;
38using System.Text.RegularExpressions; 39using System.Text.RegularExpressions;
39using System.Threading; 40using System.Threading;
40using OpenMetaverse; 41using 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
28using OpenSim.Framework.Communications.Cache;
29using OpenSim.Region.Environment.Interfaces;
30using OpenSim.Region.Environment.Modules.World.Serialiser;
31using OpenSim.Region.Environment.Scenes;
32using System.Collections.Generic; 28using System.Collections.Generic;
29using System.IO;
33using System.Reflection; 30using System.Reflection;
34using OpenMetaverse; 31using OpenMetaverse;
35using log4net; 32using log4net;
36using Nini.Config; 33using Nini.Config;
34using OpenSim.Framework.Communications.Cache;
35using OpenSim.Region.Environment.Interfaces;
36using OpenSim.Region.Environment.Modules.World.Serialiser;
37using OpenSim.Region.Environment.Scenes;
37 38
38namespace OpenSim.Region.Environment.Modules.World.Archiver 39namespace 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
28using NUnit.Framework; 28using NUnit.Framework;
29using OpenSim.Region.Environment.Modules.World.Archiver;
29 30
30namespace OpenSim.Region.Environment.Modules.World.Archiver 31namespace 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 }