diff options
Diffstat (limited to 'OpenSim/Services')
-rw-r--r-- | OpenSim/Services/Connectors/Grid/GridServiceConnector.cs | 16 | ||||
-rw-r--r-- | OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs | 151 | ||||
-rw-r--r-- | OpenSim/Services/GridService/GridService.cs | 19 |
3 files changed, 173 insertions, 13 deletions
diff --git a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs index ae7db7e..1962bcf 100644 --- a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs +++ b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs | |||
@@ -85,7 +85,7 @@ namespace OpenSim.Services.Connectors | |||
85 | 85 | ||
86 | #region IGridService | 86 | #region IGridService |
87 | 87 | ||
88 | public bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfo) | 88 | public virtual bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfo) |
89 | { | 89 | { |
90 | Dictionary<string, object> rinfo = regionInfo.ToKeyValuePairs(); | 90 | Dictionary<string, object> rinfo = regionInfo.ToKeyValuePairs(); |
91 | Dictionary<string, string> sendData = new Dictionary<string,string>(); | 91 | Dictionary<string, string> sendData = new Dictionary<string,string>(); |
@@ -108,7 +108,7 @@ namespace OpenSim.Services.Connectors | |||
108 | return false; | 108 | return false; |
109 | } | 109 | } |
110 | 110 | ||
111 | public bool DeregisterRegion(UUID regionID) | 111 | public virtual bool DeregisterRegion(UUID regionID) |
112 | { | 112 | { |
113 | Dictionary<string, string> sendData = new Dictionary<string, string>(); | 113 | Dictionary<string, string> sendData = new Dictionary<string, string>(); |
114 | 114 | ||
@@ -128,7 +128,7 @@ namespace OpenSim.Services.Connectors | |||
128 | return false; | 128 | return false; |
129 | } | 129 | } |
130 | 130 | ||
131 | public List<SimpleRegionInfo> GetNeighbours(UUID scopeID, UUID regionID) | 131 | public virtual List<SimpleRegionInfo> GetNeighbours(UUID scopeID, UUID regionID) |
132 | { | 132 | { |
133 | Dictionary<string, string> sendData = new Dictionary<string, string>(); | 133 | Dictionary<string, string> sendData = new Dictionary<string, string>(); |
134 | 134 | ||
@@ -166,7 +166,7 @@ namespace OpenSim.Services.Connectors | |||
166 | return rinfos; | 166 | return rinfos; |
167 | } | 167 | } |
168 | 168 | ||
169 | public SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID) | 169 | public virtual SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID) |
170 | { | 170 | { |
171 | Dictionary<string, string> sendData = new Dictionary<string, string>(); | 171 | Dictionary<string, string> sendData = new Dictionary<string, string>(); |
172 | 172 | ||
@@ -197,7 +197,7 @@ namespace OpenSim.Services.Connectors | |||
197 | return rinfo; | 197 | return rinfo; |
198 | } | 198 | } |
199 | 199 | ||
200 | public SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y) | 200 | public virtual SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y) |
201 | { | 201 | { |
202 | Dictionary<string, string> sendData = new Dictionary<string, string>(); | 202 | Dictionary<string, string> sendData = new Dictionary<string, string>(); |
203 | 203 | ||
@@ -229,7 +229,7 @@ namespace OpenSim.Services.Connectors | |||
229 | return rinfo; | 229 | return rinfo; |
230 | } | 230 | } |
231 | 231 | ||
232 | public SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName) | 232 | public virtual SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName) |
233 | { | 233 | { |
234 | Dictionary<string, string> sendData = new Dictionary<string, string>(); | 234 | Dictionary<string, string> sendData = new Dictionary<string, string>(); |
235 | 235 | ||
@@ -260,7 +260,7 @@ namespace OpenSim.Services.Connectors | |||
260 | return rinfo; | 260 | return rinfo; |
261 | } | 261 | } |
262 | 262 | ||
263 | public List<SimpleRegionInfo> GetRegionsByName(UUID scopeID, string name, int maxNumber) | 263 | public virtual List<SimpleRegionInfo> GetRegionsByName(UUID scopeID, string name, int maxNumber) |
264 | { | 264 | { |
265 | Dictionary<string, string> sendData = new Dictionary<string, string>(); | 265 | Dictionary<string, string> sendData = new Dictionary<string, string>(); |
266 | 266 | ||
@@ -299,7 +299,7 @@ namespace OpenSim.Services.Connectors | |||
299 | return rinfos; | 299 | return rinfos; |
300 | } | 300 | } |
301 | 301 | ||
302 | public List<SimpleRegionInfo> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) | 302 | public virtual List<SimpleRegionInfo> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) |
303 | { | 303 | { |
304 | Dictionary<string, string> sendData = new Dictionary<string, string>(); | 304 | Dictionary<string, string> sendData = new Dictionary<string, string>(); |
305 | 305 | ||
diff --git a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs new file mode 100644 index 0000000..6b0518c --- /dev/null +++ b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs | |||
@@ -0,0 +1,151 @@ | |||
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; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Text; | ||
32 | using System.Drawing; | ||
33 | using System.Net; | ||
34 | using System.Reflection; | ||
35 | using OpenSim.Services.Interfaces; | ||
36 | |||
37 | using OpenSim.Framework; | ||
38 | |||
39 | using OpenMetaverse; | ||
40 | using OpenMetaverse.Imaging; | ||
41 | using log4net; | ||
42 | using Nwc.XmlRpc; | ||
43 | |||
44 | namespace OpenSim.Services.Connectors.Grid | ||
45 | { | ||
46 | public class HypergridServiceConnector | ||
47 | { | ||
48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
49 | |||
50 | private IAssetService m_AssetService; | ||
51 | |||
52 | public HypergridServiceConnector(IAssetService assService) | ||
53 | { | ||
54 | m_AssetService = assService; | ||
55 | } | ||
56 | |||
57 | public UUID LinkRegion(SimpleRegionInfo info, out ulong realHandle) | ||
58 | { | ||
59 | UUID uuid = UUID.Zero; | ||
60 | realHandle = 0; | ||
61 | |||
62 | Hashtable hash = new Hashtable(); | ||
63 | hash["region_name"] = info.RegionName; | ||
64 | |||
65 | IList paramList = new ArrayList(); | ||
66 | paramList.Add(hash); | ||
67 | |||
68 | XmlRpcRequest request = new XmlRpcRequest("link_region", paramList); | ||
69 | string uri = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/"; | ||
70 | m_log.Debug("[HGrid]: Linking to " + uri); | ||
71 | XmlRpcResponse response = request.Send(uri, 10000); | ||
72 | if (response.IsFault) | ||
73 | { | ||
74 | m_log.ErrorFormat("[HGrid]: remote call returned an error: {0}", response.FaultString); | ||
75 | } | ||
76 | else | ||
77 | { | ||
78 | hash = (Hashtable)response.Value; | ||
79 | //foreach (Object o in hash) | ||
80 | // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); | ||
81 | try | ||
82 | { | ||
83 | UUID.TryParse((string)hash["uuid"], out uuid); | ||
84 | info.RegionID = uuid; | ||
85 | if ((string)hash["handle"] != null) | ||
86 | { | ||
87 | realHandle = Convert.ToUInt64((string)hash["handle"]); | ||
88 | m_log.Debug(">> HERE, realHandle: " + realHandle); | ||
89 | } | ||
90 | //if (hash["region_image"] != null) | ||
91 | //{ | ||
92 | // UUID img = UUID.Zero; | ||
93 | // UUID.TryParse((string)hash["region_image"], out img); | ||
94 | // info.RegionSettings.TerrainImageID = img; | ||
95 | //} | ||
96 | if (hash["region_name"] != null) | ||
97 | { | ||
98 | info.RegionName = (string)hash["region_name"]; | ||
99 | //m_log.Debug(">> " + info.RegionName); | ||
100 | } | ||
101 | if (hash["internal_port"] != null) | ||
102 | { | ||
103 | int port = Convert.ToInt32((string)hash["internal_port"]); | ||
104 | info.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), port); | ||
105 | //m_log.Debug(">> " + info.InternalEndPoint.ToString()); | ||
106 | } | ||
107 | |||
108 | } | ||
109 | catch (Exception e) | ||
110 | { | ||
111 | m_log.Error("[HGrid]: Got exception while parsing hyperlink response " + e.StackTrace); | ||
112 | } | ||
113 | } | ||
114 | return uuid; | ||
115 | } | ||
116 | |||
117 | public void GetMapImage(SimpleRegionInfo info) | ||
118 | { | ||
119 | try | ||
120 | { | ||
121 | string regionimage = "regionImage" + info.RegionID.ToString(); | ||
122 | regionimage = regionimage.Replace("-", ""); | ||
123 | |||
124 | WebClient c = new WebClient(); | ||
125 | string uri = "http://" + info.ExternalHostName + ":" + info.HttpPort + "/index.php?method=" + regionimage; | ||
126 | //m_log.Debug("JPEG: " + uri); | ||
127 | c.DownloadFile(uri, info.RegionID.ToString() + ".jpg"); | ||
128 | Bitmap m = new Bitmap(info.RegionID.ToString() + ".jpg"); | ||
129 | //m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width); | ||
130 | byte[] imageData = OpenJPEG.EncodeFromImage(m, true); | ||
131 | AssetBase ass = new AssetBase(UUID.Random(), "region " + info.RegionID.ToString()); | ||
132 | |||
133 | // !!! for now | ||
134 | //info.RegionSettings.TerrainImageID = ass.FullID; | ||
135 | |||
136 | ass.Type = (int)AssetType.Texture; | ||
137 | ass.Temporary = true; | ||
138 | ass.Local = true; | ||
139 | ass.Data = imageData; | ||
140 | |||
141 | m_AssetService.Store(ass); | ||
142 | |||
143 | } | ||
144 | catch // LEGIT: Catching problems caused by OpenJPEG p/invoke | ||
145 | { | ||
146 | m_log.Warn("[HGrid]: Failed getting/storing map image, because it is probably already in the cache"); | ||
147 | } | ||
148 | } | ||
149 | |||
150 | } | ||
151 | } | ||
diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 2229421..b37a51b 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs | |||
@@ -95,7 +95,9 @@ namespace OpenSim.Services.GridService | |||
95 | if (region != null) | 95 | if (region != null) |
96 | { | 96 | { |
97 | // Not really? Maybe? | 97 | // Not really? Maybe? |
98 | List<RegionData> rdatas = m_Database.Get(region.posX - 1, region.posY - 1, region.posX + 1, region.posY + 1, scopeID); | 98 | List<RegionData> rdatas = m_Database.Get(region.posX - (int)Constants.RegionSize, region.posY - (int)Constants.RegionSize, |
99 | region.posX + (int)Constants.RegionSize, region.posY + (int)Constants.RegionSize, scopeID); | ||
100 | |||
99 | foreach (RegionData rdata in rdatas) | 101 | foreach (RegionData rdata in rdatas) |
100 | rinfos.Add(RegionData2RegionInfo(rdata)); | 102 | rinfos.Add(RegionData2RegionInfo(rdata)); |
101 | 103 | ||
@@ -114,7 +116,9 @@ namespace OpenSim.Services.GridService | |||
114 | 116 | ||
115 | public SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y) | 117 | public SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y) |
116 | { | 118 | { |
117 | RegionData rdata = m_Database.Get(x, y, scopeID); | 119 | int snapX = (int)(x / Constants.RegionSize) * (int)Constants.RegionSize; |
120 | int snapY = (int)(y / Constants.RegionSize) * (int)Constants.RegionSize; | ||
121 | RegionData rdata = m_Database.Get(snapX, snapY, scopeID); | ||
118 | if (rdata != null) | 122 | if (rdata != null) |
119 | return RegionData2RegionInfo(rdata); | 123 | return RegionData2RegionInfo(rdata); |
120 | 124 | ||
@@ -151,7 +155,12 @@ namespace OpenSim.Services.GridService | |||
151 | 155 | ||
152 | public List<SimpleRegionInfo> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) | 156 | public List<SimpleRegionInfo> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) |
153 | { | 157 | { |
154 | List<RegionData> rdatas = m_Database.Get(xmin, ymin, xmax, ymax, scopeID); | 158 | int xminSnap = (int)(xmin / Constants.RegionSize) * (int)Constants.RegionSize; |
159 | int xmaxSnap = (int)(xmax / Constants.RegionSize) * (int)Constants.RegionSize; | ||
160 | int yminSnap = (int)(ymin / Constants.RegionSize) * (int)Constants.RegionSize; | ||
161 | int ymaxSnap = (int)(ymax / Constants.RegionSize) * (int)Constants.RegionSize; | ||
162 | |||
163 | List<RegionData> rdatas = m_Database.Get(xminSnap, yminSnap, xmaxSnap, ymaxSnap, scopeID); | ||
155 | List<SimpleRegionInfo> rinfos = new List<SimpleRegionInfo>(); | 164 | List<SimpleRegionInfo> rinfos = new List<SimpleRegionInfo>(); |
156 | foreach (RegionData rdata in rdatas) | 165 | foreach (RegionData rdata in rdatas) |
157 | rinfos.Add(RegionData2RegionInfo(rdata)); | 166 | rinfos.Add(RegionData2RegionInfo(rdata)); |
@@ -170,7 +179,7 @@ namespace OpenSim.Services.GridService | |||
170 | rdata.posY = (int)rinfo.RegionLocY; | 179 | rdata.posY = (int)rinfo.RegionLocY; |
171 | rdata.RegionID = rinfo.RegionID; | 180 | rdata.RegionID = rinfo.RegionID; |
172 | rdata.Data = rinfo.ToKeyValuePairs(); | 181 | rdata.Data = rinfo.ToKeyValuePairs(); |
173 | //rdata.RegionName = rinfo.RegionName; | 182 | rdata.RegionName = rinfo.RegionName; |
174 | 183 | ||
175 | return rdata; | 184 | return rdata; |
176 | } | 185 | } |
@@ -181,7 +190,7 @@ namespace OpenSim.Services.GridService | |||
181 | rinfo.RegionLocX = (uint)rdata.posX; | 190 | rinfo.RegionLocX = (uint)rdata.posX; |
182 | rinfo.RegionLocY = (uint)rdata.posY; | 191 | rinfo.RegionLocY = (uint)rdata.posY; |
183 | rinfo.RegionID = rdata.RegionID; | 192 | rinfo.RegionID = rdata.RegionID; |
184 | //rinfo.RegionName = rdata.RegionName; | 193 | rinfo.RegionName = rdata.RegionName; |
185 | 194 | ||
186 | return rinfo; | 195 | return rinfo; |
187 | } | 196 | } |