diff options
Diffstat (limited to 'OpenSim/Services/Connectors')
9 files changed, 296 insertions, 50 deletions
diff --git a/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs b/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs index e4c3eaf..9bd04ed 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; |
@@ -47,13 +48,15 @@ namespace OpenSim.Services.Connectors | |||
47 | 48 | ||
48 | private string m_ServerURI = String.Empty; | 49 | private string m_ServerURI = String.Empty; |
49 | private IImprovedAssetCache m_Cache = null; | 50 | private IImprovedAssetCache m_Cache = null; |
50 | 51 | private int m_retryCounter; | |
52 | private Dictionary<int, List<AssetBase>> m_retryQueue = new Dictionary<int, List<AssetBase>>(); | ||
53 | private Timer m_retryTimer; | ||
51 | private delegate void AssetRetrievedEx(AssetBase asset); | 54 | private delegate void AssetRetrievedEx(AssetBase asset); |
52 | 55 | ||
53 | // Keeps track of concurrent requests for the same asset, so that it's only loaded once. | 56 | // Keeps track of concurrent requests for the same asset, so that it's only loaded once. |
54 | // Maps: Asset ID -> Handlers which will be called when the asset has been loaded | 57 | // Maps: Asset ID -> Handlers which will be called when the asset has been loaded |
55 | private Dictionary<string, AssetRetrievedEx> m_AssetHandlers = new Dictionary<string, AssetRetrievedEx>(); | 58 | private Dictionary<string, AssetRetrievedEx> m_AssetHandlers = new Dictionary<string, AssetRetrievedEx>(); |
56 | 59 | private Dictionary<string, string> m_UriMap = new Dictionary<string, string>(); | |
57 | 60 | ||
58 | public AssetServicesConnector() | 61 | public AssetServicesConnector() |
59 | { | 62 | { |
@@ -87,7 +90,86 @@ namespace OpenSim.Services.Connectors | |||
87 | throw new Exception("Asset connector init error"); | 90 | throw new Exception("Asset connector init error"); |
88 | } | 91 | } |
89 | 92 | ||
90 | m_ServerURI = serviceURI; | 93 | MainConsole.Instance.Commands.AddCommand("asset", false, "dump asset", |
94 | "dump asset <id> <file>", | ||
95 | "dump one cached asset", HandleDumpAsset); | ||
96 | |||
97 | m_retryTimer = new Timer(); | ||
98 | m_retryTimer.Elapsed += new ElapsedEventHandler(retryCheck); | ||
99 | m_retryTimer.Interval = 60000; | ||
100 | |||
101 | Uri serverUri = new Uri(m_ServerURI); | ||
102 | |||
103 | string groupHost = serverUri.Host; | ||
104 | |||
105 | for (int i = 0 ; i < 256 ; i++) | ||
106 | { | ||
107 | string prefix = i.ToString("x2"); | ||
108 | groupHost = assetConfig.GetString("AssetServerHost_"+prefix, groupHost); | ||
109 | |||
110 | m_UriMap[prefix] = groupHost; | ||
111 | //m_log.DebugFormat("[ASSET]: Using {0} for prefix {1}", groupHost, prefix); | ||
112 | } | ||
113 | } | ||
114 | |||
115 | private string MapServer(string id) | ||
116 | { | ||
117 | UriBuilder serverUri = new UriBuilder(m_ServerURI); | ||
118 | |||
119 | string prefix = id.Substring(0, 2).ToLower(); | ||
120 | |||
121 | string host = m_UriMap[prefix]; | ||
122 | |||
123 | serverUri.Host = host; | ||
124 | |||
125 | // m_log.DebugFormat("[ASSET]: Using {0} for host name for prefix {1}", host, prefix); | ||
126 | |||
127 | return serverUri.Uri.AbsoluteUri; | ||
128 | } | ||
129 | |||
130 | protected void retryCheck(object source, ElapsedEventArgs e) | ||
131 | { | ||
132 | m_retryCounter++; | ||
133 | if (m_retryCounter > 60) m_retryCounter -= 60; | ||
134 | List<int> keys = new List<int>(); | ||
135 | foreach (int a in m_retryQueue.Keys) | ||
136 | { | ||
137 | keys.Add(a); | ||
138 | } | ||
139 | foreach (int a in keys) | ||
140 | { | ||
141 | //We exponentially fall back on frequency until we reach one attempt per hour | ||
142 | //The net result is that we end up in the queue for roughly 24 hours.. | ||
143 | //24 hours worth of assets could be a lot, so the hope is that the region admin | ||
144 | //will have gotten the asset connector back online quickly! | ||
145 | |||
146 | int timefactor = a ^ 2; | ||
147 | if (timefactor > 60) | ||
148 | { | ||
149 | timefactor = 60; | ||
150 | } | ||
151 | |||
152 | //First, find out if we care about this timefactor | ||
153 | if (timefactor % a == 0) | ||
154 | { | ||
155 | //Yes, we do! | ||
156 | List<AssetBase> retrylist = m_retryQueue[a]; | ||
157 | m_retryQueue.Remove(a); | ||
158 | |||
159 | foreach(AssetBase ass in retrylist) | ||
160 | { | ||
161 | Store(ass); //Store my ass. This function will put it back in the dictionary if it fails | ||
162 | } | ||
163 | } | ||
164 | } | ||
165 | |||
166 | if (m_retryQueue.Count == 0) | ||
167 | { | ||
168 | //It might only be one tick per minute, but I have | ||
169 | //repented and abandoned my wasteful ways | ||
170 | m_retryCounter = 0; | ||
171 | m_retryTimer.Stop(); | ||
172 | } | ||
91 | } | 173 | } |
92 | 174 | ||
93 | protected void SetCache(IImprovedAssetCache cache) | 175 | protected void SetCache(IImprovedAssetCache cache) |
@@ -97,15 +179,13 @@ namespace OpenSim.Services.Connectors | |||
97 | 179 | ||
98 | public AssetBase Get(string id) | 180 | public AssetBase Get(string id) |
99 | { | 181 | { |
100 | // m_log.DebugFormat("[ASSET SERVICE CONNECTOR]: Synchronous get request for {0}", id); | 182 | string uri = MapServer(id) + "/assets/" + id; |
101 | |||
102 | string uri = m_ServerURI + "/assets/" + id; | ||
103 | 183 | ||
104 | AssetBase asset = null; | 184 | AssetBase asset = null; |
105 | if (m_Cache != null) | 185 | if (m_Cache != null) |
106 | asset = m_Cache.Get(id); | 186 | asset = m_Cache.Get(id); |
107 | 187 | ||
108 | if (asset == null) | 188 | if (asset == null || asset.Data == null || asset.Data.Length == 0) |
109 | { | 189 | { |
110 | asset = SynchronousRestObjectRequester. | 190 | asset = SynchronousRestObjectRequester. |
111 | MakeRequest<int, AssetBase>("GET", uri, 0); | 191 | MakeRequest<int, AssetBase>("GET", uri, 0); |
@@ -136,7 +216,7 @@ namespace OpenSim.Services.Connectors | |||
136 | return fullAsset.Metadata; | 216 | return fullAsset.Metadata; |
137 | } | 217 | } |
138 | 218 | ||
139 | string uri = m_ServerURI + "/assets/" + id + "/metadata"; | 219 | string uri = MapServer(id) + "/assets/" + id + "/metadata"; |
140 | 220 | ||
141 | AssetMetadata asset = SynchronousRestObjectRequester. | 221 | AssetMetadata asset = SynchronousRestObjectRequester. |
142 | MakeRequest<int, AssetMetadata>("GET", uri, 0); | 222 | MakeRequest<int, AssetMetadata>("GET", uri, 0); |
@@ -153,7 +233,7 @@ namespace OpenSim.Services.Connectors | |||
153 | return fullAsset.Data; | 233 | return fullAsset.Data; |
154 | } | 234 | } |
155 | 235 | ||
156 | RestClient rc = new RestClient(m_ServerURI); | 236 | RestClient rc = new RestClient(MapServer(id)); |
157 | rc.AddResourcePath("assets"); | 237 | rc.AddResourcePath("assets"); |
158 | rc.AddResourcePath(id); | 238 | rc.AddResourcePath(id); |
159 | rc.AddResourcePath("data"); | 239 | rc.AddResourcePath("data"); |
@@ -178,15 +258,13 @@ namespace OpenSim.Services.Connectors | |||
178 | 258 | ||
179 | public bool Get(string id, Object sender, AssetRetrieved handler) | 259 | public bool Get(string id, Object sender, AssetRetrieved handler) |
180 | { | 260 | { |
181 | // m_log.DebugFormat("[ASSET SERVICE CONNECTOR]: Potentially asynchronous get request for {0}", id); | 261 | string uri = MapServer(id) + "/assets/" + id; |
182 | |||
183 | string uri = m_ServerURI + "/assets/" + id; | ||
184 | 262 | ||
185 | AssetBase asset = null; | 263 | AssetBase asset = null; |
186 | if (m_Cache != null) | 264 | if (m_Cache != null) |
187 | asset = m_Cache.Get(id); | 265 | asset = m_Cache.Get(id); |
188 | 266 | ||
189 | if (asset == null) | 267 | if (asset == null || asset.Data == null || asset.Data.Length == 0) |
190 | { | 268 | { |
191 | lock (m_AssetHandlers) | 269 | lock (m_AssetHandlers) |
192 | { | 270 | { |
@@ -246,38 +324,95 @@ namespace OpenSim.Services.Connectors | |||
246 | 324 | ||
247 | public string Store(AssetBase asset) | 325 | public string Store(AssetBase asset) |
248 | { | 326 | { |
249 | if (asset.Temporary || asset.Local) | 327 | // Have to assign the asset ID here. This isn't likely to |
328 | // trigger since current callers don't pass emtpy IDs | ||
329 | // We need the asset ID to route the request to the proper | ||
330 | // cluster member, so we can't have the server assign one. | ||
331 | if (asset.ID == string.Empty) | ||
250 | { | 332 | { |
251 | if (m_Cache != null) | 333 | if (asset.FullID == UUID.Zero) |
252 | m_Cache.Cache(asset); | 334 | { |
335 | asset.FullID = UUID.Random(); | ||
336 | } | ||
337 | asset.ID = asset.FullID.ToString(); | ||
338 | } | ||
339 | else if (asset.FullID == UUID.Zero) | ||
340 | { | ||
341 | UUID uuid = UUID.Zero; | ||
342 | if (UUID.TryParse(asset.ID, out uuid)) | ||
343 | { | ||
344 | asset.FullID = uuid; | ||
345 | } | ||
346 | else | ||
347 | { | ||
348 | asset.FullID = UUID.Random(); | ||
349 | } | ||
350 | } | ||
253 | 351 | ||
352 | if (m_Cache != null) | ||
353 | m_Cache.Cache(asset); | ||
354 | if (asset.Temporary || asset.Local) | ||
355 | { | ||
254 | return asset.ID; | 356 | return asset.ID; |
255 | } | 357 | } |
256 | 358 | ||
257 | string uri = m_ServerURI + "/assets/"; | 359 | string uri = MapServer(asset.FullID.ToString()) + "/assets/"; |
258 | 360 | ||
259 | string newID = string.Empty; | 361 | string newID = string.Empty; |
260 | try | 362 | try |
261 | { | 363 | { |
262 | newID = SynchronousRestObjectRequester. | 364 | newID = SynchronousRestObjectRequester. |
263 | MakeRequest<AssetBase, string>("POST", uri, asset); | 365 | MakeRequest<AssetBase, string>("POST", uri, asset, 25); |
366 | if (newID == null || newID == "") | ||
367 | { | ||
368 | newID = UUID.Zero.ToString(); | ||
369 | } | ||
264 | } | 370 | } |
265 | catch (Exception e) | 371 | catch (Exception e) |
266 | { | 372 | { |
267 | m_log.WarnFormat("[ASSET CONNECTOR]: Unable to send asset {0} to asset server. Reason: {1}", asset.ID, e.Message); | 373 | newID = UUID.Zero.ToString(); |
268 | } | 374 | } |
269 | 375 | ||
270 | if (newID != String.Empty) | 376 | if (newID == UUID.Zero.ToString()) |
377 | { | ||
378 | //The asset upload failed, put it in a queue for later | ||
379 | asset.UploadAttempts++; | ||
380 | if (asset.UploadAttempts > 30) | ||
381 | { | ||
382 | //By this stage we've been in the queue for a good few hours; | ||
383 | //We're going to drop the asset. | ||
384 | m_log.ErrorFormat("[Assets] Dropping asset {0} - Upload has been in the queue for too long.", asset.ID.ToString()); | ||
385 | } | ||
386 | else | ||
387 | { | ||
388 | if (!m_retryQueue.ContainsKey(asset.UploadAttempts)) | ||
389 | { | ||
390 | m_retryQueue.Add(asset.UploadAttempts, new List<AssetBase>()); | ||
391 | } | ||
392 | List<AssetBase> m_queue = m_retryQueue[asset.UploadAttempts]; | ||
393 | m_queue.Add(asset); | ||
394 | m_log.WarnFormat("[Assets] Upload failed: {0} - Requeuing asset for another run.", asset.ID.ToString()); | ||
395 | m_retryTimer.Start(); | ||
396 | } | ||
397 | } | ||
398 | else | ||
271 | { | 399 | { |
272 | // Placing this here, so that this work with old asset servers that don't send any reply back | 400 | if (asset.UploadAttempts > 0) |
273 | // SynchronousRestObjectRequester returns somethins that is not an empty string | 401 | { |
274 | if (newID != null) | 402 | m_log.InfoFormat("[Assets] Upload of {0} succeeded after {1} failed attempts", asset.ID.ToString(), asset.UploadAttempts.ToString()); |
275 | asset.ID = newID; | 403 | } |
404 | if (newID != String.Empty) | ||
405 | { | ||
406 | // Placing this here, so that this work with old asset servers that don't send any reply back | ||
407 | // SynchronousRestObjectRequester returns somethins that is not an empty string | ||
408 | if (newID != null) | ||
409 | asset.ID = newID; | ||
276 | 410 | ||
277 | if (m_Cache != null) | 411 | if (m_Cache != null) |
278 | m_Cache.Cache(asset); | 412 | m_Cache.Cache(asset); |
413 | } | ||
279 | } | 414 | } |
280 | return newID; | 415 | return asset.ID; |
281 | } | 416 | } |
282 | 417 | ||
283 | public bool UpdateContent(string id, byte[] data) | 418 | public bool UpdateContent(string id, byte[] data) |
@@ -298,7 +433,7 @@ namespace OpenSim.Services.Connectors | |||
298 | } | 433 | } |
299 | asset.Data = data; | 434 | asset.Data = data; |
300 | 435 | ||
301 | string uri = m_ServerURI + "/assets/" + id; | 436 | string uri = MapServer(id) + "/assets/" + id; |
302 | 437 | ||
303 | if (SynchronousRestObjectRequester. | 438 | if (SynchronousRestObjectRequester. |
304 | MakeRequest<AssetBase, bool>("POST", uri, asset)) | 439 | MakeRequest<AssetBase, bool>("POST", uri, asset)) |
@@ -313,7 +448,7 @@ namespace OpenSim.Services.Connectors | |||
313 | 448 | ||
314 | public bool Delete(string id) | 449 | public bool Delete(string id) |
315 | { | 450 | { |
316 | string uri = m_ServerURI + "/assets/" + id; | 451 | string uri = MapServer(id) + "/assets/" + id; |
317 | 452 | ||
318 | if (SynchronousRestObjectRequester. | 453 | if (SynchronousRestObjectRequester. |
319 | MakeRequest<int, bool>("DELETE", uri, 0)) | 454 | MakeRequest<int, bool>("DELETE", uri, 0)) |
@@ -326,4 +461,4 @@ namespace OpenSim.Services.Connectors | |||
326 | return false; | 461 | return false; |
327 | } | 462 | } |
328 | } | 463 | } |
329 | } \ No newline at end of file | 464 | } |
diff --git a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs index 0430ef6..bc0bc54 100644 --- a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs +++ b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs | |||
@@ -158,17 +158,10 @@ namespace OpenSim.Services.Connectors.Hypergrid | |||
158 | try | 158 | try |
159 | { | 159 | { |
160 | WebClient c = new WebClient(); | 160 | WebClient c = new WebClient(); |
161 | //m_log.Debug("JPEG: " + imageURL); | ||
161 | string name = regionID.ToString(); | 162 | string name = regionID.ToString(); |
162 | filename = Path.Combine(storagePath, name + ".jpg"); | 163 | filename = Path.Combine(storagePath, name + ".jpg"); |
163 | m_log.DebugFormat("[GATEKEEPER SERVICE CONNECTOR]: Map image at {0}, cached at {1}", imageURL, filename); | 164 | c.DownloadFile(imageURL, filename); |
164 | if (!File.Exists(filename)) | ||
165 | { | ||
166 | m_log.DebugFormat("[GATEKEEPER SERVICE CONNECTOR]: downloading..."); | ||
167 | c.DownloadFile(imageURL, filename); | ||
168 | } | ||
169 | else | ||
170 | m_log.DebugFormat("[GATEKEEPER SERVICE CONNECTOR]: using cached image"); | ||
171 | |||
172 | bitmap = new Bitmap(filename); | 165 | bitmap = new Bitmap(filename); |
173 | //m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width); | 166 | //m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width); |
174 | byte[] imageData = OpenJPEG.EncodeFromImage(bitmap, true); | 167 | byte[] imageData = OpenJPEG.EncodeFromImage(bitmap, true); |
@@ -179,11 +172,10 @@ namespace OpenSim.Services.Connectors.Hypergrid | |||
179 | 172 | ||
180 | ass.Data = imageData; | 173 | ass.Data = imageData; |
181 | 174 | ||
182 | mapTile = ass.FullID; | ||
183 | |||
184 | // finally | ||
185 | m_AssetService.Store(ass); | 175 | m_AssetService.Store(ass); |
186 | 176 | ||
177 | // finally | ||
178 | mapTile = ass.FullID; | ||
187 | } | 179 | } |
188 | catch // LEGIT: Catching problems caused by OpenJPEG p/invoke | 180 | catch // LEGIT: Catching problems caused by OpenJPEG p/invoke |
189 | { | 181 | { |
diff --git a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs index 5b27cf6..d617aee 100644 --- a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs +++ b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs | |||
@@ -98,8 +98,6 @@ namespace OpenSim.Services.Connectors.Hypergrid | |||
98 | throw new Exception("UserAgent connector init error"); | 98 | throw new Exception("UserAgent connector init error"); |
99 | } | 99 | } |
100 | m_ServerURL = serviceURI; | 100 | m_ServerURL = serviceURI; |
101 | if (!m_ServerURL.EndsWith("/")) | ||
102 | m_ServerURL += "/"; | ||
103 | 101 | ||
104 | m_log.DebugFormat("[USER AGENT CONNECTOR]: UserAgentServiceConnector started for {0}", m_ServerURL); | 102 | m_log.DebugFormat("[USER AGENT CONNECTOR]: UserAgentServiceConnector started for {0}", m_ServerURL); |
105 | } | 103 | } |
diff --git a/OpenSim/Services/Connectors/Land/LandServiceConnector.cs b/OpenSim/Services/Connectors/Land/LandServiceConnector.cs index 30a73a4..833e22a 100644 --- a/OpenSim/Services/Connectors/Land/LandServiceConnector.cs +++ b/OpenSim/Services/Connectors/Land/LandServiceConnector.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/Presence/PresenceServiceConnector.cs b/OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs index 7238afc..e16dc36 100644 --- a/OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs +++ b/OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs | |||
@@ -299,6 +299,17 @@ namespace OpenSim.Services.Connectors | |||
299 | { | 299 | { |
300 | pinfo = new PresenceInfo((Dictionary<string, object>)replyData["result"]); | 300 | pinfo = new PresenceInfo((Dictionary<string, object>)replyData["result"]); |
301 | } | 301 | } |
302 | else | ||
303 | { | ||
304 | if (replyData["result"].ToString() == "null") | ||
305 | return null; | ||
306 | |||
307 | m_log.DebugFormat("[PRESENCE CONNECTOR]: Invalid reply (result not dictionary) received from presence server when querying for sessionID {0}", sessionID.ToString()); | ||
308 | } | ||
309 | } | ||
310 | else | ||
311 | { | ||
312 | m_log.DebugFormat("[PRESENCE CONNECTOR]: Invalid reply received from presence server when querying for sessionID {0}", sessionID.ToString()); | ||
302 | } | 313 | } |
303 | 314 | ||
304 | return pinfo; | 315 | return pinfo; |
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs index 67a65ff..0e4d794 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs | |||
@@ -28,6 +28,8 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Collections.Specialized; | 30 | using System.Collections.Specialized; |
31 | using System.Drawing; | ||
32 | using System.Drawing.Imaging; | ||
31 | using System.IO; | 33 | using System.IO; |
32 | using System.Net; | 34 | using System.Net; |
33 | using System.Reflection; | 35 | using 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, 4096.0); | 115 | Vector3d maxPosition = minPosition + new Vector3d(Constants.RegionSize, Constants.RegionSize, 4096.0); |
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) }, |
@@ -399,6 +410,83 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
399 | 410 | ||
400 | #endregion IGridService | 411 | #endregion IGridService |
401 | 412 | ||
413 | private void UploadMapTile(IScene scene) | ||
414 | { | ||
415 | string errorMessage = null; | ||
416 | |||
417 | // Create a PNG map tile and upload it to the AddMapTile API | ||
418 | byte[] pngData = Utils.EmptyBytes; | ||
419 | IMapImageGenerator tileGenerator = scene.RequestModuleInterface<IMapImageGenerator>(); | ||
420 | if (tileGenerator == null) | ||
421 | { | ||
422 | m_log.Warn("[SIMIAN GRID CONNECTOR]: Cannot upload PNG map tile without an IMapImageGenerator"); | ||
423 | return; | ||
424 | } | ||
425 | |||
426 | using (Image mapTile = tileGenerator.CreateMapTile()) | ||
427 | { | ||
428 | using (MemoryStream stream = new MemoryStream()) | ||
429 | { | ||
430 | mapTile.Save(stream, ImageFormat.Png); | ||
431 | pngData = stream.ToArray(); | ||
432 | } | ||
433 | } | ||
434 | |||
435 | List<MultipartForm.Element> postParameters = new List<MultipartForm.Element>() | ||
436 | { | ||
437 | new MultipartForm.Parameter("X", scene.RegionInfo.RegionLocX.ToString()), | ||
438 | new MultipartForm.Parameter("Y", scene.RegionInfo.RegionLocY.ToString()), | ||
439 | new MultipartForm.File("Tile", "tile.png", "image/png", pngData) | ||
440 | }; | ||
441 | |||
442 | // Make the remote storage request | ||
443 | try | ||
444 | { | ||
445 | HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(m_ServerURI); | ||
446 | |||
447 | HttpWebResponse response = MultipartForm.Post(request, postParameters); | ||
448 | using (Stream responseStream = response.GetResponseStream()) | ||
449 | { | ||
450 | string responseStr = null; | ||
451 | |||
452 | try | ||
453 | { | ||
454 | responseStr = responseStream.GetStreamString(); | ||
455 | OSD responseOSD = OSDParser.Deserialize(responseStr); | ||
456 | if (responseOSD.Type == OSDType.Map) | ||
457 | { | ||
458 | OSDMap responseMap = (OSDMap)responseOSD; | ||
459 | if (responseMap["Success"].AsBoolean()) | ||
460 | m_log.Info("[SIMIAN GRID CONNECTOR]: Uploaded " + pngData.Length + " byte PNG map tile to AddMapTile"); | ||
461 | else | ||
462 | errorMessage = "Upload failed: " + responseMap["Message"].AsString(); | ||
463 | } | ||
464 | else | ||
465 | { | ||
466 | errorMessage = "Response format was invalid:\n" + responseStr; | ||
467 | } | ||
468 | } | ||
469 | catch (Exception ex) | ||
470 | { | ||
471 | if (!String.IsNullOrEmpty(responseStr)) | ||
472 | errorMessage = "Failed to parse the response:\n" + responseStr; | ||
473 | else | ||
474 | errorMessage = "Failed to retrieve the response: " + ex.Message; | ||
475 | } | ||
476 | } | ||
477 | } | ||
478 | catch (WebException ex) | ||
479 | { | ||
480 | errorMessage = ex.Message; | ||
481 | } | ||
482 | |||
483 | if (!String.IsNullOrEmpty(errorMessage)) | ||
484 | { | ||
485 | m_log.WarnFormat("[SIMIAN GRID CONNECTOR]: Failed to store {0} byte PNG map tile for {1}: {2}", | ||
486 | pngData.Length, scene.RegionInfo.RegionName, errorMessage.Replace('\n', ' ')); | ||
487 | } | ||
488 | } | ||
489 | |||
402 | private GridRegion GetNearestRegion(Vector3d position, bool onlyEnabled) | 490 | private GridRegion GetNearestRegion(Vector3d position, bool onlyEnabled) |
403 | { | 491 | { |
404 | NameValueCollection requestArgs = new NameValueCollection | 492 | NameValueCollection requestArgs = new NameValueCollection |
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs index 4350749..f38ebe8 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/SimulationServiceConnector.cs b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs index c45f456..24a23dd 100644 --- a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs +++ b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs | |||
@@ -337,6 +337,10 @@ namespace OpenSim.Services.Connectors.Simulation | |||
337 | return false; | 337 | return false; |
338 | } | 338 | } |
339 | 339 | ||
340 | OSDMap resp = (OSDMap)result["_Result"]; | ||
341 | success = resp["success"].AsBoolean(); | ||
342 | reason = resp["reason"].AsString(); | ||
343 | |||
340 | return success; | 344 | return success; |
341 | } | 345 | } |
342 | catch (Exception e) | 346 | catch (Exception e) |
@@ -365,9 +369,7 @@ namespace OpenSim.Services.Connectors.Simulation | |||
365 | return true; | 369 | return true; |
366 | } | 370 | } |
367 | 371 | ||
368 | /// <summary> | 372 | private bool CloseAgent(GridRegion destination, UUID id, bool ChildOnly) |
369 | /// </summary> | ||
370 | public bool CloseAgent(GridRegion destination, UUID id) | ||
371 | { | 373 | { |
372 | // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: CloseAgent start"); | 374 | // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: CloseAgent start"); |
373 | 375 | ||
@@ -385,6 +387,16 @@ namespace OpenSim.Services.Connectors.Simulation | |||
385 | return true; | 387 | return true; |
386 | } | 388 | } |
387 | 389 | ||
390 | public bool CloseChildAgent(GridRegion destination, UUID id) | ||
391 | { | ||
392 | return CloseAgent(destination, id, true); | ||
393 | } | ||
394 | |||
395 | public bool CloseAgent(GridRegion destination, UUID id) | ||
396 | { | ||
397 | return CloseAgent(destination, id, false); | ||
398 | } | ||
399 | |||
388 | #endregion Agents | 400 | #endregion Agents |
389 | 401 | ||
390 | #region Objects | 402 | #region Objects |
diff --git a/OpenSim/Services/Connectors/UserAccounts/UserAccountServiceConnector.cs b/OpenSim/Services/Connectors/UserAccounts/UserAccountServiceConnector.cs index f6835b9..60f3abe 100644 --- a/OpenSim/Services/Connectors/UserAccounts/UserAccountServiceConnector.cs +++ b/OpenSim/Services/Connectors/UserAccounts/UserAccountServiceConnector.cs | |||
@@ -186,6 +186,11 @@ namespace OpenSim.Services.Connectors | |||
186 | return accounts; | 186 | return accounts; |
187 | } | 187 | } |
188 | 188 | ||
189 | public List<UserAccount> GetUserAccountsWhere(UUID scopeID, string where) | ||
190 | { | ||
191 | return null; // Not implemented for regions | ||
192 | } | ||
193 | |||
189 | public virtual bool StoreUserAccount(UserAccount data) | 194 | public virtual bool StoreUserAccount(UserAccount data) |
190 | { | 195 | { |
191 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | 196 | Dictionary<string, object> sendData = new Dictionary<string, object>(); |