First working commit of AutoBackupModule.

It seems to do something! Heuristics are still TODO, but this is alpha 1.
bulletsim
Sean McNamara 2011-02-26 22:09:19 -05:00
parent d3511ca592
commit 34b6904939
1 changed files with 23 additions and 11 deletions

View File

@ -281,7 +281,7 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup
tim.Elapsed += HandleElapsed; tim.Elapsed += HandleElapsed;
tim.AutoReset = true; tim.AutoReset = true;
tim.Start(); 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. //Add the current region to the list of regions tied to this timer.
@ -292,6 +292,7 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup
else else
{ {
List<IScene> scns = new List<IScene>(1); List<IScene> scns = new List<IScene>(1);
scns.Add(scene);
timerMap.Add(st.GetTimer(), scns); timerMap.Add(st.GetTimer(), scns);
} }
@ -343,6 +344,10 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup
{ {
bool heuristicsRun = false; bool heuristicsRun = false;
bool heuristicsPassed = 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]) foreach(IScene scene in timerMap[(Timer)sender])
{ {
AutoBackupModuleState state = states[scene]; AutoBackupModuleState state = states[scene];
@ -352,16 +357,7 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup
if((heuristics && heuristicsRun && heuristicsPassed) if((heuristics && heuristicsRun && heuristicsPassed)
|| !heuristics) || !heuristics)
{ {
IRegionArchiverModule iram = scene.RequestModuleInterface<IRegionArchiverModule>(); doRegionBackup(scene);
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);
} }
//Heuristics are on; ran but we're too busy -- keep going. Maybe another region will have heuristics off! //Heuristics are on; ran but we're too busy -- keep going. Maybe another region will have heuristics off!
else if(heuristics && heuristicsRun && !heuristicsPassed) else if(heuristics && heuristicsRun && !heuristicsPassed)
@ -375,10 +371,26 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup
heuristicsRun = true; heuristicsRun = true;
if(!heuristicsPassed) if(!heuristicsPassed)
continue; continue;
doRegionBackup(scene);
} }
} }
} }
void doRegionBackup(IScene scene)
{
AutoBackupModuleState state = states[scene];
IRegionArchiverModule iram = scene.RequestModuleInterface<IRegionArchiverModule>();
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 { string IRegionModuleBase.Name {
get { get {
return "AutoBackupModule"; return "AutoBackupModule";