From 34b6904939dd551aafa68ea8e02dc5177d395b3b Mon Sep 17 00:00:00 2001 From: Sean McNamara Date: Sat, 26 Feb 2011 22:09:19 -0500 Subject: First working commit of AutoBackupModule. It seems to do something! Heuristics are still TODO, but this is alpha 1. --- .../World/AutoBackup/AutoBackupModule.cs | 34 +++++++++++++++------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs b/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs index 77126c7..e3686ac 100644 --- a/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs +++ b/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs @@ -281,7 +281,7 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup tim.Elapsed += HandleElapsed; tim.AutoReset = true; tim.Start(); - m_log.Debug("[AUTO BACKUP MODULE]: New timer for " + interval + " msec for region " + sRegionName); + //m_log.Debug("[AUTO BACKUP MODULE]: New timer for " + interval + " msec for region " + sRegionName); } //Add the current region to the list of regions tied to this timer. @@ -292,6 +292,7 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup else { List scns = new List(1); + scns.Add(scene); timerMap.Add(st.GetTimer(), scns); } @@ -343,6 +344,10 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup { bool heuristicsRun = false; bool heuristicsPassed = false; + if(!timerMap.ContainsKey((Timer) sender)) + { + m_log.Debug("Code-up error: timerMap doesn't contain timer " + sender.ToString()); + } foreach(IScene scene in timerMap[(Timer)sender]) { AutoBackupModuleState state = states[scene]; @@ -352,16 +357,7 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup if((heuristics && heuristicsRun && heuristicsPassed) || !heuristics) { - IRegionArchiverModule iram = scene.RequestModuleInterface(); - string savePath = BuildOarPath(scene.RegionInfo.RegionName, state.GetBackupDir(), state.GetNamingType()); - m_log.Debug("[AUTO BACKUP MODULE]: savePath = " + savePath); - if(savePath == null) - { - m_log.Warn("savePath is null in HandleElapsed"); - continue; - } - iram.ArchiveRegion(savePath, null); - ExecuteScript(state.GetScript(), savePath); + doRegionBackup(scene); } //Heuristics are on; ran but we're too busy -- keep going. Maybe another region will have heuristics off! else if(heuristics && heuristicsRun && !heuristicsPassed) @@ -375,9 +371,25 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup heuristicsRun = true; if(!heuristicsPassed) continue; + doRegionBackup(scene); } } } + + void doRegionBackup(IScene scene) + { + AutoBackupModuleState state = states[scene]; + IRegionArchiverModule iram = scene.RequestModuleInterface(); + string savePath = BuildOarPath(scene.RegionInfo.RegionName, state.GetBackupDir(), state.GetNamingType()); + //m_log.Debug("[AUTO BACKUP MODULE]: savePath = " + savePath); + if(savePath == null) + { + m_log.Warn("[AUTO BACKUP MODULE]: savePath is null in HandleElapsed"); + return; + } + iram.ArchiveRegion(savePath, null); + ExecuteScript(state.GetScript(), savePath); + } string IRegionModuleBase.Name { get { -- cgit v1.1