diff options
Update svn properties, formatting cleanup.
Diffstat (limited to 'OpenSim/Region/Environment/Modules/ContentManagementSystem/FileSystemDatabase.cs')
-rw-r--r-- | OpenSim/Region/Environment/Modules/ContentManagementSystem/FileSystemDatabase.cs | 159 |
1 files changed, 83 insertions, 76 deletions
diff --git a/OpenSim/Region/Environment/Modules/ContentManagementSystem/FileSystemDatabase.cs b/OpenSim/Region/Environment/Modules/ContentManagementSystem/FileSystemDatabase.cs index 66d279a..607f6a9 100644 --- a/OpenSim/Region/Environment/Modules/ContentManagementSystem/FileSystemDatabase.cs +++ b/OpenSim/Region/Environment/Modules/ContentManagementSystem/FileSystemDatabase.cs | |||
@@ -28,7 +28,7 @@ | |||
28 | #region Header | 28 | #region Header |
29 | 29 | ||
30 | // FileSystemDatabase.cs | 30 | // FileSystemDatabase.cs |
31 | // User: bongiojp | 31 | // User: bongiojp |
32 | 32 | ||
33 | #endregion Header | 33 | #endregion Header |
34 | 34 | ||
@@ -88,13 +88,13 @@ namespace OpenSim.Region.Environment.Modules.ContentManagement | |||
88 | { | 88 | { |
89 | string scenedir; | 89 | string scenedir; |
90 | if (!Directory.Exists(m_repodir)) | 90 | if (!Directory.Exists(m_repodir)) |
91 | Directory.CreateDirectory(m_repodir); | 91 | Directory.CreateDirectory(m_repodir); |
92 | 92 | ||
93 | foreach (UUID region in m_scenes.Keys) | 93 | foreach (UUID region in m_scenes.Keys) |
94 | { | 94 | { |
95 | scenedir = m_repodir + Slash.DirectorySeparatorChar + region + Slash.DirectorySeparatorChar; | 95 | scenedir = m_repodir + Slash.DirectorySeparatorChar + region + Slash.DirectorySeparatorChar; |
96 | if (!Directory.Exists(scenedir)) | 96 | if (!Directory.Exists(scenedir)) |
97 | Directory.CreateDirectory(scenedir); | 97 | Directory.CreateDirectory(scenedir); |
98 | } | 98 | } |
99 | } | 99 | } |
100 | 100 | ||
@@ -102,10 +102,14 @@ namespace OpenSim.Region.Environment.Modules.ContentManagement | |||
102 | private void SetupSerialiser() | 102 | private void SetupSerialiser() |
103 | { | 103 | { |
104 | if (m_serialiser.Count == 0) | 104 | if (m_serialiser.Count == 0) |
105 | foreach(UUID region in m_scenes.Keys) | 105 | { |
106 | m_serialiser.Add(region, | 106 | foreach (UUID region in m_scenes.Keys) |
107 | m_scenes[region].RequestModuleInterface<IRegionSerialiser>() | 107 | { |
108 | ); | 108 | m_serialiser.Add(region, |
109 | m_scenes[region].RequestModuleInterface<IRegionSerialiser>() | ||
110 | ); | ||
111 | } | ||
112 | } | ||
109 | } | 113 | } |
110 | 114 | ||
111 | #endregion Private Methods | 115 | #endregion Private Methods |
@@ -120,7 +124,7 @@ namespace OpenSim.Region.Environment.Modules.ContentManagement | |||
120 | public string GetRegionObjectHeightMap(UUID regionid) | 124 | public string GetRegionObjectHeightMap(UUID regionid) |
121 | { | 125 | { |
122 | String filename = m_repodir + Slash.DirectorySeparatorChar + regionid + | 126 | String filename = m_repodir + Slash.DirectorySeparatorChar + regionid + |
123 | Slash.DirectorySeparatorChar + "heightmap.r32"; | 127 | Slash.DirectorySeparatorChar + "heightmap.r32"; |
124 | FileStream fs = new FileStream( filename, FileMode.Open); | 128 | FileStream fs = new FileStream( filename, FileMode.Open); |
125 | StreamReader sr = new StreamReader(fs); | 129 | StreamReader sr = new StreamReader(fs); |
126 | String result = sr.ReadToEnd(); | 130 | String result = sr.ReadToEnd(); |
@@ -132,7 +136,7 @@ namespace OpenSim.Region.Environment.Modules.ContentManagement | |||
132 | public string GetRegionObjectHeightMap(UUID regionid, int revision) | 136 | public string GetRegionObjectHeightMap(UUID regionid, int revision) |
133 | { | 137 | { |
134 | String filename = m_repodir + Slash.DirectorySeparatorChar + regionid + | 138 | String filename = m_repodir + Slash.DirectorySeparatorChar + regionid + |
135 | Slash.DirectorySeparatorChar + "heightmap.r32"; | 139 | Slash.DirectorySeparatorChar + "heightmap.r32"; |
136 | FileStream fs = new FileStream( filename, FileMode.Open); | 140 | FileStream fs = new FileStream( filename, FileMode.Open); |
137 | StreamReader sr = new StreamReader(fs); | 141 | StreamReader sr = new StreamReader(fs); |
138 | String result = sr.ReadToEnd(); | 142 | String result = sr.ReadToEnd(); |
@@ -144,14 +148,14 @@ namespace OpenSim.Region.Environment.Modules.ContentManagement | |||
144 | public System.Collections.ArrayList GetRegionObjectXMLList(UUID regionid, int revision) | 148 | public System.Collections.ArrayList GetRegionObjectXMLList(UUID regionid, int revision) |
145 | { | 149 | { |
146 | System.Collections.ArrayList objectList = new System.Collections.ArrayList(); | 150 | System.Collections.ArrayList objectList = new System.Collections.ArrayList(); |
147 | string filename = m_repodir + Slash.DirectorySeparatorChar + regionid + Slash.DirectorySeparatorChar + | 151 | string filename = m_repodir + Slash.DirectorySeparatorChar + regionid + Slash.DirectorySeparatorChar + |
148 | + revision + Slash.DirectorySeparatorChar + "objects.xml"; | 152 | + revision + Slash.DirectorySeparatorChar + "objects.xml"; |
149 | XmlDocument doc = new XmlDocument(); | 153 | XmlDocument doc = new XmlDocument(); |
150 | XmlNode rootNode; | 154 | XmlNode rootNode; |
151 | //int primCount = 0; | 155 | //int primCount = 0; |
152 | //SceneObjectGroup obj = null; | 156 | //SceneObjectGroup obj = null; |
153 | 157 | ||
154 | if(File.Exists(filename)) | 158 | if (File.Exists(filename)) |
155 | { | 159 | { |
156 | XmlTextReader reader = new XmlTextReader(filename); | 160 | XmlTextReader reader = new XmlTextReader(filename); |
157 | reader.WhitespaceHandling = WhitespaceHandling.None; | 161 | reader.WhitespaceHandling = WhitespaceHandling.None; |
@@ -160,9 +164,9 @@ namespace OpenSim.Region.Environment.Modules.ContentManagement | |||
160 | rootNode = doc.FirstChild; | 164 | rootNode = doc.FirstChild; |
161 | foreach (XmlNode aPrimNode in rootNode.ChildNodes) | 165 | foreach (XmlNode aPrimNode in rootNode.ChildNodes) |
162 | { | 166 | { |
163 | objectList.Add(aPrimNode.OuterXml); | 167 | objectList.Add(aPrimNode.OuterXml); |
164 | } | 168 | } |
165 | return objectList; | 169 | return objectList; |
166 | } | 170 | } |
167 | return null; | 171 | return null; |
168 | } | 172 | } |
@@ -172,45 +176,46 @@ namespace OpenSim.Region.Environment.Modules.ContentManagement | |||
172 | int revision = NumOfRegionRev(regionid); | 176 | int revision = NumOfRegionRev(regionid); |
173 | m_log.Info("[FSDB]: found revisions:" + revision); | 177 | m_log.Info("[FSDB]: found revisions:" + revision); |
174 | System.Collections.ArrayList xmlList = new System.Collections.ArrayList(); | 178 | System.Collections.ArrayList xmlList = new System.Collections.ArrayList(); |
175 | string filename = m_repodir + Slash.DirectorySeparatorChar + regionid + Slash.DirectorySeparatorChar + | 179 | string filename = m_repodir + Slash.DirectorySeparatorChar + regionid + Slash.DirectorySeparatorChar + |
176 | + revision + Slash.DirectorySeparatorChar + "objects.xml"; | 180 | + revision + Slash.DirectorySeparatorChar + "objects.xml"; |
177 | XmlDocument doc = new XmlDocument(); | 181 | XmlDocument doc = new XmlDocument(); |
178 | XmlNode rootNode; | 182 | XmlNode rootNode; |
179 | 183 | ||
180 | |||
181 | m_log.Info("[FSDB]: Checking if " + filename + " exists."); | 184 | m_log.Info("[FSDB]: Checking if " + filename + " exists."); |
182 | if(File.Exists(filename)) | 185 | if (File.Exists(filename)) |
183 | { | 186 | { |
184 | Stopwatch x = new Stopwatch(); | 187 | Stopwatch x = new Stopwatch(); |
185 | x.Start(); | 188 | x.Start(); |
186 | 189 | ||
187 | XmlTextReader reader = new XmlTextReader(filename); | 190 | XmlTextReader reader = new XmlTextReader(filename); |
188 | reader.WhitespaceHandling = WhitespaceHandling.None; | 191 | reader.WhitespaceHandling = WhitespaceHandling.None; |
189 | doc.Load(reader); | 192 | doc.Load(reader); |
190 | reader.Close(); | 193 | reader.Close(); |
191 | rootNode = doc.FirstChild; | 194 | rootNode = doc.FirstChild; |
192 | 195 | ||
193 | foreach (XmlNode aPrimNode in rootNode.ChildNodes) | 196 | foreach (XmlNode aPrimNode in rootNode.ChildNodes) |
194 | xmlList.Add(aPrimNode.OuterXml); | 197 | { |
195 | 198 | xmlList.Add(aPrimNode.OuterXml); | |
196 | x.Stop(); | 199 | } |
197 | TimeToDownload += x.ElapsedMilliseconds; | 200 | |
198 | m_log.Info("[FileSystemDatabase] Time spent retrieving xml files so far: " + TimeToDownload); | 201 | x.Stop(); |
199 | 202 | TimeToDownload += x.ElapsedMilliseconds; | |
200 | return xmlList; | 203 | m_log.Info("[FileSystemDatabase] Time spent retrieving xml files so far: " + TimeToDownload); |
204 | |||
205 | return xmlList; | ||
201 | } | 206 | } |
202 | return null; | 207 | return null; |
203 | } | 208 | } |
204 | 209 | ||
205 | public void Initialise(Scene scene, string dir) | 210 | public void Initialise(Scene scene, string dir) |
206 | { | 211 | { |
207 | lock(this) | 212 | lock (this) |
208 | { | 213 | { |
209 | if (m_repodir == null) | 214 | if (m_repodir == null) |
210 | m_repodir = dir; | 215 | m_repodir = dir; |
211 | } | 216 | } |
212 | lock(m_scenes) | 217 | lock (m_scenes) |
213 | m_scenes.Add(scene.RegionInfo.RegionID, scene); | 218 | m_scenes.Add(scene.RegionInfo.RegionID, scene); |
214 | } | 219 | } |
215 | 220 | ||
216 | public System.Collections.Generic.SortedDictionary<string, string> ListOfRegionRevisions(UUID regionid) | 221 | public System.Collections.Generic.SortedDictionary<string, string> ListOfRegionRevisions(UUID regionid) |
@@ -224,19 +229,21 @@ namespace OpenSim.Region.Environment.Modules.ContentManagement | |||
224 | StreamReader sr = null; | 229 | StreamReader sr = null; |
225 | String logMessage = ""; | 230 | String logMessage = ""; |
226 | String logLocation = ""; | 231 | String logLocation = ""; |
227 | foreach(string revisionDir in directories) | 232 | foreach (string revisionDir in directories) |
228 | { | 233 | { |
229 | try { | 234 | try |
230 | logLocation = revisionDir + Slash.DirectorySeparatorChar + "log"; | 235 | { |
231 | fs = new FileStream( logLocation, FileMode.Open); | 236 | logLocation = revisionDir + Slash.DirectorySeparatorChar + "log"; |
232 | sr = new StreamReader(fs); | 237 | fs = new FileStream( logLocation, FileMode.Open); |
233 | logMessage = sr.ReadToEnd(); | 238 | sr = new StreamReader(fs); |
234 | sr.Close(); | 239 | logMessage = sr.ReadToEnd(); |
235 | fs.Close(); | 240 | sr.Close(); |
236 | revisionDict.Add(revisionDir, logMessage); | 241 | fs.Close(); |
237 | } | 242 | revisionDict.Add(revisionDir, logMessage); |
238 | catch (Exception) | 243 | } |
239 | {} | 244 | catch (Exception) |
245 | { | ||
246 | } | ||
240 | } | 247 | } |
241 | 248 | ||
242 | return revisionDict; | 249 | return revisionDict; |
@@ -254,9 +261,9 @@ namespace OpenSim.Region.Environment.Modules.ContentManagement | |||
254 | public void PostInitialise() | 261 | public void PostInitialise() |
255 | { | 262 | { |
256 | SetupSerialiser(); | 263 | SetupSerialiser(); |
257 | 264 | ||
258 | m_log.Info("[FSDB]: Creating repository in " + m_repodir + "."); | 265 | m_log.Info("[FSDB]: Creating repository in " + m_repodir + "."); |
259 | CreateDirectory(); | 266 | CreateDirectory(); |
260 | } | 267 | } |
261 | 268 | ||
262 | public void SaveRegion(UUID regionid, string regionName, string logMessage) | 269 | public void SaveRegion(UUID regionid, string regionName, string logMessage) |
@@ -266,44 +273,44 @@ namespace OpenSim.Region.Environment.Modules.ContentManagement | |||
266 | 273 | ||
267 | m_log.Info("[FSDB]: checking if scene directory exists: " + scenedir); | 274 | m_log.Info("[FSDB]: checking if scene directory exists: " + scenedir); |
268 | if (!Directory.Exists(scenedir)) | 275 | if (!Directory.Exists(scenedir)) |
269 | Directory.CreateDirectory(scenedir); | 276 | Directory.CreateDirectory(scenedir); |
270 | 277 | ||
271 | int newRevisionNum = GetMostRecentRevision(regionid)+1; | 278 | int newRevisionNum = GetMostRecentRevision(regionid)+1; |
272 | string revisiondir = scenedir + newRevisionNum + Slash.DirectorySeparatorChar; | 279 | string revisiondir = scenedir + newRevisionNum + Slash.DirectorySeparatorChar; |
273 | 280 | ||
274 | m_log.Info("[FSDB]: checking if revision directory exists: " + revisiondir); | 281 | m_log.Info("[FSDB]: checking if revision directory exists: " + revisiondir); |
275 | if (!Directory.Exists(revisiondir)) | 282 | if (!Directory.Exists(revisiondir)) |
276 | Directory.CreateDirectory(revisiondir); | 283 | Directory.CreateDirectory(revisiondir); |
277 | 284 | ||
278 | try { | 285 | try { |
279 | Stopwatch x = new Stopwatch(); | 286 | Stopwatch x = new Stopwatch(); |
280 | x.Start(); | 287 | x.Start(); |
281 | if (m_scenes.ContainsKey(regionid)) | 288 | if (m_scenes.ContainsKey(regionid)) |
282 | { | 289 | { |
283 | m_serialiser[regionid].SerialiseRegion(m_scenes[regionid], revisiondir); | 290 | m_serialiser[regionid].SerialiseRegion(m_scenes[regionid], revisiondir); |
284 | } | 291 | } |
285 | x.Stop(); | 292 | x.Stop(); |
286 | TimeToSave += x.ElapsedMilliseconds; | 293 | TimeToSave += x.ElapsedMilliseconds; |
287 | m_log.Info("[FileSystemDatabase] Time spent serialising regions to files on disk for " + regionName + ": " + x.ElapsedMilliseconds); | 294 | m_log.Info("[FileSystemDatabase] Time spent serialising regions to files on disk for " + regionName + ": " + x.ElapsedMilliseconds); |
288 | m_log.Info("[FileSystemDatabase] Time spent serialising regions to files on disk so far: " + TimeToSave); | 295 | m_log.Info("[FileSystemDatabase] Time spent serialising regions to files on disk so far: " + TimeToSave); |
289 | } | 296 | } |
290 | catch (Exception e) | 297 | catch (Exception e) |
291 | { | 298 | { |
292 | m_log.ErrorFormat("[FSDB]: Serialisation of region failed: " + e); | 299 | m_log.ErrorFormat("[FSDB]: Serialisation of region failed: " + e); |
293 | return; | 300 | return; |
294 | } | 301 | } |
295 | 302 | ||
296 | try { | 303 | try { |
297 | // Finish by writing log message. | 304 | // Finish by writing log message. |
298 | FileStream file = new FileStream(revisiondir + "log", FileMode.Create, FileAccess.ReadWrite); | 305 | FileStream file = new FileStream(revisiondir + "log", FileMode.Create, FileAccess.ReadWrite); |
299 | StreamWriter sw = new StreamWriter(file); | 306 | StreamWriter sw = new StreamWriter(file); |
300 | sw.Write(logMessage); | 307 | sw.Write(logMessage); |
301 | sw.Close(); | 308 | sw.Close(); |
302 | } | 309 | } |
303 | catch (Exception e) | 310 | catch (Exception e) |
304 | { | 311 | { |
305 | m_log.ErrorFormat("[FSDB]: Failed trying to save log file " + e); | 312 | m_log.ErrorFormat("[FSDB]: Failed trying to save log file " + e); |
306 | return; | 313 | return; |
307 | } | 314 | } |
308 | } | 315 | } |
309 | 316 | ||