aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services
diff options
context:
space:
mode:
authorDiva Canto2009-09-23 17:20:07 -0700
committerDiva Canto2009-09-23 17:20:07 -0700
commit67276589c883fe1a74d8d52057db1431d637dade (patch)
treedea80b87d7e11fb9a15c4b6e22c2c051e08eaf25 /OpenSim/Services
parentMerge branch 'master' of ssh://diva@opensimulator.org/var/git/opensim (diff)
downloadopensim-SC-67276589c883fe1a74d8d52057db1431d637dade.zip
opensim-SC-67276589c883fe1a74d8d52057db1431d637dade.tar.gz
opensim-SC-67276589c883fe1a74d8d52057db1431d637dade.tar.bz2
opensim-SC-67276589c883fe1a74d8d52057db1431d637dade.tar.xz
Changed IGridService to use the new GridRegion data structure instead of old SimpleRegionInfo.
Added grid configs to standalones.
Diffstat (limited to 'OpenSim/Services')
-rw-r--r--OpenSim/Services/Connectors/Grid/GridServiceConnector.cs39
-rw-r--r--OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs5
-rw-r--r--OpenSim/Services/GridService/GridService.cs32
-rw-r--r--OpenSim/Services/GridService/GridServiceBase.cs2
-rw-r--r--OpenSim/Services/Interfaces/IGridService.cs249
5 files changed, 281 insertions, 46 deletions
diff --git a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs
index 1962bcf..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 virtual 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>();
@@ -128,7 +129,7 @@ namespace OpenSim.Services.Connectors
128 return false; 129 return false;
129 } 130 }
130 131
131 public virtual 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 virtual 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 virtual 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 virtual 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 virtual 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 virtual 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
index 6b0518c..616c2c1 100644
--- a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs
@@ -33,6 +33,7 @@ using System.Drawing;
33using System.Net; 33using System.Net;
34using System.Reflection; 34using System.Reflection;
35using OpenSim.Services.Interfaces; 35using OpenSim.Services.Interfaces;
36using GridRegion = OpenSim.Services.Interfaces.GridRegion;
36 37
37using OpenSim.Framework; 38using OpenSim.Framework;
38 39
@@ -54,7 +55,7 @@ namespace OpenSim.Services.Connectors.Grid
54 m_AssetService = assService; 55 m_AssetService = assService;
55 } 56 }
56 57
57 public UUID LinkRegion(SimpleRegionInfo info, out ulong realHandle) 58 public UUID LinkRegion(GridRegion info, out ulong realHandle)
58 { 59 {
59 UUID uuid = UUID.Zero; 60 UUID uuid = UUID.Zero;
60 realHandle = 0; 61 realHandle = 0;
@@ -114,7 +115,7 @@ namespace OpenSim.Services.Connectors.Grid
114 return uuid; 115 return uuid;
115 } 116 }
116 117
117 public void GetMapImage(SimpleRegionInfo info) 118 public void GetMapImage(GridRegion info)
118 { 119 {
119 try 120 try
120 { 121 {
diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs
index b37a51b..cd462ab 100644
--- a/OpenSim/Services/GridService/GridService.cs
+++ b/OpenSim/Services/GridService/GridService.cs
@@ -35,6 +35,7 @@ using OpenSim.Framework;
35using OpenSim.Framework.Console; 35using OpenSim.Framework.Console;
36using OpenSim.Data; 36using OpenSim.Data;
37using OpenSim.Services.Interfaces; 37using OpenSim.Services.Interfaces;
38using GridRegion = OpenSim.Services.Interfaces.GridRegion;
38using OpenMetaverse; 39using OpenMetaverse;
39 40
40namespace OpenSim.Services.GridService 41namespace OpenSim.Services.GridService
@@ -48,6 +49,7 @@ namespace OpenSim.Services.GridService
48 public GridService(IConfigSource config) 49 public GridService(IConfigSource config)
49 : base(config) 50 : base(config)
50 { 51 {
52 m_log.DebugFormat("[GRID SERVICE]: Starting...");
51 MainConsole.Instance.Commands.AddCommand("kfs", false, 53 MainConsole.Instance.Commands.AddCommand("kfs", false,
52 "show digest", 54 "show digest",
53 "show digest <ID>", 55 "show digest <ID>",
@@ -62,7 +64,7 @@ namespace OpenSim.Services.GridService
62 64
63 #region IGridService 65 #region IGridService
64 66
65 public bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfos) 67 public bool RegisterRegion(UUID scopeID, GridRegion regionInfos)
66 { 68 {
67 if (m_Database.Get(regionInfos.RegionID, scopeID) != null) 69 if (m_Database.Get(regionInfos.RegionID, scopeID) != null)
68 { 70 {
@@ -88,9 +90,9 @@ namespace OpenSim.Services.GridService
88 return m_Database.Delete(regionID); 90 return m_Database.Delete(regionID);
89 } 91 }
90 92
91 public List<SimpleRegionInfo> GetNeighbours(UUID scopeID, UUID regionID) 93 public List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID)
92 { 94 {
93 List<SimpleRegionInfo> rinfos = new List<SimpleRegionInfo>(); 95 List<GridRegion> rinfos = new List<GridRegion>();
94 RegionData region = m_Database.Get(regionID, scopeID); 96 RegionData region = m_Database.Get(regionID, scopeID);
95 if (region != null) 97 if (region != null)
96 { 98 {
@@ -105,7 +107,7 @@ namespace OpenSim.Services.GridService
105 return rinfos; 107 return rinfos;
106 } 108 }
107 109
108 public SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID) 110 public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
109 { 111 {
110 RegionData rdata = m_Database.Get(regionID, scopeID); 112 RegionData rdata = m_Database.Get(regionID, scopeID);
111 if (rdata != null) 113 if (rdata != null)
@@ -114,7 +116,7 @@ namespace OpenSim.Services.GridService
114 return null; 116 return null;
115 } 117 }
116 118
117 public SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y) 119 public GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
118 { 120 {
119 int snapX = (int)(x / Constants.RegionSize) * (int)Constants.RegionSize; 121 int snapX = (int)(x / Constants.RegionSize) * (int)Constants.RegionSize;
120 int snapY = (int)(y / Constants.RegionSize) * (int)Constants.RegionSize; 122 int snapY = (int)(y / Constants.RegionSize) * (int)Constants.RegionSize;
@@ -125,7 +127,7 @@ namespace OpenSim.Services.GridService
125 return null; 127 return null;
126 } 128 }
127 129
128 public SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName) 130 public GridRegion GetRegionByName(UUID scopeID, string regionName)
129 { 131 {
130 List<RegionData> rdatas = m_Database.Get(regionName + "%", scopeID); 132 List<RegionData> rdatas = m_Database.Get(regionName + "%", scopeID);
131 if ((rdatas != null) && (rdatas.Count > 0)) 133 if ((rdatas != null) && (rdatas.Count > 0))
@@ -134,12 +136,12 @@ namespace OpenSim.Services.GridService
134 return null; 136 return null;
135 } 137 }
136 138
137 public List<SimpleRegionInfo> GetRegionsByName(UUID scopeID, string name, int maxNumber) 139 public List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber)
138 { 140 {
139 List<RegionData> rdatas = m_Database.Get("%" + name + "%", scopeID); 141 List<RegionData> rdatas = m_Database.Get("%" + name + "%", scopeID);
140 142
141 int count = 0; 143 int count = 0;
142 List<SimpleRegionInfo> rinfos = new List<SimpleRegionInfo>(); 144 List<GridRegion> rinfos = new List<GridRegion>();
143 145
144 if (rdatas != null) 146 if (rdatas != null)
145 { 147 {
@@ -153,7 +155,7 @@ namespace OpenSim.Services.GridService
153 return rinfos; 155 return rinfos;
154 } 156 }
155 157
156 public List<SimpleRegionInfo> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) 158 public List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax)
157 { 159 {
158 int xminSnap = (int)(xmin / Constants.RegionSize) * (int)Constants.RegionSize; 160 int xminSnap = (int)(xmin / Constants.RegionSize) * (int)Constants.RegionSize;
159 int xmaxSnap = (int)(xmax / Constants.RegionSize) * (int)Constants.RegionSize; 161 int xmaxSnap = (int)(xmax / Constants.RegionSize) * (int)Constants.RegionSize;
@@ -161,7 +163,7 @@ namespace OpenSim.Services.GridService
161 int ymaxSnap = (int)(ymax / Constants.RegionSize) * (int)Constants.RegionSize; 163 int ymaxSnap = (int)(ymax / Constants.RegionSize) * (int)Constants.RegionSize;
162 164
163 List<RegionData> rdatas = m_Database.Get(xminSnap, yminSnap, xmaxSnap, ymaxSnap, scopeID); 165 List<RegionData> rdatas = m_Database.Get(xminSnap, yminSnap, xmaxSnap, ymaxSnap, scopeID);
164 List<SimpleRegionInfo> rinfos = new List<SimpleRegionInfo>(); 166 List<GridRegion> rinfos = new List<GridRegion>();
165 foreach (RegionData rdata in rdatas) 167 foreach (RegionData rdata in rdatas)
166 rinfos.Add(RegionData2RegionInfo(rdata)); 168 rinfos.Add(RegionData2RegionInfo(rdata));
167 169
@@ -172,7 +174,7 @@ namespace OpenSim.Services.GridService
172 174
173 #region Data structure conversions 175 #region Data structure conversions
174 176
175 protected RegionData RegionInfo2RegionData(SimpleRegionInfo rinfo) 177 protected RegionData RegionInfo2RegionData(GridRegion rinfo)
176 { 178 {
177 RegionData rdata = new RegionData(); 179 RegionData rdata = new RegionData();
178 rdata.posX = (int)rinfo.RegionLocX; 180 rdata.posX = (int)rinfo.RegionLocX;
@@ -184,11 +186,11 @@ namespace OpenSim.Services.GridService
184 return rdata; 186 return rdata;
185 } 187 }
186 188
187 protected SimpleRegionInfo RegionData2RegionInfo(RegionData rdata) 189 protected GridRegion RegionData2RegionInfo(RegionData rdata)
188 { 190 {
189 SimpleRegionInfo rinfo = new SimpleRegionInfo(rdata.Data); 191 GridRegion rinfo = new GridRegion(rdata.Data);
190 rinfo.RegionLocX = (uint)rdata.posX; 192 rinfo.RegionLocX = rdata.posX;
191 rinfo.RegionLocY = (uint)rdata.posY; 193 rinfo.RegionLocY = rdata.posY;
192 rinfo.RegionID = rdata.RegionID; 194 rinfo.RegionID = rdata.RegionID;
193 rinfo.RegionName = rdata.RegionName; 195 rinfo.RegionName = rdata.RegionName;
194 196
diff --git a/OpenSim/Services/GridService/GridServiceBase.cs b/OpenSim/Services/GridService/GridServiceBase.cs
index 7522e64..444f79b 100644
--- a/OpenSim/Services/GridService/GridServiceBase.cs
+++ b/OpenSim/Services/GridService/GridServiceBase.cs
@@ -68,7 +68,7 @@ namespace OpenSim.Services.GridService
68 connString = gridConfig.GetString("ConnectionString", connString); 68 connString = gridConfig.GetString("ConnectionString", connString);
69 realm = gridConfig.GetString("Realm", realm); 69 realm = gridConfig.GetString("Realm", realm);
70 } 70 }
71 71
72 // 72 //
73 // We tried, but this doesn't exist. We can't proceed. 73 // We tried, but this doesn't exist. We can't proceed.
74 // 74 //
diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs
index 8f6c524..a188f7e 100644
--- a/OpenSim/Services/Interfaces/IGridService.cs
+++ b/OpenSim/Services/Interfaces/IGridService.cs
@@ -25,8 +25,11 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using OpenSim.Framework; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Net;
31using System.Net.Sockets;
32using OpenSim.Framework;
30using OpenMetaverse; 33using OpenMetaverse;
31 34
32namespace OpenSim.Services.Interfaces 35namespace OpenSim.Services.Interfaces
@@ -39,7 +42,7 @@ namespace OpenSim.Services.Interfaces
39 /// <param name="regionInfos"> </param> 42 /// <param name="regionInfos"> </param>
40 /// <returns></returns> 43 /// <returns></returns>
41 /// <exception cref="System.Exception">Thrown if region registration failed</exception> 44 /// <exception cref="System.Exception">Thrown if region registration failed</exception>
42 bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfos); 45 bool RegisterRegion(UUID scopeID, GridRegion regionInfos);
43 46
44 /// <summary> 47 /// <summary>
45 /// Deregister a region with the grid service. 48 /// Deregister a region with the grid service.
@@ -55,9 +58,9 @@ namespace OpenSim.Services.Interfaces
55 /// <param name="x"></param> 58 /// <param name="x"></param>
56 /// <param name="y"></param> 59 /// <param name="y"></param>
57 /// <returns></returns> 60 /// <returns></returns>
58 List<SimpleRegionInfo> GetNeighbours(UUID scopeID, UUID regionID); 61 List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID);
59 62
60 SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID); 63 GridRegion GetRegionByUUID(UUID scopeID, UUID regionID);
61 64
62 /// <summary> 65 /// <summary>
63 /// Get the region at the given position (in meters) 66 /// Get the region at the given position (in meters)
@@ -66,9 +69,9 @@ namespace OpenSim.Services.Interfaces
66 /// <param name="x"></param> 69 /// <param name="x"></param>
67 /// <param name="y"></param> 70 /// <param name="y"></param>
68 /// <returns></returns> 71 /// <returns></returns>
69 SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y); 72 GridRegion GetRegionByPosition(UUID scopeID, int x, int y);
70 73
71 SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName); 74 GridRegion GetRegionByName(UUID scopeID, string regionName);
72 75
73 /// <summary> 76 /// <summary>
74 /// Get information about regions starting with the provided name. 77 /// Get information about regions starting with the provided name.
@@ -83,9 +86,237 @@ namespace OpenSim.Services.Interfaces
83 /// A list of <see cref="RegionInfo"/>s of regions with matching name. If the 86 /// A list of <see cref="RegionInfo"/>s of regions with matching name. If the
84 /// grid-server couldn't be contacted or returned an error, return null. 87 /// grid-server couldn't be contacted or returned an error, return null.
85 /// </returns> 88 /// </returns>
86 List<SimpleRegionInfo> GetRegionsByName(UUID scopeID, string name, int maxNumber); 89 List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber);
87 90
88 List<SimpleRegionInfo> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax); 91 List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax);
89 92
90 } 93 }
94
95 public class GridRegion
96 {
97
98 /// <summary>
99 /// The port by which http communication occurs with the region
100 /// </summary>
101 public uint HttpPort
102 {
103 get { return m_httpPort; }
104 set { m_httpPort = value; }
105 }
106 protected uint m_httpPort;
107
108 /// <summary>
109 /// A well-formed URI for the host region server (namely "http://" + ExternalHostName)
110 /// </summary>
111 public string ServerURI
112 {
113 get { return m_serverURI; }
114 set { m_serverURI = value; }
115 }
116 protected string m_serverURI;
117
118 public string RegionName
119 {
120 get { return m_regionName; }
121 set { m_regionName = value; }
122 }
123 protected string m_regionName = String.Empty;
124
125 protected bool Allow_Alternate_Ports;
126 public bool m_allow_alternate_ports;
127
128 protected string m_externalHostName;
129
130 protected IPEndPoint m_internalEndPoint;
131
132 public int RegionLocX
133 {
134 get { return m_regionLocX; }
135 set { m_regionLocX = value; }
136 }
137 protected int m_regionLocX;
138
139 public int RegionLocY
140 {
141 get { return m_regionLocY; }
142 set { m_regionLocY = value; }
143 }
144 protected int m_regionLocY;
145
146 public UUID RegionID = UUID.Zero;
147 public UUID ScopeID = UUID.Zero;
148
149 public GridRegion()
150 {
151 }
152
153 public GridRegion(int regionLocX, int regionLocY, IPEndPoint internalEndPoint, string externalUri)
154 {
155 m_regionLocX = regionLocX;
156 m_regionLocY = regionLocY;
157
158 m_internalEndPoint = internalEndPoint;
159 m_externalHostName = externalUri;
160 }
161
162 public GridRegion(int regionLocX, int regionLocY, string externalUri, uint port)
163 {
164 m_regionLocX = regionLocX;
165 m_regionLocY = regionLocY;
166
167 m_externalHostName = externalUri;
168
169 m_internalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)port);
170 }
171
172 public GridRegion(uint xcell, uint ycell)
173 {
174 m_regionLocX = (int)(xcell * Constants.RegionSize);
175 m_regionLocY = (int)(ycell * Constants.RegionSize);
176 }
177
178 public GridRegion(RegionInfo ConvertFrom)
179 {
180 m_regionName = ConvertFrom.RegionName;
181 m_regionLocX = (int)(ConvertFrom.RegionLocX * Constants.RegionSize);
182 m_regionLocY = (int)(ConvertFrom.RegionLocY * Constants.RegionSize);
183 m_internalEndPoint = ConvertFrom.InternalEndPoint;
184 m_externalHostName = ConvertFrom.ExternalHostName;
185 m_httpPort = ConvertFrom.HttpPort;
186 m_allow_alternate_ports = ConvertFrom.m_allow_alternate_ports;
187 RegionID = UUID.Zero;
188 ServerURI = ConvertFrom.ServerURI;
189 }
190
191
192 /// <value>
193 /// This accessor can throw all the exceptions that Dns.GetHostAddresses can throw.
194 ///
195 /// XXX Isn't this really doing too much to be a simple getter, rather than an explict method?
196 /// </value>
197 public IPEndPoint ExternalEndPoint
198 {
199 get
200 {
201 // Old one defaults to IPv6
202 //return new IPEndPoint(Dns.GetHostAddresses(m_externalHostName)[0], m_internalEndPoint.Port);
203
204 IPAddress ia = null;
205 // If it is already an IP, don't resolve it - just return directly
206 if (IPAddress.TryParse(m_externalHostName, out ia))
207 return new IPEndPoint(ia, m_internalEndPoint.Port);
208
209 // Reset for next check
210 ia = null;
211 try
212 {
213 foreach (IPAddress Adr in Dns.GetHostAddresses(m_externalHostName))
214 {
215 if (ia == null)
216 ia = Adr;
217
218 if (Adr.AddressFamily == AddressFamily.InterNetwork)
219 {
220 ia = Adr;
221 break;
222 }
223 }
224 }
225 catch (SocketException e)
226 {
227 throw new Exception(
228 "Unable to resolve local hostname " + m_externalHostName + " innerException of type '" +
229 e + "' attached to this exception", e);
230 }
231
232 return new IPEndPoint(ia, m_internalEndPoint.Port);
233 }
234
235 set { m_externalHostName = value.ToString(); }
236 }
237
238 public string ExternalHostName
239 {
240 get { return m_externalHostName; }
241 set { m_externalHostName = value; }
242 }
243
244 public IPEndPoint InternalEndPoint
245 {
246 get { return m_internalEndPoint; }
247 set { m_internalEndPoint = value; }
248 }
249
250 public ulong RegionHandle
251 {
252 get { return Util.UIntsToLong((uint)RegionLocX, (uint)RegionLocY); }
253 }
254
255 public int getInternalEndPointPort()
256 {
257 return m_internalEndPoint.Port;
258 }
259
260 public Dictionary<string, object> ToKeyValuePairs()
261 {
262 Dictionary<string, object> kvp = new Dictionary<string, object>();
263 kvp["uuid"] = RegionID.ToString();
264 kvp["locX"] = RegionLocX.ToString();
265 kvp["locY"] = RegionLocY.ToString();
266 kvp["external_ip_address"] = ExternalEndPoint.Address.ToString();
267 kvp["external_port"] = ExternalEndPoint.Port.ToString();
268 kvp["external_host_name"] = ExternalHostName;
269 kvp["http_port"] = HttpPort.ToString();
270 kvp["internal_ip_address"] = InternalEndPoint.Address.ToString();
271 kvp["internal_port"] = InternalEndPoint.Port.ToString();
272 kvp["alternate_ports"] = m_allow_alternate_ports.ToString();
273 kvp["server_uri"] = ServerURI;
274
275 return kvp;
276 }
277
278 public GridRegion(Dictionary<string, object> kvp)
279 {
280 if ((kvp["external_ip_address"] != null) && (kvp["external_port"] != null))
281 {
282 int port = 0;
283 Int32.TryParse((string)kvp["external_port"], out port);
284 IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)kvp["external_ip_address"]), port);
285 ExternalEndPoint = ep;
286 }
287 else
288 ExternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0);
289
290 if (kvp["external_host_name"] != null)
291 ExternalHostName = (string)kvp["external_host_name"];
292
293 if (kvp["http_port"] != null)
294 {
295 UInt32 port = 0;
296 UInt32.TryParse((string)kvp["http_port"], out port);
297 HttpPort = port;
298 }
299
300 if ((kvp["internal_ip_address"] != null) && (kvp["internal_port"] != null))
301 {
302 int port = 0;
303 Int32.TryParse((string)kvp["internal_port"], out port);
304 IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)kvp["internal_ip_address"]), port);
305 InternalEndPoint = ep;
306 }
307 else
308 InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0);
309
310 if (kvp["alternate_ports"] != null)
311 {
312 bool alts = false;
313 Boolean.TryParse((string)kvp["alternate_ports"], out alts);
314 m_allow_alternate_ports = alts;
315 }
316
317 if (kvp["server_uri"] != null)
318 ServerURI = (string)kvp["server_uri"];
319 }
320 }
321
91} 322}