aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/Connectors
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2009-09-24 17:35:03 +0100
committerJustin Clark-Casey (justincc)2009-09-24 17:35:03 +0100
commitad753d784cfefacd8fb745a1431bf98feac9bbd6 (patch)
tree795ec1ba25eada570c342746f07654849a7199f4 /OpenSim/Services/Connectors
parentminor: make rest (not comm) modules less noisy if they are disabled (diff)
parentChanged name of the hyperlink XMLRPC method to linkk-region, so that it doesn... (diff)
downloadopensim-SC_OLD-ad753d784cfefacd8fb745a1431bf98feac9bbd6.zip
opensim-SC_OLD-ad753d784cfefacd8fb745a1431bf98feac9bbd6.tar.gz
opensim-SC_OLD-ad753d784cfefacd8fb745a1431bf98feac9bbd6.tar.bz2
opensim-SC_OLD-ad753d784cfefacd8fb745a1431bf98feac9bbd6.tar.xz
Merge branch 'master' of ssh://justincc@opensimulator.org/var/git/opensim
Diffstat (limited to 'OpenSim/Services/Connectors')
-rw-r--r--OpenSim/Services/Connectors/Grid/GridServiceConnector.cs41
-rw-r--r--OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs152
2 files changed, 173 insertions, 20 deletions
diff --git a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs
index ae7db7e..0a867db 100644
--- a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs
@@ -35,6 +35,7 @@ using OpenSim.Framework;
35using OpenSim.Framework.Communications; 35using OpenSim.Framework.Communications;
36using OpenSim.Framework.Servers.HttpServer; 36using OpenSim.Framework.Servers.HttpServer;
37using OpenSim.Services.Interfaces; 37using OpenSim.Services.Interfaces;
38using GridRegion = OpenSim.Services.Interfaces.GridRegion;
38using OpenSim.Server.Base; 39using OpenSim.Server.Base;
39using OpenMetaverse; 40using OpenMetaverse;
40 41
@@ -85,7 +86,7 @@ namespace OpenSim.Services.Connectors
85 86
86 #region IGridService 87 #region IGridService
87 88
88 public bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfo) 89 public virtual bool RegisterRegion(UUID scopeID, GridRegion regionInfo)
89 { 90 {
90 Dictionary<string, object> rinfo = regionInfo.ToKeyValuePairs(); 91 Dictionary<string, object> rinfo = regionInfo.ToKeyValuePairs();
91 Dictionary<string, string> sendData = new Dictionary<string,string>(); 92 Dictionary<string, string> sendData = new Dictionary<string,string>();
@@ -108,7 +109,7 @@ namespace OpenSim.Services.Connectors
108 return false; 109 return false;
109 } 110 }
110 111
111 public bool DeregisterRegion(UUID regionID) 112 public virtual bool DeregisterRegion(UUID regionID)
112 { 113 {
113 Dictionary<string, string> sendData = new Dictionary<string, string>(); 114 Dictionary<string, string> sendData = new Dictionary<string, string>();
114 115
@@ -128,7 +129,7 @@ namespace OpenSim.Services.Connectors
128 return false; 129 return false;
129 } 130 }
130 131
131 public List<SimpleRegionInfo> GetNeighbours(UUID scopeID, UUID regionID) 132 public virtual List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID)
132 { 133 {
133 Dictionary<string, string> sendData = new Dictionary<string, string>(); 134 Dictionary<string, string> sendData = new Dictionary<string, string>();
134 135
@@ -143,7 +144,7 @@ namespace OpenSim.Services.Connectors
143 144
144 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); 145 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
145 146
146 List<SimpleRegionInfo> rinfos = new List<SimpleRegionInfo>(); 147 List<GridRegion> rinfos = new List<GridRegion>();
147 if (replyData != null) 148 if (replyData != null)
148 { 149 {
149 Dictionary<string, object>.ValueCollection rinfosList = replyData.Values; 150 Dictionary<string, object>.ValueCollection rinfosList = replyData.Values;
@@ -151,7 +152,7 @@ namespace OpenSim.Services.Connectors
151 { 152 {
152 if (r is Dictionary<string, object>) 153 if (r is Dictionary<string, object>)
153 { 154 {
154 SimpleRegionInfo rinfo = new SimpleRegionInfo((Dictionary<string, object>)r); 155 GridRegion rinfo = new GridRegion((Dictionary<string, object>)r);
155 rinfos.Add(rinfo); 156 rinfos.Add(rinfo);
156 } 157 }
157 else 158 else
@@ -166,7 +167,7 @@ namespace OpenSim.Services.Connectors
166 return rinfos; 167 return rinfos;
167 } 168 }
168 169
169 public SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID) 170 public virtual GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
170 { 171 {
171 Dictionary<string, string> sendData = new Dictionary<string, string>(); 172 Dictionary<string, string> sendData = new Dictionary<string, string>();
172 173
@@ -181,11 +182,11 @@ namespace OpenSim.Services.Connectors
181 182
182 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); 183 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
183 184
184 SimpleRegionInfo rinfo = null; 185 GridRegion rinfo = null;
185 if ((replyData != null) && (replyData["result"] != null)) 186 if ((replyData != null) && (replyData["result"] != null))
186 { 187 {
187 if (replyData["result"] is Dictionary<string, object>) 188 if (replyData["result"] is Dictionary<string, object>)
188 rinfo = new SimpleRegionInfo((Dictionary<string, object>)replyData["result"]); 189 rinfo = new GridRegion((Dictionary<string, object>)replyData["result"]);
189 else 190 else
190 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID {0}, {1} received invalid response", 191 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID {0}, {1} received invalid response",
191 scopeID, regionID); 192 scopeID, regionID);
@@ -197,7 +198,7 @@ namespace OpenSim.Services.Connectors
197 return rinfo; 198 return rinfo;
198 } 199 }
199 200
200 public SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y) 201 public virtual GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
201 { 202 {
202 Dictionary<string, string> sendData = new Dictionary<string, string>(); 203 Dictionary<string, string> sendData = new Dictionary<string, string>();
203 204
@@ -213,11 +214,11 @@ namespace OpenSim.Services.Connectors
213 214
214 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); 215 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
215 216
216 SimpleRegionInfo rinfo = null; 217 GridRegion rinfo = null;
217 if ((replyData != null) && (replyData["result"] != null)) 218 if ((replyData != null) && (replyData["result"] != null))
218 { 219 {
219 if (replyData["result"] is Dictionary<string, object>) 220 if (replyData["result"] is Dictionary<string, object>)
220 rinfo = new SimpleRegionInfo((Dictionary<string, object>)replyData["result"]); 221 rinfo = new GridRegion((Dictionary<string, object>)replyData["result"]);
221 else 222 else
222 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received invalid response", 223 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received invalid response",
223 scopeID, x, y); 224 scopeID, x, y);
@@ -229,7 +230,7 @@ namespace OpenSim.Services.Connectors
229 return rinfo; 230 return rinfo;
230 } 231 }
231 232
232 public SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName) 233 public virtual GridRegion GetRegionByName(UUID scopeID, string regionName)
233 { 234 {
234 Dictionary<string, string> sendData = new Dictionary<string, string>(); 235 Dictionary<string, string> sendData = new Dictionary<string, string>();
235 236
@@ -244,11 +245,11 @@ namespace OpenSim.Services.Connectors
244 245
245 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); 246 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
246 247
247 SimpleRegionInfo rinfo = null; 248 GridRegion rinfo = null;
248 if ((replyData != null) && (replyData["result"] != null)) 249 if ((replyData != null) && (replyData["result"] != null))
249 { 250 {
250 if (replyData["result"] is Dictionary<string, object>) 251 if (replyData["result"] is Dictionary<string, object>)
251 rinfo = new SimpleRegionInfo((Dictionary<string, object>)replyData["result"]); 252 rinfo = new GridRegion((Dictionary<string, object>)replyData["result"]);
252 else 253 else
253 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1} received invalid response", 254 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1} received invalid response",
254 scopeID, regionName); 255 scopeID, regionName);
@@ -260,7 +261,7 @@ namespace OpenSim.Services.Connectors
260 return rinfo; 261 return rinfo;
261 } 262 }
262 263
263 public List<SimpleRegionInfo> GetRegionsByName(UUID scopeID, string name, int maxNumber) 264 public virtual List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber)
264 { 265 {
265 Dictionary<string, string> sendData = new Dictionary<string, string>(); 266 Dictionary<string, string> sendData = new Dictionary<string, string>();
266 267
@@ -276,7 +277,7 @@ namespace OpenSim.Services.Connectors
276 277
277 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); 278 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
278 279
279 List<SimpleRegionInfo> rinfos = new List<SimpleRegionInfo>(); 280 List<GridRegion> rinfos = new List<GridRegion>();
280 if (replyData != null) 281 if (replyData != null)
281 { 282 {
282 Dictionary<string, object>.ValueCollection rinfosList = replyData.Values; 283 Dictionary<string, object>.ValueCollection rinfosList = replyData.Values;
@@ -284,7 +285,7 @@ namespace OpenSim.Services.Connectors
284 { 285 {
285 if (r is Dictionary<string, object>) 286 if (r is Dictionary<string, object>)
286 { 287 {
287 SimpleRegionInfo rinfo = new SimpleRegionInfo((Dictionary<string, object>)r); 288 GridRegion rinfo = new GridRegion((Dictionary<string, object>)r);
288 rinfos.Add(rinfo); 289 rinfos.Add(rinfo);
289 } 290 }
290 else 291 else
@@ -299,7 +300,7 @@ namespace OpenSim.Services.Connectors
299 return rinfos; 300 return rinfos;
300 } 301 }
301 302
302 public List<SimpleRegionInfo> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) 303 public virtual List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax)
303 { 304 {
304 Dictionary<string, string> sendData = new Dictionary<string, string>(); 305 Dictionary<string, string> sendData = new Dictionary<string, string>();
305 306
@@ -317,7 +318,7 @@ namespace OpenSim.Services.Connectors
317 318
318 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); 319 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
319 320
320 List<SimpleRegionInfo> rinfos = new List<SimpleRegionInfo>(); 321 List<GridRegion> rinfos = new List<GridRegion>();
321 if (replyData != null) 322 if (replyData != null)
322 { 323 {
323 Dictionary<string, object>.ValueCollection rinfosList = replyData.Values; 324 Dictionary<string, object>.ValueCollection rinfosList = replyData.Values;
@@ -325,7 +326,7 @@ namespace OpenSim.Services.Connectors
325 { 326 {
326 if (r is Dictionary<string, object>) 327 if (r is Dictionary<string, object>)
327 { 328 {
328 SimpleRegionInfo rinfo = new SimpleRegionInfo((Dictionary<string, object>)r); 329 GridRegion rinfo = new GridRegion((Dictionary<string, object>)r);
329 rinfos.Add(rinfo); 330 rinfos.Add(rinfo);
330 } 331 }
331 else 332 else
diff --git a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs
new file mode 100644
index 0000000..b5e8743
--- /dev/null
+++ b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs
@@ -0,0 +1,152 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Text;
32using System.Drawing;
33using System.Net;
34using System.Reflection;
35using OpenSim.Services.Interfaces;
36using GridRegion = OpenSim.Services.Interfaces.GridRegion;
37
38using OpenSim.Framework;
39
40using OpenMetaverse;
41using OpenMetaverse.Imaging;
42using log4net;
43using Nwc.XmlRpc;
44
45namespace OpenSim.Services.Connectors.Grid
46{
47 public class HypergridServiceConnector
48 {
49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
50
51 private IAssetService m_AssetService;
52
53 public HypergridServiceConnector(IAssetService assService)
54 {
55 m_AssetService = assService;
56 }
57
58 public UUID LinkRegion(GridRegion info, out ulong realHandle)
59 {
60 UUID uuid = UUID.Zero;
61 realHandle = 0;
62
63 Hashtable hash = new Hashtable();
64 hash["region_name"] = info.RegionName;
65
66 IList paramList = new ArrayList();
67 paramList.Add(hash);
68
69 XmlRpcRequest request = new XmlRpcRequest("linkk_region", paramList);
70 string uri = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/";
71 m_log.Debug("[HGrid]: Linking to " + uri);
72 XmlRpcResponse response = request.Send(uri, 10000);
73 if (response.IsFault)
74 {
75 m_log.ErrorFormat("[HGrid]: remote call returned an error: {0}", response.FaultString);
76 }
77 else
78 {
79 hash = (Hashtable)response.Value;
80 //foreach (Object o in hash)
81 // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
82 try
83 {
84 UUID.TryParse((string)hash["uuid"], out uuid);
85 info.RegionID = uuid;
86 if ((string)hash["handle"] != null)
87 {
88 realHandle = Convert.ToUInt64((string)hash["handle"]);
89 m_log.Debug(">> HERE, realHandle: " + realHandle);
90 }
91 //if (hash["region_image"] != null)
92 //{
93 // UUID img = UUID.Zero;
94 // UUID.TryParse((string)hash["region_image"], out img);
95 // info.RegionSettings.TerrainImageID = img;
96 //}
97 if (hash["region_name"] != null)
98 {
99 info.RegionName = (string)hash["region_name"];
100 //m_log.Debug(">> " + info.RegionName);
101 }
102 if (hash["internal_port"] != null)
103 {
104 int port = Convert.ToInt32((string)hash["internal_port"]);
105 info.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), port);
106 //m_log.Debug(">> " + info.InternalEndPoint.ToString());
107 }
108
109 }
110 catch (Exception e)
111 {
112 m_log.Error("[HGrid]: Got exception while parsing hyperlink response " + e.StackTrace);
113 }
114 }
115 return uuid;
116 }
117
118 public void GetMapImage(GridRegion info)
119 {
120 try
121 {
122 string regionimage = "regionImage" + info.RegionID.ToString();
123 regionimage = regionimage.Replace("-", "");
124
125 WebClient c = new WebClient();
126 string uri = "http://" + info.ExternalHostName + ":" + info.HttpPort + "/index.php?method=" + regionimage;
127 //m_log.Debug("JPEG: " + uri);
128 c.DownloadFile(uri, info.RegionID.ToString() + ".jpg");
129 Bitmap m = new Bitmap(info.RegionID.ToString() + ".jpg");
130 //m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width);
131 byte[] imageData = OpenJPEG.EncodeFromImage(m, true);
132 AssetBase ass = new AssetBase(UUID.Random(), "region " + info.RegionID.ToString());
133
134 // !!! for now
135 //info.RegionSettings.TerrainImageID = ass.FullID;
136
137 ass.Type = (int)AssetType.Texture;
138 ass.Temporary = true;
139 ass.Local = true;
140 ass.Data = imageData;
141
142 m_AssetService.Store(ass);
143
144 }
145 catch // LEGIT: Catching problems caused by OpenJPEG p/invoke
146 {
147 m_log.Warn("[HGrid]: Failed getting/storing map image, because it is probably already in the cache");
148 }
149 }
150
151 }
152}