diff options
author | Melanie | 2010-11-25 03:16:52 +0000 |
---|---|---|
committer | Melanie | 2010-11-25 03:16:52 +0000 |
commit | 57c4def254b85997f5b8a4cd4e7d1db550947290 (patch) | |
tree | 89c9521d8e208820ff54a1505088792b1eabb1a6 /OpenSim/Region | |
parent | Finish the RestartModule and fix some bugs. Add new console commands: (diff) | |
download | opensim-SC-57c4def254b85997f5b8a4cd4e7d1db550947290.zip opensim-SC-57c4def254b85997f5b8a4cd4e7d1db550947290.tar.gz opensim-SC-57c4def254b85997f5b8a4cd4e7d1db550947290.tar.bz2 opensim-SC-57c4def254b85997f5b8a4cd4e7d1db550947290.tar.xz |
Change all restarting to use the restart module. Remove hardcoded behavior
Diffstat (limited to '')
4 files changed, 49 insertions, 71 deletions
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index 622fc08..ddae20f 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs | |||
@@ -231,7 +231,23 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
231 | 231 | ||
232 | private void handleEstateRestartSimRequest(IClientAPI remoteClient, int timeInSeconds) | 232 | private void handleEstateRestartSimRequest(IClientAPI remoteClient, int timeInSeconds) |
233 | { | 233 | { |
234 | m_scene.Restart(timeInSeconds); | 234 | IRestartModule restartModule = m_scene.RequestModuleInterface<IRestartModule>(); |
235 | if (restartModule != null) | ||
236 | { | ||
237 | List<int> times = new List<int>(); | ||
238 | while (timeInSeconds > 0) | ||
239 | { | ||
240 | times.Add(timeInSeconds); | ||
241 | if (timeInSeconds > 300) | ||
242 | timeInSeconds -= 120; | ||
243 | else if (timeInSeconds > 30) | ||
244 | timeInSeconds -= 30; | ||
245 | else | ||
246 | timeInSeconds -= 15; | ||
247 | } | ||
248 | |||
249 | restartModule.ScheduleRestart(UUID.Zero, "Region will restart in {0}", times.ToArray(), true); | ||
250 | } | ||
235 | } | 251 | } |
236 | 252 | ||
237 | private void handleChangeEstateCovenantRequest(IClientAPI remoteClient, UUID estateCovenantID) | 253 | private void handleChangeEstateCovenantRequest(IClientAPI remoteClient, UUID estateCovenantID) |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 4fc2cbc..129b52d 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -893,60 +893,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
893 | return new GridRegion(RegionInfo); | 893 | return new GridRegion(RegionInfo); |
894 | } | 894 | } |
895 | 895 | ||
896 | /// <summary> | ||
897 | /// Given float seconds, this will restart the region. | ||
898 | /// </summary> | ||
899 | /// <param name="seconds">float indicating duration before restart.</param> | ||
900 | public virtual void Restart(float seconds) | ||
901 | { | ||
902 | // notifications are done in 15 second increments | ||
903 | // so .. if the number of seconds is less then 15 seconds, it's not really a restart request | ||
904 | // It's a 'Cancel restart' request. | ||
905 | |||
906 | // RestartNow() does immediate restarting. | ||
907 | if (seconds < 15) | ||
908 | { | ||
909 | m_restartTimer.Stop(); | ||
910 | m_dialogModule.SendGeneralAlert("Restart Aborted"); | ||
911 | } | ||
912 | else | ||
913 | { | ||
914 | // Now we figure out what to set the timer to that does the notifications and calls, RestartNow() | ||
915 | m_restartTimer.Interval = 15000; | ||
916 | m_incrementsof15seconds = (int)seconds / 15; | ||
917 | m_RestartTimerCounter = 0; | ||
918 | m_restartTimer.AutoReset = true; | ||
919 | m_restartTimer.Elapsed += new ElapsedEventHandler(RestartTimer_Elapsed); | ||
920 | m_log.Info("[REGION]: Restarting Region in " + (seconds / 60) + " minutes"); | ||
921 | m_restartTimer.Start(); | ||
922 | m_dialogModule.SendNotificationToUsersInRegion( | ||
923 | UUID.Random(), String.Empty, RegionInfo.RegionName + String.Format(": Restarting in {0} Minutes", (int)(seconds / 60.0))); | ||
924 | } | ||
925 | } | ||
926 | |||
927 | // The Restart timer has occured. | ||
928 | // We have to figure out if this is a notification or if the number of seconds specified in Restart | ||
929 | // have elapsed. | ||
930 | // If they have elapsed, call RestartNow() | ||
931 | public void RestartTimer_Elapsed(object sender, ElapsedEventArgs e) | ||
932 | { | ||
933 | m_RestartTimerCounter++; | ||
934 | if (m_RestartTimerCounter <= m_incrementsof15seconds) | ||
935 | { | ||
936 | if (m_RestartTimerCounter == 4 || m_RestartTimerCounter == 6 || m_RestartTimerCounter == 7) | ||
937 | m_dialogModule.SendNotificationToUsersInRegion( | ||
938 | UUID.Random(), | ||
939 | String.Empty, | ||
940 | RegionInfo.RegionName + ": Restarting in " + ((8 - m_RestartTimerCounter) * 15) + " seconds"); | ||
941 | } | ||
942 | else | ||
943 | { | ||
944 | m_restartTimer.Stop(); | ||
945 | m_restartTimer.AutoReset = false; | ||
946 | RestartNow(); | ||
947 | } | ||
948 | } | ||
949 | |||
950 | // This causes the region to restart immediatley. | 896 | // This causes the region to restart immediatley. |
951 | public void RestartNow() | 897 | public void RestartNow() |
952 | { | 898 | { |
@@ -969,7 +915,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
969 | Close(); | 915 | Close(); |
970 | 916 | ||
971 | m_log.Error("[REGION]: Firing Region Restart Message"); | 917 | m_log.Error("[REGION]: Firing Region Restart Message"); |
972 | base.Restart(0); | 918 | |
919 | base.Restart(); | ||
973 | } | 920 | } |
974 | 921 | ||
975 | // This is a helper function that notifies root agents in this region that a new sim near them has come up | 922 | // This is a helper function that notifies root agents in this region that a new sim near them has come up |
diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs index c71aefa..f343bc8 100644 --- a/OpenSim/Region/Framework/Scenes/SceneBase.cs +++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs | |||
@@ -218,18 +218,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
218 | 218 | ||
219 | #region admin stuff | 219 | #region admin stuff |
220 | 220 | ||
221 | /// <summary> | ||
222 | /// Region Restart - Seconds till restart. | ||
223 | /// </summary> | ||
224 | /// <param name="seconds"></param> | ||
225 | public virtual void Restart(int seconds) | ||
226 | { | ||
227 | m_log.Error("[REGION]: passing Restart Message up the namespace"); | ||
228 | restart handlerPhysicsCrash = OnRestart; | ||
229 | if (handlerPhysicsCrash != null) | ||
230 | handlerPhysicsCrash(RegionInfo); | ||
231 | } | ||
232 | |||
233 | public virtual bool PresenceChildStatus(UUID avatarID) | 221 | public virtual bool PresenceChildStatus(UUID avatarID) |
234 | { | 222 | { |
235 | return false; | 223 | return false; |
@@ -562,6 +550,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
562 | get { return false; } | 550 | get { return false; } |
563 | } | 551 | } |
564 | 552 | ||
553 | public void Restart() | ||
554 | { | ||
555 | // This has to be here to fire the event | ||
556 | restart handlerPhysicsCrash = OnRestart; | ||
557 | if (handlerPhysicsCrash != null) | ||
558 | handlerPhysicsCrash(RegionInfo); | ||
559 | } | ||
560 | |||
565 | public abstract bool CheckClient(UUID agentID, System.Net.IPEndPoint ep); | 561 | public abstract bool CheckClient(UUID agentID, System.Net.IPEndPoint ep); |
566 | } | 562 | } |
567 | } | 563 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index fc92f23..827626f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -395,10 +395,29 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
395 | // | 395 | // |
396 | CheckThreatLevel(ThreatLevel.High, "osRegionRestart"); | 396 | CheckThreatLevel(ThreatLevel.High, "osRegionRestart"); |
397 | 397 | ||
398 | IRestartModule restartModule = World.RequestModuleInterface<IRestartModule>(); | ||
398 | m_host.AddScriptLPS(1); | 399 | m_host.AddScriptLPS(1); |
399 | if (World.Permissions.CanIssueEstateCommand(m_host.OwnerID, false)) | 400 | if (World.Permissions.CanIssueEstateCommand(m_host.OwnerID, false) && (restartModule != null)) |
400 | { | 401 | { |
401 | World.Restart((float)seconds); | 402 | if (seconds < 15) |
403 | { | ||
404 | restartModule.AbortRestart("Restart aborted"); | ||
405 | return 1; | ||
406 | } | ||
407 | |||
408 | List<int> times = new List<int>(); | ||
409 | while (seconds > 0) | ||
410 | { | ||
411 | times.Add((int)seconds); | ||
412 | if (seconds > 300) | ||
413 | seconds -= 120; | ||
414 | else if (seconds > 30) | ||
415 | seconds -= 30; | ||
416 | else | ||
417 | seconds -= 15; | ||
418 | } | ||
419 | |||
420 | restartModule.ScheduleRestart(UUID.Zero, "Region will restart in {0}", times.ToArray(), true); | ||
402 | return 1; | 421 | return 1; |
403 | } | 422 | } |
404 | else | 423 | else |
@@ -2315,4 +2334,4 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2315 | return date.ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ"); | 2334 | return date.ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ"); |
2316 | } | 2335 | } |
2317 | } | 2336 | } |
2318 | } \ No newline at end of file | 2337 | } |