aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/ExportSerialiser
diff options
context:
space:
mode:
authorAdam Frisby2008-04-21 09:12:47 +0000
committerAdam Frisby2008-04-21 09:12:47 +0000
commitf741a62d540f0c04eedebd9c7eb072fc50c4a111 (patch)
treef94ce4b084c538feb450dc5827358d231da37dbe /OpenSim/Region/Environment/Modules/ExportSerialiser
parentUpdate svn properties. (diff)
downloadopensim-SC-f741a62d540f0c04eedebd9c7eb072fc50c4a111.zip
opensim-SC-f741a62d540f0c04eedebd9c7eb072fc50c4a111.tar.gz
opensim-SC-f741a62d540f0c04eedebd9c7eb072fc50c4a111.tar.bz2
opensim-SC-f741a62d540f0c04eedebd9c7eb072fc50c4a111.tar.xz
* Formatted ExportSerialiserModule and SvnBackupModule
* Added a form of GZip compression support to object.xml files produced by exportserialiser. Will look towards standard GZip support. File compression seems to be highly worthwhile reducing a 1.5mb sim state to 62kb.
Diffstat (limited to 'OpenSim/Region/Environment/Modules/ExportSerialiser')
-rw-r--r--OpenSim/Region/Environment/Modules/ExportSerialiser/ExportSerialisationModule.cs97
-rw-r--r--OpenSim/Region/Environment/Modules/ExportSerialiser/IFileSerialiser.cs4
-rw-r--r--OpenSim/Region/Environment/Modules/ExportSerialiser/IRegionSerialiser.cs2
-rw-r--r--OpenSim/Region/Environment/Modules/ExportSerialiser/SerialiseObjects.cs41
-rw-r--r--OpenSim/Region/Environment/Modules/ExportSerialiser/SerialiseTerrain.cs4
5 files changed, 79 insertions, 69 deletions
diff --git a/OpenSim/Region/Environment/Modules/ExportSerialiser/ExportSerialisationModule.cs b/OpenSim/Region/Environment/Modules/ExportSerialiser/ExportSerialisationModule.cs
index f811f22..91770af 100644
--- a/OpenSim/Region/Environment/Modules/ExportSerialiser/ExportSerialisationModule.cs
+++ b/OpenSim/Region/Environment/Modules/ExportSerialiser/ExportSerialisationModule.cs
@@ -37,10 +37,54 @@ namespace OpenSim.Region.Environment.Modules.ExportSerialiser
37{ 37{
38 public class ExportSerialisationModule : IRegionModule, IRegionSerialiser 38 public class ExportSerialisationModule : IRegionModule, IRegionSerialiser
39 { 39 {
40 private List<Scene> m_regions = new List<Scene>();
41 private List<IFileSerialiser> m_serialisers = new List<IFileSerialiser>();
42 private Commander m_commander = new Commander("Export"); 40 private Commander m_commander = new Commander("Export");
41 private List<Scene> m_regions = new List<Scene>();
43 private string m_savedir = "exports" + "/"; 42 private string m_savedir = "exports" + "/";
43 private List<IFileSerialiser> m_serialisers = new List<IFileSerialiser>();
44
45 #region IRegionModule Members
46
47 public void Initialise(Scene scene, IConfigSource source)
48 {
49 scene.RegisterModuleCommander("Export", m_commander);
50 scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole;
51 scene.RegisterModuleInterface<IRegionSerialiser>(this);
52
53 lock (m_regions)
54 {
55 m_regions.Add(scene);
56 }
57 }
58
59 public void PostInitialise()
60 {
61 lock (m_serialisers)
62 {
63 m_serialisers.Add(new SerialiseTerrain());
64 m_serialisers.Add(new SerialiseObjects());
65 }
66
67 LoadCommanderCommands();
68 }
69
70 public void Close()
71 {
72 m_regions.Clear();
73 }
74
75 public string Name
76 {
77 get { return "ExportSerialisationModule"; }
78 }
79
80 public bool IsSharedModule
81 {
82 get { return true; }
83 }
84
85 #endregion
86
87 #region IRegionSerialiser Members
44 88
45 public List<string> SerialiseRegion(Scene scene, string saveDir) 89 public List<string> SerialiseRegion(Scene scene, string saveDir)
46 { 90 {
@@ -76,22 +120,9 @@ namespace OpenSim.Region.Environment.Modules.ExportSerialiser
76 return results; 120 return results;
77 } 121 }
78 122
123 #endregion
79 124
80 #region IRegionModule Members 125 private void EventManager_OnPluginConsole(string[] args)
81
82 public void Initialise(Scene scene, IConfigSource source)
83 {
84 scene.RegisterModuleCommander("Export", m_commander);
85 scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole;
86 scene.RegisterModuleInterface<IRegionSerialiser>(this);
87
88 lock (m_regions)
89 {
90 m_regions.Add(scene);
91 }
92 }
93
94 void EventManager_OnPluginConsole(string[] args)
95 { 126 {
96 if (args[0] == "export") 127 if (args[0] == "export")
97 { 128 {
@@ -108,7 +139,7 @@ namespace OpenSim.Region.Environment.Modules.ExportSerialiser
108 { 139 {
109 foreach (Scene region in m_regions) 140 foreach (Scene region in m_regions)
110 { 141 {
111 if (region.RegionInfo.RegionName == (string)args[0]) 142 if (region.RegionInfo.RegionName == (string) args[0])
112 { 143 {
113 List<string> results = SerialiseRegion(region, m_savedir + region.RegionInfo.RegionID.ToString() + "/"); 144 List<string> results = SerialiseRegion(region, m_savedir + region.RegionInfo.RegionID.ToString() + "/");
114 } 145 }
@@ -133,33 +164,5 @@ namespace OpenSim.Region.Environment.Modules.ExportSerialiser
133 m_commander.RegisterCommand("save", serialiseSceneCommand); 164 m_commander.RegisterCommand("save", serialiseSceneCommand);
134 m_commander.RegisterCommand("save-all", serialiseAllScenesCommand); 165 m_commander.RegisterCommand("save-all", serialiseAllScenesCommand);
135 } 166 }
136
137 public void PostInitialise()
138 {
139 lock (m_serialisers)
140 {
141 m_serialisers.Add(new SerialiseTerrain());
142 m_serialisers.Add(new SerialiseObjects());
143 }
144
145 LoadCommanderCommands();
146 }
147
148 public void Close()
149 {
150 m_regions.Clear();
151 }
152
153 public string Name
154 {
155 get { return "ExportSerialisationModule"; }
156 }
157
158 public bool IsSharedModule
159 {
160 get { return true; }
161 }
162
163 #endregion
164 } 167 }
165} 168} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/ExportSerialiser/IFileSerialiser.cs b/OpenSim/Region/Environment/Modules/ExportSerialiser/IFileSerialiser.cs
index 8cd97a8..77a418f 100644
--- a/OpenSim/Region/Environment/Modules/ExportSerialiser/IFileSerialiser.cs
+++ b/OpenSim/Region/Environment/Modules/ExportSerialiser/IFileSerialiser.cs
@@ -29,8 +29,8 @@ using OpenSim.Region.Environment.Scenes;
29 29
30namespace OpenSim.Region.Environment.Modules.ExportSerialiser 30namespace OpenSim.Region.Environment.Modules.ExportSerialiser
31{ 31{
32 interface IFileSerialiser 32 internal interface IFileSerialiser
33 { 33 {
34 string WriteToFile(Scene scene, string dir); 34 string WriteToFile(Scene scene, string dir);
35 } 35 }
36} 36} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/ExportSerialiser/IRegionSerialiser.cs b/OpenSim/Region/Environment/Modules/ExportSerialiser/IRegionSerialiser.cs
index 5b10957..e1721ff 100644
--- a/OpenSim/Region/Environment/Modules/ExportSerialiser/IRegionSerialiser.cs
+++ b/OpenSim/Region/Environment/Modules/ExportSerialiser/IRegionSerialiser.cs
@@ -34,4 +34,4 @@ namespace OpenSim.Region.Environment.Modules.ExportSerialiser
34 { 34 {
35 List<string> SerialiseRegion(Scene scene, string saveDir); 35 List<string> SerialiseRegion(Scene scene, string saveDir);
36 } 36 }
37} 37} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/ExportSerialiser/SerialiseObjects.cs b/OpenSim/Region/Environment/Modules/ExportSerialiser/SerialiseObjects.cs
index ac80f40..7e5cf47 100644
--- a/OpenSim/Region/Environment/Modules/ExportSerialiser/SerialiseObjects.cs
+++ b/OpenSim/Region/Environment/Modules/ExportSerialiser/SerialiseObjects.cs
@@ -27,20 +27,30 @@
27 27
28using System.Collections.Generic; 28using System.Collections.Generic;
29using System.IO; 29using System.IO;
30using System.IO.Compression;
30using System.Text; 31using System.Text;
31using System.Xml; 32using System.Xml;
32using OpenSim.Region.Environment.Scenes; 33using OpenSim.Region.Environment.Scenes;
33 34
34namespace OpenSim.Region.Environment.Modules.ExportSerialiser 35namespace OpenSim.Region.Environment.Modules.ExportSerialiser
35{ 36{
36 class SerialiseObjects : IFileSerialiser 37 internal class SerialiseObjects : IFileSerialiser
37 { 38 {
38 #region IFileSerialiser Members 39 #region IFileSerialiser Members
39 40
41 public string WriteToFile(Scene scene, string dir)
42 {
43 string targetFileName = dir + "objects.xml";
44
45 SaveSerialisedToFile(targetFileName, scene);
46
47 return "objects.xml";
48 }
49
50 #endregion
40 51
41 public void SaveSerialisedToFile(string fileName, Scene scene) 52 public void SaveSerialisedToFile(string fileName, Scene scene)
42 { 53 {
43 int primCount = 0;
44 string xmlstream = "<scene>"; 54 string xmlstream = "<scene>";
45 55
46 List<EntityBase> EntityList = scene.GetEntities(); 56 List<EntityBase> EntityList = scene.GetEntities();
@@ -50,8 +60,7 @@ namespace OpenSim.Region.Environment.Modules.ExportSerialiser
50 { 60 {
51 if (ent is SceneObjectGroup) 61 if (ent is SceneObjectGroup)
52 { 62 {
53 EntityXml.Add(((SceneObjectGroup)ent).ToXmlString2()); 63 EntityXml.Add(((SceneObjectGroup) ent).ToXmlString2());
54 primCount++;
55 } 64 }
56 } 65 }
57 EntityXml.Sort(); 66 EntityXml.Sort();
@@ -69,26 +78,24 @@ namespace OpenSim.Region.Environment.Modules.ExportSerialiser
69 formatter.Formatting = Formatting.Indented; 78 formatter.Formatting = Formatting.Indented;
70 doc.WriteContentTo(formatter); 79 doc.WriteContentTo(formatter);
71 formatter.Flush(); 80 formatter.Flush();
72 StreamReader reader = new StreamReader(stream);
73 81
74 stream.Seek(0, SeekOrigin.Begin); 82 stream.Seek(0, SeekOrigin.Begin);
75 83
76 FileStream objectsFile = new FileStream(fileName, FileMode.Create); 84 FileStream objectsFile = new FileStream(fileName, FileMode.Create);
85
77 stream.WriteTo(objectsFile); 86 stream.WriteTo(objectsFile);
78 objectsFile.Flush(); 87 objectsFile.Flush();
79 objectsFile.Close(); 88 objectsFile.Close();
80 89
90 #region GZip Compressed Version
91 FileStream objectsFileCompressed = new FileStream(fileName + ".gzs", FileMode.Create);
92 MemoryStream gzipMSStream = new MemoryStream();
93 GZipStream gzipStream = new GZipStream(gzipMSStream, CompressionMode.Compress);
94 stream.WriteTo(gzipStream);
95 gzipMSStream.WriteTo(objectsFileCompressed);
96 objectsFileCompressed.Flush();
97 objectsFileCompressed.Close();
98 #endregion
81 } 99 }
82
83 public string WriteToFile(Scene scene, string dir)
84 {
85 string targetFileName = dir + "objects.xml";
86
87 SaveSerialisedToFile(targetFileName, scene);
88
89 return "objects.xml";
90 }
91
92 #endregion
93 } 100 }
94} 101} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/ExportSerialiser/SerialiseTerrain.cs b/OpenSim/Region/Environment/Modules/ExportSerialiser/SerialiseTerrain.cs
index 8555089..c4790c2 100644
--- a/OpenSim/Region/Environment/Modules/ExportSerialiser/SerialiseTerrain.cs
+++ b/OpenSim/Region/Environment/Modules/ExportSerialiser/SerialiseTerrain.cs
@@ -31,7 +31,7 @@ using OpenSim.Region.Environment.Scenes;
31 31
32namespace OpenSim.Region.Environment.Modules.ExportSerialiser 32namespace OpenSim.Region.Environment.Modules.ExportSerialiser
33{ 33{
34 class SerialiseTerrain : IFileSerialiser 34 internal class SerialiseTerrain : IFileSerialiser
35 { 35 {
36 #region IFileSerialiser Members 36 #region IFileSerialiser Members
37 37
@@ -50,4 +50,4 @@ namespace OpenSim.Region.Environment.Modules.ExportSerialiser
50 50
51 #endregion 51 #endregion
52 } 52 }
53} 53} \ No newline at end of file