diff options
Diffstat (limited to 'OpenSim/Region/Communications/OGS1/OGS1GridServices.cs')
-rw-r--r-- | OpenSim/Region/Communications/OGS1/OGS1GridServices.cs | 183 |
1 files changed, 136 insertions, 47 deletions
diff --git a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs index a0d6bd3..282b720 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs | |||
@@ -49,11 +49,33 @@ namespace OpenSim.Region.Communications.OGS1 | |||
49 | { | 49 | { |
50 | private LocalBackEndServices m_localBackend = new LocalBackEndServices(); | 50 | private LocalBackEndServices m_localBackend = new LocalBackEndServices(); |
51 | private Dictionary<ulong, RegionInfo> m_remoteRegionInfoCache = new Dictionary<ulong, RegionInfo>(); | 51 | private Dictionary<ulong, RegionInfo> m_remoteRegionInfoCache = new Dictionary<ulong, RegionInfo>(); |
52 | private List<SimpleRegionInfo> m_knownRegions = new List<SimpleRegionInfo>(); | ||
52 | 53 | ||
53 | public BaseHttpServer httpListener; | 54 | public BaseHttpServer httpListener; |
54 | public NetworkServersInfo serversInfo; | 55 | public NetworkServersInfo serversInfo; |
55 | public BaseHttpServer httpServer; | 56 | public BaseHttpServer httpServer; |
57 | public string _gdebugRegionName = ""; | ||
56 | 58 | ||
59 | public string gdebugRegionName | ||
60 | { | ||
61 | get { return _gdebugRegionName; } | ||
62 | set | ||
63 | { | ||
64 | _gdebugRegionName = value; | ||
65 | |||
66 | } | ||
67 | } | ||
68 | public string _rdebugRegionName = ""; | ||
69 | |||
70 | public string rdebugRegionName | ||
71 | { | ||
72 | get { return _rdebugRegionName; } | ||
73 | set | ||
74 | { | ||
75 | _rdebugRegionName = value; | ||
76 | |||
77 | } | ||
78 | } | ||
57 | /// <summary> | 79 | /// <summary> |
58 | /// | 80 | /// |
59 | /// </summary> | 81 | /// </summary> |
@@ -105,10 +127,19 @@ namespace OpenSim.Region.Communications.OGS1 | |||
105 | // Process Response | 127 | // Process Response |
106 | if (GridRespData.ContainsKey("error")) | 128 | if (GridRespData.ContainsKey("error")) |
107 | { | 129 | { |
108 | string errorstring = (string) GridRespData["error"]; | 130 | string errorstring = (string)GridRespData["error"]; |
109 | MainLog.Instance.Error("Unable to connect to grid: " + errorstring); | 131 | MainLog.Instance.Error("Unable to connect to grid: " + errorstring); |
110 | return null; | 132 | return null; |
111 | } | 133 | } |
134 | else | ||
135 | { | ||
136 | //m_knownRegions = RequestNeighbours(regionInfo.RegionLocX, regionInfo.RegionLocY); | ||
137 | |||
138 | |||
139 | } | ||
140 | //SimpleRegionInfo regiondata = new SimpleRegionInfo(); | ||
141 | //regiondata.RegionID = griddatahash["UUID"]; | ||
142 | //regiondata.RemotingAddress = | ||
112 | 143 | ||
113 | return m_localBackend.RegisterRegion(regionInfo); | 144 | return m_localBackend.RegisterRegion(regionInfo); |
114 | } | 145 | } |
@@ -155,7 +186,53 @@ namespace OpenSim.Region.Communications.OGS1 | |||
155 | return neighbours; | 186 | return neighbours; |
156 | } | 187 | } |
157 | 188 | ||
189 | /// <summary> | ||
190 | /// | ||
191 | /// </summary> | ||
192 | /// <param name="regionHandle"></param> | ||
193 | /// <returns></returns> | ||
194 | public RegionInfo RequestNeighbourInfo(LLUUID Region_UUID) | ||
195 | { | ||
196 | RegionInfo regionInfo; | ||
197 | Hashtable requestData = new Hashtable(); | ||
198 | requestData["region_UUID"] = Region_UUID.ToStringHyphenated(); | ||
199 | requestData["authkey"] = serversInfo.GridSendKey; | ||
200 | ArrayList SendParams = new ArrayList(); | ||
201 | SendParams.Add(requestData); | ||
202 | XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams); | ||
203 | XmlRpcResponse GridResp = GridReq.Send(serversInfo.GridURL, 3000); | ||
204 | |||
205 | Hashtable responseData = (Hashtable)GridResp.Value; | ||
158 | 206 | ||
207 | if (responseData.ContainsKey("error")) | ||
208 | { | ||
209 | Console.WriteLine("error received from grid server" + responseData["error"]); | ||
210 | return null; | ||
211 | } | ||
212 | |||
213 | uint regX = Convert.ToUInt32((string)responseData["region_locx"]); | ||
214 | uint regY = Convert.ToUInt32((string)responseData["region_locy"]); | ||
215 | string internalIpStr = (string)responseData["sim_ip"]; | ||
216 | uint port = Convert.ToUInt32(responseData["sim_port"]); | ||
217 | string externalUri = (string)responseData["sim_uri"]; | ||
218 | |||
219 | IPEndPoint neighbourInternalEndPoint = new IPEndPoint(IPAddress.Parse(internalIpStr), (int)port); | ||
220 | string neighbourExternalUri = externalUri; | ||
221 | regionInfo = new RegionInfo(regX, regY, neighbourInternalEndPoint, internalIpStr); | ||
222 | |||
223 | regionInfo.RemotingPort = Convert.ToUInt32((string)responseData["remoting_port"]); | ||
224 | regionInfo.RemotingAddress = internalIpStr; | ||
225 | |||
226 | regionInfo.RegionID = new LLUUID((string)responseData["region_UUID"]); | ||
227 | regionInfo.RegionName = (string)responseData["region_name"]; | ||
228 | |||
229 | if (requestData.ContainsKey("regionHandle")) | ||
230 | { | ||
231 | m_remoteRegionInfoCache.Add(Convert.ToUInt64((string)requestData["regionHandle"]), regionInfo); | ||
232 | } | ||
233 | |||
234 | return regionInfo; | ||
235 | } | ||
159 | /// <summary> | 236 | /// <summary> |
160 | /// | 237 | /// |
161 | /// </summary> | 238 | /// </summary> |
@@ -381,7 +458,7 @@ namespace OpenSim.Region.Communications.OGS1 | |||
381 | InterRegionSingleton.Instance.OnPrimGroupArrival += IncomingPrim; | 458 | InterRegionSingleton.Instance.OnPrimGroupArrival += IncomingPrim; |
382 | InterRegionSingleton.Instance.OnPrimGroupNear += TriggerExpectPrimCrossing; | 459 | InterRegionSingleton.Instance.OnPrimGroupNear += TriggerExpectPrimCrossing; |
383 | InterRegionSingleton.Instance.OnRegionUp += TriggerRegionUp; | 460 | InterRegionSingleton.Instance.OnRegionUp += TriggerRegionUp; |
384 | 461 | InterRegionSingleton.Instance.OnRegionUp += RegionUp; | |
385 | } | 462 | } |
386 | 463 | ||
387 | #region Methods called by regions in this instance | 464 | #region Methods called by regions in this instance |
@@ -427,7 +504,7 @@ namespace OpenSim.Region.Communications.OGS1 | |||
427 | Console.WriteLine("remoting object not found"); | 504 | Console.WriteLine("remoting object not found"); |
428 | } | 505 | } |
429 | remObject = null; | 506 | remObject = null; |
430 | 507 | MainLog.Instance.Verbose("INTER", gdebugRegionName + ": OGS1 tried to InformRegionOfChildAgent for " + agentData.firstname + " " + agentData.lastname + " and got " + retValue.ToString()); | |
431 | 508 | ||
432 | return retValue; | 509 | return retValue; |
433 | } | 510 | } |
@@ -470,17 +547,27 @@ namespace OpenSim.Region.Communications.OGS1 | |||
470 | // UGLY! | 547 | // UGLY! |
471 | public bool RegionUp(RegionInfo region) | 548 | public bool RegionUp(RegionInfo region) |
472 | { | 549 | { |
473 | RegionInfo regInfo = null; | 550 | |
474 | try | 551 | // This is stupid. For this to work, when the region registers it must request nearby map blocks. |
552 | // In addition to filling the map blocks, it fills a 'known regions' list. | ||
553 | |||
554 | // This known regions list then gets queried on here to get the remoting data from the neighbors. | ||
555 | // *Pull yourself up by your bootstraps?* | ||
556 | |||
557 | if (m_localBackend.RegionUp(region)) | ||
475 | { | 558 | { |
476 | if (m_localBackend.RegionUp(region)) | 559 | return true; |
477 | { | 560 | } |
478 | return true; | 561 | return true; |
479 | } | 562 | foreach (SimpleRegionInfo knownregion in m_knownRegions) |
480 | foreach (RegionInfo remoteInfo in m_remoteRegionInfoCache.Values) | 563 | { |
481 | { | 564 | // Wha? |
482 | regInfo = RequestNeighbourInfo(remoteInfo.RegionHandle); | 565 | RegionInfo regInfo = RequestNeighbourInfo(knownregion.RegionID); |
483 | if (regInfo != null) | 566 | |
567 | try | ||
568 | { | ||
569 | |||
570 | if ((!(regInfo.Equals(null)) && regInfo.RemotingAddress.Length > 0)) | ||
484 | { | 571 | { |
485 | //don't want to be creating a new link to the remote instance every time like we are here | 572 | //don't want to be creating a new link to the remote instance every time like we are here |
486 | bool retValue = false; | 573 | bool retValue = false; |
@@ -501,43 +588,41 @@ namespace OpenSim.Region.Communications.OGS1 | |||
501 | Console.WriteLine("remoting object not found"); | 588 | Console.WriteLine("remoting object not found"); |
502 | } | 589 | } |
503 | remObject = null; | 590 | remObject = null; |
591 | //MainLog.Instance.Verbose("INTER", gdebugRegionName + ": OGS1 tried to NotifyRegionUp for " + region.RegionName + " and got " + retValue.ToString()); | ||
504 | 592 | ||
505 | } | 593 | } |
506 | 594 | ||
507 | } | 595 | } |
508 | 596 | catch (RemotingException e) | |
509 | 597 | { | |
510 | return true; | 598 | MainLog.Instance.Warn("Remoting Error: Unable to connect to adjacent region: " + regInfo.RegionName + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); |
511 | } | 599 | MainLog.Instance.Debug(e.ToString()); |
512 | catch (RemotingException e) | 600 | //return false; |
513 | { | 601 | } |
514 | MainLog.Instance.Warn("Remoting Error: Unable to connect to adjacent region: " + regInfo.RegionName + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); | 602 | catch (SocketException e) |
515 | MainLog.Instance.Debug(e.ToString()); | 603 | { |
516 | return false; | 604 | MainLog.Instance.Warn("Socket Error: Unable to connect to adjacent region: " + regInfo.RegionName + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); |
517 | } | 605 | MainLog.Instance.Debug(e.ToString()); |
518 | catch (SocketException e) | 606 | //return false; |
519 | { | 607 | } |
520 | MainLog.Instance.Warn("Socket Error: Unable to connect to adjacent region: " + regInfo.RegionName + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); | 608 | catch (InvalidCredentialException e) |
521 | MainLog.Instance.Debug(e.ToString()); | 609 | { |
522 | return false; | 610 | MainLog.Instance.Warn("Invalid Credentials: Unable to connect to adjacent region: " + regInfo.RegionName + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); |
523 | } | 611 | MainLog.Instance.Debug(e.ToString()); |
524 | catch (InvalidCredentialException e) | 612 | //return false; |
525 | { | 613 | } |
526 | MainLog.Instance.Warn("Invalid Credentials: Unable to connect to adjacent region: " + regInfo.RegionName + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); | 614 | catch (AuthenticationException e) |
527 | MainLog.Instance.Debug(e.ToString()); | 615 | { |
528 | return false; | 616 | MainLog.Instance.Warn("Authentication exception: Unable to connect to adjacent region: " + regInfo.RegionName + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); |
529 | } | 617 | MainLog.Instance.Debug(e.ToString()); |
530 | catch (AuthenticationException e) | 618 | //return false; |
531 | { | 619 | } |
532 | MainLog.Instance.Warn("Authentication exception: Unable to connect to adjacent region: " + regInfo.RegionName + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); | 620 | catch (Exception e) |
533 | MainLog.Instance.Debug(e.ToString()); | 621 | { |
534 | return false; | 622 | MainLog.Instance.Warn("Unknown exception: Unable to connect to adjacent region: " + regInfo.RegionName + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); |
535 | } | 623 | MainLog.Instance.Debug(e.ToString()); |
536 | catch (Exception e) | 624 | //return false; |
537 | { | 625 | } |
538 | MainLog.Instance.Warn("Unknown exception: Unable to connect to adjacent region: " + regInfo.RegionName + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); | ||
539 | MainLog.Instance.Debug(e.ToString()); | ||
540 | return false; | ||
541 | } | 626 | } |
542 | return true; | 627 | return true; |
543 | } | 628 | } |
@@ -745,19 +830,23 @@ namespace OpenSim.Region.Communications.OGS1 | |||
745 | /// <returns></returns> | 830 | /// <returns></returns> |
746 | public bool IncomingChildAgent(ulong regionHandle, AgentCircuitData agentData) | 831 | public bool IncomingChildAgent(ulong regionHandle, AgentCircuitData agentData) |
747 | { | 832 | { |
833 | //MainLog.Instance.Verbose("INTER", gdebugRegionName + ": Incoming OGS1 Agent " + agentData.firstname + " " + agentData.lastname); | ||
834 | |||
748 | try | 835 | try |
749 | { | 836 | { |
750 | return m_localBackend.IncomingChildAgent(regionHandle, agentData); | 837 | return m_localBackend.IncomingChildAgent(regionHandle, agentData); |
751 | } | 838 | } |
752 | catch (RemotingException e) | 839 | catch (RemotingException e) |
753 | { | 840 | { |
754 | MainLog.Instance.Error("Remoting Error: Unable to connect to adjacent region.\n" + e.ToString()); | 841 | //MainLog.Instance.Error("Remoting Error: Unable to connect to adjacent region.\n" + e.ToString()); |
755 | return false; | 842 | return false; |
756 | } | 843 | } |
757 | } | 844 | } |
758 | 845 | ||
759 | public bool TriggerRegionUp(RegionInfo regionData) | 846 | public bool TriggerRegionUp(RegionInfo regionData) |
760 | { | 847 | { |
848 | //MainLog.Instance.Verbose("INTER", gdebugRegionName + ": Incoming OGS1 RegionUpReport " + regionData.RegionName); | ||
849 | |||
761 | try | 850 | try |
762 | { | 851 | { |
763 | return m_localBackend.TriggerRegionUp(regionData); | 852 | return m_localBackend.TriggerRegionUp(regionData); |