aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Modules
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/Modules
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 '')
-rw-r--r--OpenSim/Region/Modules/SvnSerialiser/SvnBackupModule.cs141
1 files changed, 72 insertions, 69 deletions
diff --git a/OpenSim/Region/Modules/SvnSerialiser/SvnBackupModule.cs b/OpenSim/Region/Modules/SvnSerialiser/SvnBackupModule.cs
index 4046a7c..d932c55 100644
--- a/OpenSim/Region/Modules/SvnSerialiser/SvnBackupModule.cs
+++ b/OpenSim/Region/Modules/SvnSerialiser/SvnBackupModule.cs
@@ -18,22 +18,21 @@ namespace OpenSim.Region.Modules.SvnSerialiser
18 public class SvnBackupModule : IRegionModule 18 public class SvnBackupModule : IRegionModule
19 { 19 {
20 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 20 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
21 21
22 private SvnClient m_svnClient;
23 private bool m_enabled = false; 22 private bool m_enabled = false;
24 private bool m_installBackupOnLoad = false; 23 private bool m_installBackupOnLoad = false;
25 private string m_svnurl = "svn://insert.your.svn/here/"; 24 private List<Scene> m_scenes = new List<Scene>();
26 private string m_svnuser = "username"; 25 private IRegionSerialiser m_serialiser;
27 private string m_svnpass = "password"; 26 private bool m_svnAutoSave = false;
27 private SvnClient m_svnClient;
28 private string m_svndir = "SVNmodule\\repo"; 28 private string m_svndir = "SVNmodule\\repo";
29 private string m_svnpass = "password";
29 30
30 private TimeSpan m_svnperiod = new TimeSpan(0, 0, 15, 0, 0); 31 private TimeSpan m_svnperiod = new TimeSpan(0, 0, 15, 0, 0);
31 private bool m_svnAutoSave = false; 32 private string m_svnurl = "svn://insert.your.svn/here/";
33 private string m_svnuser = "username";
32 private Timer m_timer = new Timer(); 34 private Timer m_timer = new Timer();
33 35
34 private IRegionSerialiser m_serialiser;
35 private List<Scene> m_scenes = new List<Scene>();
36
37 #region SvnModule Core 36 #region SvnModule Core
38 37
39 /// <summary> 38 /// <summary>
@@ -76,7 +75,9 @@ namespace OpenSim.Region.Modules.SvnSerialiser
76 { 75 {
77 m_svnClient.Add3(m_svndir + Slash.DirectorySeparatorChar + scene.RegionInfo.RegionID.ToString(), true, false, false); 76 m_svnClient.Add3(m_svndir + Slash.DirectorySeparatorChar + scene.RegionInfo.RegionID.ToString(), true, false, false);
78 } 77 }
79 catch (SvnException) { } 78 catch (SvnException)
79 {
80 }
80 81
81 List<string> svnfilenames = new List<string>(); 82 List<string> svnfilenames = new List<string>();
82 foreach (string filename in filenames) 83 foreach (string filename in filenames)
@@ -88,10 +89,10 @@ namespace OpenSim.Region.Modules.SvnSerialiser
88 89
89 public void LoadRegion(Scene scene) 90 public void LoadRegion(Scene scene)
90 { 91 {
91 scene.LoadPrimsFromXml2(m_svndir + Slash.DirectorySeparatorChar + scene.RegionInfo.RegionID.ToString() + 92 scene.LoadPrimsFromXml2(m_svndir + Slash.DirectorySeparatorChar + scene.RegionInfo.RegionID.ToString() +
92 Slash.DirectorySeparatorChar + "objects.xml"); 93 Slash.DirectorySeparatorChar + "objects.xml");
93 scene.RequestModuleInterface<ITerrainModule>().LoadFromFile(m_svndir + Slash.DirectorySeparatorChar + scene.RegionInfo.RegionID.ToString() + 94 scene.RequestModuleInterface<ITerrainModule>().LoadFromFile(m_svndir + Slash.DirectorySeparatorChar + scene.RegionInfo.RegionID.ToString() +
94 Slash.DirectorySeparatorChar + "heightmap.r32"); 95 Slash.DirectorySeparatorChar + "heightmap.r32");
95 m_log.Info("[SVNBACKUP]: Region load successful (" + scene.RegionInfo.RegionName + ")."); 96 m_log.Info("[SVNBACKUP]: Region load successful (" + scene.RegionInfo.RegionName + ").");
96 } 97 }
97 98
@@ -126,7 +127,7 @@ namespace OpenSim.Region.Modules.SvnSerialiser
126 #region SvnDotNet Callbacks 127 #region SvnDotNet Callbacks
127 128
128 private SvnError SimpleAuth(out SvnAuthCredSimple svnCredentials, IntPtr baton, 129 private SvnError SimpleAuth(out SvnAuthCredSimple svnCredentials, IntPtr baton,
129 AprString realm, AprString username, bool maySave, AprPool pool) 130 AprString realm, AprString username, bool maySave, AprPool pool)
130 { 131 {
131 svnCredentials = SvnAuthCredSimple.Alloc(pool); 132 svnCredentials = SvnAuthCredSimple.Alloc(pool);
132 svnCredentials.Username = new AprString(m_svnuser, pool); 133 svnCredentials.Username = new AprString(m_svnuser, pool);
@@ -140,7 +141,7 @@ namespace OpenSim.Region.Modules.SvnSerialiser
140 if (!commitItems.IsNull) 141 if (!commitItems.IsNull)
141 { 142 {
142 foreach (SvnClientCommitItem2 item in commitItems) 143 foreach (SvnClientCommitItem2 item in commitItems)
143 { 144 {
144 m_log.Debug("[SVNBACKUP]: ... " + Path.GetFileName(item.Path.ToString()) + " (" + item.Kind.ToString() + ") r" + item.Revision.ToString()); 145 m_log.Debug("[SVNBACKUP]: ... " + Path.GetFileName(item.Path.ToString()) + " (" + item.Kind.ToString() + ") r" + item.Revision.ToString());
145 } 146 }
146 } 147 }
@@ -174,8 +175,11 @@ namespace OpenSim.Region.Modules.SvnSerialiser
174 m_svnpass = source.Configs["SVN"].GetString("Password", m_svnpass); 175 m_svnpass = source.Configs["SVN"].GetString("Password", m_svnpass);
175 m_installBackupOnLoad = source.Configs["SVN"].GetBoolean("ImportOnStartup", m_installBackupOnLoad); 176 m_installBackupOnLoad = source.Configs["SVN"].GetBoolean("ImportOnStartup", m_installBackupOnLoad);
176 m_svnAutoSave = source.Configs["SVN"].GetBoolean("Autosave", m_svnAutoSave); 177 m_svnAutoSave = source.Configs["SVN"].GetBoolean("Autosave", m_svnAutoSave);
177 m_svnperiod = new TimeSpan(0, source.Configs["SVN"].GetInt("AutosavePeriod", (int)m_svnperiod.TotalMinutes), 0); 178 m_svnperiod = new TimeSpan(0, source.Configs["SVN"].GetInt("AutosavePeriod", (int) m_svnperiod.TotalMinutes), 0);
178 } catch(Exception) { } 179 }
180 catch (Exception)
181 {
182 }
179 183
180 lock (m_scenes) 184 lock (m_scenes)
181 { 185 {
@@ -185,7 +189,54 @@ namespace OpenSim.Region.Modules.SvnSerialiser
185 scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole; 189 scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole;
186 } 190 }
187 191
188 void EventManager_OnPluginConsole(string[] args) 192 public void PostInitialise()
193 {
194 if (m_enabled == false)
195 return;
196
197 if (m_svnAutoSave == true)
198 {
199 m_timer.Interval = m_svnperiod.TotalMilliseconds;
200 m_timer.Elapsed += new ElapsedEventHandler(m_timer_Elapsed);
201 m_timer.AutoReset = true;
202 m_timer.Start();
203 }
204
205 m_log.Info("[SVNBACKUP]: Connecting to SVN server " + m_svnurl + " ...");
206 SetupSvnProvider();
207
208 m_log.Info("[SVNBACKUP]: Creating repository in " + m_svndir + ".");
209 CreateSvnDirectory();
210 CheckoutSvn();
211 SetupSerialiser();
212
213 if (m_installBackupOnLoad)
214 {
215 m_log.Info("[SVNBACKUP]: Importing latest SVN revision to scenes...");
216 foreach (Scene scene in m_scenes)
217 {
218 LoadRegion(scene);
219 }
220 }
221 }
222
223 public void Close()
224 {
225 }
226
227 public string Name
228 {
229 get { return "SvnBackupModule"; }
230 }
231
232 public bool IsSharedModule
233 {
234 get { return true; }
235 }
236
237 #endregion
238
239 private void EventManager_OnPluginConsole(string[] args)
189 { 240 {
190 if (args[0] == "svn" && args[1] == "save") 241 if (args[0] == "svn" && args[1] == "save")
191 { 242 {
@@ -272,38 +323,7 @@ namespace OpenSim.Region.Modules.SvnSerialiser
272 } 323 }
273 } 324 }
274 325
275 public void PostInitialise() 326 private void m_timer_Elapsed(object sender, ElapsedEventArgs e)
276 {
277 if (m_enabled == false)
278 return;
279
280 if (m_svnAutoSave == true)
281 {
282 m_timer.Interval = m_svnperiod.TotalMilliseconds;
283 m_timer.Elapsed += new ElapsedEventHandler(m_timer_Elapsed);
284 m_timer.AutoReset = true;
285 m_timer.Start();
286 }
287
288 m_log.Info("[SVNBACKUP]: Connecting to SVN server " + m_svnurl + " ...");
289 SetupSvnProvider();
290
291 m_log.Info("[SVNBACKUP]: Creating repository in " + m_svndir + ".");
292 CreateSvnDirectory();
293 CheckoutSvn();
294 SetupSerialiser();
295
296 if (m_installBackupOnLoad)
297 {
298 m_log.Info("[SVNBACKUP]: Importing latest SVN revision to scenes...");
299 foreach (Scene scene in m_scenes)
300 {
301 LoadRegion(scene);
302 }
303 }
304 }
305
306 void m_timer_Elapsed(object sender, ElapsedEventArgs e)
307 { 327 {
308 SaveAllRegions(); 328 SaveAllRegions();
309 } 329 }
@@ -320,7 +340,7 @@ namespace OpenSim.Region.Modules.SvnSerialiser
320 m_svnClient.AddUsernameProvider(); 340 m_svnClient.AddUsernameProvider();
321 m_svnClient.AddPromptProvider(new SvnAuthProviderObject.SimplePrompt(SimpleAuth), IntPtr.Zero, 2); 341 m_svnClient.AddPromptProvider(new SvnAuthProviderObject.SimplePrompt(SimpleAuth), IntPtr.Zero, 2);
322 m_svnClient.OpenAuth(); 342 m_svnClient.OpenAuth();
323 m_svnClient.Context.LogMsgFunc2 = new SvnDelegate(new SvnClient.GetCommitLog2(GetCommitLogCallback)); 343 m_svnClient.Context.LogMsgFunc2 = new SvnDelegate(new SvnClient.GetCommitLog2(GetCommitLogCallback));
324 } 344 }
325 345
326 private void CreateSvnDirectory() 346 private void CreateSvnDirectory()
@@ -328,22 +348,5 @@ namespace OpenSim.Region.Modules.SvnSerialiser
328 if (!Directory.Exists(m_svndir)) 348 if (!Directory.Exists(m_svndir))
329 Directory.CreateDirectory(m_svndir); 349 Directory.CreateDirectory(m_svndir);
330 } 350 }
331
332 public void Close()
333 {
334
335 }
336
337 public string Name
338 {
339 get { return "SvnBackupModule"; }
340 }
341
342 public bool IsSharedModule
343 {
344 get { return true; }
345 }
346
347 #endregion
348 } 351 }
349} 352} \ No newline at end of file