diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/DataSnapshot/DataSnapshotManager.cs | 158 |
1 files changed, 87 insertions, 71 deletions
diff --git a/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs b/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs index 5540656..defbadc 100644 --- a/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs +++ b/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs | |||
@@ -35,15 +35,20 @@ using System.Xml; | |||
35 | using log4net; | 35 | using log4net; |
36 | using Nini.Config; | 36 | using Nini.Config; |
37 | using OpenMetaverse; | 37 | using OpenMetaverse; |
38 | using Mono.Addins; | ||
38 | using OpenSim.Framework; | 39 | using OpenSim.Framework; |
39 | using OpenSim.Framework.Communications; | 40 | using OpenSim.Framework.Communications; |
40 | using OpenSim.Region.DataSnapshot.Interfaces; | 41 | using OpenSim.Region.DataSnapshot.Interfaces; |
41 | using OpenSim.Region.Framework.Interfaces; | 42 | using OpenSim.Region.Framework.Interfaces; |
42 | using OpenSim.Region.Framework.Scenes; | 43 | using OpenSim.Region.Framework.Scenes; |
43 | 44 | ||
45 | [assembly: Addin("LindenCaps", "0.1")] | ||
46 | [assembly: AddinDependency("OpenSim", "0.5")] | ||
47 | |||
44 | namespace OpenSim.Region.DataSnapshot | 48 | namespace OpenSim.Region.DataSnapshot |
45 | { | 49 | { |
46 | public class DataSnapshotManager : IRegionModule, IDataSnapshot | 50 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] |
51 | public class DataSnapshotManager : ISharedRegionModule, IDataSnapshot | ||
47 | { | 52 | { |
48 | #region Class members | 53 | #region Class members |
49 | //Information from config | 54 | //Information from config |
@@ -95,7 +100,7 @@ namespace OpenSim.Region.DataSnapshot | |||
95 | 100 | ||
96 | #region IRegionModule | 101 | #region IRegionModule |
97 | 102 | ||
98 | public void Initialise(Scene scene, IConfigSource config) | 103 | public void Initialise(IConfigSource config) |
99 | { | 104 | { |
100 | if (!m_configLoaded) | 105 | if (!m_configLoaded) |
101 | { | 106 | { |
@@ -133,82 +138,121 @@ namespace OpenSim.Region.DataSnapshot | |||
133 | m_enabled = false; | 138 | m_enabled = false; |
134 | return; | 139 | return; |
135 | } | 140 | } |
136 | } | ||
137 | 141 | ||
138 | if (m_enabled) | 142 | if (m_enabled) |
139 | { | 143 | m_snapStore = new SnapshotStore(m_snapsDir, m_gridinfo, m_listener_port, m_hostname); |
140 | //Hand it the first scene, assuming that all scenes have the same BaseHTTPServer | 144 | } |
141 | new DataRequestHandler(scene, this); | ||
142 | 145 | ||
143 | m_hostname = scene.RegionInfo.ExternalHostName; | 146 | } |
144 | m_snapStore = new SnapshotStore(m_snapsDir, m_gridinfo, m_listener_port, m_hostname); | ||
145 | 147 | ||
146 | MakeEverythingStale(); | 148 | } |
147 | 149 | ||
148 | if (m_dataServices != "" && m_dataServices != "noservices") | 150 | public void AddRegion(Scene scene) |
149 | NotifyDataServices(m_dataServices, "online"); | 151 | { |
150 | } | 152 | if (!m_enabled) |
151 | } | 153 | return; |
152 | 154 | ||
153 | if (m_enabled) | 155 | m_log.DebugFormat("[DATASNAPSHOT]: Module added to Scene {0}.", scene.RegionInfo.RegionName); |
154 | { | ||
155 | m_log.Info("[DATASNAPSHOT]: Scene added to module."); | ||
156 | 156 | ||
157 | m_snapStore.AddScene(scene); | 157 | m_snapStore.AddScene(scene); |
158 | m_scenes.Add(scene); | 158 | m_scenes.Add(scene); |
159 | 159 | ||
160 | Assembly currentasm = Assembly.GetExecutingAssembly(); | 160 | Assembly currentasm = Assembly.GetExecutingAssembly(); |
161 | 161 | ||
162 | foreach (Type pluginType in currentasm.GetTypes()) | 162 | foreach (Type pluginType in currentasm.GetTypes()) |
163 | { | ||
164 | if (pluginType.IsPublic) | ||
163 | { | 165 | { |
164 | if (pluginType.IsPublic) | 166 | if (!pluginType.IsAbstract) |
165 | { | 167 | { |
166 | if (!pluginType.IsAbstract) | 168 | if (pluginType.GetInterface("IDataSnapshotProvider") != null) |
167 | { | 169 | { |
168 | if (pluginType.GetInterface("IDataSnapshotProvider") != null) | 170 | IDataSnapshotProvider module = (IDataSnapshotProvider)Activator.CreateInstance(pluginType); |
169 | { | 171 | module.Initialize(scene, this); |
170 | IDataSnapshotProvider module = (IDataSnapshotProvider)Activator.CreateInstance(pluginType); | 172 | module.OnStale += MarkDataStale; |
171 | module.Initialize(scene, this); | ||
172 | module.OnStale += MarkDataStale; | ||
173 | 173 | ||
174 | m_dataproviders.Add(module); | 174 | m_dataproviders.Add(module); |
175 | m_snapStore.AddProvider(module); | 175 | m_snapStore.AddProvider(module); |
176 | 176 | ||
177 | m_log.Info("[DATASNAPSHOT]: Added new data provider type: " + pluginType.Name); | 177 | m_log.Debug("[DATASNAPSHOT]: Added new data provider type: " + pluginType.Name); |
178 | } | ||
179 | } | 178 | } |
180 | } | 179 | } |
181 | } | 180 | } |
181 | } | ||
182 | } | ||
183 | |||
184 | public void RemoveRegion(Scene scene) | ||
185 | { | ||
186 | if (!m_enabled) | ||
187 | return; | ||
188 | |||
189 | m_log.Info("[DATASNAPSHOT]: Region " + scene.RegionInfo.RegionName + " is being removed, removing from indexing"); | ||
190 | Scene restartedScene = SceneForUUID(scene.RegionInfo.RegionID); | ||
191 | |||
192 | m_scenes.Remove(restartedScene); | ||
193 | m_snapStore.RemoveScene(restartedScene); | ||
182 | 194 | ||
183 | //scene.OnRestart += OnSimRestart; | 195 | //Getting around the fact that we can't remove objects from a collection we are enumerating over |
184 | scene.EventManager.OnShutdown += delegate() { OnSimRestart(scene.RegionInfo); }; | 196 | List<IDataSnapshotProvider> providersToRemove = new List<IDataSnapshotProvider>(); |
197 | |||
198 | foreach (IDataSnapshotProvider provider in m_dataproviders) | ||
199 | { | ||
200 | if (provider.GetParentScene == restartedScene) | ||
201 | { | ||
202 | providersToRemove.Add(provider); | ||
203 | } | ||
185 | } | 204 | } |
186 | else | 205 | |
206 | foreach (IDataSnapshotProvider provider in providersToRemove) | ||
187 | { | 207 | { |
188 | //m_log.Debug("[DATASNAPSHOT]: Data snapshot disabled, not adding scene to module (or anything else)."); | 208 | m_dataproviders.Remove(provider); |
209 | m_snapStore.RemoveProvider(provider); | ||
189 | } | 210 | } |
211 | |||
212 | m_snapStore.RemoveScene(restartedScene); | ||
190 | } | 213 | } |
191 | 214 | ||
192 | public void Close() | 215 | public void PostInitialise() |
193 | { | 216 | { |
194 | if (m_enabled && m_dataServices != "" && m_dataServices != "noservices") | 217 | if (!m_enabled) |
195 | NotifyDataServices(m_dataServices, "offline"); | 218 | return; |
219 | |||
220 | //Hand it the first scene, assuming that all scenes have the same BaseHTTPServer | ||
221 | new DataRequestHandler(m_scenes[0], this); | ||
222 | |||
223 | m_hostname = m_scenes[0].RegionInfo.ExternalHostName; | ||
224 | |||
225 | if (m_dataServices != "" && m_dataServices != "noservices") | ||
226 | NotifyDataServices(m_dataServices, "online"); | ||
196 | } | 227 | } |
197 | 228 | ||
229 | public void RegionLoaded(Scene scene) | ||
230 | { | ||
231 | if (!m_enabled) | ||
232 | return; | ||
233 | |||
234 | m_log.DebugFormat("[DATASNAPSHOT]: Marking scene {0} as stale.", scene.RegionInfo.RegionName); | ||
235 | m_snapStore.ForceSceneStale(scene); | ||
236 | } | ||
198 | 237 | ||
199 | public bool IsSharedModule | 238 | public void Close() |
200 | { | 239 | { |
201 | get { return true; } | 240 | if (!m_enabled) |
241 | return; | ||
242 | |||
243 | if (m_enabled && m_dataServices != "" && m_dataServices != "noservices") | ||
244 | NotifyDataServices(m_dataServices, "offline"); | ||
202 | } | 245 | } |
203 | 246 | ||
247 | |||
204 | public string Name | 248 | public string Name |
205 | { | 249 | { |
206 | get { return "External Data Generator"; } | 250 | get { return "External Data Generator"; } |
207 | } | 251 | } |
208 | 252 | ||
209 | public void PostInitialise() | 253 | public Type ReplaceableInterface |
210 | { | 254 | { |
211 | 255 | get { return null; } | |
212 | } | 256 | } |
213 | 257 | ||
214 | #endregion | 258 | #endregion |
@@ -399,35 +443,7 @@ namespace OpenSim.Region.DataSnapshot | |||
399 | m_snapStore.ForceSceneStale(scene); | 443 | m_snapStore.ForceSceneStale(scene); |
400 | } | 444 | } |
401 | } | 445 | } |
402 | |||
403 | #endregion | 446 | #endregion |
404 | 447 | ||
405 | public void OnSimRestart(RegionInfo thisRegion) | ||
406 | { | ||
407 | m_log.Info("[DATASNAPSHOT]: Region " + thisRegion.RegionName + " is restarting, removing from indexing"); | ||
408 | Scene restartedScene = SceneForUUID(thisRegion.RegionID); | ||
409 | |||
410 | m_scenes.Remove(restartedScene); | ||
411 | m_snapStore.RemoveScene(restartedScene); | ||
412 | |||
413 | //Getting around the fact that we can't remove objects from a collection we are enumerating over | ||
414 | List<IDataSnapshotProvider> providersToRemove = new List<IDataSnapshotProvider>(); | ||
415 | |||
416 | foreach (IDataSnapshotProvider provider in m_dataproviders) | ||
417 | { | ||
418 | if (provider.GetParentScene == restartedScene) | ||
419 | { | ||
420 | providersToRemove.Add(provider); | ||
421 | } | ||
422 | } | ||
423 | |||
424 | foreach (IDataSnapshotProvider provider in providersToRemove) | ||
425 | { | ||
426 | m_dataproviders.Remove(provider); | ||
427 | m_snapStore.RemoveProvider(provider); | ||
428 | } | ||
429 | |||
430 | m_snapStore.RemoveScene(restartedScene); | ||
431 | } | ||
432 | } | 448 | } |
433 | } | 449 | } |