aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs
diff options
context:
space:
mode:
authorJustin Clarke Casey2009-05-14 20:37:54 +0000
committerJustin Clarke Casey2009-05-14 20:37:54 +0000
commit62771560448edbc2112d427acd4b37780dfe2154 (patch)
treeba07c1ae1d8de5e24e24a013fcaa39ade898f039 /OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs
parent* refactor: move SceneXmlLoader into subpackage (diff)
downloadopensim-SC_OLD-62771560448edbc2112d427acd4b37780dfe2154.zip
opensim-SC_OLD-62771560448edbc2112d427acd4b37780dfe2154.tar.gz
opensim-SC_OLD-62771560448edbc2112d427acd4b37780dfe2154.tar.bz2
opensim-SC_OLD-62771560448edbc2112d427acd4b37780dfe2154.tar.xz
* When saving an oar, save assets when immediately received rather than storing them all up in memory
* Hopefully this will remove out of memory problems when saving large oars on machines without much memory * It may also speed up saving of large oars
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs29
1 files changed, 12 insertions, 17 deletions
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs
index 943d9d1..b167ce2 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs
@@ -44,7 +44,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver
44 /// <summary> 44 /// <summary>
45 /// Method called when all the necessary assets for an archive request have been received. 45 /// Method called when all the necessary assets for an archive request have been received.
46 /// </summary> 46 /// </summary>
47 public delegate void AssetsRequestCallback(IDictionary<UUID, AssetBase> assetsFound, ICollection<UUID> assetsNotFoundUuids); 47 public delegate void AssetsRequestCallback(
48 ICollection<UUID> assetsFoundUuids, ICollection<UUID> assetsNotFoundUuids);
48 49
49 /// <summary> 50 /// <summary>
50 /// Execute the write of an archive once we have received all the necessary data 51 /// Execute the write of an archive once we have received all the necessary data
@@ -57,7 +58,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
57 protected IRegionSerialiserModule m_serialiser; 58 protected IRegionSerialiserModule m_serialiser;
58 protected List<SceneObjectGroup> m_sceneObjects; 59 protected List<SceneObjectGroup> m_sceneObjects;
59 protected Scene m_scene; 60 protected Scene m_scene;
60 protected Stream m_saveStream; 61 protected TarArchiveWriter m_archiveWriter;
61 protected Guid m_requestId; 62 protected Guid m_requestId;
62 63
63 public ArchiveWriteRequestExecution( 64 public ArchiveWriteRequestExecution(
@@ -65,19 +66,19 @@ namespace OpenSim.Region.CoreModules.World.Archiver
65 ITerrainModule terrainModule, 66 ITerrainModule terrainModule,
66 IRegionSerialiserModule serialiser, 67 IRegionSerialiserModule serialiser,
67 Scene scene, 68 Scene scene,
68 Stream saveStream, 69 TarArchiveWriter archiveWriter,
69 Guid requestId) 70 Guid requestId)
70 { 71 {
71 m_sceneObjects = sceneObjects; 72 m_sceneObjects = sceneObjects;
72 m_terrainModule = terrainModule; 73 m_terrainModule = terrainModule;
73 m_serialiser = serialiser; 74 m_serialiser = serialiser;
74 m_scene = scene; 75 m_scene = scene;
75 m_saveStream = saveStream; 76 m_archiveWriter = archiveWriter;
76 m_requestId = requestId; 77 m_requestId = requestId;
77 } 78 }
78 79
79 protected internal void ReceivedAllAssets( 80 protected internal void ReceivedAllAssets(
80 IDictionary<UUID, AssetBase> assetsFound, ICollection<UUID> assetsNotFoundUuids) 81 ICollection<UUID> assetsFoundUuids, ICollection<UUID> assetsNotFoundUuids)
81 { 82 {
82 foreach (UUID uuid in assetsNotFoundUuids) 83 foreach (UUID uuid in assetsNotFoundUuids)
83 { 84 {
@@ -86,21 +87,19 @@ namespace OpenSim.Region.CoreModules.World.Archiver
86 87
87 m_log.InfoFormat( 88 m_log.InfoFormat(
88 "[ARCHIVER]: Received {0} of {1} assets requested", 89 "[ARCHIVER]: Received {0} of {1} assets requested",
89 assetsFound.Count, assetsFound.Count + assetsNotFoundUuids.Count); 90 assetsFoundUuids.Count, assetsFoundUuids.Count + assetsNotFoundUuids.Count);
90 91
91 m_log.InfoFormat("[ARCHIVER]: Creating archive file. This may take some time."); 92 m_log.InfoFormat("[ARCHIVER]: Creating archive file. This may take some time.");
92 93
93 TarArchiveWriter archive = new TarArchiveWriter(m_saveStream);
94
95 // Write out control file 94 // Write out control file
96 archive.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, Create0p2ControlFile()); 95 m_archiveWriter.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, Create0p2ControlFile());
97 96
98 m_log.InfoFormat("[ARCHIVER]: Added control file to archive."); 97 m_log.InfoFormat("[ARCHIVER]: Added control file to archive.");
99 98
100 // Write out region settings 99 // Write out region settings
101 string settingsPath 100 string settingsPath
102 = String.Format("{0}{1}.xml", ArchiveConstants.SETTINGS_PATH, m_scene.RegionInfo.RegionName); 101 = String.Format("{0}{1}.xml", ArchiveConstants.SETTINGS_PATH, m_scene.RegionInfo.RegionName);
103 archive.WriteFile(settingsPath, RegionSettingsSerializer.Serialize(m_scene.RegionInfo.RegionSettings)); 102 m_archiveWriter.WriteFile(settingsPath, RegionSettingsSerializer.Serialize(m_scene.RegionInfo.RegionSettings));
104 103
105 m_log.InfoFormat("[ARCHIVER]: Added region settings to archive."); 104 m_log.InfoFormat("[ARCHIVER]: Added region settings to archive.");
106 105
@@ -110,7 +109,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
110 109
111 MemoryStream ms = new MemoryStream(); 110 MemoryStream ms = new MemoryStream();
112 m_terrainModule.SaveToStream(terrainPath, ms); 111 m_terrainModule.SaveToStream(terrainPath, ms);
113 archive.WriteFile(terrainPath, ms.ToArray()); 112 m_archiveWriter.WriteFile(terrainPath, ms.ToArray());
114 ms.Close(); 113 ms.Close();
115 114
116 m_log.InfoFormat("[ARCHIVER]: Added terrain information to archive."); 115 m_log.InfoFormat("[ARCHIVER]: Added terrain information to archive.");
@@ -130,16 +129,12 @@ namespace OpenSim.Region.CoreModules.World.Archiver
130 Math.Round(position.X), Math.Round(position.Y), Math.Round(position.Z), 129 Math.Round(position.X), Math.Round(position.Y), Math.Round(position.Z),
131 sceneObject.UUID); 130 sceneObject.UUID);
132 131
133 archive.WriteFile(filename, serializedObject); 132 m_archiveWriter.WriteFile(filename, serializedObject);
134 } 133 }
135 134
136 m_log.InfoFormat("[ARCHIVER]: Added scene objects to archive."); 135 m_log.InfoFormat("[ARCHIVER]: Added scene objects to archive.");
137 136
138 // Write out assets 137 m_archiveWriter.Close();
139 AssetsArchiver assetsArchiver = new AssetsArchiver(assetsFound);
140 assetsArchiver.Archive(archive);
141
142 archive.Close();
143 138
144 m_log.InfoFormat("[ARCHIVER]: Wrote out OpenSimulator archive for {0}", m_scene.RegionInfo.RegionName); 139 m_log.InfoFormat("[ARCHIVER]: Wrote out OpenSimulator archive for {0}", m_scene.RegionInfo.RegionName);
145 140