aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/DataSnapshot/DataSnapshotManager.cs85
1 files changed, 67 insertions, 18 deletions
diff --git a/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs b/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs
index 78c050a..7472050 100644
--- a/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs
+++ b/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs
@@ -29,8 +29,10 @@
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;
@@ -42,8 +44,8 @@ using OpenSim.Region.DataSnapshot.Interfaces;
42using OpenSim.Region.Framework.Interfaces; 44using OpenSim.Region.Framework.Interfaces;
43using OpenSim.Region.Framework.Scenes; 45using OpenSim.Region.Framework.Scenes;
44 46
45[assembly: Addin("DataSnapshot", "0.1")] 47[assembly: Addin("DataSnapshot", OpenSim.VersionInfo.VersionNumber)]
46[assembly: AddinDependency("OpenSim", "0.5")] 48[assembly: AddinDependency("OpenSim.Region.Framework", OpenSim.VersionInfo.VersionNumber)]
47 49
48namespace OpenSim.Region.DataSnapshot 50namespace OpenSim.Region.DataSnapshot
49{ 51{
@@ -131,9 +133,12 @@ namespace OpenSim.Region.DataSnapshot
131 m_period = config.Configs["DataSnapshot"].GetInt("default_snapshot_period", m_period); 133 m_period = config.Configs["DataSnapshot"].GetInt("default_snapshot_period", m_period);
132 m_maxStales = config.Configs["DataSnapshot"].GetInt("max_changes_before_update", m_maxStales); 134 m_maxStales = config.Configs["DataSnapshot"].GetInt("max_changes_before_update", m_maxStales);
133 m_snapsDir = config.Configs["DataSnapshot"].GetString("snapshot_cache_directory", m_snapsDir); 135 m_snapsDir = config.Configs["DataSnapshot"].GetString("snapshot_cache_directory", m_snapsDir);
134 m_dataServices = config.Configs["DataSnapshot"].GetString("data_services", m_dataServices);
135 m_listener_port = config.Configs["Network"].GetString("http_listener_port", m_listener_port); 136 m_listener_port = config.Configs["Network"].GetString("http_listener_port", m_listener_port);
136 137
138 m_dataServices = config.Configs["DataSnapshot"].GetString("data_services", m_dataServices);
139 // New way of spec'ing data services, one per line
140 AddDataServicesVars(config.Configs["DataSnapshot"]);
141
137 String[] annoying_string_array = config.Configs["DataSnapshot"].GetString("disable_modules", "").Split(".".ToCharArray()); 142 String[] annoying_string_array = config.Configs["DataSnapshot"].GetString("disable_modules", "").Split(".".ToCharArray());
138 foreach (String bloody_wanker in annoying_string_array) 143 foreach (String bloody_wanker in annoying_string_array)
139 { 144 {
@@ -289,6 +294,28 @@ namespace OpenSim.Region.DataSnapshot
289 return null; 294 return null;
290 } 295 }
291 296
297 private void AddDataServicesVars(IConfig config)
298 {
299 // Make sure the services given this way aren't in m_dataServices already
300 List<string> servs = new List<string>(m_dataServices.Split(new char[] { ';' }));
301
302 StringBuilder sb = new StringBuilder();
303 string[] keys = config.GetKeys();
304
305 if (keys.Length > 0)
306 {
307 IEnumerable<string> serviceKeys = keys.Where(value => value.StartsWith("DATA_SRV_"));
308 foreach (string serviceKey in serviceKeys)
309 {
310 string keyValue = config.GetString(serviceKey, string.Empty).Trim();
311 if (!servs.Contains(keyValue))
312 sb.Append(keyValue).Append(";");
313 }
314 }
315
316 m_dataServices = (m_dataServices == "noservices") ? sb.ToString() : sb.Append(m_dataServices).ToString();
317 }
318
292 #endregion 319 #endregion
293 320
294 #region [Public] Snapshot storage functions 321 #region [Public] Snapshot storage functions
@@ -368,27 +395,48 @@ namespace OpenSim.Region.DataSnapshot
368 string delimStr = ";"; 395 string delimStr = ";";
369 char [] delimiter = delimStr.ToCharArray(); 396 char [] delimiter = delimStr.ToCharArray();
370 397
371 string[] services = servicesStr.Split(delimiter); 398 string[] services = servicesStr.Split(delimiter, StringSplitOptions.RemoveEmptyEntries);
372 399
373 for (int i = 0; i < services.Length; i++) 400 for (int i = 0; i < services.Length; i++)
374 { 401 {
375 string url = services[i].Trim(); 402 string url = services[i].Trim();
376 RestClient cli = new RestClient(url); 403 using (RestClient cli = new RestClient(url))
377 cli.AddQueryParameter("service", serviceName);
378 cli.AddQueryParameter("host", m_hostname);
379 cli.AddQueryParameter("port", m_listener_port);
380 cli.AddQueryParameter("secret", m_Secret.ToString());
381 cli.RequestMethod = "GET";
382 try
383 {
384 reply = cli.Request();
385 }
386 catch (WebException)
387 { 404 {
388 m_log.Warn("[DATASNAPSHOT]: Unable to notify " + url); 405<<<<<<< HEAD
406 cli.AddQueryParameter("service", serviceName);
407 cli.AddQueryParameter("host", m_hostname);
408 cli.AddQueryParameter("port", m_listener_port);
409 cli.AddQueryParameter("secret", m_Secret.ToString());
410 cli.RequestMethod = "GET";
411 try
412 {
413 reply = cli.Request(null);
414 }
415 catch (WebException)
416 {
417 m_log.Warn("[DATASNAPSHOT]: Unable to notify " + url);
418 }
419 catch (Exception e)
420 {
421 m_log.Warn("[DATASNAPSHOT]: Ignoring unknown exception " + e.ToString());
422 }
423
424 byte[] response = new byte[1024];
425 // int n = 0;
426 try
427 {
428 // n = reply.Read(response, 0, 1024);
429 reply.Read(response, 0, 1024);
430 }
431 catch (Exception e)
432 {
433 m_log.WarnFormat("[DATASNAPSHOT]: Unable to decode reply from data service. Ignoring. {0}", e.StackTrace);
434 }
435 // This is not quite working, so...
436 // string responseStr = Util.UTF8.GetString(response);
437 m_log.Info("[DATASNAPSHOT]: data service " + url + " notified. Secret: " + m_Secret);
389 } 438 }
390 catch (Exception e) 439=======
391 {
392 m_log.Warn("[DATASNAPSHOT]: Ignoring unknown exception " + e.ToString()); 440 m_log.Warn("[DATASNAPSHOT]: Ignoring unknown exception " + e.ToString());
393 } 441 }
394 442
@@ -409,6 +457,7 @@ namespace OpenSim.Region.DataSnapshot
409 457
410 if(reply != null) 458 if(reply != null)
411 reply.Close(); 459 reply.Close();
460>>>>>>> avn/ubitvar
412 } 461 }
413 462
414 } 463 }