aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/DataSnapshot/DataSnapshotManager.cs
diff options
context:
space:
mode:
authorDavid Walter Seikel2016-11-03 21:44:39 +1000
committerDavid Walter Seikel2016-11-03 21:44:39 +1000
commit134f86e8d5c414409631b25b8c6f0ee45fbd8631 (patch)
tree216b89d3fb89acfb81be1e440c25c41ab09fa96d /OpenSim/Region/OptionalModules/DataSnapshot/DataSnapshotManager.cs
parentMore changing to production grid. Double oops. (diff)
downloadopensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.zip
opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.gz
opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.bz2
opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.xz
Initial update to OpenSim 0.8.2.1 source code.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/OptionalModules/DataSnapshot/DataSnapshotManager.cs (renamed from OpenSim/Region/DataSnapshot/DataSnapshotManager.cs)148
1 files changed, 89 insertions, 59 deletions
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 @@
29using System; 29using System;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.IO; 31using System.IO;
32using System.Linq;
32using System.Net; 33using System.Net;
33using System.Reflection; 34using System.Reflection;
35using System.Text;
34using System.Xml; 36using System.Xml;
35using log4net; 37using log4net;
36using Nini.Config; 38using Nini.Config;
37using OpenMetaverse; 39using OpenMetaverse;
38using Mono.Addins; 40using Mono.Addins;
39using OpenSim.Framework; 41using OpenSim.Framework;
40using OpenSim.Framework.Communications;
41using OpenSim.Region.DataSnapshot.Interfaces; 42using OpenSim.Region.DataSnapshot.Interfaces;
42using OpenSim.Region.Framework.Interfaces; 43using OpenSim.Region.Framework.Interfaces;
43using OpenSim.Region.Framework.Scenes; 44using OpenSim.Region.Framework.Scenes;
44 45
45[assembly: Addin("DataSnapshot", "0.1")]
46[assembly: AddinDependency("OpenSim", "0.5")]
47
48namespace OpenSim.Region.DataSnapshot 46namespace 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 }