diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/OptionalModules/DataSnapshot/DataRequestHandler.cs (renamed from OpenSim/Region/DataSnapshot/DataRequestHandler.cs) | 4 | ||||
-rw-r--r-- | OpenSim/Region/OptionalModules/DataSnapshot/DataSnapshotManager.cs (renamed from OpenSim/Region/DataSnapshot/DataSnapshotManager.cs) | 148 | ||||
-rw-r--r-- | OpenSim/Region/OptionalModules/DataSnapshot/EstateSnapshot.cs (renamed from OpenSim/Region/DataSnapshot/EstateSnapshot.cs) | 0 | ||||
-rw-r--r-- | OpenSim/Region/OptionalModules/DataSnapshot/Interfaces/IDataSnapshot.cs (renamed from OpenSim/Region/DataSnapshot/Interfaces/IDataSnapshot.cs) | 0 | ||||
-rw-r--r-- | OpenSim/Region/OptionalModules/DataSnapshot/Interfaces/IDataSnapshotProvider.cs (renamed from OpenSim/Region/DataSnapshot/Interfaces/IDataSnapshotProvider.cs) | 0 | ||||
-rw-r--r-- | OpenSim/Region/OptionalModules/DataSnapshot/LLSDDiscovery.cs (renamed from OpenSim/Region/DataSnapshot/LLSDDiscovery.cs) | 0 | ||||
-rw-r--r-- | OpenSim/Region/OptionalModules/DataSnapshot/LandSnapshot.cs (renamed from OpenSim/Region/DataSnapshot/LandSnapshot.cs) | 0 | ||||
-rw-r--r-- | OpenSim/Region/OptionalModules/DataSnapshot/ObjectSnapshot.cs (renamed from OpenSim/Region/DataSnapshot/ObjectSnapshot.cs) | 0 | ||||
-rw-r--r-- | OpenSim/Region/OptionalModules/DataSnapshot/SnapshotStore.cs (renamed from OpenSim/Region/DataSnapshot/SnapshotStore.cs) | 12 |
9 files changed, 97 insertions, 67 deletions
diff --git a/OpenSim/Region/DataSnapshot/DataRequestHandler.cs b/OpenSim/Region/OptionalModules/DataSnapshot/DataRequestHandler.cs index 32e93b4..50276ae 100644 --- a/OpenSim/Region/DataSnapshot/DataRequestHandler.cs +++ b/OpenSim/Region/OptionalModules/DataSnapshot/DataRequestHandler.cs | |||
@@ -63,7 +63,7 @@ namespace OpenSim.Region.DataSnapshot | |||
63 | 63 | ||
64 | public Hashtable OnGetSnapshot(Hashtable keysvals) | 64 | public Hashtable OnGetSnapshot(Hashtable keysvals) |
65 | { | 65 | { |
66 | m_log.Info("[DATASNAPSHOT] Received collection request"); | 66 | m_log.Debug("[DATASNAPSHOT] Received collection request"); |
67 | Hashtable reply = new Hashtable(); | 67 | Hashtable reply = new Hashtable(); |
68 | int statuscode = 200; | 68 | int statuscode = 200; |
69 | 69 | ||
@@ -80,7 +80,7 @@ namespace OpenSim.Region.DataSnapshot | |||
80 | 80 | ||
81 | public Hashtable OnValidate(Hashtable keysvals) | 81 | public Hashtable OnValidate(Hashtable keysvals) |
82 | { | 82 | { |
83 | m_log.Info("[DATASNAPSHOT] Received validation request"); | 83 | m_log.Debug("[DATASNAPSHOT] Received validation request"); |
84 | Hashtable reply = new Hashtable(); | 84 | Hashtable reply = new Hashtable(); |
85 | int statuscode = 200; | 85 | int statuscode = 200; |
86 | 86 | ||
diff --git a/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs b/OpenSim/Region/OptionalModules/DataSnapshot/DataSnapshotManager.cs index 5e62f23..0c3446d 100644 --- a/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs +++ b/OpenSim/Region/OptionalModules/DataSnapshot/DataSnapshotManager.cs | |||
@@ -29,22 +29,20 @@ | |||
29 | using System; | 29 | using System; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.IO; | 31 | using System.IO; |
32 | using System.Linq; | ||
32 | using System.Net; | 33 | using System.Net; |
33 | using System.Reflection; | 34 | using System.Reflection; |
35 | using System.Text; | ||
34 | using System.Xml; | 36 | using System.Xml; |
35 | using log4net; | 37 | using log4net; |
36 | using Nini.Config; | 38 | using Nini.Config; |
37 | using OpenMetaverse; | 39 | using OpenMetaverse; |
38 | using Mono.Addins; | 40 | using Mono.Addins; |
39 | using OpenSim.Framework; | 41 | using OpenSim.Framework; |
40 | using OpenSim.Framework.Communications; | ||
41 | using OpenSim.Region.DataSnapshot.Interfaces; | 42 | using OpenSim.Region.DataSnapshot.Interfaces; |
42 | using OpenSim.Region.Framework.Interfaces; | 43 | using OpenSim.Region.Framework.Interfaces; |
43 | using OpenSim.Region.Framework.Scenes; | 44 | using OpenSim.Region.Framework.Scenes; |
44 | 45 | ||
45 | [assembly: Addin("DataSnapshot", "0.1")] | ||
46 | [assembly: AddinDependency("OpenSim", "0.5")] | ||
47 | |||
48 | namespace OpenSim.Region.DataSnapshot | 46 | namespace OpenSim.Region.DataSnapshot |
49 | { | 47 | { |
50 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "DataSnapshotManager")] | 48 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "DataSnapshotManager")] |
@@ -113,9 +111,17 @@ namespace OpenSim.Region.DataSnapshot | |||
113 | try | 111 | try |
114 | { | 112 | { |
115 | m_enabled = config.Configs["DataSnapshot"].GetBoolean("index_sims", m_enabled); | 113 | m_enabled = config.Configs["DataSnapshot"].GetBoolean("index_sims", m_enabled); |
116 | IConfig conf = config.Configs["GridService"]; | 114 | string gatekeeper = Util.GetConfigVarFromSections<string>(config, "GatekeeperURI", |
117 | if (conf != null) | 115 | new string[] { "Startup", "Hypergrid", "GridService" }, String.Empty); |
118 | m_gridinfo.Add("gatekeeperURL", conf.GetString("Gatekeeper", String.Empty)); | 116 | // Legacy. Remove soon! |
117 | if (string.IsNullOrEmpty(gatekeeper)) | ||
118 | { | ||
119 | IConfig conf = config.Configs["GridService"]; | ||
120 | if (conf != null) | ||
121 | gatekeeper = conf.GetString("Gatekeeper", gatekeeper); | ||
122 | } | ||
123 | if (!string.IsNullOrEmpty(gatekeeper)) | ||
124 | m_gridinfo.Add("gatekeeperURL", gatekeeper); | ||
119 | 125 | ||
120 | m_gridinfo.Add( | 126 | m_gridinfo.Add( |
121 | "name", config.Configs["DataSnapshot"].GetString("gridname", "the lost continent of hippo")); | 127 | "name", config.Configs["DataSnapshot"].GetString("gridname", "the lost continent of hippo")); |
@@ -123,9 +129,12 @@ namespace OpenSim.Region.DataSnapshot | |||
123 | m_period = config.Configs["DataSnapshot"].GetInt("default_snapshot_period", m_period); | 129 | m_period = config.Configs["DataSnapshot"].GetInt("default_snapshot_period", m_period); |
124 | m_maxStales = config.Configs["DataSnapshot"].GetInt("max_changes_before_update", m_maxStales); | 130 | m_maxStales = config.Configs["DataSnapshot"].GetInt("max_changes_before_update", m_maxStales); |
125 | m_snapsDir = config.Configs["DataSnapshot"].GetString("snapshot_cache_directory", m_snapsDir); | 131 | m_snapsDir = config.Configs["DataSnapshot"].GetString("snapshot_cache_directory", m_snapsDir); |
126 | m_dataServices = config.Configs["DataSnapshot"].GetString("data_services", m_dataServices); | ||
127 | m_listener_port = config.Configs["Network"].GetString("http_listener_port", m_listener_port); | 132 | m_listener_port = config.Configs["Network"].GetString("http_listener_port", m_listener_port); |
128 | 133 | ||
134 | m_dataServices = config.Configs["DataSnapshot"].GetString("data_services", m_dataServices); | ||
135 | // New way of spec'ing data services, one per line | ||
136 | AddDataServicesVars(config.Configs["DataSnapshot"]); | ||
137 | |||
129 | String[] annoying_string_array = config.Configs["DataSnapshot"].GetString("disable_modules", "").Split(".".ToCharArray()); | 138 | String[] annoying_string_array = config.Configs["DataSnapshot"].GetString("disable_modules", "").Split(".".ToCharArray()); |
130 | foreach (String bloody_wanker in annoying_string_array) | 139 | foreach (String bloody_wanker in annoying_string_array) |
131 | { | 140 | { |
@@ -140,8 +149,6 @@ namespace OpenSim.Region.DataSnapshot | |||
140 | return; | 149 | return; |
141 | } | 150 | } |
142 | 151 | ||
143 | if (m_enabled) | ||
144 | m_snapStore = new SnapshotStore(m_snapsDir, m_gridinfo, m_listener_port, m_hostname); | ||
145 | } | 152 | } |
146 | 153 | ||
147 | } | 154 | } |
@@ -155,8 +162,22 @@ namespace OpenSim.Region.DataSnapshot | |||
155 | 162 | ||
156 | m_log.DebugFormat("[DATASNAPSHOT]: Module added to Scene {0}.", scene.RegionInfo.RegionName); | 163 | m_log.DebugFormat("[DATASNAPSHOT]: Module added to Scene {0}.", scene.RegionInfo.RegionName); |
157 | 164 | ||
158 | m_snapStore.AddScene(scene); | 165 | if (!m_servicesNotified) |
166 | { | ||
167 | m_hostname = scene.RegionInfo.ExternalHostName; | ||
168 | m_snapStore = new SnapshotStore(m_snapsDir, m_gridinfo, m_listener_port, m_hostname); | ||
169 | |||
170 | //Hand it the first scene, assuming that all scenes have the same BaseHTTPServer | ||
171 | new DataRequestHandler(scene, this); | ||
172 | |||
173 | if (m_dataServices != "" && m_dataServices != "noservices") | ||
174 | NotifyDataServices(m_dataServices, "online"); | ||
175 | |||
176 | m_servicesNotified = true; | ||
177 | } | ||
178 | |||
159 | m_scenes.Add(scene); | 179 | m_scenes.Add(scene); |
180 | m_snapStore.AddScene(scene); | ||
160 | 181 | ||
161 | Assembly currentasm = Assembly.GetExecutingAssembly(); | 182 | Assembly currentasm = Assembly.GetExecutingAssembly(); |
162 | 183 | ||
@@ -181,22 +202,6 @@ namespace OpenSim.Region.DataSnapshot | |||
181 | } | 202 | } |
182 | } | 203 | } |
183 | 204 | ||
184 | // Must be done here because on shared modules, PostInitialise() will run | ||
185 | // BEFORE any scenes are registered. There is no "all scenes have been loaded" | ||
186 | // kind of callback because scenes may be created dynamically, so we cannot | ||
187 | // have that info, ever. | ||
188 | if (!m_servicesNotified) | ||
189 | { | ||
190 | //Hand it the first scene, assuming that all scenes have the same BaseHTTPServer | ||
191 | new DataRequestHandler(m_scenes[0], this); | ||
192 | |||
193 | m_hostname = m_scenes[0].RegionInfo.ExternalHostName; | ||
194 | |||
195 | if (m_dataServices != "" && m_dataServices != "noservices") | ||
196 | NotifyDataServices(m_dataServices, "online"); | ||
197 | |||
198 | m_servicesNotified = true; | ||
199 | } | ||
200 | } | 205 | } |
201 | 206 | ||
202 | public void RemoveRegion(Scene scene) | 207 | public void RemoveRegion(Scene scene) |
@@ -285,6 +290,28 @@ namespace OpenSim.Region.DataSnapshot | |||
285 | return null; | 290 | return null; |
286 | } | 291 | } |
287 | 292 | ||
293 | private void AddDataServicesVars(IConfig config) | ||
294 | { | ||
295 | // Make sure the services given this way aren't in m_dataServices already | ||
296 | List<string> servs = new List<string>(m_dataServices.Split(new char[] { ';' })); | ||
297 | |||
298 | StringBuilder sb = new StringBuilder(); | ||
299 | string[] keys = config.GetKeys(); | ||
300 | |||
301 | if (keys.Length > 0) | ||
302 | { | ||
303 | IEnumerable<string> serviceKeys = keys.Where(value => value.StartsWith("DATA_SRV_")); | ||
304 | foreach (string serviceKey in serviceKeys) | ||
305 | { | ||
306 | string keyValue = config.GetString(serviceKey, string.Empty).Trim(); | ||
307 | if (!servs.Contains(keyValue)) | ||
308 | sb.Append(keyValue).Append(";"); | ||
309 | } | ||
310 | } | ||
311 | |||
312 | m_dataServices = (m_dataServices == "noservices") ? sb.ToString() : sb.Append(m_dataServices).ToString(); | ||
313 | } | ||
314 | |||
288 | #endregion | 315 | #endregion |
289 | 316 | ||
290 | #region [Public] Snapshot storage functions | 317 | #region [Public] Snapshot storage functions |
@@ -303,7 +330,7 @@ namespace OpenSim.Region.DataSnapshot | |||
303 | XmlNode regiondata = requestedSnap.CreateNode(XmlNodeType.Element, "regiondata", ""); | 330 | XmlNode regiondata = requestedSnap.CreateNode(XmlNodeType.Element, "regiondata", ""); |
304 | try | 331 | try |
305 | { | 332 | { |
306 | if (regionName == null || regionName == "") | 333 | if (string.IsNullOrEmpty(regionName)) |
307 | { | 334 | { |
308 | XmlNode timerblock = requestedSnap.CreateNode(XmlNodeType.Element, "expire", ""); | 335 | XmlNode timerblock = requestedSnap.CreateNode(XmlNodeType.Element, "expire", ""); |
309 | timerblock.InnerText = m_period.ToString(); | 336 | timerblock.InnerText = m_period.ToString(); |
@@ -364,43 +391,46 @@ namespace OpenSim.Region.DataSnapshot | |||
364 | string delimStr = ";"; | 391 | string delimStr = ";"; |
365 | char [] delimiter = delimStr.ToCharArray(); | 392 | char [] delimiter = delimStr.ToCharArray(); |
366 | 393 | ||
367 | string[] services = servicesStr.Split(delimiter); | 394 | string[] services = servicesStr.Split(delimiter, StringSplitOptions.RemoveEmptyEntries); |
368 | 395 | ||
369 | for (int i = 0; i < services.Length; i++) | 396 | for (int i = 0; i < services.Length; i++) |
370 | { | 397 | { |
371 | string url = services[i].Trim(); | 398 | string url = services[i].Trim(); |
372 | RestClient cli = new RestClient(url); | 399 | using (RestClient cli = new RestClient(url)) |
373 | cli.AddQueryParameter("service", serviceName); | ||
374 | cli.AddQueryParameter("host", m_hostname); | ||
375 | cli.AddQueryParameter("port", m_listener_port); | ||
376 | cli.AddQueryParameter("secret", m_Secret.ToString()); | ||
377 | cli.RequestMethod = "GET"; | ||
378 | try | ||
379 | { | ||
380 | reply = cli.Request(); | ||
381 | } | ||
382 | catch (WebException) | ||
383 | { | ||
384 | m_log.Warn("[DATASNAPSHOT]: Unable to notify " + url); | ||
385 | } | ||
386 | catch (Exception e) | ||
387 | { | ||
388 | m_log.Warn("[DATASNAPSHOT]: Ignoring unknown exception " + e.ToString()); | ||
389 | } | ||
390 | byte[] response = new byte[1024]; | ||
391 | // int n = 0; | ||
392 | try | ||
393 | { | 400 | { |
394 | // n = reply.Read(response, 0, 1024); | 401 | cli.AddQueryParameter("service", serviceName); |
395 | reply.Read(response, 0, 1024); | 402 | cli.AddQueryParameter("host", m_hostname); |
396 | } | 403 | cli.AddQueryParameter("port", m_listener_port); |
397 | catch (Exception e) | 404 | cli.AddQueryParameter("secret", m_Secret.ToString()); |
398 | { | 405 | cli.RequestMethod = "GET"; |
399 | m_log.WarnFormat("[DATASNAPSHOT]: Unable to decode reply from data service. Ignoring. {0}", e.StackTrace); | 406 | try |
407 | { | ||
408 | reply = cli.Request(null); | ||
409 | } | ||
410 | catch (WebException) | ||
411 | { | ||
412 | m_log.Warn("[DATASNAPSHOT]: Unable to notify " + url); | ||
413 | } | ||
414 | catch (Exception e) | ||
415 | { | ||
416 | m_log.Warn("[DATASNAPSHOT]: Ignoring unknown exception " + e.ToString()); | ||
417 | } | ||
418 | |||
419 | byte[] response = new byte[1024]; | ||
420 | // int n = 0; | ||
421 | try | ||
422 | { | ||
423 | // n = reply.Read(response, 0, 1024); | ||
424 | reply.Read(response, 0, 1024); | ||
425 | } | ||
426 | catch (Exception e) | ||
427 | { | ||
428 | m_log.WarnFormat("[DATASNAPSHOT]: Unable to decode reply from data service. Ignoring. {0}", e.StackTrace); | ||
429 | } | ||
430 | // This is not quite working, so... | ||
431 | // string responseStr = Util.UTF8.GetString(response); | ||
432 | m_log.Info("[DATASNAPSHOT]: data service " + url + " notified. Secret: " + m_Secret); | ||
400 | } | 433 | } |
401 | // This is not quite working, so... | ||
402 | // string responseStr = Util.UTF8.GetString(response); | ||
403 | m_log.Info("[DATASNAPSHOT]: data service " + url + " notified. Secret: " + m_Secret); | ||
404 | } | 434 | } |
405 | 435 | ||
406 | } | 436 | } |
diff --git a/OpenSim/Region/DataSnapshot/EstateSnapshot.cs b/OpenSim/Region/OptionalModules/DataSnapshot/EstateSnapshot.cs index 8da9e8c..8da9e8c 100644 --- a/OpenSim/Region/DataSnapshot/EstateSnapshot.cs +++ b/OpenSim/Region/OptionalModules/DataSnapshot/EstateSnapshot.cs | |||
diff --git a/OpenSim/Region/DataSnapshot/Interfaces/IDataSnapshot.cs b/OpenSim/Region/OptionalModules/DataSnapshot/Interfaces/IDataSnapshot.cs index 3b3db65..3b3db65 100644 --- a/OpenSim/Region/DataSnapshot/Interfaces/IDataSnapshot.cs +++ b/OpenSim/Region/OptionalModules/DataSnapshot/Interfaces/IDataSnapshot.cs | |||
diff --git a/OpenSim/Region/DataSnapshot/Interfaces/IDataSnapshotProvider.cs b/OpenSim/Region/OptionalModules/DataSnapshot/Interfaces/IDataSnapshotProvider.cs index daea373..daea373 100644 --- a/OpenSim/Region/DataSnapshot/Interfaces/IDataSnapshotProvider.cs +++ b/OpenSim/Region/OptionalModules/DataSnapshot/Interfaces/IDataSnapshotProvider.cs | |||
diff --git a/OpenSim/Region/DataSnapshot/LLSDDiscovery.cs b/OpenSim/Region/OptionalModules/DataSnapshot/LLSDDiscovery.cs index 54a87f9..54a87f9 100644 --- a/OpenSim/Region/DataSnapshot/LLSDDiscovery.cs +++ b/OpenSim/Region/OptionalModules/DataSnapshot/LLSDDiscovery.cs | |||
diff --git a/OpenSim/Region/DataSnapshot/LandSnapshot.cs b/OpenSim/Region/OptionalModules/DataSnapshot/LandSnapshot.cs index b8c90cd..b8c90cd 100644 --- a/OpenSim/Region/DataSnapshot/LandSnapshot.cs +++ b/OpenSim/Region/OptionalModules/DataSnapshot/LandSnapshot.cs | |||
diff --git a/OpenSim/Region/DataSnapshot/ObjectSnapshot.cs b/OpenSim/Region/OptionalModules/DataSnapshot/ObjectSnapshot.cs index 0bb4044..0bb4044 100644 --- a/OpenSim/Region/DataSnapshot/ObjectSnapshot.cs +++ b/OpenSim/Region/OptionalModules/DataSnapshot/ObjectSnapshot.cs | |||
diff --git a/OpenSim/Region/DataSnapshot/SnapshotStore.cs b/OpenSim/Region/OptionalModules/DataSnapshot/SnapshotStore.cs index aa3d2ff..480aaaf 100644 --- a/OpenSim/Region/DataSnapshot/SnapshotStore.cs +++ b/OpenSim/Region/OptionalModules/DataSnapshot/SnapshotStore.cs | |||
@@ -120,7 +120,7 @@ namespace OpenSim.Region.DataSnapshot | |||
120 | provider.Stale = false; | 120 | provider.Stale = false; |
121 | m_scenes[provider.GetParentScene] = true; | 121 | m_scenes[provider.GetParentScene] = true; |
122 | 122 | ||
123 | m_log.Info("[DATASNAPSHOT]: Generated fragment response for provider type " + provider.Name); | 123 | m_log.Debug("[DATASNAPSHOT]: Generated fragment response for provider type " + provider.Name); |
124 | } | 124 | } |
125 | else | 125 | else |
126 | { | 126 | { |
@@ -134,7 +134,7 @@ namespace OpenSim.Region.DataSnapshot | |||
134 | data = factory.ImportNode(node, true); | 134 | data = factory.ImportNode(node, true); |
135 | } | 135 | } |
136 | 136 | ||
137 | m_log.Info("[DATASNAPSHOT]: Retrieved fragment response for provider type " + provider.Name); | 137 | m_log.Debug("[DATASNAPSHOT]: Retrieved fragment response for provider type " + provider.Name); |
138 | } | 138 | } |
139 | 139 | ||
140 | return data; | 140 | return data; |
@@ -154,7 +154,7 @@ namespace OpenSim.Region.DataSnapshot | |||
154 | 154 | ||
155 | if (!m_scenes[scene]) | 155 | if (!m_scenes[scene]) |
156 | { | 156 | { |
157 | m_log.Info("[DATASNAPSHOT]: Attempting to retrieve snapshot from cache."); | 157 | m_log.Debug("[DATASNAPSHOT]: Attempting to retrieve snapshot from cache."); |
158 | //get snapshot from cache | 158 | //get snapshot from cache |
159 | String path = DataFileNameScene(scene); | 159 | String path = DataFileNameScene(scene); |
160 | 160 | ||
@@ -168,11 +168,11 @@ namespace OpenSim.Region.DataSnapshot | |||
168 | regionElement = factory.ImportNode(node, true); | 168 | regionElement = factory.ImportNode(node, true); |
169 | } | 169 | } |
170 | 170 | ||
171 | m_log.Info("[DATASNAPSHOT]: Obtained snapshot from cache for " + scene.RegionInfo.RegionName); | 171 | m_log.Debug("[DATASNAPSHOT]: Obtained snapshot from cache for " + scene.RegionInfo.RegionName); |
172 | } | 172 | } |
173 | else | 173 | else |
174 | { | 174 | { |
175 | m_log.Info("[DATASNAPSHOT]: Attempting to generate snapshot."); | 175 | m_log.Debug("[DATASNAPSHOT]: Attempting to generate snapshot."); |
176 | //make snapshot | 176 | //make snapshot |
177 | regionElement = MakeRegionNode(scene, factory); | 177 | regionElement = MakeRegionNode(scene, factory); |
178 | 178 | ||
@@ -211,7 +211,7 @@ namespace OpenSim.Region.DataSnapshot | |||
211 | 211 | ||
212 | m_scenes[scene] = false; | 212 | m_scenes[scene] = false; |
213 | 213 | ||
214 | m_log.Info("[DATASNAPSHOT]: Generated new snapshot for " + scene.RegionInfo.RegionName); | 214 | m_log.Debug("[DATASNAPSHOT]: Generated new snapshot for " + scene.RegionInfo.RegionName); |
215 | } | 215 | } |
216 | 216 | ||
217 | return regionElement; | 217 | return regionElement; |