aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/GridServer/GridDBService.cs
diff options
context:
space:
mode:
authorJeff Ames2009-02-22 01:18:49 +0000
committerJeff Ames2009-02-22 01:18:49 +0000
commit551bebdc84515d77bc3d7a564100efd0525a1949 (patch)
tree1e3300c3a60d51a5607b69ee357f1d08936014f3 /OpenSim/Grid/GridServer/GridDBService.cs
parentApplied patch from mantis #3217, which allows Dynamic Images of type RGB (so ... (diff)
downloadopensim-SC_OLD-551bebdc84515d77bc3d7a564100efd0525a1949.zip
opensim-SC_OLD-551bebdc84515d77bc3d7a564100efd0525a1949.tar.gz
opensim-SC_OLD-551bebdc84515d77bc3d7a564100efd0525a1949.tar.bz2
opensim-SC_OLD-551bebdc84515d77bc3d7a564100efd0525a1949.tar.xz
Update svn properties, add copyright headers, minor formatting cleanup.
Diffstat (limited to 'OpenSim/Grid/GridServer/GridDBService.cs')
-rw-r--r--OpenSim/Grid/GridServer/GridDBService.cs568
1 files changed, 284 insertions, 284 deletions
diff --git a/OpenSim/Grid/GridServer/GridDBService.cs b/OpenSim/Grid/GridServer/GridDBService.cs
index cc244a9..f58f42b 100644
--- a/OpenSim/Grid/GridServer/GridDBService.cs
+++ b/OpenSim/Grid/GridServer/GridDBService.cs
@@ -1,284 +1,284 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright 9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the 12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products 13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 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 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 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 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. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.IO; 31using System.IO;
32using System.Reflection; 32using System.Reflection;
33using System.Xml; 33using System.Xml;
34using log4net; 34using log4net;
35using Nwc.XmlRpc; 35using Nwc.XmlRpc;
36using OpenMetaverse; 36using OpenMetaverse;
37using OpenSim.Data; 37using OpenSim.Data;
38using OpenSim.Framework; 38using OpenSim.Framework;
39using OpenSim.Framework.Communications; 39using OpenSim.Framework.Communications;
40using OpenSim.Framework.Servers; 40using OpenSim.Framework.Servers;
41 41
42 42
43namespace OpenSim.Grid.GridServer 43namespace OpenSim.Grid.GridServer
44{ 44{
45 public class GridDBService 45 public class GridDBService
46 { 46 {
47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48 48
49 private List<IGridDataPlugin> _plugins = new List<IGridDataPlugin>(); 49 private List<IGridDataPlugin> _plugins = new List<IGridDataPlugin>();
50 private List<ILogDataPlugin> _logplugins = new List<ILogDataPlugin>(); 50 private List<ILogDataPlugin> _logplugins = new List<ILogDataPlugin>();
51 51
52 /// <summary> 52 /// <summary>
53 /// Adds a list of grid and log data plugins, as described by 53 /// Adds a list of grid and log data plugins, as described by
54 /// `provider' and `connect', to `_plugins' and `_logplugins', 54 /// `provider' and `connect', to `_plugins' and `_logplugins',
55 /// respectively. 55 /// respectively.
56 /// </summary> 56 /// </summary>
57 /// <param name="provider"> 57 /// <param name="provider">
58 /// The filename of the inventory server plugin DLL. 58 /// The filename of the inventory server plugin DLL.
59 /// </param> 59 /// </param>
60 /// <param name="connect"> 60 /// <param name="connect">
61 /// The connection string for the storage backend. 61 /// The connection string for the storage backend.
62 /// </param> 62 /// </param>
63 public void AddPlugin(string provider, string connect) 63 public void AddPlugin(string provider, string connect)
64 { 64 {
65 _plugins = DataPluginFactory.LoadDataPlugins<IGridDataPlugin>(provider, connect); 65 _plugins = DataPluginFactory.LoadDataPlugins<IGridDataPlugin>(provider, connect);
66 _logplugins = DataPluginFactory.LoadDataPlugins<ILogDataPlugin>(provider, connect); 66 _logplugins = DataPluginFactory.LoadDataPlugins<ILogDataPlugin>(provider, connect);
67 } 67 }
68 68
69 public int GetNumberOfPlugins() 69 public int GetNumberOfPlugins()
70 { 70 {
71 return _plugins.Count; 71 return _plugins.Count;
72 } 72 }
73 73
74 /// <summary> 74 /// <summary>
75 /// Logs a piece of information to the database 75 /// Logs a piece of information to the database
76 /// </summary> 76 /// </summary>
77 /// <param name="target">What you were operating on (in grid server, this will likely be the region UUIDs)</param> 77 /// <param name="target">What you were operating on (in grid server, this will likely be the region UUIDs)</param>
78 /// <param name="method">Which method is being called?</param> 78 /// <param name="method">Which method is being called?</param>
79 /// <param name="args">What arguments are being passed?</param> 79 /// <param name="args">What arguments are being passed?</param>
80 /// <param name="priority">How high priority is this? 1 = Max, 6 = Verbose</param> 80 /// <param name="priority">How high priority is this? 1 = Max, 6 = Verbose</param>
81 /// <param name="message">The message to log</param> 81 /// <param name="message">The message to log</param>
82 private void logToDB(string target, string method, string args, int priority, string message) 82 private void logToDB(string target, string method, string args, int priority, string message)
83 { 83 {
84 foreach (ILogDataPlugin plugin in _logplugins) 84 foreach (ILogDataPlugin plugin in _logplugins)
85 { 85 {
86 try 86 try
87 { 87 {
88 plugin.saveLog("Gridserver", target, method, args, priority, message); 88 plugin.saveLog("Gridserver", target, method, args, priority, message);
89 } 89 }
90 catch (Exception) 90 catch (Exception)
91 { 91 {
92 m_log.Warn("[storage]: Unable to write log via " + plugin.Name); 92 m_log.Warn("[storage]: Unable to write log via " + plugin.Name);
93 } 93 }
94 } 94 }
95 } 95 }
96 96
97 /// <summary> 97 /// <summary>
98 /// Returns a region by argument 98 /// Returns a region by argument
99 /// </summary> 99 /// </summary>
100 /// <param name="uuid">A UUID key of the region to return</param> 100 /// <param name="uuid">A UUID key of the region to return</param>
101 /// <returns>A SimProfileData for the region</returns> 101 /// <returns>A SimProfileData for the region</returns>
102 public RegionProfileData GetRegion(UUID uuid) 102 public RegionProfileData GetRegion(UUID uuid)
103 { 103 {
104 foreach (IGridDataPlugin plugin in _plugins) 104 foreach (IGridDataPlugin plugin in _plugins)
105 { 105 {
106 try 106 try
107 { 107 {
108 return plugin.GetProfileByUUID(uuid); 108 return plugin.GetProfileByUUID(uuid);
109 } 109 }
110 catch (Exception e) 110 catch (Exception e)
111 { 111 {
112 m_log.Warn("[storage]: GetRegion - " + e.Message); 112 m_log.Warn("[storage]: GetRegion - " + e.Message);
113 } 113 }
114 } 114 }
115 return null; 115 return null;
116 } 116 }
117 117
118 /// <summary> 118 /// <summary>
119 /// Returns a region by argument 119 /// Returns a region by argument
120 /// </summary> 120 /// </summary>
121 /// <param name="uuid">A regionHandle of the region to return</param> 121 /// <param name="uuid">A regionHandle of the region to return</param>
122 /// <returns>A SimProfileData for the region</returns> 122 /// <returns>A SimProfileData for the region</returns>
123 public RegionProfileData GetRegion(ulong handle) 123 public RegionProfileData GetRegion(ulong handle)
124 { 124 {
125 foreach (IGridDataPlugin plugin in _plugins) 125 foreach (IGridDataPlugin plugin in _plugins)
126 { 126 {
127 try 127 try
128 { 128 {
129 return plugin.GetProfileByHandle(handle); 129 return plugin.GetProfileByHandle(handle);
130 } 130 }
131 catch (Exception ex) 131 catch (Exception ex)
132 { 132 {
133 m_log.Debug("[storage]: " + ex.Message); 133 m_log.Debug("[storage]: " + ex.Message);
134 m_log.Warn("[storage]: Unable to find region " + handle.ToString() + " via " + plugin.Name); 134 m_log.Warn("[storage]: Unable to find region " + handle.ToString() + " via " + plugin.Name);
135 } 135 }
136 } 136 }
137 return null; 137 return null;
138 } 138 }
139 139
140 /// <summary> 140 /// <summary>
141 /// Returns a region by argument 141 /// Returns a region by argument
142 /// </summary> 142 /// </summary>
143 /// <param name="regionName">A partial regionName of the region to return</param> 143 /// <param name="regionName">A partial regionName of the region to return</param>
144 /// <returns>A SimProfileData for the region</returns> 144 /// <returns>A SimProfileData for the region</returns>
145 public RegionProfileData GetRegion(string regionName) 145 public RegionProfileData GetRegion(string regionName)
146 { 146 {
147 foreach (IGridDataPlugin plugin in _plugins) 147 foreach (IGridDataPlugin plugin in _plugins)
148 { 148 {
149 try 149 try
150 { 150 {
151 return plugin.GetProfileByString(regionName); 151 return plugin.GetProfileByString(regionName);
152 } 152 }
153 catch 153 catch
154 { 154 {
155 m_log.Warn("[storage]: Unable to find region " + regionName + " via " + plugin.Name); 155 m_log.Warn("[storage]: Unable to find region " + regionName + " via " + plugin.Name);
156 } 156 }
157 } 157 }
158 return null; 158 return null;
159 } 159 }
160 160
161 public List<RegionProfileData> GetRegions(uint xmin, uint ymin, uint xmax, uint ymax) 161 public List<RegionProfileData> GetRegions(uint xmin, uint ymin, uint xmax, uint ymax)
162 { 162 {
163 List<RegionProfileData> regions = new List<RegionProfileData>(); 163 List<RegionProfileData> regions = new List<RegionProfileData>();
164 164
165 foreach (IGridDataPlugin plugin in _plugins) 165 foreach (IGridDataPlugin plugin in _plugins)
166 { 166 {
167 try 167 try
168 { 168 {
169 regions.AddRange(plugin.GetProfilesInRange(xmin, ymin, xmax, ymax)); 169 regions.AddRange(plugin.GetProfilesInRange(xmin, ymin, xmax, ymax));
170 } 170 }
171 catch 171 catch
172 { 172 {
173 m_log.Warn("[storage]: Unable to query regionblock via " + plugin.Name); 173 m_log.Warn("[storage]: Unable to query regionblock via " + plugin.Name);
174 } 174 }
175 } 175 }
176 176
177 return regions; 177 return regions;
178 } 178 }
179 179
180 public List<RegionProfileData> GetRegions(string name, int maxNum) 180 public List<RegionProfileData> GetRegions(string name, int maxNum)
181 { 181 {
182 List<RegionProfileData> regions = new List<RegionProfileData>(); 182 List<RegionProfileData> regions = new List<RegionProfileData>();
183 foreach (IGridDataPlugin plugin in _plugins) 183 foreach (IGridDataPlugin plugin in _plugins)
184 { 184 {
185 try 185 try
186 { 186 {
187 int num = maxNum - regions.Count; 187 int num = maxNum - regions.Count;
188 List<RegionProfileData> profiles = plugin.GetRegionsByName(name, (uint)num); 188 List<RegionProfileData> profiles = plugin.GetRegionsByName(name, (uint)num);
189 if (profiles != null) regions.AddRange(profiles); 189 if (profiles != null) regions.AddRange(profiles);
190 } 190 }
191 catch 191 catch
192 { 192 {
193 m_log.Warn("[storage]: Unable to query regionblock via " + plugin.Name); 193 m_log.Warn("[storage]: Unable to query regionblock via " + plugin.Name);
194 } 194 }
195 } 195 }
196 196
197 return regions; 197 return regions;
198 } 198 }
199 199
200 public DataResponse AddUpdateRegion(RegionProfileData sim, RegionProfileData existingSim) 200 public DataResponse AddUpdateRegion(RegionProfileData sim, RegionProfileData existingSim)
201 { 201 {
202 DataResponse insertResponse = DataResponse.RESPONSE_ERROR; 202 DataResponse insertResponse = DataResponse.RESPONSE_ERROR;
203 foreach (IGridDataPlugin plugin in _plugins) 203 foreach (IGridDataPlugin plugin in _plugins)
204 { 204 {
205 try 205 try
206 { 206 {
207 if (existingSim == null) 207 if (existingSim == null)
208 { 208 {
209 insertResponse = plugin.AddProfile(sim); 209 insertResponse = plugin.AddProfile(sim);
210 } 210 }
211 else 211 else
212 { 212 {
213 insertResponse = plugin.UpdateProfile(sim); 213 insertResponse = plugin.UpdateProfile(sim);
214 } 214 }
215 } 215 }
216 catch (Exception e) 216 catch (Exception e)
217 { 217 {
218 m_log.Warn("[LOGIN END]: " + 218 m_log.Warn("[LOGIN END]: " +
219 "Unable to login region " + sim.ToString() + " via " + plugin.Name); 219 "Unable to login region " + sim.ToString() + " via " + plugin.Name);
220 m_log.Warn("[LOGIN END]: " + e.ToString()); 220 m_log.Warn("[LOGIN END]: " + e.ToString());
221 } 221 }
222 } 222 }
223 return insertResponse; 223 return insertResponse;
224 } 224 }
225 225
226 public DataResponse DeleteRegion(string uuid) 226 public DataResponse DeleteRegion(string uuid)
227 { 227 {
228 DataResponse insertResponse = DataResponse.RESPONSE_ERROR; 228 DataResponse insertResponse = DataResponse.RESPONSE_ERROR;
229 foreach (IGridDataPlugin plugin in _plugins) 229 foreach (IGridDataPlugin plugin in _plugins)
230 { 230 {
231 //OpenSim.Data.MySQL.MySQLGridData dbengine = new OpenSim.Data.MySQL.MySQLGridData(); 231 //OpenSim.Data.MySQL.MySQLGridData dbengine = new OpenSim.Data.MySQL.MySQLGridData();
232 try 232 try
233 { 233 {
234 //Nice are we not using multiple databases? 234 //Nice are we not using multiple databases?
235 //MySQLGridData mysqldata = (MySQLGridData)(plugin); 235 //MySQLGridData mysqldata = (MySQLGridData)(plugin);
236 236
237 //DataResponse insertResponse = mysqldata.DeleteProfile(TheSim); 237 //DataResponse insertResponse = mysqldata.DeleteProfile(TheSim);
238 insertResponse = plugin.DeleteProfile(uuid); 238 insertResponse = plugin.DeleteProfile(uuid);
239 } 239 }
240 catch (Exception) 240 catch (Exception)
241 { 241 {
242 m_log.Error("storage Unable to delete region " + uuid + " via " + plugin.Name); 242 m_log.Error("storage Unable to delete region " + uuid + " via " + plugin.Name);
243 //MainLog.Instance.Warn("storage", e.ToString()); 243 //MainLog.Instance.Warn("storage", e.ToString());
244 insertResponse = DataResponse.RESPONSE_ERROR; 244 insertResponse = DataResponse.RESPONSE_ERROR;
245 } 245 }
246 } 246 }
247 return insertResponse; 247 return insertResponse;
248 } 248 }
249 249
250 public string CheckReservations(RegionProfileData theSim, XmlNode authkeynode) 250 public string CheckReservations(RegionProfileData theSim, XmlNode authkeynode)
251 { 251 {
252 foreach (IGridDataPlugin plugin in _plugins) 252 foreach (IGridDataPlugin plugin in _plugins)
253 { 253 {
254 try 254 try
255 { 255 {
256 //Check reservations 256 //Check reservations
257 ReservationData reserveData = 257 ReservationData reserveData =
258 plugin.GetReservationAtPoint(theSim.regionLocX, theSim.regionLocY); 258 plugin.GetReservationAtPoint(theSim.regionLocX, theSim.regionLocY);
259 if ((reserveData != null && reserveData.gridRecvKey == theSim.regionRecvKey) || 259 if ((reserveData != null && reserveData.gridRecvKey == theSim.regionRecvKey) ||
260 (reserveData == null && authkeynode.InnerText != theSim.regionRecvKey)) 260 (reserveData == null && authkeynode.InnerText != theSim.regionRecvKey))
261 { 261 {
262 plugin.AddProfile(theSim); 262 plugin.AddProfile(theSim);
263 m_log.Info("[grid]: New sim added to grid (" + theSim.regionName + ")"); 263 m_log.Info("[grid]: New sim added to grid (" + theSim.regionName + ")");
264 logToDB(theSim.ToString(), "RestSetSimMethod", String.Empty, 5, 264 logToDB(theSim.ToString(), "RestSetSimMethod", String.Empty, 5,
265 "Region successfully updated and connected to grid."); 265 "Region successfully updated and connected to grid.");
266 } 266 }
267 else 267 else
268 { 268 {
269 m_log.Warn("[grid]: " + 269 m_log.Warn("[grid]: " +
270 "Unable to update region (RestSetSimMethod): Incorrect reservation auth key."); 270 "Unable to update region (RestSetSimMethod): Incorrect reservation auth key.");
271 // Wanted: " + reserveData.gridRecvKey + ", Got: " + theSim.regionRecvKey + "."); 271 // Wanted: " + reserveData.gridRecvKey + ", Got: " + theSim.regionRecvKey + ".");
272 return "Unable to update region (RestSetSimMethod): Incorrect auth key."; 272 return "Unable to update region (RestSetSimMethod): Incorrect auth key.";
273 } 273 }
274 } 274 }
275 catch (Exception e) 275 catch (Exception e)
276 { 276 {
277 m_log.Warn("[GRID]: GetRegionPlugin Handle " + plugin.Name + " unable to add new sim: " + 277 m_log.Warn("[GRID]: GetRegionPlugin Handle " + plugin.Name + " unable to add new sim: " +
278 e.ToString()); 278 e.ToString());
279 } 279 }
280 } 280 }
281 return "OK"; 281 return "OK";
282 } 282 }
283 } 283 }
284} 284}