aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data
diff options
context:
space:
mode:
authorlbsa712009-04-13 20:04:18 +0000
committerlbsa712009-04-13 20:04:18 +0000
commit29355de6ee01b1f44f32ea45b9c06f636ae9a241 (patch)
tree677fb0c71117a6feaa5891f5c7ceacdd8d2069a6 /OpenSim/Data
parent* Remove null reference exception in the J2KDecoderModule's J2K repair routin... (diff)
downloadopensim-SC-29355de6ee01b1f44f32ea45b9c06f636ae9a241.zip
opensim-SC-29355de6ee01b1f44f32ea45b9c06f636ae9a241.tar.gz
opensim-SC-29355de6ee01b1f44f32ea45b9c06f636ae9a241.tar.bz2
opensim-SC-29355de6ee01b1f44f32ea45b9c06f636ae9a241.tar.xz
* Some more experimental work on distributed assets. Nothing hotwired yet.
* Introduced preprocess step in FetchAsset (Might revert this later) * Some minor CCC * Added actual implementation of GetUserProfile( uri ) and the corresponding handler to OGS1. * Introduced non-functioning GetUserUri( userProfile) awaiting user server wireup (this might move elsewhere)
Diffstat (limited to 'OpenSim/Data')
-rw-r--r--OpenSim/Data/AssetDataBase.cs11
-rw-r--r--OpenSim/Data/MSSQL/MSSQLAssetData.cs78
-rw-r--r--OpenSim/Data/MySQL/MySQLAssetData.cs36
-rw-r--r--OpenSim/Data/NHibernate/NHibernateAssetData.cs2
-rw-r--r--OpenSim/Data/SQLite/SQLiteAssetData.cs2
5 files changed, 70 insertions, 59 deletions
diff --git a/OpenSim/Data/AssetDataBase.cs b/OpenSim/Data/AssetDataBase.cs
index d699f17..e67d9cb 100644
--- a/OpenSim/Data/AssetDataBase.cs
+++ b/OpenSim/Data/AssetDataBase.cs
@@ -25,7 +25,10 @@
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.Collections.Generic; 29using System.Collections.Generic;
30using System.Text;
31using System.Text.RegularExpressions;
29using OpenMetaverse; 32using OpenMetaverse;
30using OpenSim.Framework; 33using OpenSim.Framework;
31 34
@@ -33,7 +36,13 @@ namespace OpenSim.Data
33{ 36{
34 public abstract class AssetDataBase : IAssetDataPlugin 37 public abstract class AssetDataBase : IAssetDataPlugin
35 { 38 {
36 public abstract AssetBase FetchAsset(UUID uuid); 39 public virtual AssetBase FetchAsset(UUID uuid)
40 {
41 return FetchStoredAsset(uuid);
42 }
43
44 protected abstract AssetBase FetchStoredAsset(UUID uuid);
45
37 public abstract void CreateAsset(AssetBase asset); 46 public abstract void CreateAsset(AssetBase asset);
38 public abstract void UpdateAsset(AssetBase asset); 47 public abstract void UpdateAsset(AssetBase asset);
39 public abstract bool ExistsAsset(UUID uuid); 48 public abstract bool ExistsAsset(UUID uuid);
diff --git a/OpenSim/Data/MSSQL/MSSQLAssetData.cs b/OpenSim/Data/MSSQL/MSSQLAssetData.cs
index 54578bc..927b02b 100644
--- a/OpenSim/Data/MSSQL/MSSQLAssetData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLAssetData.cs
@@ -43,11 +43,11 @@ namespace OpenSim.Data.MSSQL
43 private const string _migrationStore = "AssetStore"; 43 private const string _migrationStore = "AssetStore";
44 44
45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46 private long TicksToEpoch; 46 private long m_ticksToEpoch;
47 /// <summary> 47 /// <summary>
48 /// Database manager 48 /// Database manager
49 /// </summary> 49 /// </summary>
50 private MSSQLManager database; 50 private MSSQLManager m_database;
51 51
52 #region IPlugin Members 52 #region IPlugin Members
53 53
@@ -72,11 +72,11 @@ namespace OpenSim.Data.MSSQL
72 /// <param name="connectionString">connect string</param> 72 /// <param name="connectionString">connect string</param>
73 override public void Initialise(string connectionString) 73 override public void Initialise(string connectionString)
74 { 74 {
75 TicksToEpoch = new System.DateTime(1970, 1, 1).Ticks; 75 m_ticksToEpoch = new System.DateTime(1970, 1, 1).Ticks;
76 76
77 if (!string.IsNullOrEmpty(connectionString)) 77 if (!string.IsNullOrEmpty(connectionString))
78 { 78 {
79 database = new MSSQLManager(connectionString); 79 m_database = new MSSQLManager(connectionString);
80 } 80 }
81 else 81 else
82 { 82 {
@@ -88,13 +88,13 @@ namespace OpenSim.Data.MSSQL
88 string settingUserId = gridDataMSSqlFile.ParseFileReadValue("user_id"); 88 string settingUserId = gridDataMSSqlFile.ParseFileReadValue("user_id");
89 string settingPassword = gridDataMSSqlFile.ParseFileReadValue("password"); 89 string settingPassword = gridDataMSSqlFile.ParseFileReadValue("password");
90 90
91 database = 91 m_database =
92 new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId, 92 new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId,
93 settingPassword); 93 settingPassword);
94 } 94 }
95 95
96 //New migration to check for DB changes 96 //New migration to check for DB changes
97 database.CheckMigration(_migrationStore); 97 m_database.CheckMigration(_migrationStore);
98 } 98 }
99 99
100 /// <summary> 100 /// <summary>
@@ -102,7 +102,7 @@ namespace OpenSim.Data.MSSQL
102 /// </summary> 102 /// </summary>
103 override public string Version 103 override public string Version
104 { 104 {
105 get { return database.getVersion(); } 105 get { return m_database.getVersion(); }
106 } 106 }
107 107
108 /// <summary> 108 /// <summary>
@@ -118,15 +118,15 @@ namespace OpenSim.Data.MSSQL
118 #region IAssetDataPlugin Members 118 #region IAssetDataPlugin Members
119 119
120 /// <summary> 120 /// <summary>
121 /// Fetch Asset from database 121 /// Fetch Asset from m_database
122 /// </summary> 122 /// </summary>
123 /// <param name="assetID">the asset UUID</param> 123 /// <param name="assetID">the asset UUID</param>
124 /// <returns></returns> 124 /// <returns></returns>
125 override public AssetBase FetchAsset(UUID assetID) 125 override protected AssetBase FetchStoredAsset(UUID assetID)
126 { 126 {
127 using (AutoClosingSqlCommand command = database.Query("SELECT * FROM assets WHERE id = @id")) 127 using (AutoClosingSqlCommand command = m_database.Query("SELECT * FROM assets WHERE id = @id"))
128 { 128 {
129 command.Parameters.Add(database.CreateParameter("id", assetID)); 129 command.Parameters.Add(m_database.CreateParameter("id", assetID));
130 using (IDataReader reader = command.ExecuteReader()) 130 using (IDataReader reader = command.ExecuteReader())
131 { 131 {
132 if (reader.Read()) 132 if (reader.Read())
@@ -148,7 +148,7 @@ namespace OpenSim.Data.MSSQL
148 } 148 }
149 149
150 /// <summary> 150 /// <summary>
151 /// Create asset in database 151 /// Create asset in m_database
152 /// </summary> 152 /// </summary>
153 /// <param name="asset">the asset</param> 153 /// <param name="asset">the asset</param>
154 override public void CreateAsset(AssetBase asset) 154 override public void CreateAsset(AssetBase asset)
@@ -158,33 +158,33 @@ namespace OpenSim.Data.MSSQL
158 return; 158 return;
159 } 159 }
160 160
161 using (AutoClosingSqlCommand command = database.Query( 161 using (AutoClosingSqlCommand command = m_database.Query(
162 "INSERT INTO assets ([id], [name], [description], [assetType], [local], [temporary], [create_time], [access_time], [data])" + 162 "INSERT INTO assets ([id], [name], [description], [assetType], [local], [temporary], [create_time], [access_time], [data])" +
163 " VALUES " + 163 " VALUES " +
164 "(@id, @name, @description, @assetType, @local, @temporary, @create_time, @access_time, @data)")) 164 "(@id, @name, @description, @assetType, @local, @temporary, @create_time, @access_time, @data)"))
165 { 165 {
166 int now = (int)((System.DateTime.Now.Ticks - TicksToEpoch) / 10000000); 166 int now = (int)((System.DateTime.Now.Ticks - m_ticksToEpoch) / 10000000);
167 command.Parameters.Add(database.CreateParameter("id", asset.FullID)); 167 command.Parameters.Add(m_database.CreateParameter("id", asset.FullID));
168 command.Parameters.Add(database.CreateParameter("name", asset.Name)); 168 command.Parameters.Add(m_database.CreateParameter("name", asset.Name));
169 command.Parameters.Add(database.CreateParameter("description", asset.Description)); 169 command.Parameters.Add(m_database.CreateParameter("description", asset.Description));
170 command.Parameters.Add(database.CreateParameter("assetType", asset.Type)); 170 command.Parameters.Add(m_database.CreateParameter("assetType", asset.Type));
171 command.Parameters.Add(database.CreateParameter("local", asset.Local)); 171 command.Parameters.Add(m_database.CreateParameter("local", asset.Local));
172 command.Parameters.Add(database.CreateParameter("temporary", asset.Temporary)); 172 command.Parameters.Add(m_database.CreateParameter("temporary", asset.Temporary));
173 command.Parameters.Add(database.CreateParameter("access_time", now)); 173 command.Parameters.Add(m_database.CreateParameter("access_time", now));
174 command.Parameters.Add(database.CreateParameter("create_time", now)); 174 command.Parameters.Add(m_database.CreateParameter("create_time", now));
175 command.Parameters.Add(database.CreateParameter("data", asset.Data)); 175 command.Parameters.Add(m_database.CreateParameter("data", asset.Data));
176 176
177 command.ExecuteNonQuery(); 177 command.ExecuteNonQuery();
178 } 178 }
179 } 179 }
180 180
181 /// <summary> 181 /// <summary>
182 /// Update asset in database 182 /// Update asset in m_database
183 /// </summary> 183 /// </summary>
184 /// <param name="asset">the asset</param> 184 /// <param name="asset">the asset</param>
185 override public void UpdateAsset(AssetBase asset) 185 override public void UpdateAsset(AssetBase asset)
186 { 186 {
187 using (AutoClosingSqlCommand command = database.Query("UPDATE assets set id = @id, " + 187 using (AutoClosingSqlCommand command = m_database.Query("UPDATE assets set id = @id, " +
188 "name = @name, " + 188 "name = @name, " +
189 "description = @description," + 189 "description = @description," +
190 "assetType = @assetType," + 190 "assetType = @assetType," +
@@ -193,14 +193,14 @@ namespace OpenSim.Data.MSSQL
193 "data = @data where " + 193 "data = @data where " +
194 "id = @keyId;")) 194 "id = @keyId;"))
195 { 195 {
196 command.Parameters.Add(database.CreateParameter("id", asset.FullID)); 196 command.Parameters.Add(m_database.CreateParameter("id", asset.FullID));
197 command.Parameters.Add(database.CreateParameter("name", asset.Name)); 197 command.Parameters.Add(m_database.CreateParameter("name", asset.Name));
198 command.Parameters.Add(database.CreateParameter("description", asset.Description)); 198 command.Parameters.Add(m_database.CreateParameter("description", asset.Description));
199 command.Parameters.Add(database.CreateParameter("assetType", asset.Type)); 199 command.Parameters.Add(m_database.CreateParameter("assetType", asset.Type));
200 command.Parameters.Add(database.CreateParameter("local", asset.Local)); 200 command.Parameters.Add(m_database.CreateParameter("local", asset.Local));
201 command.Parameters.Add(database.CreateParameter("temporary", asset.Temporary)); 201 command.Parameters.Add(m_database.CreateParameter("temporary", asset.Temporary));
202 command.Parameters.Add(database.CreateParameter("data", asset.Data)); 202 command.Parameters.Add(m_database.CreateParameter("data", asset.Data));
203 command.Parameters.Add(database.CreateParameter("@keyId", asset.FullID)); 203 command.Parameters.Add(m_database.CreateParameter("@keyId", asset.FullID));
204 204
205 try 205 try
206 { 206 {
@@ -216,9 +216,9 @@ namespace OpenSim.Data.MSSQL
216// Commented out since currently unused - this probably should be called in FetchAsset() 216// Commented out since currently unused - this probably should be called in FetchAsset()
217// private void UpdateAccessTime(AssetBase asset) 217// private void UpdateAccessTime(AssetBase asset)
218// { 218// {
219// using (AutoClosingSqlCommand cmd = database.Query("UPDATE assets SET access_time = @access_time WHERE id=@id")) 219// using (AutoClosingSqlCommand cmd = m_database.Query("UPDATE assets SET access_time = @access_time WHERE id=@id"))
220// { 220// {
221// int now = (int)((System.DateTime.Now.Ticks - TicksToEpoch) / 10000000); 221// int now = (int)((System.DateTime.Now.Ticks - m_ticksToEpoch) / 10000000);
222// cmd.Parameters.AddWithValue("@id", asset.FullID.ToString()); 222// cmd.Parameters.AddWithValue("@id", asset.FullID.ToString());
223// cmd.Parameters.AddWithValue("@access_time", now); 223// cmd.Parameters.AddWithValue("@access_time", now);
224// try 224// try
@@ -233,7 +233,7 @@ namespace OpenSim.Data.MSSQL
233// } 233// }
234 234
235 /// <summary> 235 /// <summary>
236 /// Check if asset exist in database 236 /// Check if asset exist in m_database
237 /// </summary> 237 /// </summary>
238 /// <param name="uuid"></param> 238 /// <param name="uuid"></param>
239 /// <returns>true if exist.</returns> 239 /// <returns>true if exist.</returns>
@@ -258,10 +258,10 @@ namespace OpenSim.Data.MSSQL
258 { 258 {
259 List<AssetMetadata> retList = new List<AssetMetadata>(count); 259 List<AssetMetadata> retList = new List<AssetMetadata>(count);
260 260
261 using (AutoClosingSqlCommand command = database.Query("SELECT (name,description,assetType,temporary,id), Row = ROW_NUMBER() OVER (ORDER BY (some column to order by)) WHERE Row >= @Start AND Row < @Start + @Count")) 261 using (AutoClosingSqlCommand command = m_database.Query("SELECT (name,description,assetType,temporary,id), Row = ROW_NUMBER() OVER (ORDER BY (some column to order by)) WHERE Row >= @Start AND Row < @Start + @Count"))
262 { 262 {
263 command.Parameters.Add(database.CreateParameter("start", start)); 263 command.Parameters.Add(m_database.CreateParameter("start", start));
264 command.Parameters.Add(database.CreateParameter("count", count)); 264 command.Parameters.Add(m_database.CreateParameter("count", count));
265 265
266 using (IDataReader reader = command.ExecuteReader()) 266 using (IDataReader reader = command.ExecuteReader())
267 { 267 {
diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs
index 20b2673..cc16389 100644
--- a/OpenSim/Data/MySQL/MySQLAssetData.cs
+++ b/OpenSim/Data/MySQL/MySQLAssetData.cs
@@ -109,6 +109,24 @@ namespace OpenSim.Data.MySQL
109 109
110 public override void Dispose() { } 110 public override void Dispose() { }
111 111
112 /// <summary>
113 /// Database provider version
114 /// </summary>
115 override public string Version
116 {
117 get { return _dbConnection.getVersion(); }
118 }
119
120 /// <summary>
121 /// The name of this DB provider
122 /// </summary>
123 override public string Name
124 {
125 get { return "MySQL Asset storage engine"; }
126 }
127
128 #endregion
129
112 #region IAssetDataPlugin Members 130 #region IAssetDataPlugin Members
113 131
114 /// <summary> 132 /// <summary>
@@ -117,7 +135,7 @@ namespace OpenSim.Data.MySQL
117 /// <param name="assetID">Asset UUID to fetch</param> 135 /// <param name="assetID">Asset UUID to fetch</param>
118 /// <returns>Return the asset</returns> 136 /// <returns>Return the asset</returns>
119 /// <remarks>On failure : throw an exception and attempt to reconnect to database</remarks> 137 /// <remarks>On failure : throw an exception and attempt to reconnect to database</remarks>
120 override public AssetBase FetchAsset(UUID assetID) 138 override protected AssetBase FetchStoredAsset(UUID assetID)
121 { 139 {
122 AssetBase asset = null; 140 AssetBase asset = null;
123 lock (_dbConnection) 141 lock (_dbConnection)
@@ -364,22 +382,6 @@ namespace OpenSim.Data.MySQL
364 382
365 #endregion 383 #endregion
366 384
367 /// <summary>
368 /// Database provider version
369 /// </summary>
370 override public string Version
371 {
372 get { return _dbConnection.getVersion(); }
373 }
374 385
375 /// <summary>
376 /// The name of this DB provider
377 /// </summary>
378 override public string Name
379 {
380 get { return "MySQL Asset storage engine"; }
381 }
382
383 #endregion
384 } 386 }
385} 387}
diff --git a/OpenSim/Data/NHibernate/NHibernateAssetData.cs b/OpenSim/Data/NHibernate/NHibernateAssetData.cs
index 4e8f708..6e13dbb 100644
--- a/OpenSim/Data/NHibernate/NHibernateAssetData.cs
+++ b/OpenSim/Data/NHibernate/NHibernateAssetData.cs
@@ -65,7 +65,7 @@ namespace OpenSim.Data.NHibernate
65 65
66 } 66 }
67 67
68 override public AssetBase FetchAsset(UUID uuid) 68 override protected AssetBase FetchStoredAsset(UUID uuid)
69 { 69 {
70 return (AssetBase)manager.Get(typeof(AssetBase), uuid); 70 return (AssetBase)manager.Get(typeof(AssetBase), uuid);
71 } 71 }
diff --git a/OpenSim/Data/SQLite/SQLiteAssetData.cs b/OpenSim/Data/SQLite/SQLiteAssetData.cs
index d3f1308..41a75a3 100644
--- a/OpenSim/Data/SQLite/SQLiteAssetData.cs
+++ b/OpenSim/Data/SQLite/SQLiteAssetData.cs
@@ -90,7 +90,7 @@ namespace OpenSim.Data.SQLite
90 /// </summary> 90 /// </summary>
91 /// <param name="uuid">UUID of ... ?</param> 91 /// <param name="uuid">UUID of ... ?</param>
92 /// <returns>Asset base</returns> 92 /// <returns>Asset base</returns>
93 override public AssetBase FetchAsset(UUID uuid) 93 override protected AssetBase FetchStoredAsset(UUID uuid)
94 { 94 {
95 lock (this) 95 lock (this)
96 { 96 {