aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules
diff options
context:
space:
mode:
authorJustin Clarke Casey2009-04-15 19:12:37 +0000
committerJustin Clarke Casey2009-04-15 19:12:37 +0000
commit63936d442ca7e6bdc0f09a5e974c57b3b5726353 (patch)
treeadd84f90ce716015e93f9dae721e7876992e6b6c /OpenSim/Region/CoreModules
parentConvert both script engines to new region module format. Add proper unload (diff)
downloadopensim-SC_OLD-63936d442ca7e6bdc0f09a5e974c57b3b5726353.zip
opensim-SC_OLD-63936d442ca7e6bdc0f09a5e974c57b3b5726353.tar.gz
opensim-SC_OLD-63936d442ca7e6bdc0f09a5e974c57b3b5726353.tar.bz2
opensim-SC_OLD-63936d442ca7e6bdc0f09a5e974c57b3b5726353.tar.xz
* Make it possible to add a request id to load and save oar requests
* This allows specific requests to be identified.
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs14
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs7
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs13
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs27
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs13
5 files changed, 51 insertions, 23 deletions
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
index 3f6e822..1e57be0 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
@@ -55,6 +55,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
55 55
56 private Scene m_scene; 56 private Scene m_scene;
57 private Stream m_loadStream; 57 private Stream m_loadStream;
58 private Guid m_requestId;
58 private string m_errorMessage; 59 private string m_errorMessage;
59 60
60 /// <value> 61 /// <value>
@@ -67,19 +68,21 @@ namespace OpenSim.Region.CoreModules.World.Archiver
67 /// </summary> 68 /// </summary>
68 private IDictionary<UUID, bool> m_validUserUuids = new Dictionary<UUID, bool>(); 69 private IDictionary<UUID, bool> m_validUserUuids = new Dictionary<UUID, bool>();
69 70
70 public ArchiveReadRequest(Scene scene, string loadPath, bool merge) 71 public ArchiveReadRequest(Scene scene, string loadPath, bool merge, Guid requestId)
71 { 72 {
72 m_scene = scene; 73 m_scene = scene;
73 m_loadStream = new GZipStream(GetStream(loadPath), CompressionMode.Decompress); 74 m_loadStream = new GZipStream(GetStream(loadPath), CompressionMode.Decompress);
74 m_errorMessage = String.Empty; 75 m_errorMessage = String.Empty;
75 m_merge = merge; 76 m_merge = merge;
77 m_requestId = requestId;
76 } 78 }
77 79
78 public ArchiveReadRequest(Scene scene, Stream loadStream, bool merge) 80 public ArchiveReadRequest(Scene scene, Stream loadStream, bool merge, Guid requestId)
79 { 81 {
80 m_scene = scene; 82 m_scene = scene;
81 m_loadStream = loadStream; 83 m_loadStream = loadStream;
82 m_merge = merge; 84 m_merge = merge;
85 m_requestId = requestId;
83 } 86 }
84 87
85 /// <summary> 88 /// <summary>
@@ -141,7 +144,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
141 m_log.ErrorFormat( 144 m_log.ErrorFormat(
142 "[ARCHIVER]: Error loading oar file. Exception was: {0}", e); 145 "[ARCHIVER]: Error loading oar file. Exception was: {0}", e);
143 m_errorMessage += e.ToString(); 146 m_errorMessage += e.ToString();
144 m_scene.EventManager.TriggerOarFileLoaded(m_errorMessage); 147 m_scene.EventManager.TriggerOarFileLoaded(m_requestId, m_errorMessage);
145 return; 148 return;
146 } 149 }
147 150
@@ -163,8 +166,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
163 m_log.InfoFormat("[ARCHIVER]: Loading {0} scene objects. Please wait.", serialisedSceneObjects.Count); 166 m_log.InfoFormat("[ARCHIVER]: Loading {0} scene objects. Please wait.", serialisedSceneObjects.Count);
164 167
165 IRegionSerialiserModule serialiser = m_scene.RequestModuleInterface<IRegionSerialiserModule>(); 168 IRegionSerialiserModule serialiser = m_scene.RequestModuleInterface<IRegionSerialiserModule>();
166 int sceneObjectsLoadedCount = 0; 169 int sceneObjectsLoadedCount = 0;
167
168 170
169 foreach (string serialisedSceneObject in serialisedSceneObjects) 171 foreach (string serialisedSceneObject in serialisedSceneObjects)
170 { 172 {
@@ -247,7 +249,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
247 249
248 m_log.InfoFormat("[ARCHIVER]: Successfully loaded archive"); 250 m_log.InfoFormat("[ARCHIVER]: Successfully loaded archive");
249 251
250 m_scene.EventManager.TriggerOarFileLoaded(m_errorMessage); 252 m_scene.EventManager.TriggerOarFileLoaded(m_requestId, m_errorMessage);
251 } 253 }
252 254
253 /// <summary> 255 /// <summary>
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs
index 85391b3..943d9d1 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs
@@ -58,19 +58,22 @@ namespace OpenSim.Region.CoreModules.World.Archiver
58 protected List<SceneObjectGroup> m_sceneObjects; 58 protected List<SceneObjectGroup> m_sceneObjects;
59 protected Scene m_scene; 59 protected Scene m_scene;
60 protected Stream m_saveStream; 60 protected Stream m_saveStream;
61 protected Guid m_requestId;
61 62
62 public ArchiveWriteRequestExecution( 63 public ArchiveWriteRequestExecution(
63 List<SceneObjectGroup> sceneObjects, 64 List<SceneObjectGroup> sceneObjects,
64 ITerrainModule terrainModule, 65 ITerrainModule terrainModule,
65 IRegionSerialiserModule serialiser, 66 IRegionSerialiserModule serialiser,
66 Scene scene, 67 Scene scene,
67 Stream saveStream) 68 Stream saveStream,
69 Guid requestId)
68 { 70 {
69 m_sceneObjects = sceneObjects; 71 m_sceneObjects = sceneObjects;
70 m_terrainModule = terrainModule; 72 m_terrainModule = terrainModule;
71 m_serialiser = serialiser; 73 m_serialiser = serialiser;
72 m_scene = scene; 74 m_scene = scene;
73 m_saveStream = saveStream; 75 m_saveStream = saveStream;
76 m_requestId = requestId;
74 } 77 }
75 78
76 protected internal void ReceivedAllAssets( 79 protected internal void ReceivedAllAssets(
@@ -140,7 +143,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
140 143
141 m_log.InfoFormat("[ARCHIVER]: Wrote out OpenSimulator archive for {0}", m_scene.RegionInfo.RegionName); 144 m_log.InfoFormat("[ARCHIVER]: Wrote out OpenSimulator archive for {0}", m_scene.RegionInfo.RegionName);
142 145
143 m_scene.EventManager.TriggerOarFileSaved(String.Empty); 146 m_scene.EventManager.TriggerOarFileSaved(m_requestId, String.Empty);
144 } 147 }
145 148
146 /// <summary> 149 /// <summary>
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs
index accf7e4..a6ad24c 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs
@@ -50,14 +50,16 @@ namespace OpenSim.Region.CoreModules.World.Archiver
50 50
51 protected Scene m_scene; 51 protected Scene m_scene;
52 protected Stream m_saveStream; 52 protected Stream m_saveStream;
53 protected Guid m_requestId;
53 54
54 /// <summary> 55 /// <summary>
55 /// Constructor 56 /// Constructor
56 /// </summary> 57 /// </summary>
57 public ArchiveWriteRequestPreparation(Scene scene, string savePath) 58 public ArchiveWriteRequestPreparation(Scene scene, string savePath, Guid requestId)
58 { 59 {
59 m_scene = scene; 60 m_scene = scene;
60 m_saveStream = new GZipStream(new FileStream(savePath, FileMode.Create), CompressionMode.Compress); 61 m_saveStream = new GZipStream(new FileStream(savePath, FileMode.Create), CompressionMode.Compress);
62 m_requestId = requestId;
61 } 63 }
62 64
63 /// <summary> 65 /// <summary>
@@ -65,10 +67,12 @@ namespace OpenSim.Region.CoreModules.World.Archiver
65 /// </summary> 67 /// </summary>
66 /// <param name="scene"></param> 68 /// <param name="scene"></param>
67 /// <param name="saveStream">The stream to which to save data.</param> 69 /// <param name="saveStream">The stream to which to save data.</param>
68 public ArchiveWriteRequestPreparation(Scene scene, Stream saveStream) 70 /// <param name="requestId">The id associated with this request</param>
71 public ArchiveWriteRequestPreparation(Scene scene, Stream saveStream, Guid requestId)
69 { 72 {
70 m_scene = scene; 73 m_scene = scene;
71 m_saveStream = saveStream; 74 m_saveStream = saveStream;
75 m_requestId = requestId;
72 } 76 }
73 77
74 /// <summary> 78 /// <summary>
@@ -129,7 +133,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver
129 m_scene.RequestModuleInterface<ITerrainModule>(), 133 m_scene.RequestModuleInterface<ITerrainModule>(),
130 m_scene.RequestModuleInterface<IRegionSerialiserModule>(), 134 m_scene.RequestModuleInterface<IRegionSerialiserModule>(),
131 m_scene, 135 m_scene,
132 m_saveStream); 136 m_saveStream,
137 m_requestId);
133 138
134 new AssetsRequest(assetUuids.Keys, m_scene.CommsManager.AssetCache, awre.ReceivedAllAssets).Execute(); 139 new AssetsRequest(assetUuids.Keys, m_scene.CommsManager.AssetCache, awre.ReceivedAllAssets).Execute();
135 } 140 }
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs
index dd67027..b6e2d31 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs
@@ -25,6 +25,7 @@
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;
28using System.IO; 29using System.IO;
29using System.Reflection; 30using System.Reflection;
30using log4net; 31using log4net;
@@ -63,38 +64,48 @@ namespace OpenSim.Region.CoreModules.World.Archiver
63 64
64 public void ArchiveRegion(string savePath) 65 public void ArchiveRegion(string savePath)
65 { 66 {
67 ArchiveRegion(savePath, Guid.Empty);
68 }
69
70 public void ArchiveRegion(string savePath, Guid requestId)
71 {
66 m_log.InfoFormat( 72 m_log.InfoFormat(
67 "[ARCHIVER]: Writing archive for region {0} to {1}", m_scene.RegionInfo.RegionName, savePath); 73 "[ARCHIVER]: Writing archive for region {0} to {1}", m_scene.RegionInfo.RegionName, savePath);
68 74
69 new ArchiveWriteRequestPreparation(m_scene, savePath).ArchiveRegion(); 75 new ArchiveWriteRequestPreparation(m_scene, savePath, requestId).ArchiveRegion();
70 } 76 }
71 77
72 public void ArchiveRegion(Stream saveStream) 78 public void ArchiveRegion(Stream saveStream)
73 { 79 {
74 new ArchiveWriteRequestPreparation(m_scene, saveStream).ArchiveRegion(); 80 ArchiveRegion(saveStream, Guid.Empty);
75 } 81 }
82
83 public void ArchiveRegion(Stream saveStream, Guid requestId)
84 {
85 new ArchiveWriteRequestPreparation(m_scene, saveStream, requestId).ArchiveRegion();
86 }
76 87
77 public void DearchiveRegion(string loadPath) 88 public void DearchiveRegion(string loadPath)
78 { 89 {
79 DearchiveRegion(loadPath, false); 90 DearchiveRegion(loadPath, false, Guid.Empty);
80 } 91 }
81 92
82 public void DearchiveRegion(string loadPath, bool merge) 93 public void DearchiveRegion(string loadPath, bool merge, Guid requestId)
83 { 94 {
84 m_log.InfoFormat( 95 m_log.InfoFormat(
85 "[ARCHIVER]: Loading archive to region {0} from {1}", m_scene.RegionInfo.RegionName, loadPath); 96 "[ARCHIVER]: Loading archive to region {0} from {1}", m_scene.RegionInfo.RegionName, loadPath);
86 97
87 new ArchiveReadRequest(m_scene, loadPath, merge).DearchiveRegion(); 98 new ArchiveReadRequest(m_scene, loadPath, merge, requestId).DearchiveRegion();
88 } 99 }
89 100
90 public void DearchiveRegion(Stream loadStream) 101 public void DearchiveRegion(Stream loadStream)
91 { 102 {
92 DearchiveRegion(loadStream, false); 103 DearchiveRegion(loadStream, false, Guid.Empty);
93 } 104 }
94 105
95 public void DearchiveRegion(Stream loadStream, bool merge) 106 public void DearchiveRegion(Stream loadStream, bool merge, Guid requestId)
96 { 107 {
97 new ArchiveReadRequest(m_scene, loadStream, merge).DearchiveRegion(); 108 new ArchiveReadRequest(m_scene, loadStream, merge, requestId).DearchiveRegion();
98 } 109 }
99 } 110 }
100} 111}
diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
index 165a607..3ffabbd 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
@@ -47,10 +47,13 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
47 [TestFixture, LongRunning] 47 [TestFixture, LongRunning]
48 public class ArchiverTests 48 public class ArchiverTests
49 { 49 {
50 private void SaveCompleted(string errorMessage) 50 private Guid m_lastRequestId;
51
52 private void SaveCompleted(Guid requestId, string errorMessage)
51 { 53 {
52 lock (this) 54 lock (this)
53 { 55 {
56 m_lastRequestId = requestId;
54 System.Console.WriteLine("About to pulse ArchiverTests"); 57 System.Console.WriteLine("About to pulse ArchiverTests");
55 Monitor.PulseAll(this); 58 Monitor.PulseAll(this);
56 } 59 }
@@ -112,15 +115,19 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
112 MemoryStream archiveWriteStream = new MemoryStream(); 115 MemoryStream archiveWriteStream = new MemoryStream();
113 scene.EventManager.OnOarFileSaved += SaveCompleted; 116 scene.EventManager.OnOarFileSaved += SaveCompleted;
114 117
118 Guid requestId = new Guid("00000000-0000-0000-0000-808080808080");
119
115 lock (this) 120 lock (this)
116 { 121 {
117 archiverModule.ArchiveRegion(archiveWriteStream); 122 archiverModule.ArchiveRegion(archiveWriteStream, requestId);
118 AssetServerBase assetServer = (AssetServerBase)scene.CommsManager.AssetCache.AssetServer; 123 AssetServerBase assetServer = (AssetServerBase)scene.CommsManager.AssetCache.AssetServer;
119 while (assetServer.HasWaitingRequests()) 124 while (assetServer.HasWaitingRequests())
120 assetServer.ProcessNextRequest(); 125 assetServer.ProcessNextRequest();
121 126
122 Monitor.Wait(this, 60000); 127 Monitor.Wait(this, 60000);
123 } 128 }
129
130 Assert.That(m_lastRequestId, Is.EqualTo(requestId));
124 131
125 byte[] archive = archiveWriteStream.ToArray(); 132 byte[] archive = archiveWriteStream.ToArray();
126 MemoryStream archiveReadStream = new MemoryStream(archive); 133 MemoryStream archiveReadStream = new MemoryStream(archive);
@@ -303,7 +310,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
303 byte[] archive = archiveWriteStream.ToArray(); 310 byte[] archive = archiveWriteStream.ToArray();
304 MemoryStream archiveReadStream = new MemoryStream(archive); 311 MemoryStream archiveReadStream = new MemoryStream(archive);
305 312
306 archiverModule.DearchiveRegion(archiveReadStream, true); 313 archiverModule.DearchiveRegion(archiveReadStream, true, Guid.Empty);
307 314
308 SceneObjectPart object1Existing = scene.GetSceneObjectPart(part1Name); 315 SceneObjectPart object1Existing = scene.GetSceneObjectPart(part1Name);
309 Assert.That(object1Existing, Is.Not.Null, "object1 was not present after merge"); 316 Assert.That(object1Existing, Is.Not.Null, "object1 was not present after merge");