aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/Connectors
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Services/Connectors')
-rw-r--r--OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs324
-rw-r--r--OpenSim/Services/Connectors/Authentication/AuthenticationServicesConnector.cs7
-rw-r--r--OpenSim/Services/Connectors/Friends/FriendsSimConnector.cs68
-rw-r--r--OpenSim/Services/Connectors/Grid/GridServicesConnector.cs10
-rw-r--r--OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs6
-rw-r--r--OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs2
-rw-r--r--OpenSim/Services/Connectors/Land/LandServicesConnector.cs2
-rw-r--r--OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs8
-rw-r--r--OpenSim/Services/Connectors/Presence/PresenceServicesConnector.cs11
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs6
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs90
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs5
-rw-r--r--OpenSim/Services/Connectors/Simulation/SimulationDataService.cs5
-rw-r--r--OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs10
-rw-r--r--OpenSim/Services/Connectors/UserAccounts/UserAccountServicesConnector.cs5
15 files changed, 455 insertions, 104 deletions
diff --git a/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs b/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs
index 8b04d7f..bf0cc35 100644
--- a/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs
@@ -27,9 +27,11 @@
27 27
28using log4net; 28using log4net;
29using System; 29using System;
30using System.Threading;
30using System.Collections.Generic; 31using System.Collections.Generic;
31using System.IO; 32using System.IO;
32using System.Reflection; 33using System.Reflection;
34using System.Timers;
33using Nini.Config; 35using Nini.Config;
34using OpenSim.Framework; 36using OpenSim.Framework;
35using OpenSim.Framework.Console; 37using OpenSim.Framework.Console;
@@ -47,13 +49,22 @@ namespace OpenSim.Services.Connectors
47 49
48 private string m_ServerURI = String.Empty; 50 private string m_ServerURI = String.Empty;
49 private IImprovedAssetCache m_Cache = null; 51 private IImprovedAssetCache m_Cache = null;
52 private int m_retryCounter;
53 private Dictionary<int, List<AssetBase>> m_retryQueue = new Dictionary<int, List<AssetBase>>();
54 private System.Timers.Timer m_retryTimer;
50 private int m_maxAssetRequestConcurrency = 30; 55 private int m_maxAssetRequestConcurrency = 30;
51 56
52 private delegate void AssetRetrievedEx(AssetBase asset); 57 private delegate void AssetRetrievedEx(AssetBase asset);
53 58
54 // Keeps track of concurrent requests for the same asset, so that it's only loaded once. 59 // Keeps track of concurrent requests for the same asset, so that it's only loaded once.
55 // Maps: Asset ID -> Handlers which will be called when the asset has been loaded 60 // Maps: Asset ID -> Handlers which will be called when the asset has been loaded
56 private Dictionary<string, AssetRetrievedEx> m_AssetHandlers = new Dictionary<string, AssetRetrievedEx>(); 61// private Dictionary<string, AssetRetrievedEx> m_AssetHandlers = new Dictionary<string, AssetRetrievedEx>();
62
63 private Dictionary<string, List<AssetRetrievedEx>> m_AssetHandlers = new Dictionary<string, List<AssetRetrievedEx>>();
64
65 private Dictionary<string, string> m_UriMap = new Dictionary<string, string>();
66
67 private Thread[] m_fetchThreads;
57 68
58 public int MaxAssetRequestConcurrency 69 public int MaxAssetRequestConcurrency
59 { 70 {
@@ -91,13 +102,108 @@ namespace OpenSim.Services.Connectors
91 string serviceURI = assetConfig.GetString("AssetServerURI", 102 string serviceURI = assetConfig.GetString("AssetServerURI",
92 String.Empty); 103 String.Empty);
93 104
105 m_ServerURI = serviceURI;
106
94 if (serviceURI == String.Empty) 107 if (serviceURI == String.Empty)
95 { 108 {
96 m_log.Error("[ASSET CONNECTOR]: No Server URI named in section AssetService"); 109 m_log.Error("[ASSET CONNECTOR]: No Server URI named in section AssetService");
97 throw new Exception("Asset connector init error"); 110 throw new Exception("Asset connector init error");
98 } 111 }
99 112
100 m_ServerURI = serviceURI; 113
114 m_retryTimer = new System.Timers.Timer();
115 m_retryTimer.Elapsed += new ElapsedEventHandler(retryCheck);
116 m_retryTimer.Interval = 60000;
117
118 Uri serverUri = new Uri(m_ServerURI);
119
120 string groupHost = serverUri.Host;
121
122 for (int i = 0 ; i < 256 ; i++)
123 {
124 string prefix = i.ToString("x2");
125 groupHost = assetConfig.GetString("AssetServerHost_"+prefix, groupHost);
126
127 m_UriMap[prefix] = groupHost;
128 //m_log.DebugFormat("[ASSET]: Using {0} for prefix {1}", groupHost, prefix);
129 }
130
131 m_fetchThreads = new Thread[2];
132
133 for (int i = 0 ; i < 2 ; i++)
134 {
135 m_fetchThreads[i] = new Thread(AssetRequestProcessor);
136 m_fetchThreads[i].Start();
137 }
138 }
139
140 private string MapServer(string id)
141 {
142 UriBuilder serverUri = new UriBuilder(m_ServerURI);
143
144 string prefix = id.Substring(0, 2).ToLower();
145
146 string host;
147
148 // HG URLs will not be valid UUIDS
149 if (m_UriMap.ContainsKey(prefix))
150 host = m_UriMap[prefix];
151 else
152 host = m_UriMap["00"];
153
154 serverUri.Host = host;
155
156 // m_log.DebugFormat("[ASSET]: Using {0} for host name for prefix {1}", host, prefix);
157
158 string ret = serverUri.Uri.AbsoluteUri;
159 if (ret.EndsWith("/"))
160 ret = ret.Substring(0, ret.Length - 1);
161 return ret;
162 }
163
164 protected void retryCheck(object source, ElapsedEventArgs e)
165 {
166 m_retryCounter++;
167 if (m_retryCounter > 60) m_retryCounter -= 60;
168 List<int> keys = new List<int>();
169 foreach (int a in m_retryQueue.Keys)
170 {
171 keys.Add(a);
172 }
173 foreach (int a in keys)
174 {
175 //We exponentially fall back on frequency until we reach one attempt per hour
176 //The net result is that we end up in the queue for roughly 24 hours..
177 //24 hours worth of assets could be a lot, so the hope is that the region admin
178 //will have gotten the asset connector back online quickly!
179
180 int timefactor = a ^ 2;
181 if (timefactor > 60)
182 {
183 timefactor = 60;
184 }
185
186 //First, find out if we care about this timefactor
187 if (timefactor % a == 0)
188 {
189 //Yes, we do!
190 List<AssetBase> retrylist = m_retryQueue[a];
191 m_retryQueue.Remove(a);
192
193 foreach(AssetBase ass in retrylist)
194 {
195 Store(ass); //Store my ass. This function will put it back in the dictionary if it fails
196 }
197 }
198 }
199
200 if (m_retryQueue.Count == 0)
201 {
202 //It might only be one tick per minute, but I have
203 //repented and abandoned my wasteful ways
204 m_retryCounter = 0;
205 m_retryTimer.Stop();
206 }
101 } 207 }
102 208
103 protected void SetCache(IImprovedAssetCache cache) 209 protected void SetCache(IImprovedAssetCache cache)
@@ -107,15 +213,13 @@ namespace OpenSim.Services.Connectors
107 213
108 public AssetBase Get(string id) 214 public AssetBase Get(string id)
109 { 215 {
110// m_log.DebugFormat("[ASSET SERVICE CONNECTOR]: Synchronous get request for {0}", id); 216 string uri = MapServer(id) + "/assets/" + id;
111
112 string uri = m_ServerURI + "/assets/" + id;
113 217
114 AssetBase asset = null; 218 AssetBase asset = null;
115 if (m_Cache != null) 219 if (m_Cache != null)
116 asset = m_Cache.Get(id); 220 asset = m_Cache.Get(id);
117 221
118 if (asset == null) 222 if (asset == null || asset.Data == null || asset.Data.Length == 0)
119 { 223 {
120 asset = SynchronousRestObjectRequester. 224 asset = SynchronousRestObjectRequester.
121 MakeRequest<int, AssetBase>("GET", uri, 0, m_maxAssetRequestConcurrency); 225 MakeRequest<int, AssetBase>("GET", uri, 0, m_maxAssetRequestConcurrency);
@@ -146,7 +250,7 @@ namespace OpenSim.Services.Connectors
146 return fullAsset.Metadata; 250 return fullAsset.Metadata;
147 } 251 }
148 252
149 string uri = m_ServerURI + "/assets/" + id + "/metadata"; 253 string uri = MapServer(id) + "/assets/" + id + "/metadata";
150 254
151 AssetMetadata asset = SynchronousRestObjectRequester. 255 AssetMetadata asset = SynchronousRestObjectRequester.
152 MakeRequest<int, AssetMetadata>("GET", uri, 0); 256 MakeRequest<int, AssetMetadata>("GET", uri, 0);
@@ -163,7 +267,7 @@ namespace OpenSim.Services.Connectors
163 return fullAsset.Data; 267 return fullAsset.Data;
164 } 268 }
165 269
166 RestClient rc = new RestClient(m_ServerURI); 270 RestClient rc = new RestClient(MapServer(id));
167 rc.AddResourcePath("assets"); 271 rc.AddResourcePath("assets");
168 rc.AddResourcePath(id); 272 rc.AddResourcePath(id);
169 rc.AddResourcePath("data"); 273 rc.AddResourcePath("data");
@@ -186,66 +290,109 @@ namespace OpenSim.Services.Connectors
186 return null; 290 return null;
187 } 291 }
188 292
189 public bool Get(string id, Object sender, AssetRetrieved handler) 293 private class QueuedAssetRequest
190 { 294 {
191// m_log.DebugFormat("[ASSET SERVICE CONNECTOR]: Potentially asynchronous get request for {0}", id); 295 public string uri;
296 public string id;
297 }
192 298
193 string uri = m_ServerURI + "/assets/" + id; 299 private OpenMetaverse.BlockingQueue<QueuedAssetRequest> m_requestQueue =
300 new OpenMetaverse.BlockingQueue<QueuedAssetRequest>();
194 301
195 AssetBase asset = null; 302 private void AssetRequestProcessor()
196 if (m_Cache != null) 303 {
197 asset = m_Cache.Get(id); 304 QueuedAssetRequest r;
198 305
199 if (asset == null) 306 while (true)
200 { 307 {
201 lock (m_AssetHandlers) 308 r = m_requestQueue.Dequeue();
202 {
203 AssetRetrievedEx handlerEx = new AssetRetrievedEx(delegate(AssetBase _asset) { handler(id, sender, _asset); });
204
205 AssetRetrievedEx handlers;
206 if (m_AssetHandlers.TryGetValue(id, out handlers))
207 {
208 // Someone else is already loading this asset. It will notify our handler when done.
209 handlers += handlerEx;
210 return true;
211 }
212 309
213 // Load the asset ourselves 310 string uri = r.uri;
214 handlers += handlerEx; 311 string id = r.id;
215 m_AssetHandlers.Add(id, handlers);
216 }
217 312
218 bool success = false; 313 bool success = false;
219 try 314 try
220 { 315 {
221 AsynchronousRestObjectRequester.MakeRequest<int, AssetBase>("GET", uri, 0, 316 AssetBase a = SynchronousRestObjectRequester.MakeRequest<int, AssetBase>("GET", uri, 0, 30);
222 delegate(AssetBase a) 317 if (a != null)
223 { 318 {
224 if (m_Cache != null) 319 if (m_Cache != null)
225 m_Cache.Cache(a); 320 m_Cache.Cache(a);
226 321
227 AssetRetrievedEx handlers; 322 List<AssetRetrievedEx> handlers;
228 lock (m_AssetHandlers) 323 lock (m_AssetHandlers)
324 {
325 handlers = m_AssetHandlers[id];
326 m_AssetHandlers.Remove(id);
327 }
328 foreach (AssetRetrievedEx h in handlers)
329 {
330 Util.FireAndForget(x =>
229 { 331 {
230 handlers = m_AssetHandlers[id]; 332 h.Invoke(a);
231 m_AssetHandlers.Remove(id); 333 });
232 } 334 }
233 handlers.Invoke(a); 335 if (handlers != null)
234 }, m_maxAssetRequestConcurrency); 336 handlers.Clear();
235 337
236 success = true; 338 success = true;
339 }
237 } 340 }
238 finally 341 finally
239 { 342 {
240 if (!success) 343 if (!success)
241 { 344 {
345 List<AssetRetrievedEx> handlers;
242 lock (m_AssetHandlers) 346 lock (m_AssetHandlers)
243 { 347 {
348 handlers = m_AssetHandlers[id];
244 m_AssetHandlers.Remove(id); 349 m_AssetHandlers.Remove(id);
245 } 350 }
351 if (handlers != null)
352 handlers.Clear();
246 } 353 }
247 } 354 }
248 } 355 }
356 }
357
358 public bool Get(string id, Object sender, AssetRetrieved handler)
359 {
360 string uri = MapServer(id) + "/assets/" + id;
361
362 AssetBase asset = null;
363 if (m_Cache != null)
364 asset = m_Cache.Get(id);
365
366 if (asset == null || asset.Data == null || asset.Data.Length == 0)
367 {
368 lock (m_AssetHandlers)
369 {
370 AssetRetrievedEx handlerEx = new AssetRetrievedEx(delegate(AssetBase _asset) { handler(id, sender, _asset); });
371
372// AssetRetrievedEx handlers;
373 List<AssetRetrievedEx> handlers;
374 if (m_AssetHandlers.TryGetValue(id, out handlers))
375 {
376 // Someone else is already loading this asset. It will notify our handler when done.
377// handlers += handlerEx;
378 handlers.Add(handlerEx);
379 return true;
380 }
381
382 // Load the asset ourselves
383// handlers += handlerEx;
384 handlers = new List<AssetRetrievedEx>();
385 handlers.Add(handlerEx);
386
387 m_AssetHandlers.Add(id, handlers);
388 }
389
390 QueuedAssetRequest request = new QueuedAssetRequest();
391 request.id = id;
392 request.uri = uri;
393
394 m_requestQueue.Enqueue(request);
395 }
249 else 396 else
250 { 397 {
251 handler(id, sender, asset); 398 handler(id, sender, asset);
@@ -256,38 +403,95 @@ namespace OpenSim.Services.Connectors
256 403
257 public string Store(AssetBase asset) 404 public string Store(AssetBase asset)
258 { 405 {
259 if (asset.Local) 406 // Have to assign the asset ID here. This isn't likely to
407 // trigger since current callers don't pass emtpy IDs
408 // We need the asset ID to route the request to the proper
409 // cluster member, so we can't have the server assign one.
410 if (asset.ID == string.Empty)
260 { 411 {
261 if (m_Cache != null) 412 if (asset.FullID == UUID.Zero)
262 m_Cache.Cache(asset); 413 {
414 asset.FullID = UUID.Random();
415 }
416 asset.ID = asset.FullID.ToString();
417 }
418 else if (asset.FullID == UUID.Zero)
419 {
420 UUID uuid = UUID.Zero;
421 if (UUID.TryParse(asset.ID, out uuid))
422 {
423 asset.FullID = uuid;
424 }
425 else
426 {
427 asset.FullID = UUID.Random();
428 }
429 }
263 430
431 if (m_Cache != null)
432 m_Cache.Cache(asset);
433 if (asset.Temporary || asset.Local)
434 {
264 return asset.ID; 435 return asset.ID;
265 } 436 }
266 437
267 string uri = m_ServerURI + "/assets/"; 438 string uri = MapServer(asset.FullID.ToString()) + "/assets/";
268 439
269 string newID = string.Empty; 440 string newID = string.Empty;
270 try 441 try
271 { 442 {
272 newID = SynchronousRestObjectRequester. 443 newID = SynchronousRestObjectRequester.
273 MakeRequest<AssetBase, string>("POST", uri, asset); 444 MakeRequest<AssetBase, string>("POST", uri, asset, 25);
445 if (newID == null || newID == "")
446 {
447 newID = UUID.Zero.ToString();
448 }
274 } 449 }
275 catch (Exception e) 450 catch (Exception e)
276 { 451 {
277 m_log.WarnFormat("[ASSET CONNECTOR]: Unable to send asset {0} to asset server. Reason: {1}", asset.ID, e.Message); 452 newID = UUID.Zero.ToString();
278 } 453 }
279 454
280 if (newID != String.Empty) 455 if (newID == UUID.Zero.ToString())
456 {
457 //The asset upload failed, put it in a queue for later
458 asset.UploadAttempts++;
459 if (asset.UploadAttempts > 30)
460 {
461 //By this stage we've been in the queue for a good few hours;
462 //We're going to drop the asset.
463 m_log.ErrorFormat("[Assets] Dropping asset {0} - Upload has been in the queue for too long.", asset.ID.ToString());
464 }
465 else
466 {
467 if (!m_retryQueue.ContainsKey(asset.UploadAttempts))
468 {
469 m_retryQueue.Add(asset.UploadAttempts, new List<AssetBase>());
470 }
471 List<AssetBase> m_queue = m_retryQueue[asset.UploadAttempts];
472 m_queue.Add(asset);
473 m_log.WarnFormat("[Assets] Upload failed: {0} - Requeuing asset for another run.", asset.ID.ToString());
474 m_retryTimer.Start();
475 }
476 }
477 else
281 { 478 {
282 // Placing this here, so that this work with old asset servers that don't send any reply back 479 if (asset.UploadAttempts > 0)
283 // SynchronousRestObjectRequester returns somethins that is not an empty string 480 {
284 if (newID != null) 481 m_log.InfoFormat("[Assets] Upload of {0} succeeded after {1} failed attempts", asset.ID.ToString(), asset.UploadAttempts.ToString());
285 asset.ID = newID; 482 }
483 if (newID != String.Empty)
484 {
485 // Placing this here, so that this work with old asset servers that don't send any reply back
486 // SynchronousRestObjectRequester returns somethins that is not an empty string
487 if (newID != null)
488 asset.ID = newID;
286 489
287 if (m_Cache != null) 490 if (m_Cache != null)
288 m_Cache.Cache(asset); 491 m_Cache.Cache(asset);
492 }
289 } 493 }
290 return newID; 494 return asset.ID;
291 } 495 }
292 496
293 public bool UpdateContent(string id, byte[] data) 497 public bool UpdateContent(string id, byte[] data)
@@ -308,7 +512,7 @@ namespace OpenSim.Services.Connectors
308 } 512 }
309 asset.Data = data; 513 asset.Data = data;
310 514
311 string uri = m_ServerURI + "/assets/" + id; 515 string uri = MapServer(id) + "/assets/" + id;
312 516
313 if (SynchronousRestObjectRequester. 517 if (SynchronousRestObjectRequester.
314 MakeRequest<AssetBase, bool>("POST", uri, asset)) 518 MakeRequest<AssetBase, bool>("POST", uri, asset))
@@ -323,7 +527,7 @@ namespace OpenSim.Services.Connectors
323 527
324 public bool Delete(string id) 528 public bool Delete(string id)
325 { 529 {
326 string uri = m_ServerURI + "/assets/" + id; 530 string uri = MapServer(id) + "/assets/" + id;
327 531
328 if (SynchronousRestObjectRequester. 532 if (SynchronousRestObjectRequester.
329 MakeRequest<int, bool>("DELETE", uri, 0)) 533 MakeRequest<int, bool>("DELETE", uri, 0))
diff --git a/OpenSim/Services/Connectors/Authentication/AuthenticationServicesConnector.cs b/OpenSim/Services/Connectors/Authentication/AuthenticationServicesConnector.cs
index 2b77154..f996aca 100644
--- a/OpenSim/Services/Connectors/Authentication/AuthenticationServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Authentication/AuthenticationServicesConnector.cs
@@ -81,6 +81,13 @@ namespace OpenSim.Services.Connectors
81 m_ServerURI = serviceURI; 81 m_ServerURI = serviceURI;
82 } 82 }
83 83
84 public string Authenticate(UUID principalID, string password, int lifetime, out UUID realID)
85 {
86 realID = UUID.Zero;
87
88 return Authenticate(principalID, password, lifetime);
89 }
90
84 public string Authenticate(UUID principalID, string password, int lifetime) 91 public string Authenticate(UUID principalID, string password, int lifetime)
85 { 92 {
86 Dictionary<string, object> sendData = new Dictionary<string, object>(); 93 Dictionary<string, object> sendData = new Dictionary<string, object>();
diff --git a/OpenSim/Services/Connectors/Friends/FriendsSimConnector.cs b/OpenSim/Services/Connectors/Friends/FriendsSimConnector.cs
index 6d5ce4b..45f4514 100644
--- a/OpenSim/Services/Connectors/Friends/FriendsSimConnector.cs
+++ b/OpenSim/Services/Connectors/Friends/FriendsSimConnector.cs
@@ -144,44 +144,48 @@ namespace OpenSim.Services.Connectors.Friends
144 144
145 private bool Call(GridRegion region, Dictionary<string, object> sendData) 145 private bool Call(GridRegion region, Dictionary<string, object> sendData)
146 { 146 {
147 string reqString = ServerUtils.BuildQueryString(sendData); 147 Util.FireAndForget(x => {
148 //m_log.DebugFormat("[FRIENDS SIM CONNECTOR]: queryString = {0}", reqString); 148 string reqString = ServerUtils.BuildQueryString(sendData);
149 if (region == null) 149 //m_log.DebugFormat("[FRIENDS SIM CONNECTOR]: queryString = {0}", reqString);
150 return false; 150 if (region == null)
151 151 return;
152 string path = ServicePath(); 152
153 if (!region.ServerURI.EndsWith("/")) 153 string path = ServicePath();
154 path = "/" + path; 154 if (!region.ServerURI.EndsWith("/"))
155 string uri = region.ServerURI + path; 155 path = "/" + path;
156// m_log.DebugFormat("[FRIENDS SIM CONNECTOR]: calling {0}", uri); 156 string uri = region.ServerURI + path;
157 157 // m_log.DebugFormat("[FRIENDS SIM CONNECTOR]: calling {0}", uri);
158 try 158
159 { 159 try
160 string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString);
161 if (reply != string.Empty)
162 { 160 {
163 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); 161 string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString);
164 162 if (reply != string.Empty)
165 if (replyData.ContainsKey("RESULT"))
166 { 163 {
167 if (replyData["RESULT"].ToString().ToLower() == "true") 164 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
168 return true; 165
166 if (replyData.ContainsKey("RESULT"))
167 {
168// if (replyData["RESULT"].ToString().ToLower() == "true")
169// return;
170// else
171 return;
172 }
169 else 173 else
170 return false; 174 m_log.DebugFormat("[FRIENDS SIM CONNECTOR]: reply data does not contain result field");
175
171 } 176 }
172 else 177 else
173 m_log.DebugFormat("[FRIENDS SIM CONNECTOR]: reply data does not contain result field"); 178 m_log.DebugFormat("[FRIENDS SIM CONNECTOR]: received empty reply");
174 179 }
180 catch (Exception e)
181 {
182 m_log.DebugFormat("[FRIENDS SIM CONNECTOR]: Exception when contacting remote sim at {0}: {1}", uri, e.Message);
175 } 183 }
176 else 184
177 m_log.DebugFormat("[FRIENDS SIM CONNECTOR]: received empty reply"); 185 return;
178 } 186 });
179 catch (Exception e) 187
180 { 188 return true;
181 m_log.DebugFormat("[FRIENDS SIM CONNECTOR]: Exception when contacting remote sim at {0}: {1}", uri, e.Message);
182 }
183
184 return false;
185 } 189 }
186 } 190 }
187} 191}
diff --git a/OpenSim/Services/Connectors/Grid/GridServicesConnector.cs b/OpenSim/Services/Connectors/Grid/GridServicesConnector.cs
index 0f5a613..af91cdb 100644
--- a/OpenSim/Services/Connectors/Grid/GridServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Grid/GridServicesConnector.cs
@@ -48,6 +48,9 @@ namespace OpenSim.Services.Connectors
48 48
49 private string m_ServerURI = String.Empty; 49 private string m_ServerURI = String.Empty;
50 50
51 private ExpiringCache<ulong, GridRegion> m_regionCache =
52 new ExpiringCache<ulong, GridRegion>();
53
51 public GridServicesConnector() 54 public GridServicesConnector()
52 { 55 {
53 } 56 }
@@ -272,6 +275,11 @@ namespace OpenSim.Services.Connectors
272 275
273 public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) 276 public GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
274 { 277 {
278 ulong regionHandle = Util.UIntsToLong((uint)x, (uint)y);
279
280 if (m_regionCache.Contains(regionHandle))
281 return (GridRegion)m_regionCache[regionHandle];
282
275 Dictionary<string, object> sendData = new Dictionary<string, object>(); 283 Dictionary<string, object> sendData = new Dictionary<string, object>();
276 284
277 sendData["SCOPEID"] = scopeID.ToString(); 285 sendData["SCOPEID"] = scopeID.ToString();
@@ -313,6 +321,8 @@ namespace OpenSim.Services.Connectors
313 else 321 else
314 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition received null reply"); 322 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition received null reply");
315 323
324 m_regionCache.Add(regionHandle, rinfo, TimeSpan.FromSeconds(600));
325
316 return rinfo; 326 return rinfo;
317 } 327 }
318 328
diff --git a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs
index c9c6c31..803cd1b 100644
--- a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs
@@ -161,6 +161,7 @@ namespace OpenSim.Services.Connectors.Hypergrid
161 try 161 try
162 { 162 {
163 WebClient c = new WebClient(); 163 WebClient c = new WebClient();
164 //m_log.Debug("JPEG: " + imageURL);
164 string name = regionID.ToString(); 165 string name = regionID.ToString();
165 filename = Path.Combine(storagePath, name + ".jpg"); 166 filename = Path.Combine(storagePath, name + ".jpg");
166 m_log.DebugFormat("[GATEKEEPER SERVICE CONNECTOR]: Map image at {0}, cached at {1}", imageURL, filename); 167 m_log.DebugFormat("[GATEKEEPER SERVICE CONNECTOR]: Map image at {0}, cached at {1}", imageURL, filename);
@@ -189,11 +190,10 @@ namespace OpenSim.Services.Connectors.Hypergrid
189 190
190 ass.Data = imageData; 191 ass.Data = imageData;
191 192
192 mapTile = ass.FullID;
193
194 // finally
195 m_AssetService.Store(ass); 193 m_AssetService.Store(ass);
196 194
195 // finally
196 mapTile = ass.FullID;
197 } 197 }
198 catch // LEGIT: Catching problems caused by OpenJPEG p/invoke 198 catch // LEGIT: Catching problems caused by OpenJPEG p/invoke
199 { 199 {
diff --git a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
index d8a3184..5f5b7a7 100644
--- a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
@@ -99,8 +99,6 @@ namespace OpenSim.Services.Connectors.Hypergrid
99 throw new Exception("UserAgent connector init error"); 99 throw new Exception("UserAgent connector init error");
100 } 100 }
101 m_ServerURL = serviceURI; 101 m_ServerURL = serviceURI;
102 if (!m_ServerURL.EndsWith("/"))
103 m_ServerURL += "/";
104 102
105 m_log.DebugFormat("[USER AGENT CONNECTOR]: UserAgentServiceConnector started for {0}", m_ServerURL); 103 m_log.DebugFormat("[USER AGENT CONNECTOR]: UserAgentServiceConnector started for {0}", m_ServerURL);
106 } 104 }
diff --git a/OpenSim/Services/Connectors/Land/LandServicesConnector.cs b/OpenSim/Services/Connectors/Land/LandServicesConnector.cs
index 30a73a4..833e22a 100644
--- a/OpenSim/Services/Connectors/Land/LandServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Land/LandServicesConnector.cs
@@ -130,4 +130,4 @@ namespace OpenSim.Services.Connectors
130 return landData; 130 return landData;
131 } 131 }
132 } 132 }
133} \ No newline at end of file 133}
diff --git a/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs b/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs
index 774fe2a..245703c 100644
--- a/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs
@@ -153,9 +153,9 @@ namespace OpenSim.Services.Connectors
153 } 153 }
154 catch (Exception e) 154 catch (Exception e)
155 { 155 {
156 m_log.WarnFormat( 156// m_log.WarnFormat(
157 "[NEIGHBOUR SERVICES CONNECTOR]: Unable to send HelloNeighbour from {0} to {1}. Exception {2}{3}", 157// "[NEIGHBOUR SERVICE CONNCTOR]: Unable to send HelloNeighbour from {0} to {1}. Exception {2}{3}",
158 thisRegion.RegionName, region.RegionName, e.Message, e.StackTrace); 158// thisRegion.RegionName, region.RegionName, e.Message, e.StackTrace);
159 159
160 return false; 160 return false;
161 } 161 }
@@ -202,4 +202,4 @@ namespace OpenSim.Services.Connectors
202 return true; 202 return true;
203 } 203 }
204 } 204 }
205} \ No newline at end of file 205}
diff --git a/OpenSim/Services/Connectors/Presence/PresenceServicesConnector.cs b/OpenSim/Services/Connectors/Presence/PresenceServicesConnector.cs
index f7d8c53..378aab6 100644
--- a/OpenSim/Services/Connectors/Presence/PresenceServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Presence/PresenceServicesConnector.cs
@@ -304,6 +304,17 @@ namespace OpenSim.Services.Connectors
304 { 304 {
305 pinfo = new PresenceInfo((Dictionary<string, object>)replyData["result"]); 305 pinfo = new PresenceInfo((Dictionary<string, object>)replyData["result"]);
306 } 306 }
307 else
308 {
309 if (replyData["result"].ToString() == "null")
310 return null;
311
312 m_log.DebugFormat("[PRESENCE CONNECTOR]: Invalid reply (result not dictionary) received from presence server when querying for sessionID {0}", sessionID.ToString());
313 }
314 }
315 else
316 {
317 m_log.DebugFormat("[PRESENCE CONNECTOR]: Invalid reply received from presence server when querying for sessionID {0}", sessionID.ToString());
307 } 318 }
308 319
309 return pinfo; 320 return pinfo;
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs
index 3bd11d9..c402907 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs
@@ -102,6 +102,12 @@ namespace OpenSim.Services.Connectors.SimianGrid
102 m_log.Info("[SIMIAN AUTH CONNECTOR]: No AuthenticationServerURI specified, disabling connector"); 102 m_log.Info("[SIMIAN AUTH CONNECTOR]: No AuthenticationServerURI specified, disabling connector");
103 } 103 }
104 104
105 public string Authenticate(UUID principalID, string password, int lifetime, out UUID realID)
106 {
107 realID = UUID.Zero;
108 return Authenticate(principalID, password, lifetime);
109 }
110
105 public string Authenticate(UUID principalID, string password, int lifetime) 111 public string Authenticate(UUID principalID, string password, int lifetime)
106 { 112 {
107 NameValueCollection requestArgs = new NameValueCollection 113 NameValueCollection requestArgs = new NameValueCollection
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs
index 816591b..36a5182 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs
@@ -28,6 +28,8 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Collections.Specialized; 30using System.Collections.Specialized;
31using System.Drawing;
32using System.Drawing.Imaging;
31using System.IO; 33using System.IO;
32using System.Net; 34using System.Net;
33using System.Reflection; 35using System.Reflection;
@@ -100,6 +102,15 @@ namespace OpenSim.Services.Connectors.SimianGrid
100 102
101 public string RegisterRegion(UUID scopeID, GridRegion regionInfo) 103 public string RegisterRegion(UUID scopeID, GridRegion regionInfo)
102 { 104 {
105 IPEndPoint ext = regionInfo.ExternalEndPoint;
106 if (ext == null) return "Region registration for " + regionInfo.RegionName + " failed: Could not resolve EndPoint";
107 // Generate and upload our map tile in PNG format to the SimianGrid AddMapTile service
108// Scene scene;
109// if (m_scenes.TryGetValue(regionInfo.RegionID, out scene))
110// UploadMapTile(scene);
111// else
112// m_log.Warn("Registering region " + regionInfo.RegionName + " (" + regionInfo.RegionID + ") that we are not tracking");
113
103 Vector3d minPosition = new Vector3d(regionInfo.RegionLocX, regionInfo.RegionLocY, 0.0); 114 Vector3d minPosition = new Vector3d(regionInfo.RegionLocX, regionInfo.RegionLocY, 0.0);
104 Vector3d maxPosition = minPosition + new Vector3d(Constants.RegionSize, Constants.RegionSize, Constants.RegionHeight); 115 Vector3d maxPosition = minPosition + new Vector3d(Constants.RegionSize, Constants.RegionSize, Constants.RegionHeight);
105 116
@@ -108,7 +119,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
108 { "ServerURI", OSD.FromString(regionInfo.ServerURI) }, 119 { "ServerURI", OSD.FromString(regionInfo.ServerURI) },
109 { "InternalAddress", OSD.FromString(regionInfo.InternalEndPoint.Address.ToString()) }, 120 { "InternalAddress", OSD.FromString(regionInfo.InternalEndPoint.Address.ToString()) },
110 { "InternalPort", OSD.FromInteger(regionInfo.InternalEndPoint.Port) }, 121 { "InternalPort", OSD.FromInteger(regionInfo.InternalEndPoint.Port) },
111 { "ExternalAddress", OSD.FromString(regionInfo.ExternalEndPoint.Address.ToString()) }, 122 { "ExternalAddress", OSD.FromString(ext.Address.ToString()) },
112 { "ExternalPort", OSD.FromInteger(regionInfo.ExternalEndPoint.Port) }, 123 { "ExternalPort", OSD.FromInteger(regionInfo.ExternalEndPoint.Port) },
113 { "MapTexture", OSD.FromUUID(regionInfo.TerrainImage) }, 124 { "MapTexture", OSD.FromUUID(regionInfo.TerrainImage) },
114 { "Access", OSD.FromInteger(regionInfo.Access) }, 125 { "Access", OSD.FromInteger(regionInfo.Access) },
@@ -405,6 +416,83 @@ namespace OpenSim.Services.Connectors.SimianGrid
405 416
406 #endregion IGridService 417 #endregion IGridService
407 418
419 private void UploadMapTile(IScene scene)
420 {
421 string errorMessage = null;
422
423 // Create a PNG map tile and upload it to the AddMapTile API
424 byte[] pngData = Utils.EmptyBytes;
425 IMapImageGenerator tileGenerator = scene.RequestModuleInterface<IMapImageGenerator>();
426 if (tileGenerator == null)
427 {
428 m_log.Warn("[SIMIAN GRID CONNECTOR]: Cannot upload PNG map tile without an IMapImageGenerator");
429 return;
430 }
431
432 using (Image mapTile = tileGenerator.CreateMapTile())
433 {
434 using (MemoryStream stream = new MemoryStream())
435 {
436 mapTile.Save(stream, ImageFormat.Png);
437 pngData = stream.ToArray();
438 }
439 }
440
441 List<MultipartForm.Element> postParameters = new List<MultipartForm.Element>()
442 {
443 new MultipartForm.Parameter("X", scene.RegionInfo.RegionLocX.ToString()),
444 new MultipartForm.Parameter("Y", scene.RegionInfo.RegionLocY.ToString()),
445 new MultipartForm.File("Tile", "tile.png", "image/png", pngData)
446 };
447
448 // Make the remote storage request
449 try
450 {
451 HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(m_ServerURI);
452
453 HttpWebResponse response = MultipartForm.Post(request, postParameters);
454 using (Stream responseStream = response.GetResponseStream())
455 {
456 string responseStr = null;
457
458 try
459 {
460 responseStr = responseStream.GetStreamString();
461 OSD responseOSD = OSDParser.Deserialize(responseStr);
462 if (responseOSD.Type == OSDType.Map)
463 {
464 OSDMap responseMap = (OSDMap)responseOSD;
465 if (responseMap["Success"].AsBoolean())
466 m_log.Info("[SIMIAN GRID CONNECTOR]: Uploaded " + pngData.Length + " byte PNG map tile to AddMapTile");
467 else
468 errorMessage = "Upload failed: " + responseMap["Message"].AsString();
469 }
470 else
471 {
472 errorMessage = "Response format was invalid:\n" + responseStr;
473 }
474 }
475 catch (Exception ex)
476 {
477 if (!String.IsNullOrEmpty(responseStr))
478 errorMessage = "Failed to parse the response:\n" + responseStr;
479 else
480 errorMessage = "Failed to retrieve the response: " + ex.Message;
481 }
482 }
483 }
484 catch (WebException ex)
485 {
486 errorMessage = ex.Message;
487 }
488
489 if (!String.IsNullOrEmpty(errorMessage))
490 {
491 m_log.WarnFormat("[SIMIAN GRID CONNECTOR]: Failed to store {0} byte PNG map tile for {1}: {2}",
492 pngData.Length, scene.RegionInfo.RegionName, errorMessage.Replace('\n', ' '));
493 }
494 }
495
408 private GridRegion GetNearestRegion(Vector3d position, bool onlyEnabled) 496 private GridRegion GetNearestRegion(Vector3d position, bool onlyEnabled)
409 { 497 {
410 NameValueCollection requestArgs = new NameValueCollection 498 NameValueCollection requestArgs = new NameValueCollection
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs
index 7e36c69..fdc8697 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs
@@ -191,6 +191,11 @@ namespace OpenSim.Services.Connectors.SimianGrid
191 return accounts; 191 return accounts;
192 } 192 }
193 193
194 public List<UserAccount> GetUserAccountsWhere(UUID scopeID, string query)
195 {
196 return null;
197 }
198
194 public bool StoreUserAccount(UserAccount data) 199 public bool StoreUserAccount(UserAccount data)
195 { 200 {
196// m_log.InfoFormat("[SIMIAN ACCOUNT CONNECTOR]: Storing user account for " + data.Name); 201// m_log.InfoFormat("[SIMIAN ACCOUNT CONNECTOR]: Storing user account for " + data.Name);
diff --git a/OpenSim/Services/Connectors/Simulation/SimulationDataService.cs b/OpenSim/Services/Connectors/Simulation/SimulationDataService.cs
index 504fcaf..96c02d9 100644
--- a/OpenSim/Services/Connectors/Simulation/SimulationDataService.cs
+++ b/OpenSim/Services/Connectors/Simulation/SimulationDataService.cs
@@ -164,6 +164,11 @@ namespace OpenSim.Services.Connectors
164 m_database.RemoveRegionEnvironmentSettings(regionUUID); 164 m_database.RemoveRegionEnvironmentSettings(regionUUID);
165 } 165 }
166 166
167 public UUID[] GetObjectIDs(UUID regionID)
168 {
169 return m_database.GetObjectIDs(regionID);
170 }
171
167 public void SaveExtra(UUID regionID, string name, string val) 172 public void SaveExtra(UUID regionID, string name, string val)
168 { 173 {
169 m_database.SaveExtra(regionID, name, val); 174 m_database.SaveExtra(regionID, name, val);
diff --git a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
index aca414b..0e74073 100644
--- a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
@@ -102,6 +102,7 @@ namespace OpenSim.Services.Connectors.Simulation
102 102
103 if (destination == null) 103 if (destination == null)
104 { 104 {
105 reason = "Destination not found";
105 m_log.Debug("[REMOTE SIMULATION CONNECTOR]: Given destination is null"); 106 m_log.Debug("[REMOTE SIMULATION CONNECTOR]: Given destination is null");
106 return false; 107 return false;
107 } 108 }
@@ -337,6 +338,10 @@ namespace OpenSim.Services.Connectors.Simulation
337 return false; 338 return false;
338 } 339 }
339 340
341 OSDMap resp = (OSDMap)result["_Result"];
342 success = resp["success"].AsBoolean();
343 reason = resp["reason"].AsString();
344
340 return success; 345 return success;
341 } 346 }
342 catch (Exception e) 347 catch (Exception e)
@@ -421,11 +426,14 @@ namespace OpenSim.Services.Connectors.Simulation
421 args["destination_name"] = OSD.FromString(destination.RegionName); 426 args["destination_name"] = OSD.FromString(destination.RegionName);
422 args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString()); 427 args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString());
423 428
424 WebUtil.PostToService(uri, args, 40000); 429 OSDMap response = WebUtil.PostToService(uri, args, 40000);
430 if (response["Success"] == "False")
431 return false;
425 } 432 }
426 catch (Exception e) 433 catch (Exception e)
427 { 434 {
428 m_log.WarnFormat("[REMOTE SIMULATION CONNECTOR] CreateObject failed with exception; {0}",e.ToString()); 435 m_log.WarnFormat("[REMOTE SIMULATION CONNECTOR] CreateObject failed with exception; {0}",e.ToString());
436 return false;
429 } 437 }
430 438
431 return true; 439 return true;
diff --git a/OpenSim/Services/Connectors/UserAccounts/UserAccountServicesConnector.cs b/OpenSim/Services/Connectors/UserAccounts/UserAccountServicesConnector.cs
index 97d9458..6b2d710 100644
--- a/OpenSim/Services/Connectors/UserAccounts/UserAccountServicesConnector.cs
+++ b/OpenSim/Services/Connectors/UserAccounts/UserAccountServicesConnector.cs
@@ -187,6 +187,11 @@ namespace OpenSim.Services.Connectors
187 return accounts; 187 return accounts;
188 } 188 }
189 189
190 public List<UserAccount> GetUserAccountsWhere(UUID scopeID, string where)
191 {
192 return null; // Not implemented for regions
193 }
194
190 public virtual bool StoreUserAccount(UserAccount data) 195 public virtual bool StoreUserAccount(UserAccount data)
191 { 196 {
192 Dictionary<string, object> sendData = new Dictionary<string, object>(); 197 Dictionary<string, object> sendData = new Dictionary<string, object>();