aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorMelanie2010-11-25 01:24:32 +0000
committerMelanie2010-11-25 01:24:32 +0000
commit2c1c04119d11a98cd847c6a86afc8a6e3d6bbe33 (patch)
tree03e8cf7dbc1b11b424b238b6362a360ac176dbe8 /OpenSim
parentMerge branch 'master' into careminster-presence-refactor (diff)
parentImplement the restart module (diff)
downloadopensim-SC_OLD-2c1c04119d11a98cd847c6a86afc8a6e3d6bbe33.zip
opensim-SC_OLD-2c1c04119d11a98cd847c6a86afc8a6e3d6bbe33.tar.gz
opensim-SC_OLD-2c1c04119d11a98cd847c6a86afc8a6e3d6bbe33.tar.bz2
opensim-SC_OLD-2c1c04119d11a98cd847c6a86afc8a6e3d6bbe33.tar.xz
Merge branch 'master' into careminster-presence-refactor
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Data/Tests/InventoryTests.cs6
-rw-r--r--OpenSim/Region/CoreModules/World/Region/RestartModule.cs204
-rw-r--r--OpenSim/Region/Framework/Interfaces/IRestartModule.cs39
-rw-r--r--OpenSim/Region/Physics/Meshing/Meshmerizer.cs11
4 files changed, 256 insertions, 4 deletions
diff --git a/OpenSim/Data/Tests/InventoryTests.cs b/OpenSim/Data/Tests/InventoryTests.cs
index 3205bfa..dc03259 100644
--- a/OpenSim/Data/Tests/InventoryTests.cs
+++ b/OpenSim/Data/Tests/InventoryTests.cs
@@ -323,7 +323,8 @@ namespace OpenSim.Data.Tests
323 .IgnoreProperty(x => x.InvType) 323 .IgnoreProperty(x => x.InvType)
324 .IgnoreProperty(x => x.CreatorIdAsUuid) 324 .IgnoreProperty(x => x.CreatorIdAsUuid)
325 .IgnoreProperty(x => x.Description) 325 .IgnoreProperty(x => x.Description)
326 .IgnoreProperty(x => x.CreatorId)); 326 .IgnoreProperty(x => x.CreatorId)
327 .IgnoreProperty(x => x.CreatorData));
327 328
328 inventoryScrambler.Scramble(expected); 329 inventoryScrambler.Scramble(expected);
329 db.updateInventoryItem(expected); 330 db.updateInventoryItem(expected);
@@ -333,7 +334,8 @@ namespace OpenSim.Data.Tests
333 .IgnoreProperty(x => x.InvType) 334 .IgnoreProperty(x => x.InvType)
334 .IgnoreProperty(x => x.CreatorIdAsUuid) 335 .IgnoreProperty(x => x.CreatorIdAsUuid)
335 .IgnoreProperty(x => x.Description) 336 .IgnoreProperty(x => x.Description)
336 .IgnoreProperty(x => x.CreatorId)); 337 .IgnoreProperty(x => x.CreatorId)
338 .IgnoreProperty(x => x.CreatorData));
337 } 339 }
338 340
339 [Test] 341 [Test]
diff --git a/OpenSim/Region/CoreModules/World/Region/RestartModule.cs b/OpenSim/Region/CoreModules/World/Region/RestartModule.cs
new file mode 100644
index 0000000..1c26c38
--- /dev/null
+++ b/OpenSim/Region/CoreModules/World/Region/RestartModule.cs
@@ -0,0 +1,204 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Reflection;
30using System.Timers;
31using System.Threading;
32using System.Collections.Generic;
33using log4net;
34using Nini.Config;
35using OpenMetaverse;
36using OpenSim.Framework;
37using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes;
39using Timer=System.Timers.Timer;
40
41namespace OpenSim.Region.CoreModules.World.Region
42{
43 public class RestartModule : INonSharedRegionModule, IRestartModule
44 {
45 private static readonly ILog m_log =
46 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
47
48 protected Scene m_Scene;
49 protected Timer m_CountdownTimer = null;
50 protected DateTime m_RestartBegin;
51 protected List<int> m_Alerts;
52 protected string m_Message;
53 protected UUID m_Initiator;
54 protected bool m_Notice = false;
55 protected IDialogModule m_DialogModule = null;
56
57 public void Initialise(IConfigSource config)
58 {
59 }
60
61 public void AddRegion(Scene scene)
62 {
63 m_Scene = scene;
64 m_DialogModule = m_Scene.RequestModuleInterface<IDialogModule>();
65 }
66
67 public void RegionLoaded(Scene scene)
68 {
69 }
70
71 public void RemoveRegion(Scene scene)
72 {
73 }
74
75 public void Close()
76 {
77 }
78
79 public string Name
80 {
81 get { return "RestartModule"; }
82 }
83
84 public Type ReplaceableInterface
85 {
86 get { return typeof(IRestartModule); }
87 }
88
89 public TimeSpan TimeUntilRestart
90 {
91 get { return DateTime.Now - m_RestartBegin; }
92 }
93
94 public void ScheduleRestart(UUID initiator, string message, int[] alerts, bool notice)
95 {
96 if (m_CountdownTimer != null)
97 return;
98
99 if (alerts == null)
100 {
101 m_Scene.RestartNow();
102 return;
103 }
104
105 m_Message = message;
106 m_Initiator = initiator;
107 m_Notice = notice;
108 m_Alerts = new List<int>(alerts);
109 m_Alerts.Sort();
110 m_Alerts.Reverse();
111
112 if (m_Alerts[0] == 0)
113 {
114 m_Scene.RestartNow();
115 return;
116 }
117
118 int nextInterval = DoOneNotice();
119
120 SetTimer(nextInterval);
121 }
122
123 public int DoOneNotice()
124 {
125 if (m_Alerts.Count == 0 || m_Alerts[0] == 0)
126 {
127 m_Scene.RestartNow();
128 return 0;
129 }
130
131 int nextAlert = 0;
132 while (m_Alerts.Count > 1)
133 {
134 if (m_Alerts[1] == m_Alerts[0])
135 {
136 m_Alerts.RemoveAt(0);
137 continue;
138 }
139 nextAlert = m_Alerts[1];
140 }
141
142 int currentAlert = m_Alerts[0];
143
144 m_Alerts.RemoveAt(0);
145
146 int minutes = currentAlert / 60;
147 string currentAlertString = "";
148 if (minutes > 0)
149 {
150 if (minutes == 1)
151 currentAlertString += "1 minute";
152 else
153 currentAlertString += String.Format("{0} minutes", minutes);
154 if ((currentAlert % 60) != 0)
155 currentAlertString += " and ";
156 }
157 if ((currentAlert % 60) != 0)
158 {
159 int seconds = currentAlert % 60;
160 if (seconds == 1)
161 currentAlertString += "1 second";
162 else
163 currentAlertString += String.Format("{0} seconds", seconds);
164 }
165
166 string msg = String.Format(m_Message, currentAlertString);
167
168 if (m_DialogModule != null)
169 {
170 if (m_Notice)
171 m_DialogModule.SendGeneralAlert(msg);
172 else
173 m_DialogModule.SendNotificationToUsersInRegion(m_Initiator, "System", msg);
174 }
175
176 return currentAlert - nextAlert;
177 }
178
179 public void SetTimer(int intervalSeconds)
180 {
181 m_CountdownTimer = new Timer();
182 m_CountdownTimer.AutoReset = false;
183 m_CountdownTimer.Interval = intervalSeconds * 1000;
184 m_CountdownTimer.Elapsed += OnTimer;
185 m_CountdownTimer.Start();
186 }
187
188 private void OnTimer(object source, ElapsedEventArgs e)
189 {
190 int nextInterval = DoOneNotice();
191
192 SetTimer(nextInterval);
193 }
194
195 public void AbortRestart(string message)
196 {
197 if (m_CountdownTimer != null)
198 {
199 m_CountdownTimer.Stop();
200 m_CountdownTimer = null;
201 }
202 }
203 }
204}
diff --git a/OpenSim/Region/Framework/Interfaces/IRestartModule.cs b/OpenSim/Region/Framework/Interfaces/IRestartModule.cs
new file mode 100644
index 0000000..c68550f
--- /dev/null
+++ b/OpenSim/Region/Framework/Interfaces/IRestartModule.cs
@@ -0,0 +1,39 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using OpenMetaverse;
30
31namespace OpenSim.Region.Framework.Interfaces
32{
33 public interface IRestartModule
34 {
35 TimeSpan TimeUntilRestart { get; }
36 void ScheduleRestart(UUID initiator, string message, int[] alerts, bool notice);
37 void AbortRestart(string message);
38 }
39}
diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
index d770ad1..3386e72 100644
--- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
+++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
@@ -276,7 +276,7 @@ namespace OpenSim.Region.Physics.Meshing
276 276
277 m_log.Debug("[MESH]: experimental mesh proxy generation"); 277 m_log.Debug("[MESH]: experimental mesh proxy generation");
278 278
279 OSD meshOsd; 279 OSD meshOsd = null;
280 280
281 if (primShape.SculptData.Length <= 0) 281 if (primShape.SculptData.Length <= 0)
282 { 282 {
@@ -287,7 +287,14 @@ namespace OpenSim.Region.Physics.Meshing
287 long start = 0; 287 long start = 0;
288 using (MemoryStream data = new MemoryStream(primShape.SculptData)) 288 using (MemoryStream data = new MemoryStream(primShape.SculptData))
289 { 289 {
290 meshOsd = (OSDMap)OSDParser.DeserializeLLSDBinary(data); 290 try
291 {
292 meshOsd = (OSDMap)OSDParser.DeserializeLLSDBinary(data);
293 }
294 catch (Exception e)
295 {
296 m_log.Error("[MESH]: Exception deserializing mesh asset header:" + e.ToString());
297 }
291 start = data.Position; 298 start = data.Position;
292 } 299 }
293 300