diff options
author | Diva Canto | 2009-09-18 19:16:30 -0700 |
---|---|---|
committer | Diva Canto | 2009-09-18 19:16:30 -0700 |
commit | e7362738155c0a0a5c9ef8b867eb14b18bb31a44 (patch) | |
tree | 527dba75b3d61ecbf2a18df0e2b2467376a569e1 | |
parent | Add the Null storage implementation for the RegionData service. Standalones (diff) | |
download | opensim-SC_OLD-e7362738155c0a0a5c9ef8b867eb14b18bb31a44.zip opensim-SC_OLD-e7362738155c0a0a5c9ef8b867eb14b18bb31a44.tar.gz opensim-SC_OLD-e7362738155c0a0a5c9ef8b867eb14b18bb31a44.tar.bz2 opensim-SC_OLD-e7362738155c0a0a5c9ef8b867eb14b18bb31a44.tar.xz |
First pass at the grid service.
-rw-r--r-- | OpenSim/Data/IRegionData.cs | 3 | ||||
-rw-r--r-- | OpenSim/Services/Grid/GridService.cs | 79 | ||||
-rw-r--r-- | OpenSim/Services/GridService/GridService.cs | 297 | ||||
-rw-r--r-- | OpenSim/Services/GridService/GridServiceBase.cs | 84 | ||||
-rw-r--r-- | OpenSim/Services/Interfaces/IGridService.cs | 17 | ||||
-rw-r--r-- | prebuild.xml | 31 |
6 files changed, 425 insertions, 86 deletions
diff --git a/OpenSim/Data/IRegionData.cs b/OpenSim/Data/IRegionData.cs index 71dd525..c5201ea 100644 --- a/OpenSim/Data/IRegionData.cs +++ b/OpenSim/Data/IRegionData.cs | |||
@@ -45,7 +45,7 @@ namespace OpenSim.Data | |||
45 | /// <summary> | 45 | /// <summary> |
46 | /// An interface for connecting to the authentication datastore | 46 | /// An interface for connecting to the authentication datastore |
47 | /// </summary> | 47 | /// </summary> |
48 | public interface IRegionData | 48 | public interface IRegionData |
49 | { | 49 | { |
50 | RegionData Get(UUID regionID, UUID ScopeID); | 50 | RegionData Get(UUID regionID, UUID ScopeID); |
51 | List<RegionData> Get(string regionName, UUID ScopeID); | 51 | List<RegionData> Get(string regionName, UUID ScopeID); |
@@ -57,5 +57,6 @@ namespace OpenSim.Data | |||
57 | bool SetDataItem(UUID principalID, string item, string value); | 57 | bool SetDataItem(UUID principalID, string item, string value); |
58 | 58 | ||
59 | bool Delete(UUID regionID); | 59 | bool Delete(UUID regionID); |
60 | |||
60 | } | 61 | } |
61 | } | 62 | } |
diff --git a/OpenSim/Services/Grid/GridService.cs b/OpenSim/Services/Grid/GridService.cs deleted file mode 100644 index 47710d8..0000000 --- a/OpenSim/Services/Grid/GridService.cs +++ /dev/null | |||
@@ -1,79 +0,0 @@ | |||
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 | |||
28 | using System.Collections.Generic; | ||
29 | using OpenMetaverse; | ||
30 | using OpenSim.Services.Interfaces; | ||
31 | |||
32 | namespace OpenSim.Services.Interfaces | ||
33 | { | ||
34 | public class GridService : IGridService | ||
35 | { | ||
36 | bool RegisterRegion(UUID scopeID, RegionInfo regionInfos); | ||
37 | { | ||
38 | return false; | ||
39 | } | ||
40 | |||
41 | bool DeregisterRegion(UUID regionID); | ||
42 | { | ||
43 | return false; | ||
44 | } | ||
45 | |||
46 | List<SimpleRegionInfo> RequestNeighbours(UUID scopeID, uint x, uint y) | ||
47 | { | ||
48 | return new List<SimpleRegionInfo>() | ||
49 | } | ||
50 | |||
51 | RegionInfo RequestNeighbourInfo(UUID regionID) | ||
52 | { | ||
53 | return null; | ||
54 | } | ||
55 | |||
56 | RegionInfo RequestClosestRegion(UUID scopeID, string regionName) | ||
57 | { | ||
58 | return null; | ||
59 | } | ||
60 | |||
61 | List<MapBlockData> RequestNeighbourMapBlocks(UUID scopeID, int minX, | ||
62 | int minY, int maxX, int maxY) | ||
63 | { | ||
64 | return new List<MapBlockData>(); | ||
65 | } | ||
66 | |||
67 | LandData RequestLandData(UUID scopeID, ulong regionHandle, | ||
68 | uint x, uint y) | ||
69 | { | ||
70 | return null; | ||
71 | } | ||
72 | |||
73 | List<RegionInfo> RequestNamedRegions(UUID scopeID, string name, | ||
74 | int maxNumber) | ||
75 | { | ||
76 | return new List<RegionInfo>(); | ||
77 | } | ||
78 | } | ||
79 | } | ||
diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs new file mode 100644 index 0000000..6aa1c4f --- /dev/null +++ b/OpenSim/Services/GridService/GridService.cs | |||
@@ -0,0 +1,297 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Net; | ||
31 | using System.Reflection; | ||
32 | using Nini.Config; | ||
33 | using log4net; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Framework.Console; | ||
36 | using OpenSim.Data; | ||
37 | using OpenSim.Services.Interfaces; | ||
38 | using OpenMetaverse; | ||
39 | |||
40 | namespace OpenSim.Services.GridService | ||
41 | { | ||
42 | public class GridService : GridServiceBase, IGridService | ||
43 | { | ||
44 | private static readonly ILog m_log = | ||
45 | LogManager.GetLogger( | ||
46 | MethodBase.GetCurrentMethod().DeclaringType); | ||
47 | |||
48 | public GridService(IConfigSource config) | ||
49 | : base(config) | ||
50 | { | ||
51 | MainConsole.Instance.Commands.AddCommand("kfs", false, | ||
52 | "show digest", | ||
53 | "show digest <ID>", | ||
54 | "Show asset digest", HandleShowDigest); | ||
55 | |||
56 | MainConsole.Instance.Commands.AddCommand("kfs", false, | ||
57 | "delete asset", | ||
58 | "delete asset <ID>", | ||
59 | "Delete asset from database", HandleDeleteAsset); | ||
60 | |||
61 | } | ||
62 | |||
63 | #region IGridService | ||
64 | |||
65 | public bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfos) | ||
66 | { | ||
67 | if (m_Database.Get(regionInfos.RegionID, scopeID) != null) | ||
68 | { | ||
69 | m_log.WarnFormat("[GRID SERVICE]: Region {0} already registered in scope {1}.", regionInfos.RegionID, scopeID); | ||
70 | return false; | ||
71 | } | ||
72 | if (m_Database.Get((int)regionInfos.RegionLocX, (int)regionInfos.RegionLocY, scopeID) != null) | ||
73 | { | ||
74 | m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register in coordinates {1}, {2} which are already in use in scope {3}.", | ||
75 | regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); | ||
76 | return false; | ||
77 | } | ||
78 | |||
79 | // Everything is ok, let's register | ||
80 | RegionData rdata = RegionInfo2RegionData(regionInfos); | ||
81 | rdata.ScopeID = scopeID; | ||
82 | m_Database.Store(rdata); | ||
83 | return true; | ||
84 | } | ||
85 | |||
86 | public bool DeregisterRegion(UUID regionID) | ||
87 | { | ||
88 | return m_Database.Delete(regionID); | ||
89 | } | ||
90 | |||
91 | public List<SimpleRegionInfo> GetNeighbours(UUID scopeID, int x, int y) | ||
92 | { | ||
93 | List<RegionData> rdatas = m_Database.Get(x - 1, y - 1, x + 1, y + 1, scopeID); | ||
94 | List<SimpleRegionInfo> rinfos = new List<SimpleRegionInfo>(); | ||
95 | foreach (RegionData rdata in rdatas) | ||
96 | rinfos.Add(RegionData2RegionInfo(rdata)); | ||
97 | |||
98 | return rinfos; | ||
99 | } | ||
100 | |||
101 | public SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID) | ||
102 | { | ||
103 | RegionData rdata = m_Database.Get(regionID, scopeID); | ||
104 | if (rdata != null) | ||
105 | return RegionData2RegionInfo(rdata); | ||
106 | |||
107 | return null; | ||
108 | } | ||
109 | |||
110 | public SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y) | ||
111 | { | ||
112 | RegionData rdata = m_Database.Get(x, y, scopeID); | ||
113 | if (rdata != null) | ||
114 | return RegionData2RegionInfo(rdata); | ||
115 | |||
116 | return null; | ||
117 | } | ||
118 | |||
119 | public SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName) | ||
120 | { | ||
121 | List<RegionData> rdatas = m_Database.Get(regionName + "%", scopeID); | ||
122 | if ((rdatas != null) && (rdatas.Count > 0)) | ||
123 | return RegionData2RegionInfo(rdatas[0]); // get the first | ||
124 | |||
125 | return null; | ||
126 | } | ||
127 | |||
128 | public List<SimpleRegionInfo> GetRegionsByName(UUID scopeID, string name, int maxNumber) | ||
129 | { | ||
130 | List<RegionData> rdatas = m_Database.Get("%" + name + "%", scopeID); | ||
131 | |||
132 | int count = 0; | ||
133 | List<SimpleRegionInfo> rinfos = new List<SimpleRegionInfo>(); | ||
134 | |||
135 | if (rdatas != null) | ||
136 | { | ||
137 | foreach (RegionData rdata in rdatas) | ||
138 | { | ||
139 | if (count++ < maxNumber) | ||
140 | rinfos.Add(RegionData2RegionInfo(rdata)); | ||
141 | } | ||
142 | } | ||
143 | |||
144 | return rinfos; | ||
145 | } | ||
146 | |||
147 | public List<SimpleRegionInfo> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) | ||
148 | { | ||
149 | List<RegionData> rdatas = m_Database.Get(xmin, ymin, xmax, ymax, scopeID); | ||
150 | List<SimpleRegionInfo> rinfos = new List<SimpleRegionInfo>(); | ||
151 | foreach (RegionData rdata in rdatas) | ||
152 | rinfos.Add(RegionData2RegionInfo(rdata)); | ||
153 | |||
154 | return rinfos; | ||
155 | } | ||
156 | |||
157 | #endregion | ||
158 | |||
159 | #region Data structure conversions | ||
160 | |||
161 | protected RegionData RegionInfo2RegionData(SimpleRegionInfo rinfo) | ||
162 | { | ||
163 | RegionData rdata = new RegionData(); | ||
164 | rdata.posX = (int)rinfo.RegionLocX; | ||
165 | rdata.posY = (int)rinfo.RegionLocY; | ||
166 | rdata.RegionID = rinfo.RegionID; | ||
167 | //rdata.RegionName = rinfo.RegionName; | ||
168 | rdata.Data["external_ip_address"] = rinfo.ExternalEndPoint.Address.ToString(); | ||
169 | rdata.Data["external_port"] = rinfo.ExternalEndPoint.Port.ToString(); | ||
170 | rdata.Data["external_host_name"] = rinfo.ExternalHostName; | ||
171 | rdata.Data["http_port"] = rinfo.HttpPort.ToString(); | ||
172 | rdata.Data["internal_ip_address"] = rinfo.InternalEndPoint.Address.ToString(); | ||
173 | rdata.Data["internal_port"] = rinfo.InternalEndPoint.Port.ToString(); | ||
174 | rdata.Data["alternate_ports"] = rinfo.m_allow_alternate_ports.ToString(); | ||
175 | rdata.Data["server_uri"] = rinfo.ServerURI; | ||
176 | |||
177 | return rdata; | ||
178 | } | ||
179 | |||
180 | protected SimpleRegionInfo RegionData2RegionInfo(RegionData rdata) | ||
181 | { | ||
182 | SimpleRegionInfo rinfo = new SimpleRegionInfo(); | ||
183 | rinfo.RegionLocX = (uint)rdata.posX; | ||
184 | rinfo.RegionLocY = (uint)rdata.posY; | ||
185 | rinfo.RegionID = rdata.RegionID; | ||
186 | //rinfo.RegionName = rdata.RegionName; | ||
187 | |||
188 | // Now for the variable data | ||
189 | if ((rdata.Data["external_ip_address"] != null) && (rdata.Data["external_port"] != null)) | ||
190 | { | ||
191 | int port = 0; | ||
192 | Int32.TryParse((string)rdata.Data["external_port"], out port); | ||
193 | IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)rdata.Data["external_ip_address"]), port); | ||
194 | rinfo.ExternalEndPoint = ep; | ||
195 | } | ||
196 | else | ||
197 | rinfo.ExternalEndPoint = new IPEndPoint(new IPAddress(0), 0); | ||
198 | |||
199 | if (rdata.Data["external_host_name"] != null) | ||
200 | rinfo.ExternalHostName = (string)rdata.Data["external_host_name"] ; | ||
201 | |||
202 | if (rdata.Data["http_port"] != null) | ||
203 | { | ||
204 | UInt32 port = 0; | ||
205 | UInt32.TryParse((string)rdata.Data["http_port"], out port); | ||
206 | rinfo.HttpPort = port; | ||
207 | } | ||
208 | |||
209 | if ((rdata.Data["internal_ip_address"] != null) && (rdata.Data["internal_port"] != null)) | ||
210 | { | ||
211 | int port = 0; | ||
212 | Int32.TryParse((string)rdata.Data["internal_port"], out port); | ||
213 | IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)rdata.Data["internal_ip_address"]), port); | ||
214 | rinfo.InternalEndPoint = ep; | ||
215 | } | ||
216 | else | ||
217 | rinfo.InternalEndPoint = new IPEndPoint(new IPAddress(0), 0); | ||
218 | |||
219 | if (rdata.Data["alternate_ports"] != null) | ||
220 | { | ||
221 | bool alts = false; | ||
222 | Boolean.TryParse((string)rdata.Data["alternate_ports"], out alts); | ||
223 | rinfo.m_allow_alternate_ports = alts; | ||
224 | } | ||
225 | |||
226 | if (rdata.Data["server_uri"] != null) | ||
227 | rinfo.ServerURI = (string)rdata.Data["server_uri"]; | ||
228 | |||
229 | return rinfo; | ||
230 | } | ||
231 | |||
232 | #endregion | ||
233 | |||
234 | void HandleShowDigest(string module, string[] args) | ||
235 | { | ||
236 | //if (args.Length < 3) | ||
237 | //{ | ||
238 | // MainConsole.Instance.Output("Syntax: show digest <ID>"); | ||
239 | // return; | ||
240 | //} | ||
241 | |||
242 | //AssetBase asset = Get(args[2]); | ||
243 | |||
244 | //if (asset == null || asset.Data.Length == 0) | ||
245 | //{ | ||
246 | // MainConsole.Instance.Output("Asset not found"); | ||
247 | // return; | ||
248 | //} | ||
249 | |||
250 | //int i; | ||
251 | |||
252 | //MainConsole.Instance.Output(String.Format("Name: {0}", asset.Name)); | ||
253 | //MainConsole.Instance.Output(String.Format("Description: {0}", asset.Description)); | ||
254 | //MainConsole.Instance.Output(String.Format("Type: {0}", asset.Type)); | ||
255 | //MainConsole.Instance.Output(String.Format("Content-type: {0}", asset.Metadata.ContentType)); | ||
256 | |||
257 | //for (i = 0 ; i < 5 ; i++) | ||
258 | //{ | ||
259 | // int off = i * 16; | ||
260 | // if (asset.Data.Length <= off) | ||
261 | // break; | ||
262 | // int len = 16; | ||
263 | // if (asset.Data.Length < off + len) | ||
264 | // len = asset.Data.Length - off; | ||
265 | |||
266 | // byte[] line = new byte[len]; | ||
267 | // Array.Copy(asset.Data, off, line, 0, len); | ||
268 | |||
269 | // string text = BitConverter.ToString(line); | ||
270 | // MainConsole.Instance.Output(String.Format("{0:x4}: {1}", off, text)); | ||
271 | //} | ||
272 | } | ||
273 | |||
274 | void HandleDeleteAsset(string module, string[] args) | ||
275 | { | ||
276 | //if (args.Length < 3) | ||
277 | //{ | ||
278 | // MainConsole.Instance.Output("Syntax: delete asset <ID>"); | ||
279 | // return; | ||
280 | //} | ||
281 | |||
282 | //AssetBase asset = Get(args[2]); | ||
283 | |||
284 | //if (asset == null || asset.Data.Length == 0) | ||
285 | // MainConsole.Instance.Output("Asset not found"); | ||
286 | // return; | ||
287 | //} | ||
288 | |||
289 | //Delete(args[2]); | ||
290 | |||
291 | ////MainConsole.Instance.Output("Asset deleted"); | ||
292 | //// TODO: Implement this | ||
293 | |||
294 | //MainConsole.Instance.Output("Asset deletion not supported by database"); | ||
295 | } | ||
296 | } | ||
297 | } | ||
diff --git a/OpenSim/Services/GridService/GridServiceBase.cs b/OpenSim/Services/GridService/GridServiceBase.cs new file mode 100644 index 0000000..7b69290 --- /dev/null +++ b/OpenSim/Services/GridService/GridServiceBase.cs | |||
@@ -0,0 +1,84 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Reflection; | ||
30 | using Nini.Config; | ||
31 | using OpenSim.Framework; | ||
32 | using OpenSim.Data; | ||
33 | using OpenSim.Services.Interfaces; | ||
34 | using OpenSim.Services.Base; | ||
35 | |||
36 | namespace OpenSim.Services.GridService | ||
37 | { | ||
38 | public class GridServiceBase : ServiceBase | ||
39 | { | ||
40 | protected IRegionData m_Database = null; | ||
41 | |||
42 | public GridServiceBase(IConfigSource config) | ||
43 | : base(config) | ||
44 | { | ||
45 | string dllName = String.Empty; | ||
46 | string connString = String.Empty; | ||
47 | string realm = "regions"; | ||
48 | |||
49 | // | ||
50 | // Try reading the [AssetService] section first, if it exists | ||
51 | // | ||
52 | IConfig gridConfig = config.Configs["GridService"]; | ||
53 | if (gridConfig != null) | ||
54 | { | ||
55 | dllName = gridConfig.GetString("StorageProvider", dllName); | ||
56 | connString = gridConfig.GetString("ConnectionString", connString); | ||
57 | realm = gridConfig.GetString("Realm", realm); | ||
58 | } | ||
59 | |||
60 | // | ||
61 | // Try reading the [DatabaseService] section, if it exists | ||
62 | // | ||
63 | IConfig dbConfig = config.Configs["DatabaseService"]; | ||
64 | if (dbConfig != null) | ||
65 | { | ||
66 | if (dllName == String.Empty) | ||
67 | dllName = dbConfig.GetString("StorageProvider", String.Empty); | ||
68 | if (connString == String.Empty) | ||
69 | connString = dbConfig.GetString("ConnectionString", String.Empty); | ||
70 | } | ||
71 | |||
72 | // | ||
73 | // We tried, but this doesn't exist. We can't proceed. | ||
74 | // | ||
75 | if (dllName.Equals(String.Empty)) | ||
76 | throw new Exception("No StorageProvider configured"); | ||
77 | |||
78 | m_Database = LoadPlugin<IRegionData>(dllName, new Object[] { connString, realm }); | ||
79 | if (m_Database == null) | ||
80 | throw new Exception("Could not find a storage interface in the given module"); | ||
81 | |||
82 | } | ||
83 | } | ||
84 | } | ||
diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs index ac4539a..83ab9c1 100644 --- a/OpenSim/Services/Interfaces/IGridService.cs +++ b/OpenSim/Services/Interfaces/IGridService.cs | |||
@@ -39,7 +39,7 @@ namespace OpenSim.Services.Interfaces | |||
39 | /// <param name="regionInfos"> </param> | 39 | /// <param name="regionInfos"> </param> |
40 | /// <returns></returns> | 40 | /// <returns></returns> |
41 | /// <exception cref="System.Exception">Thrown if region registration failed</exception> | 41 | /// <exception cref="System.Exception">Thrown if region registration failed</exception> |
42 | bool RegisterRegion(UUID scopeID, RegionInfo regionInfos); | 42 | bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfos); |
43 | 43 | ||
44 | /// <summary> | 44 | /// <summary> |
45 | /// Deregister a region with the grid service. | 45 | /// Deregister a region with the grid service. |
@@ -50,15 +50,22 @@ namespace OpenSim.Services.Interfaces | |||
50 | bool DeregisterRegion(UUID regionID); | 50 | bool DeregisterRegion(UUID regionID); |
51 | 51 | ||
52 | /// <summary> | 52 | /// <summary> |
53 | /// Get information about the regions neighbouring the given co-ordinates. | 53 | /// Get information about the regions neighbouring the given co-ordinates (in meters). |
54 | /// </summary> | 54 | /// </summary> |
55 | /// <param name="x"></param> | 55 | /// <param name="x"></param> |
56 | /// <param name="y"></param> | 56 | /// <param name="y"></param> |
57 | /// <returns></returns> | 57 | /// <returns></returns> |
58 | List<SimpleRegionInfo> GetNeighbours(UUID scopeID, uint x, uint y); | 58 | List<SimpleRegionInfo> GetNeighbours(UUID scopeID, int x, int y); |
59 | 59 | ||
60 | SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID); | 60 | SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID); |
61 | 61 | ||
62 | /// <summary> | ||
63 | /// Get the region at the given position (in meters) | ||
64 | /// </summary> | ||
65 | /// <param name="scopeID"></param> | ||
66 | /// <param name="x"></param> | ||
67 | /// <param name="y"></param> | ||
68 | /// <returns></returns> | ||
62 | SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y); | 69 | SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y); |
63 | 70 | ||
64 | SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName); | 71 | SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName); |
@@ -78,9 +85,7 @@ namespace OpenSim.Services.Interfaces | |||
78 | /// </returns> | 85 | /// </returns> |
79 | List<SimpleRegionInfo> GetRegionsByName(UUID scopeID, string name, int maxNumber); | 86 | List<SimpleRegionInfo> GetRegionsByName(UUID scopeID, string name, int maxNumber); |
80 | 87 | ||
81 | 88 | List<SimpleRegionInfo> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax); | |
82 | // Not sure about these two (diva) | ||
83 | |||
84 | 89 | ||
85 | } | 90 | } |
86 | } | 91 | } |
diff --git a/prebuild.xml b/prebuild.xml index 79c767c..3e5e1e0 100644 --- a/prebuild.xml +++ b/prebuild.xml | |||
@@ -1383,6 +1383,37 @@ | |||
1383 | </Files> | 1383 | </Files> |
1384 | </Project> | 1384 | </Project> |
1385 | 1385 | ||
1386 | <Project frameworkVersion="v3_5" name="OpenSim.Services.GridService" path="OpenSim/Services/GridService" type="Library"> | ||
1387 | <Configuration name="Debug"> | ||
1388 | <Options> | ||
1389 | <OutputPath>../../../bin/</OutputPath> | ||
1390 | </Options> | ||
1391 | </Configuration> | ||
1392 | <Configuration name="Release"> | ||
1393 | <Options> | ||
1394 | <OutputPath>../../../bin/</OutputPath> | ||
1395 | </Options> | ||
1396 | </Configuration> | ||
1397 | |||
1398 | <ReferencePath>../../../bin/</ReferencePath> | ||
1399 | <Reference name="System"/> | ||
1400 | <Reference name="OpenMetaverseTypes.dll"/> | ||
1401 | <Reference name="OpenMetaverse.dll"/> | ||
1402 | <Reference name="OpenSim.Framework"/> | ||
1403 | <Reference name="OpenSim.Framework.Console"/> | ||
1404 | <Reference name="OpenSim.Framework.Servers.HttpServer"/> | ||
1405 | <Reference name="OpenSim.Services.Interfaces"/> | ||
1406 | <Reference name="OpenSim.Services.Base"/> | ||
1407 | <Reference name="OpenSim.Services.Connectors"/> | ||
1408 | <Reference name="OpenSim.Data"/> | ||
1409 | <Reference name="Nini.dll" /> | ||
1410 | <Reference name="log4net.dll"/> | ||
1411 | |||
1412 | <Files> | ||
1413 | <Match pattern="*.cs" recurse="true"/> | ||
1414 | </Files> | ||
1415 | </Project> | ||
1416 | |||
1386 | <Project frameworkVersion="v3_5" name="OpenSim.Services.InventoryService" path="OpenSim/Services/InventoryService" type="Library"> | 1417 | <Project frameworkVersion="v3_5" name="OpenSim.Services.InventoryService" path="OpenSim/Services/InventoryService" type="Library"> |
1387 | <Configuration name="Debug"> | 1418 | <Configuration name="Debug"> |
1388 | <Options> | 1419 | <Options> |