aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-05-19 02:45:17 +0100
committerJustin Clark-Casey (justincc)2012-05-19 02:45:17 +0100
commit2b60a5c5d64f38caf243119105416c1101c6eb6c (patch)
treeac4ba64c4ef8aa37ff534e3ec7be80281130dc19
parentEnable FetchInventoryDescendents2 and FetchInventory2 caps by default. This ... (diff)
downloadopensim-SC-2b60a5c5d64f38caf243119105416c1101c6eb6c.zip
opensim-SC-2b60a5c5d64f38caf243119105416c1101c6eb6c.tar.gz
opensim-SC-2b60a5c5d64f38caf243119105416c1101c6eb6c.tar.bz2
opensim-SC-2b60a5c5d64f38caf243119105416c1101c6eb6c.tar.xz
Add is_megaregion flag into oar control file. Not currently read - for future use. Please do not rely on this remaining here.
An adaptation of part of Garmin's patch from http://opensimulator.org/mantis/view.php?id=5975, thanks! Flag only written if the SW corner OAR is saved - this is the only one that captures object data presently (though not land or terrain data). This adds an IRegionCombinerModule interface and the necessary methods on RegionCombinerModule
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs95
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs20
-rw-r--r--OpenSim/Region/Framework/Interfaces/IRegionCombinerModule.cs51
-rw-r--r--OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs22
4 files changed, 145 insertions, 43 deletions
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs
index 5679ad5..838b741 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs
@@ -67,7 +67,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver
67 /// Determine whether this archive will save assets. Default is true. 67 /// Determine whether this archive will save assets. Default is true.
68 /// </summary> 68 /// </summary>
69 public bool SaveAssets { get; set; } 69 public bool SaveAssets { get; set; }
70 70
71 protected ArchiverModule m_module;
71 protected Scene m_scene; 72 protected Scene m_scene;
72 protected Stream m_saveStream; 73 protected Stream m_saveStream;
73 protected Guid m_requestId; 74 protected Guid m_requestId;
@@ -75,13 +76,13 @@ namespace OpenSim.Region.CoreModules.World.Archiver
75 /// <summary> 76 /// <summary>
76 /// Constructor 77 /// Constructor
77 /// </summary> 78 /// </summary>
78 /// <param name="scene"></param> 79 /// <param name="module">Calling module</param>
79 /// <param name="savePath">The path to which to save data.</param> 80 /// <param name="savePath">The path to which to save data.</param>
80 /// <param name="requestId">The id associated with this request</param> 81 /// <param name="requestId">The id associated with this request</param>
81 /// <exception cref="System.IO.IOException"> 82 /// <exception cref="System.IO.IOException">
82 /// If there was a problem opening a stream for the file specified by the savePath 83 /// If there was a problem opening a stream for the file specified by the savePath
83 /// </exception> 84 /// </exception>
84 public ArchiveWriteRequestPreparation(Scene scene, string savePath, Guid requestId) : this(scene, requestId) 85 public ArchiveWriteRequestPreparation(ArchiverModule module, string savePath, Guid requestId) : this(module, requestId)
85 { 86 {
86 try 87 try
87 { 88 {
@@ -99,17 +100,23 @@ namespace OpenSim.Region.CoreModules.World.Archiver
99 /// <summary> 100 /// <summary>
100 /// Constructor. 101 /// Constructor.
101 /// </summary> 102 /// </summary>
102 /// <param name="scene"></param> 103 /// <param name="module">Calling module</param>
103 /// <param name="saveStream">The stream to which to save data.</param> 104 /// <param name="saveStream">The stream to which to save data.</param>
104 /// <param name="requestId">The id associated with this request</param> 105 /// <param name="requestId">The id associated with this request</param>
105 public ArchiveWriteRequestPreparation(Scene scene, Stream saveStream, Guid requestId) : this(scene, requestId) 106 public ArchiveWriteRequestPreparation(ArchiverModule module, Stream saveStream, Guid requestId) : this(module, requestId)
106 { 107 {
107 m_saveStream = saveStream; 108 m_saveStream = saveStream;
108 } 109 }
109 110
110 protected ArchiveWriteRequestPreparation(Scene scene, Guid requestId) 111 protected ArchiveWriteRequestPreparation(ArchiverModule module, Guid requestId)
111 { 112 {
112 m_scene = scene; 113 m_module = module;
114
115 // FIXME: This is only here for regression test purposes since they do not supply a module. Need to fix
116 // this.
117 if (m_module != null)
118 m_scene = m_module.Scene;
119
113 m_requestId = requestId; 120 m_requestId = requestId;
114 121
115 SaveAssets = true; 122 SaveAssets = true;
@@ -364,32 +371,56 @@ namespace OpenSim.Region.CoreModules.World.Archiver
364 //if (majorVersion == 1) 371 //if (majorVersion == 1)
365 //{ 372 //{
366 // m_log.WarnFormat("[ARCHIVER]: Please be aware that version 1.0 OARs are not compatible with OpenSim 0.7.0.2 and earlier. Please use the --version=0 option if you want to produce a compatible OAR"); 373 // m_log.WarnFormat("[ARCHIVER]: Please be aware that version 1.0 OARs are not compatible with OpenSim 0.7.0.2 and earlier. Please use the --version=0 option if you want to produce a compatible OAR");
367 //} 374 //}
375
376 String s;
368 377
369 StringWriter sw = new StringWriter(); 378 using (StringWriter sw = new StringWriter())
370 XmlTextWriter xtw = new XmlTextWriter(sw); 379 {
371 xtw.Formatting = Formatting.Indented; 380 using (XmlTextWriter xtw = new XmlTextWriter(sw))
372 xtw.WriteStartDocument(); 381 {
373 xtw.WriteStartElement("archive"); 382 xtw.Formatting = Formatting.Indented;
374 xtw.WriteAttributeString("major_version", majorVersion.ToString()); 383 xtw.WriteStartDocument();
375 xtw.WriteAttributeString("minor_version", minorVersion.ToString()); 384 xtw.WriteStartElement("archive");
376 385 xtw.WriteAttributeString("major_version", majorVersion.ToString());
377 xtw.WriteStartElement("creation_info"); 386 xtw.WriteAttributeString("minor_version", minorVersion.ToString());
378 DateTime now = DateTime.UtcNow; 387
379 TimeSpan t = now - new DateTime(1970, 1, 1); 388 xtw.WriteStartElement("creation_info");
380 xtw.WriteElementString("datetime", ((int)t.TotalSeconds).ToString()); 389 DateTime now = DateTime.UtcNow;
381 xtw.WriteElementString("id", UUID.Random().ToString()); 390 TimeSpan t = now - new DateTime(1970, 1, 1);
382 xtw.WriteEndElement(); 391 xtw.WriteElementString("datetime", ((int)t.TotalSeconds).ToString());
383 392 xtw.WriteElementString("id", UUID.Random().ToString());
384 xtw.WriteElementString("assets_included", SaveAssets.ToString()); 393 xtw.WriteEndElement();
385 394
386 xtw.WriteEndElement(); 395 xtw.WriteElementString("assets_included", SaveAssets.ToString());
387 396
388 xtw.Flush(); 397 bool isMegaregion;
389 xtw.Close(); 398
390 399 // FIXME: This is only here for regression test purposes since they do not supply a module. Need to fix
391 String s = sw.ToString(); 400 // this, possibly by doing control file creation somewhere else.
392 sw.Close(); 401 if (m_module != null && m_module.RegionCombinerModule != null)
402 {
403 IRegionCombinerModule mod = m_module.RegionCombinerModule;
404 isMegaregion = mod.IsMegaregion && mod.IsRootRegion(m_scene.RegionInfo.RegionID);
405 }
406 else
407 {
408 isMegaregion = false;
409 }
410
411 xtw.WriteElementString("is_megaregion", isMegaregion.ToString());
412
413 xtw.WriteEndElement();
414
415 xtw.Flush();
416 xtw.Close();
417 }
418
419 s = sw.ToString();
420 }
421
422// Console.WriteLine(
423// "[ARCHIVE WRITE REQUEST PREPARATION]: Control file for {0} is: {1}", m_scene.RegionInfo.RegionName, s);
393 424
394 return s; 425 return s;
395 } 426 }
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs
index f5a5a8d..bf3b124 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs
@@ -45,7 +45,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver
45 private static readonly ILog m_log = 45 private static readonly ILog m_log =
46 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 46 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
47 47
48 private Scene m_scene; 48 public Scene Scene { get; private set; }
49 public IRegionCombinerModule RegionCombinerModule { get; private set; }
49 50
50 /// <value> 51 /// <value>
51 /// The file used to load and save an opensimulator archive if no filename has been specified 52 /// The file used to load and save an opensimulator archive if no filename has been specified
@@ -70,13 +71,14 @@ namespace OpenSim.Region.CoreModules.World.Archiver
70 71
71 public void AddRegion(Scene scene) 72 public void AddRegion(Scene scene)
72 { 73 {
73 m_scene = scene; 74 Scene = scene;
74 m_scene.RegisterModuleInterface<IRegionArchiverModule>(this); 75 Scene.RegisterModuleInterface<IRegionArchiverModule>(this);
75 //m_log.DebugFormat("[ARCHIVER]: Enabled for region {0}", scene.RegionInfo.RegionName); 76 //m_log.DebugFormat("[ARCHIVER]: Enabled for region {0}", scene.RegionInfo.RegionName);
76 } 77 }
77 78
78 public void RegionLoaded(Scene scene) 79 public void RegionLoaded(Scene scene)
79 { 80 {
81 RegionCombinerModule = scene.RequestModuleInterface<IRegionCombinerModule>();
80 } 82 }
81 83
82 public void RemoveRegion(Scene scene) 84 public void RemoveRegion(Scene scene)
@@ -165,9 +167,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver
165 public void ArchiveRegion(string savePath, Guid requestId, Dictionary<string, object> options) 167 public void ArchiveRegion(string savePath, Guid requestId, Dictionary<string, object> options)
166 { 168 {
167 m_log.InfoFormat( 169 m_log.InfoFormat(
168 "[ARCHIVER]: Writing archive for region {0} to {1}", m_scene.RegionInfo.RegionName, savePath); 170 "[ARCHIVER]: Writing archive for region {0} to {1}", Scene.RegionInfo.RegionName, savePath);
169 171
170 new ArchiveWriteRequestPreparation(m_scene, savePath, requestId).ArchiveRegion(options); 172 new ArchiveWriteRequestPreparation(this, savePath, requestId).ArchiveRegion(options);
171 } 173 }
172 174
173 public void ArchiveRegion(Stream saveStream) 175 public void ArchiveRegion(Stream saveStream)
@@ -182,7 +184,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
182 184
183 public void ArchiveRegion(Stream saveStream, Guid requestId, Dictionary<string, object> options) 185 public void ArchiveRegion(Stream saveStream, Guid requestId, Dictionary<string, object> options)
184 { 186 {
185 new ArchiveWriteRequestPreparation(m_scene, saveStream, requestId).ArchiveRegion(options); 187 new ArchiveWriteRequestPreparation(this, saveStream, requestId).ArchiveRegion(options);
186 } 188 }
187 189
188 public void DearchiveRegion(string loadPath) 190 public void DearchiveRegion(string loadPath)
@@ -193,9 +195,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver
193 public void DearchiveRegion(string loadPath, bool merge, bool skipAssets, Guid requestId) 195 public void DearchiveRegion(string loadPath, bool merge, bool skipAssets, Guid requestId)
194 { 196 {
195 m_log.InfoFormat( 197 m_log.InfoFormat(
196 "[ARCHIVER]: Loading archive to region {0} from {1}", m_scene.RegionInfo.RegionName, loadPath); 198 "[ARCHIVER]: Loading archive to region {0} from {1}", Scene.RegionInfo.RegionName, loadPath);
197 199
198 new ArchiveReadRequest(m_scene, loadPath, merge, skipAssets, requestId).DearchiveRegion(); 200 new ArchiveReadRequest(Scene, loadPath, merge, skipAssets, requestId).DearchiveRegion();
199 } 201 }
200 202
201 public void DearchiveRegion(Stream loadStream) 203 public void DearchiveRegion(Stream loadStream)
@@ -205,7 +207,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
205 207
206 public void DearchiveRegion(Stream loadStream, bool merge, bool skipAssets, Guid requestId) 208 public void DearchiveRegion(Stream loadStream, bool merge, bool skipAssets, Guid requestId)
207 { 209 {
208 new ArchiveReadRequest(m_scene, loadStream, merge, skipAssets, requestId).DearchiveRegion(); 210 new ArchiveReadRequest(Scene, loadStream, merge, skipAssets, requestId).DearchiveRegion();
209 } 211 }
210 } 212 }
211} 213}
diff --git a/OpenSim/Region/Framework/Interfaces/IRegionCombinerModule.cs b/OpenSim/Region/Framework/Interfaces/IRegionCombinerModule.cs
new file mode 100644
index 0000000..30e49b1
--- /dev/null
+++ b/OpenSim/Region/Framework/Interfaces/IRegionCombinerModule.cs
@@ -0,0 +1,51 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Linq;
31using System.Text;
32using OpenSim.Region.Framework.Scenes;
33using System.IO;
34using OpenMetaverse;
35
36namespace OpenSim.Region.Framework.Interfaces
37{
38 public interface IRegionCombinerModule
39 {
40 /// <summary>
41 /// Is this simulator hosting a megaregion?
42 /// </summary>
43 /// <value></value>
44 bool IsMegaregion { get; }
45
46 /// <summary>
47 /// Does the given id belong to the root region of the megaregion?
48 /// </summary>
49 bool IsRootRegion(UUID sceneId);
50 }
51} \ No newline at end of file
diff --git a/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs b/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs
index a142f26..37b3037 100644
--- a/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs
+++ b/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs
@@ -43,9 +43,8 @@ using Mono.Addins;
43[assembly: AddinDependency("OpenSim", "0.5")] 43[assembly: AddinDependency("OpenSim", "0.5")]
44namespace OpenSim.Region.RegionCombinerModule 44namespace OpenSim.Region.RegionCombinerModule
45{ 45{
46
47 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] 46 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
48 public class RegionCombinerModule : ISharedRegionModule 47 public class RegionCombinerModule : ISharedRegionModule, IRegionCombinerModule
49 { 48 {
50 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
51 50
@@ -59,6 +58,15 @@ namespace OpenSim.Region.RegionCombinerModule
59 get { return null; } 58 get { return null; }
60 } 59 }
61 60
61 public bool IsMegaregion
62 {
63 get
64 {
65 lock (m_startingScenes)
66 return m_startingScenes.Count > 1;
67 }
68 }
69
62 private Dictionary<UUID, RegionConnections> m_regions = new Dictionary<UUID, RegionConnections>(); 70 private Dictionary<UUID, RegionConnections> m_regions = new Dictionary<UUID, RegionConnections>();
63 private bool enabledYN = false; 71 private bool enabledYN = false;
64 private Dictionary<UUID, Scene> m_startingScenes = new Dictionary<UUID, Scene>(); 72 private Dictionary<UUID, Scene> m_startingScenes = new Dictionary<UUID, Scene>();
@@ -69,9 +77,11 @@ namespace OpenSim.Region.RegionCombinerModule
69 enabledYN = myConfig.GetBoolean("CombineContiguousRegions", false); 77 enabledYN = myConfig.GetBoolean("CombineContiguousRegions", false);
70 78
71 if (enabledYN) 79 if (enabledYN)
80 {
72 MainConsole.Instance.Commands.AddCommand( 81 MainConsole.Instance.Commands.AddCommand(
73 "RegionCombinerModule", false, "fix-phantoms", "fix-phantoms", 82 "RegionCombinerModule", false, "fix-phantoms", "fix-phantoms",
74 "Fixes phantom objects after an import to megaregions", FixPhantoms); 83 "Fixes phantom objects after an import to megaregions", FixPhantoms);
84 }
75 } 85 }
76 86
77 public void Close() 87 public void Close()
@@ -80,6 +90,8 @@ namespace OpenSim.Region.RegionCombinerModule
80 90
81 public void AddRegion(Scene scene) 91 public void AddRegion(Scene scene)
82 { 92 {
93 if (enabledYN)
94 scene.RegisterModuleInterface<IRegionCombinerModule>(this);
83 } 95 }
84 96
85 public void RemoveRegion(Scene scene) 97 public void RemoveRegion(Scene scene)
@@ -96,6 +108,12 @@ namespace OpenSim.Region.RegionCombinerModule
96 } 108 }
97 } 109 }
98 110
111 public bool IsRootRegion(UUID sceneId)
112 {
113 lock (m_regions)
114 return m_regions.ContainsKey(sceneId);
115 }
116
99 private void NewPresence(ScenePresence presence) 117 private void NewPresence(ScenePresence presence)
100 { 118 {
101 if (presence.IsChildAgent) 119 if (presence.IsChildAgent)