aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/Connectors
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2014-02-13 23:55:38 +0000
committerJustin Clark-Casey (justincc)2014-02-14 00:01:12 +0000
commitfc35b45e2176ee2dc8bf5627e84e463a2e9d3a52 (patch)
tree6f0e2c67c462543a052783cb1390070b7b58fe96 /OpenSim/Services/Connectors
parentIf a caller tries to queue a CAPs message to a scene presence that has no eve... (diff)
downloadopensim-SC_OLD-fc35b45e2176ee2dc8bf5627e84e463a2e9d3a52.zip
opensim-SC_OLD-fc35b45e2176ee2dc8bf5627e84e463a2e9d3a52.tar.gz
opensim-SC_OLD-fc35b45e2176ee2dc8bf5627e84e463a2e9d3a52.tar.bz2
opensim-SC_OLD-fc35b45e2176ee2dc8bf5627e84e463a2e9d3a52.tar.xz
If calls to UserAgentServiceConnector fail then throw an exception. This lets the caller decide whether to discard the error or not.
This is Oren Hurvitz's 0001 patch from http://opensimulator.org/mantis/view.php?id=6956 but I ended up doing some tweaking to resolve patch application issues.
Diffstat (limited to 'OpenSim/Services/Connectors')
-rw-r--r--OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs383
1 files changed, 94 insertions, 289 deletions
diff --git a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
index 2511c08..cbd62cb 100644
--- a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
@@ -78,7 +78,8 @@ namespace OpenSim.Services.Connectors.Hypergrid
78 m_log.DebugFormat("[USER AGENT CONNECTOR]: Malformed Uri {0}: {1}", m_ServerURL, e.Message); 78 m_log.DebugFormat("[USER AGENT CONNECTOR]: Malformed Uri {0}: {1}", m_ServerURL, e.Message);
79 } 79 }
80 } 80 }
81 m_log.DebugFormat("[USER AGENT CONNECTOR]: new connector to {0} ({1})", url, m_ServerURL); 81
82 //m_log.DebugFormat("[USER AGENT CONNECTOR]: new connector to {0} ({1})", url, m_ServerURL);
82 } 83 }
83 84
84 public UserAgentServiceConnector(IConfigSource config) 85 public UserAgentServiceConnector(IConfigSource config)
@@ -190,96 +191,99 @@ namespace OpenSim.Services.Connectors.Hypergrid
190 // no-op 191 // no-op
191 } 192 }
192 193
193 public GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt) 194 private Hashtable CallServer(string methodName, Hashtable hash)
194 { 195 {
195 position = Vector3.UnitY; lookAt = Vector3.UnitY;
196
197 Hashtable hash = new Hashtable();
198 hash["userID"] = userID.ToString();
199
200 IList paramList = new ArrayList(); 196 IList paramList = new ArrayList();
201 paramList.Add(hash); 197 paramList.Add(hash);
202 198
203 XmlRpcRequest request = new XmlRpcRequest("get_home_region", paramList); 199 XmlRpcRequest request = new XmlRpcRequest(methodName, paramList);
200
201 // Send and get reply
204 XmlRpcResponse response = null; 202 XmlRpcResponse response = null;
205 try 203 try
206 { 204 {
207 response = request.Send(m_ServerURL, 10000); 205 response = request.Send(m_ServerURL, 10000);
208 } 206 }
209 catch (Exception) 207 catch (Exception e)
210 { 208 {
211 return null; 209 m_log.WarnFormat("[USER AGENT CONNECTOR]: {0} call to {1} failed: {2}", methodName, m_ServerURL, e.Message);
210 throw;
212 } 211 }
213 212
214 if (response.IsFault) 213 if (response.IsFault)
215 { 214 {
216 return null; 215 throw new Exception(string.Format("[USER AGENT CONNECTOR]: {0} call to {1} returned an error: {2}", methodName, m_ServerURL, response.FaultString));
217 } 216 }
218 217
219 hash = (Hashtable)response.Value; 218 hash = (Hashtable)response.Value;
220 //foreach (Object o in hash) 219
221 // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); 220 if (hash == null)
222 try
223 { 221 {
224 bool success = false; 222 throw new Exception(string.Format("[USER AGENT CONNECTOR]: {0} call to {1} returned null", methodName, m_ServerURL));
225 Boolean.TryParse((string)hash["result"], out success); 223 }
226 if (success)
227 {
228 GridRegion region = new GridRegion();
229 224
230 UUID.TryParse((string)hash["uuid"], out region.RegionID); 225 return hash;
231 //m_log.Debug(">> HERE, uuid: " + region.RegionID); 226 }
232 int n = 0;
233 if (hash["x"] != null)
234 {
235 Int32.TryParse((string)hash["x"], out n);
236 region.RegionLocX = n;
237 //m_log.Debug(">> HERE, x: " + region.RegionLocX);
238 }
239 if (hash["y"] != null)
240 {
241 Int32.TryParse((string)hash["y"], out n);
242 region.RegionLocY = n;
243 //m_log.Debug(">> HERE, y: " + region.RegionLocY);
244 }
245 if (hash["region_name"] != null)
246 {
247 region.RegionName = (string)hash["region_name"];
248 //m_log.Debug(">> HERE, name: " + region.RegionName);
249 }
250 if (hash["hostname"] != null)
251 region.ExternalHostName = (string)hash["hostname"];
252 if (hash["http_port"] != null)
253 {
254 uint p = 0;
255 UInt32.TryParse((string)hash["http_port"], out p);
256 region.HttpPort = p;
257 }
258 if (hash.ContainsKey("server_uri") && hash["server_uri"] != null)
259 region.ServerURI = (string)hash["server_uri"];
260 227
261 if (hash["internal_port"] != null) 228 public GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt)
262 { 229 {
263 int p = 0; 230 position = Vector3.UnitY; lookAt = Vector3.UnitY;
264 Int32.TryParse((string)hash["internal_port"], out p);
265 region.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), p);
266 }
267 if (hash["position"] != null)
268 Vector3.TryParse((string)hash["position"], out position);
269 if (hash["lookAt"] != null)
270 Vector3.TryParse((string)hash["lookAt"], out lookAt);
271 231
272 // Successful return 232 Hashtable hash = new Hashtable();
273 return region; 233 hash["userID"] = userID.ToString();
274 }
275 234
235 hash = CallServer("get_home_region", hash);
236
237 bool success;
238 if (!Boolean.TryParse((string)hash["result"], out success) || !success)
239 return null;
240
241 GridRegion region = new GridRegion();
242
243 UUID.TryParse((string)hash["uuid"], out region.RegionID);
244 //m_log.Debug(">> HERE, uuid: " + region.RegionID);
245 int n = 0;
246 if (hash["x"] != null)
247 {
248 Int32.TryParse((string)hash["x"], out n);
249 region.RegionLocX = n;
250 //m_log.Debug(">> HERE, x: " + region.RegionLocX);
276 } 251 }
277 catch (Exception) 252 if (hash["y"] != null)
278 { 253 {
279 return null; 254 Int32.TryParse((string)hash["y"], out n);
255 region.RegionLocY = n;
256 //m_log.Debug(">> HERE, y: " + region.RegionLocY);
257 }
258 if (hash["region_name"] != null)
259 {
260 region.RegionName = (string)hash["region_name"];
261 //m_log.Debug(">> HERE, name: " + region.RegionName);
280 } 262 }
263 if (hash["hostname"] != null)
264 region.ExternalHostName = (string)hash["hostname"];
265 if (hash["http_port"] != null)
266 {
267 uint p = 0;
268 UInt32.TryParse((string)hash["http_port"], out p);
269 region.HttpPort = p;
270 }
271 if (hash.ContainsKey("server_uri") && hash["server_uri"] != null)
272 region.ServerURI = (string)hash["server_uri"];
281 273
282 return null; 274 if (hash["internal_port"] != null)
275 {
276 int p = 0;
277 Int32.TryParse((string)hash["internal_port"], out p);
278 region.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), p);
279 }
280 if (hash["position"] != null)
281 Vector3.TryParse((string)hash["position"], out position);
282 if (hash["lookAt"] != null)
283 Vector3.TryParse((string)hash["lookAt"], out lookAt);
284
285 // Successful return
286 return region;
283 } 287 }
284 288
285 public bool IsAgentComingHome(UUID sessionID, string thisGridExternalName) 289 public bool IsAgentComingHome(UUID sessionID, string thisGridExternalName)
@@ -488,51 +492,17 @@ namespace OpenSim.Services.Connectors.Hypergrid
488 Hashtable hash = new Hashtable(); 492 Hashtable hash = new Hashtable();
489 hash["userID"] = userID.ToString(); 493 hash["userID"] = userID.ToString();
490 494
491 IList paramList = new ArrayList(); 495 hash = CallServer("get_user_info", hash);
492 paramList.Add(hash);
493
494 XmlRpcRequest request = new XmlRpcRequest("get_user_info", paramList);
495 496
496 Dictionary<string, object> info = new Dictionary<string, object>(); 497 Dictionary<string, object> info = new Dictionary<string, object>();
497 XmlRpcResponse response = null;
498 try
499 {
500 response = request.Send(m_ServerURL, 10000);
501 }
502 catch
503 {
504 m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetUserInfo", m_ServerURL);
505 return info;
506 }
507
508 if (response.IsFault)
509 {
510 m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for GetServerURLs returned an error: {1}", m_ServerURL, response.FaultString);
511 return info;
512 }
513 498
514 hash = (Hashtable)response.Value; 499 foreach (object key in hash.Keys)
515 try
516 { 500 {
517 if (hash == null) 501 if (hash[key] != null)
518 { 502 {
519 m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetUserInfo Got null response from {0}! THIS IS BAAAAD", m_ServerURL); 503 info.Add(key.ToString(), hash[key]);
520 return info;
521 }
522
523 // Here is the actual response
524 foreach (object key in hash.Keys)
525 {
526 if (hash[key] != null)
527 {
528 info.Add(key.ToString(), hash[key]);
529 }
530 } 504 }
531 } 505 }
532 catch
533 {
534 m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on GetOnlineFriends response.");
535 }
536 506
537 return info; 507 return info;
538 } 508 }
@@ -542,60 +512,16 @@ namespace OpenSim.Services.Connectors.Hypergrid
542 Hashtable hash = new Hashtable(); 512 Hashtable hash = new Hashtable();
543 hash["userID"] = userID.ToString(); 513 hash["userID"] = userID.ToString();
544 514
545 IList paramList = new ArrayList(); 515 hash = CallServer("get_server_urls", hash);
546 paramList.Add(hash); 516
547 517 Dictionary<string, object> serverURLs = new Dictionary<string, object>();
548 XmlRpcRequest request = new XmlRpcRequest("get_server_urls", paramList); 518 foreach (object key in hash.Keys)
549// string reason = string.Empty;
550
551 // Send and get reply
552 Dictionary<string, object> serverURLs = new Dictionary<string,object>();
553 XmlRpcResponse response = null;
554 try
555 {
556 response = request.Send(m_ServerURL, 10000);
557 }
558 catch
559 {
560 m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetServerURLs for user {1}", m_ServerURL, userID);
561// reason = "Exception: " + e.Message;
562 return serverURLs;
563 }
564
565 if (response.IsFault)
566 { 519 {
567 m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for GetServerURLs returned an error: {1}", m_ServerURL, response.FaultString); 520 if (key is string && ((string)key).StartsWith("SRV_") && hash[key] != null)
568// reason = "XMLRPC Fault";
569 return serverURLs;
570 }
571
572 hash = (Hashtable)response.Value;
573 //foreach (Object o in hash)
574 // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
575 try
576 {
577 if (hash == null)
578 {
579 m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetServerURLs Got null response from {0}! THIS IS BAAAAD", m_ServerURL);
580// reason = "Internal error 1";
581 return serverURLs;
582 }
583
584 // Here is the actual response
585 foreach (object key in hash.Keys)
586 { 521 {
587 if (key is string && ((string)key).StartsWith("SRV_") && hash[key] != null) 522 string serverType = key.ToString().Substring(4); // remove "SRV_"
588 { 523 serverURLs.Add(serverType, hash[key].ToString());
589 string serverType = key.ToString().Substring(4); // remove "SRV_"
590 serverURLs.Add(serverType, hash[key].ToString());
591 }
592 } 524 }
593
594 }
595 catch
596 {
597 m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on GetOnlineFriends response.");
598// reason = "Exception: " + e.Message;
599 } 525 }
600 526
601 return serverURLs; 527 return serverURLs;
@@ -606,55 +532,13 @@ namespace OpenSim.Services.Connectors.Hypergrid
606 Hashtable hash = new Hashtable(); 532 Hashtable hash = new Hashtable();
607 hash["userID"] = userID.ToString(); 533 hash["userID"] = userID.ToString();
608 534
609 IList paramList = new ArrayList(); 535 hash = CallServer("locate_user", hash);
610 paramList.Add(hash);
611 536
612 XmlRpcRequest request = new XmlRpcRequest("locate_user", paramList);
613// string reason = string.Empty;
614
615 // Send and get reply
616 string url = string.Empty; 537 string url = string.Empty;
617 XmlRpcResponse response = null;
618 try
619 {
620 response = request.Send(m_ServerURL, 10000);
621 }
622 catch
623 {
624 m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for LocateUser", m_ServerURL);
625// reason = "Exception: " + e.Message;
626 return url;
627 }
628
629 if (response.IsFault)
630 {
631 m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for LocateUser returned an error: {1}", m_ServerURL, response.FaultString);
632// reason = "XMLRPC Fault";
633 return url;
634 }
635
636 hash = (Hashtable)response.Value;
637 //foreach (Object o in hash)
638 // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
639 try
640 {
641 if (hash == null)
642 {
643 m_log.ErrorFormat("[USER AGENT CONNECTOR]: LocateUser Got null response from {0}! THIS IS BAAAAD", m_ServerURL);
644// reason = "Internal error 1";
645 return url;
646 }
647 538
648 // Here's the actual response 539 // Here's the actual response
649 if (hash.ContainsKey("URL")) 540 if (hash.ContainsKey("URL"))
650 url = hash["URL"].ToString(); 541 url = hash["URL"].ToString();
651
652 }
653 catch
654 {
655 m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on LocateUser response.");
656// reason = "Exception: " + e.Message;
657 }
658 542
659 return url; 543 return url;
660 } 544 }
@@ -665,55 +549,13 @@ namespace OpenSim.Services.Connectors.Hypergrid
665 hash["userID"] = userID.ToString(); 549 hash["userID"] = userID.ToString();
666 hash["targetUserID"] = targetUserID.ToString(); 550 hash["targetUserID"] = targetUserID.ToString();
667 551
668 IList paramList = new ArrayList(); 552 hash = CallServer("get_uui", hash);
669 paramList.Add(hash);
670 553
671 XmlRpcRequest request = new XmlRpcRequest("get_uui", paramList);
672// string reason = string.Empty;
673
674 // Send and get reply
675 string uui = string.Empty; 554 string uui = string.Empty;
676 XmlRpcResponse response = null;
677 try
678 {
679 response = request.Send(m_ServerURL, 10000);
680 }
681 catch
682 {
683 m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetUUI", m_ServerURL);
684// reason = "Exception: " + e.Message;
685 return uui;
686 }
687
688 if (response.IsFault)
689 {
690 m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for GetUUI returned an error: {1}", m_ServerURL, response.FaultString);
691// reason = "XMLRPC Fault";
692 return uui;
693 }
694 555
695 hash = (Hashtable)response.Value; 556 // Here's the actual response
696 //foreach (Object o in hash) 557 if (hash.ContainsKey("UUI"))
697 // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); 558 uui = hash["UUI"].ToString();
698 try
699 {
700 if (hash == null)
701 {
702 m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetUUI Got null response from {0}! THIS IS BAAAAD", m_ServerURL);
703// reason = "Internal error 1";
704 return uui;
705 }
706
707 // Here's the actual response
708 if (hash.ContainsKey("UUI"))
709 uui = hash["UUI"].ToString();
710
711 }
712 catch
713 {
714 m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on GetUUI response.");
715// reason = "Exception: " + e.Message;
716 }
717 559
718 return uui; 560 return uui;
719 } 561 }
@@ -724,54 +566,17 @@ namespace OpenSim.Services.Connectors.Hypergrid
724 hash["first"] = first; 566 hash["first"] = first;
725 hash["last"] = last; 567 hash["last"] = last;
726 568
727 IList paramList = new ArrayList(); 569 hash = CallServer("get_uuid", hash);
728 paramList.Add(hash);
729
730 XmlRpcRequest request = new XmlRpcRequest("get_uuid", paramList);
731 // string reason = string.Empty;
732
733 // Send and get reply
734 UUID uuid = UUID.Zero;
735 XmlRpcResponse response = null;
736 try
737 {
738 response = request.Send(m_ServerURL, 10000);
739 }
740 catch
741 {
742 m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetUUID", m_ServerURL);
743 // reason = "Exception: " + e.Message;
744 return uuid;
745 }
746 570
747 if (response.IsFault) 571 if (!hash.ContainsKey("UUID"))
748 { 572 {
749 m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for GetUUID returned an error: {1}", m_ServerURL, response.FaultString); 573 throw new Exception(string.Format("[USER AGENT CONNECTOR]: get_uuid call to {0} didn't return a UUID", m_ServerURL));
750 // reason = "XMLRPC Fault";
751 return uuid;
752 } 574 }
753 575
754 hash = (Hashtable)response.Value; 576 UUID uuid;
755 //foreach (Object o in hash) 577 if (!UUID.TryParse(hash["UUID"].ToString(), out uuid))
756 // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
757 try
758 {
759 if (hash == null)
760 {
761 m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetUUDI Got null response from {0}! THIS IS BAAAAD", m_ServerURL);
762 // reason = "Internal error 1";
763 return uuid;
764 }
765
766 // Here's the actual response
767 if (hash.ContainsKey("UUID"))
768 UUID.TryParse(hash["UUID"].ToString(), out uuid);
769
770 }
771 catch
772 { 578 {
773 m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on UUID response."); 579 throw new Exception(string.Format("[USER AGENT CONNECTOR]: get_uuid call to {0} returned an invalid UUID: {1}", m_ServerURL, hash["UUID"].ToString()));
774 // reason = "Exception: " + e.Message;
775 } 580 }
776 581
777 return uuid; 582 return uuid;