Merge branch 'master' of ssh://opensimulator.org/var/git/opensim

viewer-2-initial-appearance
Diva Canto 2010-11-25 16:27:19 -08:00
commit 1cbd2842d5
9 changed files with 373 additions and 79 deletions

View File

@ -208,18 +208,25 @@ namespace OpenSim.ApplicationPlugins.RemoteController
UUID regionID = new UUID((string) requestData["regionID"]);
responseData["accepted"] = true;
responseData["success"] = true;
response.Value = responseData;
Scene rebootedScene;
responseData["success"] = false;
responseData["accepted"] = true;
if (!m_application.SceneManager.TryGetScene(regionID, out rebootedScene))
throw new Exception("region not found");
responseData["rebooting"] = true;
IRestartModule restartModule = rebootedScene.RequestModuleInterface<IRestartModule>();
if (restartModule != null)
{
List<int> times = new List<int> { 30, 15 };
restartModule.ScheduleRestart(UUID.Zero, "Region will restart in {0}", times.ToArray(), true);
responseData["success"] = true;
}
response.Value = responseData;
rebootedScene.Restart(30);
}
catch (Exception e)
{

View File

@ -73,7 +73,7 @@ namespace OpenSim.Framework
void AddNewClient(IClientAPI client);
void RemoveClient(UUID agentID);
void Restart(int seconds);
void Restart();
//RegionInfo OtherRegionUp(RegionInfo thisRegion);
string GetSimulatorVersion();

View File

@ -231,7 +231,23 @@ namespace OpenSim.Region.CoreModules.World.Estate
private void handleEstateRestartSimRequest(IClientAPI remoteClient, int timeInSeconds)
{
m_scene.Restart(timeInSeconds);
IRestartModule restartModule = m_scene.RequestModuleInterface<IRestartModule>();
if (restartModule != null)
{
List<int> times = new List<int>();
while (timeInSeconds > 0)
{
times.Add(timeInSeconds);
if (timeInSeconds > 300)
timeInSeconds -= 120;
else if (timeInSeconds > 30)
timeInSeconds -= 30;
else
timeInSeconds -= 15;
}
restartModule.ScheduleRestart(UUID.Zero, "Region will restart in {0}", times.ToArray(), true);
}
}
private void handleChangeEstateCovenantRequest(IClientAPI remoteClient, UUID estateCovenantID)

View File

@ -0,0 +1,263 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Reflection;
using System.Timers;
using System.Threading;
using System.Collections.Generic;
using log4net;
using Nini.Config;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.Console;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using Timer=System.Timers.Timer;
using Mono.Addins;
namespace OpenSim.Region.CoreModules.World.Region
{
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "RestartModule")]
public class RestartModule : INonSharedRegionModule, IRestartModule
{
private static readonly ILog m_log =
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
protected Scene m_Scene;
protected Timer m_CountdownTimer = null;
protected DateTime m_RestartBegin;
protected List<int> m_Alerts;
protected string m_Message;
protected UUID m_Initiator;
protected bool m_Notice = false;
protected IDialogModule m_DialogModule = null;
public void Initialise(IConfigSource config)
{
}
public void AddRegion(Scene scene)
{
m_Scene = scene;
scene.RegisterModuleInterface<IRestartModule>(this);
MainConsole.Instance.Commands.AddCommand("RestartModule",
false, "region restart bluebox",
"region restart bluebox <message> <time> ...",
"Restart the region", HandleRegionRestart);
MainConsole.Instance.Commands.AddCommand("RestartModule",
false, "region restart notice",
"region restart notice <message> <time> ...",
"Restart the region", HandleRegionRestart);
MainConsole.Instance.Commands.AddCommand("RestartModule",
false, "region restart abort",
"region restart abort [<message>]",
"Restart the region", HandleRegionRestart);
}
public void RegionLoaded(Scene scene)
{
m_DialogModule = m_Scene.RequestModuleInterface<IDialogModule>();
}
public void RemoveRegion(Scene scene)
{
}
public void Close()
{
}
public string Name
{
get { return "RestartModule"; }
}
public Type ReplaceableInterface
{
get { return typeof(IRestartModule); }
}
public TimeSpan TimeUntilRestart
{
get { return DateTime.Now - m_RestartBegin; }
}
public void ScheduleRestart(UUID initiator, string message, int[] alerts, bool notice)
{
if (m_CountdownTimer != null)
return;
if (alerts == null)
{
m_Scene.RestartNow();
return;
}
m_Message = message;
m_Initiator = initiator;
m_Notice = notice;
m_Alerts = new List<int>(alerts);
m_Alerts.Sort();
m_Alerts.Reverse();
if (m_Alerts[0] == 0)
{
m_Scene.RestartNow();
return;
}
int nextInterval = DoOneNotice();
SetTimer(nextInterval);
}
public int DoOneNotice()
{
if (m_Alerts.Count == 0 || m_Alerts[0] == 0)
{
m_Scene.RestartNow();
return 0;
}
int nextAlert = 0;
while (m_Alerts.Count > 1)
{
if (m_Alerts[1] == m_Alerts[0])
{
m_Alerts.RemoveAt(0);
continue;
}
nextAlert = m_Alerts[1];
break;
}
int currentAlert = m_Alerts[0];
m_Alerts.RemoveAt(0);
int minutes = currentAlert / 60;
string currentAlertString = String.Empty;
if (minutes > 0)
{
if (minutes == 1)
currentAlertString += "1 minute";
else
currentAlertString += String.Format("{0} minutes", minutes);
if ((currentAlert % 60) != 0)
currentAlertString += " and ";
}
if ((currentAlert % 60) != 0)
{
int seconds = currentAlert % 60;
if (seconds == 1)
currentAlertString += "1 second";
else
currentAlertString += String.Format("{0} seconds", seconds);
}
string msg = String.Format(m_Message, currentAlertString);
if (m_DialogModule != null && msg != String.Empty)
{
if (m_Notice)
m_DialogModule.SendGeneralAlert(msg);
else
m_DialogModule.SendNotificationToUsersInRegion(m_Initiator, "System", msg);
}
return currentAlert - nextAlert;
}
public void SetTimer(int intervalSeconds)
{
m_CountdownTimer = new Timer();
m_CountdownTimer.AutoReset = false;
m_CountdownTimer.Interval = intervalSeconds * 1000;
m_CountdownTimer.Elapsed += OnTimer;
m_CountdownTimer.Start();
}
private void OnTimer(object source, ElapsedEventArgs e)
{
int nextInterval = DoOneNotice();
SetTimer(nextInterval);
}
public void AbortRestart(string message)
{
if (m_CountdownTimer != null)
{
m_CountdownTimer.Stop();
m_CountdownTimer = null;
if (m_DialogModule != null && message != String.Empty)
m_DialogModule.SendGeneralAlert(message);
}
}
private void HandleRegionRestart(string module, string[] args)
{
if (!(MainConsole.Instance.ConsoleScene is Scene))
return;
if (MainConsole.Instance.ConsoleScene != m_Scene)
return;
if (args.Length < 5)
{
if (args.Length > 2)
{
if (args[2] == "abort")
{
string msg = String.Empty;
if (args.Length > 3)
msg = args[3];
AbortRestart(msg);
MainConsole.Instance.Output("Region restart aborted");
return;
}
}
MainConsole.Instance.Output("Error: restart region <mode> <name> <time> ...");
return;
}
bool notice = false;
if (args[2] == "notice")
notice = true;
List<int> times = new List<int>();
for (int i = 4 ; i < args.Length ; i++)
times.Add(Convert.ToInt32(args[i]));
ScheduleRestart(UUID.Zero, args[3], times.ToArray(), notice);
}
}
}

View File

@ -0,0 +1,39 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using OpenMetaverse;
namespace OpenSim.Region.Framework.Interfaces
{
public interface IRestartModule
{
TimeSpan TimeUntilRestart { get; }
void ScheduleRestart(UUID initiator, string message, int[] alerts, bool notice);
void AbortRestart(string message);
}
}

View File

@ -893,60 +893,6 @@ namespace OpenSim.Region.Framework.Scenes
return new GridRegion(RegionInfo);
}
/// <summary>
/// Given float seconds, this will restart the region.
/// </summary>
/// <param name="seconds">float indicating duration before restart.</param>
public virtual void Restart(float seconds)
{
// notifications are done in 15 second increments
// so .. if the number of seconds is less then 15 seconds, it's not really a restart request
// It's a 'Cancel restart' request.
// RestartNow() does immediate restarting.
if (seconds < 15)
{
m_restartTimer.Stop();
m_dialogModule.SendGeneralAlert("Restart Aborted");
}
else
{
// Now we figure out what to set the timer to that does the notifications and calls, RestartNow()
m_restartTimer.Interval = 15000;
m_incrementsof15seconds = (int)seconds / 15;
m_RestartTimerCounter = 0;
m_restartTimer.AutoReset = true;
m_restartTimer.Elapsed += new ElapsedEventHandler(RestartTimer_Elapsed);
m_log.Info("[REGION]: Restarting Region in " + (seconds / 60) + " minutes");
m_restartTimer.Start();
m_dialogModule.SendNotificationToUsersInRegion(
UUID.Random(), String.Empty, RegionInfo.RegionName + String.Format(": Restarting in {0} Minutes", (int)(seconds / 60.0)));
}
}
// The Restart timer has occured.
// We have to figure out if this is a notification or if the number of seconds specified in Restart
// have elapsed.
// If they have elapsed, call RestartNow()
public void RestartTimer_Elapsed(object sender, ElapsedEventArgs e)
{
m_RestartTimerCounter++;
if (m_RestartTimerCounter <= m_incrementsof15seconds)
{
if (m_RestartTimerCounter == 4 || m_RestartTimerCounter == 6 || m_RestartTimerCounter == 7)
m_dialogModule.SendNotificationToUsersInRegion(
UUID.Random(),
String.Empty,
RegionInfo.RegionName + ": Restarting in " + ((8 - m_RestartTimerCounter) * 15) + " seconds");
}
else
{
m_restartTimer.Stop();
m_restartTimer.AutoReset = false;
RestartNow();
}
}
// This causes the region to restart immediatley.
public void RestartNow()
{
@ -969,7 +915,8 @@ namespace OpenSim.Region.Framework.Scenes
Close();
m_log.Error("[REGION]: Firing Region Restart Message");
base.Restart(0);
base.Restart();
}
// This is a helper function that notifies root agents in this region that a new sim near them has come up

View File

@ -218,18 +218,6 @@ namespace OpenSim.Region.Framework.Scenes
#region admin stuff
/// <summary>
/// Region Restart - Seconds till restart.
/// </summary>
/// <param name="seconds"></param>
public virtual void Restart(int seconds)
{
m_log.Error("[REGION]: passing Restart Message up the namespace");
restart handlerPhysicsCrash = OnRestart;
if (handlerPhysicsCrash != null)
handlerPhysicsCrash(RegionInfo);
}
public virtual bool PresenceChildStatus(UUID avatarID)
{
return false;
@ -562,6 +550,14 @@ namespace OpenSim.Region.Framework.Scenes
get { return false; }
}
public void Restart()
{
// This has to be here to fire the event
restart handlerPhysicsCrash = OnRestart;
if (handlerPhysicsCrash != null)
handlerPhysicsCrash(RegionInfo);
}
public abstract bool CheckClient(UUID agentID, System.Net.IPEndPoint ep);
}
}

View File

@ -276,7 +276,7 @@ namespace OpenSim.Region.Physics.Meshing
m_log.Debug("[MESH]: experimental mesh proxy generation");
OSD meshOsd;
OSD meshOsd = null;
if (primShape.SculptData.Length <= 0)
{
@ -287,7 +287,14 @@ namespace OpenSim.Region.Physics.Meshing
long start = 0;
using (MemoryStream data = new MemoryStream(primShape.SculptData))
{
meshOsd = (OSDMap)OSDParser.DeserializeLLSDBinary(data);
try
{
meshOsd = (OSDMap)OSDParser.DeserializeLLSDBinary(data);
}
catch (Exception e)
{
m_log.Error("[MESH]: Exception deserializing mesh asset header:" + e.ToString());
}
start = data.Position;
}

View File

@ -395,10 +395,29 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
//
CheckThreatLevel(ThreatLevel.High, "osRegionRestart");
IRestartModule restartModule = World.RequestModuleInterface<IRestartModule>();
m_host.AddScriptLPS(1);
if (World.Permissions.CanIssueEstateCommand(m_host.OwnerID, false))
if (World.Permissions.CanIssueEstateCommand(m_host.OwnerID, false) && (restartModule != null))
{
World.Restart((float)seconds);
if (seconds < 15)
{
restartModule.AbortRestart("Restart aborted");
return 1;
}
List<int> times = new List<int>();
while (seconds > 0)
{
times.Add((int)seconds);
if (seconds > 300)
seconds -= 120;
else if (seconds > 30)
seconds -= 30;
else
seconds -= 15;
}
restartModule.ScheduleRestart(UUID.Zero, "Region will restart in {0}", times.ToArray(), true);
return 1;
}
else
@ -2315,4 +2334,4 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return date.ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ");
}
}
}
}