aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data
diff options
context:
space:
mode:
authorMike Mazur2009-03-09 07:29:34 +0000
committerMike Mazur2009-03-09 07:29:34 +0000
commita2f07ecd2e248966957a8ea70d772276359b02e8 (patch)
tree5050ec85024e44e4946bfc29782875b3f50f5d37 /OpenSim/Data
parent* Tweak llMoveToTarget per mantis 3265 (diff)
downloadopensim-SC_OLD-a2f07ecd2e248966957a8ea70d772276359b02e8.zip
opensim-SC_OLD-a2f07ecd2e248966957a8ea70d772276359b02e8.tar.gz
opensim-SC_OLD-a2f07ecd2e248966957a8ea70d772276359b02e8.tar.bz2
opensim-SC_OLD-a2f07ecd2e248966957a8ea70d772276359b02e8.tar.xz
Implemented FetchAssetMetadataSet in DB backends.
This method fetches metadata for a subset of the entries in the assets database. This functionality is used in the ForEach calls in the asset storage providers in AssetInventoryServer. With this implemented, frontends such as the BrowseFrontend should now work. - MySQL: implemented, sanity tested - SQLite: implemented, sanity tested - MSSQL: implemented, not tested - NHibernate: not implemented
Diffstat (limited to 'OpenSim/Data')
-rw-r--r--OpenSim/Data/AssetDataBase.cs3
-rw-r--r--OpenSim/Data/IAssetData.cs2
-rw-r--r--OpenSim/Data/MSSQL/MSSQLAssetData.cs36
-rw-r--r--OpenSim/Data/MySQL/MySQLAssetData.cs51
-rw-r--r--OpenSim/Data/NHibernate/NHibernateAssetData.cs15
-rw-r--r--OpenSim/Data/SQLite/SQLiteAssetData.cs50
6 files changed, 157 insertions, 0 deletions
diff --git a/OpenSim/Data/AssetDataBase.cs b/OpenSim/Data/AssetDataBase.cs
index 2cdbbe1..d699f17 100644
--- a/OpenSim/Data/AssetDataBase.cs
+++ b/OpenSim/Data/AssetDataBase.cs
@@ -25,6 +25,7 @@
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.Collections.Generic;
28using OpenMetaverse; 29using OpenMetaverse;
29using OpenSim.Framework; 30using OpenSim.Framework;
30 31
@@ -37,6 +38,8 @@ namespace OpenSim.Data
37 public abstract void UpdateAsset(AssetBase asset); 38 public abstract void UpdateAsset(AssetBase asset);
38 public abstract bool ExistsAsset(UUID uuid); 39 public abstract bool ExistsAsset(UUID uuid);
39 40
41 public abstract List<AssetMetadata> FetchAssetMetadataSet(int start, int count);
42
40 public abstract string Version { get; } 43 public abstract string Version { get; }
41 public abstract string Name { get; } 44 public abstract string Name { get; }
42 public abstract void Initialise(string connect); 45 public abstract void Initialise(string connect);
diff --git a/OpenSim/Data/IAssetData.cs b/OpenSim/Data/IAssetData.cs
index 47e25f3..ddbc10f 100644
--- a/OpenSim/Data/IAssetData.cs
+++ b/OpenSim/Data/IAssetData.cs
@@ -25,6 +25,7 @@
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.Collections.Generic;
28using OpenMetaverse; 29using OpenMetaverse;
29using OpenSim.Framework; 30using OpenSim.Framework;
30 31
@@ -36,6 +37,7 @@ namespace OpenSim.Data
36 void CreateAsset(AssetBase asset); 37 void CreateAsset(AssetBase asset);
37 void UpdateAsset(AssetBase asset); 38 void UpdateAsset(AssetBase asset);
38 bool ExistsAsset(UUID uuid); 39 bool ExistsAsset(UUID uuid);
40 List<AssetMetadata> FetchAssetMetadataSet(int start, int count);
39 void Initialise(string connect); 41 void Initialise(string connect);
40 } 42 }
41 43
diff --git a/OpenSim/Data/MSSQL/MSSQLAssetData.cs b/OpenSim/Data/MSSQL/MSSQLAssetData.cs
index 61db8f5..edacf08 100644
--- a/OpenSim/Data/MSSQL/MSSQLAssetData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLAssetData.cs
@@ -28,6 +28,7 @@
28using System; 28using System;
29using System.Data; 29using System.Data;
30using System.Reflection; 30using System.Reflection;
31using System.Collections.Generic;
31using OpenMetaverse; 32using OpenMetaverse;
32using log4net; 33using log4net;
33using OpenSim.Framework; 34using OpenSim.Framework;
@@ -245,6 +246,41 @@ namespace OpenSim.Data.MSSQL
245 return false; 246 return false;
246 } 247 }
247 248
249 /// <summary>
250 /// Returns a list of AssetMetadata objects. The list is a subset of
251 /// the entire data set offset by <paramref name="start" /> containing
252 /// <paramref name="count" /> elements.
253 /// </summary>
254 /// <param name="start">The number of results to discard from the total data set.</param>
255 /// <param name="count">The number of rows the returned list should contain.</param>
256 /// <returns>A list of AssetMetadata objects.</returns>
257 public override List<AssetMetadata> FetchAssetMetadataSet(int start, int count)
258 {
259 List<AssetMetadata> retList = new List<AssetMetadata>(count);
260
261 using (AutoClosingSqlCommand command = database.Query("SELECT name,description,assetType,temporary,id FROM assets LIMIT @start, @count"))
262 {
263 command.Parameters.Add(database.CreateParameter("start", start));
264 command.Parameters.Add(database.CreateParameter("count", count));
265
266 using (IDataReader reader = command.ExecuteReader())
267 {
268 while (reader.Read())
269 {
270 AssetMetadata metadata = new AssetMetadata();
271 // Region Main
272 metadata.FullID = new UUID((Guid)reader["id"]);
273 metadata.Name = (string)reader["name"];
274 metadata.Description = (string)reader["description"];
275 metadata.Type = Convert.ToSByte(reader["assetType"]);
276 metadata.Temporary = Convert.ToBoolean(reader["temporary"]);
277 }
278 }
279 }
280
281 return retList;
282 }
283
248 #endregion 284 #endregion
249 } 285 }
250} 286}
diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs
index 2211d4c..466f5db 100644
--- a/OpenSim/Data/MySQL/MySQLAssetData.cs
+++ b/OpenSim/Data/MySQL/MySQLAssetData.cs
@@ -28,6 +28,7 @@
28using System; 28using System;
29using System.Data; 29using System.Data;
30using System.Reflection; 30using System.Reflection;
31using System.Collections.Generic;
31using log4net; 32using log4net;
32using MySql.Data.MySqlClient; 33using MySql.Data.MySqlClient;
33using OpenMetaverse; 34using OpenMetaverse;
@@ -311,6 +312,56 @@ namespace OpenSim.Data.MySQL
311 return assetExists; 312 return assetExists;
312 } 313 }
313 314
315 /// <summary>
316 /// Returns a list of AssetMetadata objects. The list is a subset of
317 /// the entire data set offset by <paramref name="start" /> containing
318 /// <paramref name="count" /> elements.
319 /// </summary>
320 /// <param name="start">The number of results to discard from the total data set.</param>
321 /// <param name="count">The number of rows the returned list should contain.</param>
322 /// <returns>A list of AssetMetadata objects.</returns>
323 public override List<AssetMetadata> FetchAssetMetadataSet(int start, int count)
324 {
325 List<AssetMetadata> retList = new List<AssetMetadata>(count);
326
327 lock (_dbConnection)
328 {
329 _dbConnection.CheckConnection();
330
331 MySqlCommand cmd = new MySqlCommand("SELECT name,description,assetType,temporary,id FROM assets LIMIT ?start, ?count", _dbConnection.Connection);
332 cmd.Parameters.AddWithValue("?start", start);
333 cmd.Parameters.AddWithValue("?count", count);
334
335 try
336 {
337 using (MySqlDataReader dbReader = cmd.ExecuteReader())
338 {
339 while (dbReader.Read())
340 {
341 AssetMetadata metadata = new AssetMetadata();
342 metadata.Name = (string) dbReader["name"];
343 metadata.Description = (string) dbReader["description"];
344 metadata.Type = (sbyte) dbReader["assetType"];
345 metadata.Temporary = (bool) dbReader["temporary"]; // Not sure if this is correct.
346 metadata.FullID = new UUID((string) dbReader["id"]);
347
348 // Current SHA1s are not stored/computed.
349 metadata.SHA1 = new byte[] {};
350
351 retList.Add(metadata);
352 }
353 }
354 }
355 catch (Exception e)
356 {
357 m_log.Error("[ASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString() + Environment.NewLine + "Attempting reconnection");
358 _dbConnection.Reconnect();
359 }
360 }
361
362 return retList;
363 }
364
314 #endregion 365 #endregion
315 366
316 /// <summary> 367 /// <summary>
diff --git a/OpenSim/Data/NHibernate/NHibernateAssetData.cs b/OpenSim/Data/NHibernate/NHibernateAssetData.cs
index 387d3d4..4e8f708 100644
--- a/OpenSim/Data/NHibernate/NHibernateAssetData.cs
+++ b/OpenSim/Data/NHibernate/NHibernateAssetData.cs
@@ -26,6 +26,7 @@
26 */ 26 */
27 27
28using System.Reflection; 28using System.Reflection;
29using System.Collections.Generic;
29using log4net; 30using log4net;
30using OpenMetaverse; 31using OpenMetaverse;
31using OpenSim.Framework; 32using OpenSim.Framework;
@@ -109,6 +110,20 @@ namespace OpenSim.Data.NHibernate
109 return (FetchAsset(uuid) != null); 110 return (FetchAsset(uuid) != null);
110 } 111 }
111 112
113 /// <summary>
114 /// Returns a list of AssetMetadata objects. The list is a subset of
115 /// the entire data set offset by <paramref name="start" /> containing
116 /// <paramref name="count" /> elements.
117 /// </summary>
118 /// <param name="start">The number of results to discard from the total data set.</param>
119 /// <param name="count">The number of rows the returned list should contain.</param>
120 /// <returns>A list of AssetMetadata objects.</returns>
121 public override List<AssetMetadata> FetchAssetMetadataSet(int start, int count)
122 {
123 List<AssetMetadata> retList = new List<AssetMetadata>(count);
124 return retList;
125 }
126
112 public void DeleteAsset(UUID uuid) 127 public void DeleteAsset(UUID uuid)
113 { 128 {
114 129
diff --git a/OpenSim/Data/SQLite/SQLiteAssetData.cs b/OpenSim/Data/SQLite/SQLiteAssetData.cs
index 1b42198..6a323e1 100644
--- a/OpenSim/Data/SQLite/SQLiteAssetData.cs
+++ b/OpenSim/Data/SQLite/SQLiteAssetData.cs
@@ -28,6 +28,7 @@
28using System; 28using System;
29using System.Data; 29using System.Data;
30using System.Reflection; 30using System.Reflection;
31using System.Collections.Generic;
31using log4net; 32using log4net;
32using Mono.Data.SqliteClient; 33using Mono.Data.SqliteClient;
33using OpenMetaverse; 34using OpenMetaverse;
@@ -49,6 +50,7 @@ namespace OpenSim.Data.SQLite
49 /// Artificial constructor called upon plugin load 50 /// Artificial constructor called upon plugin load
50 /// </summary> 51 /// </summary>
51 private const string SelectAssetSQL = "select * from assets where UUID=:UUID"; 52 private const string SelectAssetSQL = "select * from assets where UUID=:UUID";
53 private const string SelectAssetMetadataSQL = "select Name, Description, Type, Temporary, UUID from assets limit :start, :count";
52 private const string DeleteAssetSQL = "delete from assets where UUID=:UUID"; 54 private const string DeleteAssetSQL = "delete from assets where UUID=:UUID";
53 private const string InsertAssetSQL = "insert into assets(UUID, Name, Description, Type, Local, Temporary, Data) values(:UUID, :Name, :Description, :Type, :Local, :Temporary, :Data)"; 55 private const string InsertAssetSQL = "insert into assets(UUID, Name, Description, Type, Local, Temporary, Data) values(:UUID, :Name, :Description, :Type, :Local, :Temporary, :Data)";
54 private const string UpdateAssetSQL = "update assets set Name=:Name, Description=:Description, Type=:Type, Local=:Local, Temporary=:Temporary, Data=:Data where UUID=:UUID"; 56 private const string UpdateAssetSQL = "update assets set Name=:Name, Description=:Description, Type=:Type, Local=:Local, Temporary=:Temporary, Data=:Data where UUID=:UUID";
@@ -256,6 +258,54 @@ namespace OpenSim.Data.SQLite
256 return asset; 258 return asset;
257 } 259 }
258 260
261 private static AssetMetadata buildAssetMetadata(IDataReader row)
262 {
263 AssetMetadata metadata = new AssetMetadata();
264
265 metadata.FullID = new UUID((string) row["UUID"]);
266 metadata.Name = (string) row["Name"];
267 metadata.Description = (string) row["Description"];
268 metadata.Type = Convert.ToSByte(row["Type"]);
269 metadata.Temporary = Convert.ToBoolean(row["Temporary"]); // Not sure if this is correct.
270
271 // Current SHA1s are not stored/computed.
272 metadata.SHA1 = new byte[] {};
273
274 return metadata;
275 }
276
277 /// <summary>
278 /// Returns a list of AssetMetadata objects. The list is a subset of
279 /// the entire data set offset by <paramref name="start" /> containing
280 /// <paramref name="count" /> elements.
281 /// </summary>
282 /// <param name="start">The number of results to discard from the total data set.</param>
283 /// <param name="count">The number of rows the returned list should contain.</param>
284 /// <returns>A list of AssetMetadata objects.</returns>
285 public override List<AssetMetadata> FetchAssetMetadataSet(int start, int count)
286 {
287 List<AssetMetadata> retList = new List<AssetMetadata>(count);
288
289 lock (this)
290 {
291 using (SqliteCommand cmd = new SqliteCommand(SelectAssetMetadataSQL, m_conn))
292 {
293 cmd.Parameters.Add(new SqliteParameter(":start", start));
294 cmd.Parameters.Add(new SqliteParameter(":count", count));
295
296 using (IDataReader reader = cmd.ExecuteReader())
297 {
298 while (reader.Read())
299 {
300 AssetMetadata metadata = buildAssetMetadata(reader);
301 retList.Add(metadata);
302 }
303 }
304 }
305 }
306
307 return retList;
308 }
259 309
260 /*********************************************************************** 310 /***********************************************************************
261 * 311 *