diff options
Diffstat (limited to 'OpenSim/Services/Connectors')
7 files changed, 145 insertions, 21 deletions
diff --git a/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs b/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs index 65b3537..e63dd50 100644 --- a/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs +++ b/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs | |||
@@ -30,6 +30,7 @@ using System; | |||
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.IO; | 31 | using System.IO; |
32 | using System.Reflection; | 32 | using System.Reflection; |
33 | using System.Timers; | ||
33 | using Nini.Config; | 34 | using Nini.Config; |
34 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
35 | using OpenSim.Framework.Console; | 36 | using OpenSim.Framework.Console; |
@@ -48,7 +49,9 @@ namespace OpenSim.Services.Connectors | |||
48 | 49 | ||
49 | private string m_ServerURI = String.Empty; | 50 | private string m_ServerURI = String.Empty; |
50 | private IImprovedAssetCache m_Cache = null; | 51 | private IImprovedAssetCache m_Cache = null; |
51 | 52 | private int m_retryCounter; | |
53 | private Dictionary<int, List<AssetBase>> m_retryQueue = new Dictionary<int, List<AssetBase>>(); | ||
54 | private Timer m_retryTimer; | ||
52 | public AssetServicesConnector() | 55 | public AssetServicesConnector() |
53 | { | 56 | { |
54 | } | 57 | } |
@@ -85,6 +88,55 @@ namespace OpenSim.Services.Connectors | |||
85 | MainConsole.Instance.Commands.AddCommand("asset", false, "dump asset", | 88 | MainConsole.Instance.Commands.AddCommand("asset", false, "dump asset", |
86 | "dump asset <id> <file>", | 89 | "dump asset <id> <file>", |
87 | "dump one cached asset", HandleDumpAsset); | 90 | "dump one cached asset", HandleDumpAsset); |
91 | |||
92 | m_retryTimer = new Timer(); | ||
93 | m_retryTimer.Elapsed += new ElapsedEventHandler(retryCheck); | ||
94 | m_retryTimer.Interval = 60000; | ||
95 | } | ||
96 | |||
97 | protected void retryCheck(object source, ElapsedEventArgs e) | ||
98 | { | ||
99 | m_retryCounter++; | ||
100 | if (m_retryCounter > 60) m_retryCounter -= 60; | ||
101 | List<int> keys = new List<int>(); | ||
102 | foreach (int a in m_retryQueue.Keys) | ||
103 | { | ||
104 | keys.Add(a); | ||
105 | } | ||
106 | foreach (int a in keys) | ||
107 | { | ||
108 | //We exponentially fall back on frequency until we reach one attempt per hour | ||
109 | //The net result is that we end up in the queue for roughly 24 hours.. | ||
110 | //24 hours worth of assets could be a lot, so the hope is that the region admin | ||
111 | //will have gotten the asset connector back online quickly! | ||
112 | |||
113 | int timefactor = a ^ 2; | ||
114 | if (timefactor > 60) | ||
115 | { | ||
116 | timefactor = 60; | ||
117 | } | ||
118 | |||
119 | //First, find out if we care about this timefactor | ||
120 | if (timefactor % a == 0) | ||
121 | { | ||
122 | //Yes, we do! | ||
123 | List<AssetBase> retrylist = m_retryQueue[a]; | ||
124 | m_retryQueue.Remove(a); | ||
125 | |||
126 | foreach(AssetBase ass in retrylist) | ||
127 | { | ||
128 | Store(ass); //Store my ass. This function will put it back in the dictionary if it fails | ||
129 | } | ||
130 | } | ||
131 | } | ||
132 | |||
133 | if (m_retryQueue.Count == 0) | ||
134 | { | ||
135 | //It might only be one tick per minute, but I have | ||
136 | //repented and abandoned my wasteful ways | ||
137 | m_retryCounter = 0; | ||
138 | m_retryTimer.Stop(); | ||
139 | } | ||
88 | } | 140 | } |
89 | 141 | ||
90 | protected void SetCache(IImprovedAssetCache cache) | 142 | protected void SetCache(IImprovedAssetCache cache) |
@@ -204,11 +256,10 @@ namespace OpenSim.Services.Connectors | |||
204 | 256 | ||
205 | public string Store(AssetBase asset) | 257 | public string Store(AssetBase asset) |
206 | { | 258 | { |
259 | if (m_Cache != null) | ||
260 | m_Cache.Cache(asset); | ||
207 | if (asset.Temporary || asset.Local) | 261 | if (asset.Temporary || asset.Local) |
208 | { | 262 | { |
209 | if (m_Cache != null) | ||
210 | m_Cache.Cache(asset); | ||
211 | |||
212 | return asset.ID; | 263 | return asset.ID; |
213 | } | 264 | } |
214 | 265 | ||
@@ -219,23 +270,56 @@ namespace OpenSim.Services.Connectors | |||
219 | { | 270 | { |
220 | newID = SynchronousRestObjectRequester. | 271 | newID = SynchronousRestObjectRequester. |
221 | MakeRequest<AssetBase, string>("POST", uri, asset); | 272 | MakeRequest<AssetBase, string>("POST", uri, asset); |
273 | if (newID == null) | ||
274 | { | ||
275 | newID = UUID.Zero.ToString(); | ||
276 | } | ||
222 | } | 277 | } |
223 | catch (Exception e) | 278 | catch (Exception e) |
224 | { | 279 | { |
225 | m_log.WarnFormat("[ASSET CONNECTOR]: Unable to send asset {0} to asset server. Reason: {1}", asset.ID, e.Message); | 280 | newID = UUID.Zero.ToString(); |
226 | } | 281 | } |
227 | 282 | ||
228 | if (newID != String.Empty) | 283 | if (newID == UUID.Zero.ToString()) |
229 | { | 284 | { |
230 | // Placing this here, so that this work with old asset servers that don't send any reply back | 285 | //The asset upload failed, put it in a queue for later |
231 | // SynchronousRestObjectRequester returns somethins that is not an empty string | 286 | asset.UploadAttempts++; |
232 | if (newID != null) | 287 | if (asset.UploadAttempts > 30) |
233 | asset.ID = newID; | 288 | { |
234 | 289 | //By this stage we've been in the queue for a good few hours; | |
235 | if (m_Cache != null) | 290 | //We're going to drop the asset. |
236 | m_Cache.Cache(asset); | 291 | m_log.ErrorFormat("[Assets] Dropping asset {0} - Upload has been in the queue for too long.", asset.ID.ToString()); |
292 | } | ||
293 | else | ||
294 | { | ||
295 | if (!m_retryQueue.ContainsKey(asset.UploadAttempts)) | ||
296 | { | ||
297 | m_retryQueue.Add(asset.UploadAttempts, new List<AssetBase>()); | ||
298 | } | ||
299 | List<AssetBase> m_queue = m_retryQueue[asset.UploadAttempts]; | ||
300 | m_queue.Add(asset); | ||
301 | m_log.WarnFormat("[Assets] Upload failed: {0} - Requeuing asset for another run.", asset.ID.ToString()); | ||
302 | m_retryTimer.Start(); | ||
303 | } | ||
304 | } | ||
305 | else | ||
306 | { | ||
307 | if (asset.UploadAttempts > 0) | ||
308 | { | ||
309 | m_log.InfoFormat("[Assets] Upload of {0} succeeded after {1} failed attempts", asset.ID.ToString(), asset.UploadAttempts.ToString()); | ||
310 | } | ||
311 | if (newID != String.Empty) | ||
312 | { | ||
313 | // Placing this here, so that this work with old asset servers that don't send any reply back | ||
314 | // SynchronousRestObjectRequester returns somethins that is not an empty string | ||
315 | if (newID != null) | ||
316 | asset.ID = newID; | ||
317 | |||
318 | if (m_Cache != null) | ||
319 | m_Cache.Cache(asset); | ||
320 | } | ||
237 | } | 321 | } |
238 | return newID; | 322 | return asset.ID; |
239 | } | 323 | } |
240 | 324 | ||
241 | public bool UpdateContent(string id, byte[] data) | 325 | public bool UpdateContent(string id, byte[] data) |
diff --git a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs index c426bba..6f159a0 100644 --- a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs +++ b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs | |||
@@ -87,7 +87,12 @@ namespace OpenSim.Services.Connectors.Hypergrid | |||
87 | paramList.Add(hash); | 87 | paramList.Add(hash); |
88 | 88 | ||
89 | XmlRpcRequest request = new XmlRpcRequest("link_region", paramList); | 89 | XmlRpcRequest request = new XmlRpcRequest("link_region", paramList); |
90 | string uri = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/"; | 90 | IPEndPoint ext = info.ExternalEndPoint; |
91 | string uri = ""; | ||
92 | if (ext != null) | ||
93 | { | ||
94 | uri = "http://" + ext.Address + ":" + info.HttpPort + "/"; | ||
95 | } | ||
91 | //m_log.Debug("[GATEKEEPER SERVICE CONNECTOR]: Linking to " + uri); | 96 | //m_log.Debug("[GATEKEEPER SERVICE CONNECTOR]: Linking to " + uri); |
92 | XmlRpcResponse response = null; | 97 | XmlRpcResponse response = null; |
93 | try | 98 | try |
@@ -189,7 +194,12 @@ namespace OpenSim.Services.Connectors.Hypergrid | |||
189 | paramList.Add(hash); | 194 | paramList.Add(hash); |
190 | 195 | ||
191 | XmlRpcRequest request = new XmlRpcRequest("get_region", paramList); | 196 | XmlRpcRequest request = new XmlRpcRequest("get_region", paramList); |
192 | string uri = "http://" + gatekeeper.ExternalEndPoint.Address + ":" + gatekeeper.HttpPort + "/"; | 197 | IPEndPoint ext = gatekeeper.ExternalEndPoint; |
198 | string uri = ""; | ||
199 | if (ext != null) | ||
200 | { | ||
201 | uri = "http://" + ext.Address + ":" + gatekeeper.HttpPort + "/"; | ||
202 | } | ||
193 | m_log.Debug("[GATEKEEPER SERVICE CONNECTOR]: contacting " + uri); | 203 | m_log.Debug("[GATEKEEPER SERVICE CONNECTOR]: contacting " + uri); |
194 | XmlRpcResponse response = null; | 204 | XmlRpcResponse response = null; |
195 | try | 205 | try |
diff --git a/OpenSim/Services/Connectors/Land/LandServiceConnector.cs b/OpenSim/Services/Connectors/Land/LandServiceConnector.cs index 06bc11c..0223a77 100644 --- a/OpenSim/Services/Connectors/Land/LandServiceConnector.cs +++ b/OpenSim/Services/Connectors/Land/LandServiceConnector.cs | |||
@@ -83,6 +83,8 @@ namespace OpenSim.Services.Connectors | |||
83 | if (info != null) // just to be sure | 83 | if (info != null) // just to be sure |
84 | { | 84 | { |
85 | XmlRpcRequest request = new XmlRpcRequest("land_data", paramList); | 85 | XmlRpcRequest request = new XmlRpcRequest("land_data", paramList); |
86 | |||
87 | //Possible nullref from info.externalendpoint will be caught here | ||
86 | string uri = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/"; | 88 | string uri = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/"; |
87 | XmlRpcResponse response = request.Send(uri, 10000); | 89 | XmlRpcResponse response = request.Send(uri, 10000); |
88 | if (response.IsFault) | 90 | if (response.IsFault) |
diff --git a/OpenSim/Services/Connectors/Neighbour/NeighbourServiceConnector.cs b/OpenSim/Services/Connectors/Neighbour/NeighbourServiceConnector.cs index 0a982f8..daf0439 100644 --- a/OpenSim/Services/Connectors/Neighbour/NeighbourServiceConnector.cs +++ b/OpenSim/Services/Connectors/Neighbour/NeighbourServiceConnector.cs | |||
@@ -87,7 +87,9 @@ namespace OpenSim.Services.Connectors | |||
87 | 87 | ||
88 | public bool DoHelloNeighbourCall(GridRegion region, RegionInfo thisRegion) | 88 | public bool DoHelloNeighbourCall(GridRegion region, RegionInfo thisRegion) |
89 | { | 89 | { |
90 | string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/region/" + thisRegion.RegionID + "/"; | 90 | IPEndPoint ext = region.ExternalEndPoint; |
91 | if (ext == null) return false; | ||
92 | string uri = "http://" + ext.Address + ":" + region.HttpPort + "/region/" + thisRegion.RegionID + "/"; | ||
91 | //m_log.Debug(" >>> DoHelloNeighbourCall <<< " + uri); | 93 | //m_log.Debug(" >>> DoHelloNeighbourCall <<< " + uri); |
92 | 94 | ||
93 | WebRequest HelloNeighbourRequest = WebRequest.Create(uri); | 95 | WebRequest HelloNeighbourRequest = WebRequest.Create(uri); |
diff --git a/OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs b/OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs index 41ebeaf..9f86078 100644 --- a/OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs +++ b/OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs | |||
@@ -300,6 +300,14 @@ namespace OpenSim.Services.Connectors | |||
300 | { | 300 | { |
301 | pinfo = new PresenceInfo((Dictionary<string, object>)replyData["result"]); | 301 | pinfo = new PresenceInfo((Dictionary<string, object>)replyData["result"]); |
302 | } | 302 | } |
303 | else | ||
304 | { | ||
305 | m_log.DebugFormat("[PRESENCE CONNECTOR]: Invalid reply (result not dictionary) received from presence server when querying for sessionID {0}", sessionID.ToString()); | ||
306 | } | ||
307 | } | ||
308 | else | ||
309 | { | ||
310 | m_log.DebugFormat("[PRESENCE CONNECTOR]: Invalid reply received from presence server when querying for sessionID {0}", sessionID.ToString()); | ||
303 | } | 311 | } |
304 | 312 | ||
305 | return pinfo; | 313 | return pinfo; |
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs index bea8172..496eb2c 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs | |||
@@ -122,6 +122,8 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
122 | 122 | ||
123 | public string RegisterRegion(UUID scopeID, GridRegion regionInfo) | 123 | public string RegisterRegion(UUID scopeID, GridRegion regionInfo) |
124 | { | 124 | { |
125 | IPEndPoint ext = regionInfo.ExternalEndPoint; | ||
126 | if (ext == null) return "Region registration for " + regionInfo.RegionName + " failed: Could not resolve EndPoint"; | ||
125 | // Generate and upload our map tile in PNG format to the SimianGrid AddMapTile service | 127 | // Generate and upload our map tile in PNG format to the SimianGrid AddMapTile service |
126 | Scene scene; | 128 | Scene scene; |
127 | if (m_scenes.TryGetValue(regionInfo.RegionID, out scene)) | 129 | if (m_scenes.TryGetValue(regionInfo.RegionID, out scene)) |
@@ -139,7 +141,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
139 | { "ServerURI", OSD.FromString(regionInfo.ServerURI) }, | 141 | { "ServerURI", OSD.FromString(regionInfo.ServerURI) }, |
140 | { "InternalAddress", OSD.FromString(regionInfo.InternalEndPoint.Address.ToString()) }, | 142 | { "InternalAddress", OSD.FromString(regionInfo.InternalEndPoint.Address.ToString()) }, |
141 | { "InternalPort", OSD.FromInteger(regionInfo.InternalEndPoint.Port) }, | 143 | { "InternalPort", OSD.FromInteger(regionInfo.InternalEndPoint.Port) }, |
142 | { "ExternalAddress", OSD.FromString(regionInfo.ExternalEndPoint.Address.ToString()) }, | 144 | { "ExternalAddress", OSD.FromString(ext.Address.ToString()) }, |
143 | { "ExternalPort", OSD.FromInteger(regionInfo.ExternalEndPoint.Port) }, | 145 | { "ExternalPort", OSD.FromInteger(regionInfo.ExternalEndPoint.Port) }, |
144 | { "MapTexture", OSD.FromUUID(regionInfo.TerrainImage) }, | 146 | { "MapTexture", OSD.FromUUID(regionInfo.TerrainImage) }, |
145 | { "Access", OSD.FromInteger(regionInfo.Access) }, | 147 | { "Access", OSD.FromInteger(regionInfo.Access) }, |
diff --git a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs index 32f02fb..0947b5f 100644 --- a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs +++ b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs | |||
@@ -348,9 +348,11 @@ namespace OpenSim.Services.Connectors.Simulation | |||
348 | 348 | ||
349 | public bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent) | 349 | public bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent) |
350 | { | 350 | { |
351 | IPEndPoint ext = destination.ExternalEndPoint; | ||
351 | agent = null; | 352 | agent = null; |
353 | if (ext == null) return false; | ||
352 | // Eventually, we want to use a caps url instead of the agentID | 354 | // Eventually, we want to use a caps url instead of the agentID |
353 | string uri = "http://" + destination.ExternalEndPoint.Address + ":" + destination.HttpPort + AgentPath() + id + "/" + destination.RegionID.ToString() + "/"; | 355 | string uri = "http://" + ext.Address + ":" + destination.HttpPort + AgentPath() + id + "/" + destination.RegionID.ToString() + "/"; |
354 | //Console.WriteLine(" >>> DoRetrieveRootAgentCall <<< " + uri); | 356 | //Console.WriteLine(" >>> DoRetrieveRootAgentCall <<< " + uri); |
355 | 357 | ||
356 | HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri); | 358 | HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri); |
@@ -442,7 +444,7 @@ namespace OpenSim.Services.Connectors.Simulation | |||
442 | return true; | 444 | return true; |
443 | } | 445 | } |
444 | 446 | ||
445 | public bool CloseAgent(GridRegion destination, UUID id) | 447 | private bool CloseAgent(GridRegion destination, UUID id, bool ChildOnly) |
446 | { | 448 | { |
447 | string uri = string.Empty; | 449 | string uri = string.Empty; |
448 | try | 450 | try |
@@ -459,6 +461,8 @@ namespace OpenSim.Services.Connectors.Simulation | |||
459 | 461 | ||
460 | WebRequest request = WebRequest.Create(uri); | 462 | WebRequest request = WebRequest.Create(uri); |
461 | request.Method = "DELETE"; | 463 | request.Method = "DELETE"; |
464 | if (ChildOnly) | ||
465 | request.Method += "CHILD"; | ||
462 | request.Timeout = 10000; | 466 | request.Timeout = 10000; |
463 | 467 | ||
464 | StreamReader sr = null; | 468 | StreamReader sr = null; |
@@ -491,6 +495,16 @@ namespace OpenSim.Services.Connectors.Simulation | |||
491 | return true; | 495 | return true; |
492 | } | 496 | } |
493 | 497 | ||
498 | public bool CloseChildAgent(GridRegion destination, UUID id) | ||
499 | { | ||
500 | return CloseAgent(destination, id, true); | ||
501 | } | ||
502 | |||
503 | public bool CloseAgent(GridRegion destination, UUID id) | ||
504 | { | ||
505 | return CloseAgent(destination, id, false); | ||
506 | } | ||
507 | |||
494 | #endregion Agents | 508 | #endregion Agents |
495 | 509 | ||
496 | #region Objects | 510 | #region Objects |
@@ -502,8 +516,10 @@ namespace OpenSim.Services.Connectors.Simulation | |||
502 | 516 | ||
503 | public bool CreateObject(GridRegion destination, ISceneObject sog, bool isLocalCall) | 517 | public bool CreateObject(GridRegion destination, ISceneObject sog, bool isLocalCall) |
504 | { | 518 | { |
519 | IPEndPoint ext = destination.ExternalEndPoint; | ||
520 | if (ext == null) return false; | ||
505 | string uri | 521 | string uri |
506 | = "http://" + destination.ExternalEndPoint.Address + ":" + destination.HttpPort + ObjectPath() + sog.UUID + "/"; | 522 | = "http://" + ext.Address + ":" + destination.HttpPort + ObjectPath() + sog.UUID + "/"; |
507 | //m_log.Debug(" >>> DoCreateObjectCall <<< " + uri); | 523 | //m_log.Debug(" >>> DoCreateObjectCall <<< " + uri); |
508 | 524 | ||
509 | WebRequest ObjectCreateRequest = WebRequest.Create(uri); | 525 | WebRequest ObjectCreateRequest = WebRequest.Create(uri); |