diff options
author | AliciaRaven | 2015-07-12 01:35:57 +0100 |
---|---|---|
committer | Melanie Thielker | 2015-07-12 04:03:08 +0200 |
commit | f3f748ed111223bdf9cbc25fcabb18b4ab427d37 (patch) | |
tree | 382d6390ec5ae88149bd03df8d5d82787df60bda | |
parent | More cleanup, add missing refs to prebuild, remove refs to stuff not (diff) | |
download | opensim-SC-f3f748ed111223bdf9cbc25fcabb18b4ab427d37.zip opensim-SC-f3f748ed111223bdf9cbc25fcabb18b4ab427d37.tar.gz opensim-SC-f3f748ed111223bdf9cbc25fcabb18b4ab427d37.tar.bz2 opensim-SC-f3f748ed111223bdf9cbc25fcabb18b4ab427d37.tar.xz |
Bringing FSAssets more inline with current OpenSim standards. * If no connection string found in assets config, fallback to using default database config * Create database storage interface to allow other db connectors to be written at some point * Add MySQL migrations file to create the initial db table * Added new config option named DaysBetweenAccessTimeUpdates to reduce db load by only updating access times when fetching assets if the last access time was over the threshold. This idea was taken from XAssets service. * Change log message headers to indicate FS assets is the source not just assets
Signed-off-by: Melanie Thielker <melanie@t-data.com>
-rw-r--r-- | OpenSim/Data/IFSAssetData.cs | 47 | ||||
-rw-r--r-- | OpenSim/Data/MySQL/MySQLFSAssetData.cs | 107 | ||||
-rw-r--r-- | OpenSim/Data/MySQL/Resources/FSAssetStore.migrations | 18 | ||||
-rw-r--r-- | OpenSim/Services/FSAssetService/FSAssetService.cs | 80 |
4 files changed, 198 insertions, 54 deletions
diff --git a/OpenSim/Data/IFSAssetData.cs b/OpenSim/Data/IFSAssetData.cs new file mode 100644 index 0000000..8751dc0 --- /dev/null +++ b/OpenSim/Data/IFSAssetData.cs | |||
@@ -0,0 +1,47 @@ | |||
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.Framework; | ||
31 | |||
32 | namespace OpenSim.Data | ||
33 | { | ||
34 | public delegate string FSStoreDelegate(AssetBase asset, bool force); | ||
35 | |||
36 | public interface IFSAssetDataPlugin : IPlugin | ||
37 | { | ||
38 | bool[] AssetsExist(UUID[] uuids); | ||
39 | void Initialise(string connect, string realm, int SkipAccessTimeDays); | ||
40 | bool Delete(string id); | ||
41 | |||
42 | AssetMetadata Get(string id, out string hash); | ||
43 | bool Store(AssetMetadata metadata, string hash); | ||
44 | void Import(string conn, string table, int start, int count, bool force, FSStoreDelegate store); | ||
45 | int Count(); | ||
46 | } | ||
47 | } | ||
diff --git a/OpenSim/Data/MySQL/MySQLFSAssetData.cs b/OpenSim/Data/MySQL/MySQLFSAssetData.cs index 4d7a395..19e23b5 100644 --- a/OpenSim/Data/MySQL/MySQLFSAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLFSAssetData.cs | |||
@@ -29,37 +29,77 @@ using System; | |||
29 | using System.Reflection; | 29 | using System.Reflection; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Data; | 31 | using System.Data; |
32 | using OpenSim.Data; | ||
33 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
34 | using OpenSim.Framework.Console; | 33 | using OpenSim.Framework.Console; |
35 | using log4net; | 34 | using log4net; |
36 | using MySql.Data.MySqlClient; | 35 | using MySql.Data.MySqlClient; |
37 | using System.Data; | ||
38 | using OpenMetaverse; | 36 | using OpenMetaverse; |
39 | 37 | ||
40 | namespace OpenSim.Data.MySQL | 38 | namespace OpenSim.Data.MySQL |
41 | { | 39 | { |
42 | public delegate string StoreDelegate(AssetBase asset, bool force); | 40 | public class MySQLFSAssetData : IFSAssetDataPlugin |
43 | |||
44 | public class FSAssetConnectorData | ||
45 | { | 41 | { |
46 | private static readonly ILog m_log = | 42 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
47 | LogManager.GetLogger( | ||
48 | MethodBase.GetCurrentMethod().DeclaringType); | ||
49 | 43 | ||
50 | protected MySqlConnection m_Connection = null; | 44 | protected MySqlConnection m_Connection = null; |
51 | protected string m_ConnectionString; | 45 | protected string m_ConnectionString; |
52 | protected string m_Table; | 46 | protected string m_Table; |
53 | protected Object m_connLock = new Object(); | 47 | protected Object m_connLock = new Object(); |
54 | 48 | ||
55 | public FSAssetConnectorData(string connectionString, string table) | 49 | /// <summary> |
50 | /// Number of days that must pass before we update the access time on an asset when it has been fetched | ||
51 | /// Config option to change this is "DaysBetweenAccessTimeUpdates" | ||
52 | /// </summary> | ||
53 | private int DaysBetweenAccessTimeUpdates = 0; | ||
54 | |||
55 | protected virtual Assembly Assembly | ||
56 | { | ||
57 | get { return GetType().Assembly; } | ||
58 | } | ||
59 | |||
60 | public MySQLFSAssetData() | ||
61 | { | ||
62 | } | ||
63 | |||
64 | #region IPlugin Members | ||
65 | |||
66 | public string Version { get { return "1.0.0.0"; } } | ||
67 | |||
68 | // Loads and initialises the MySQL storage plugin and checks for migrations | ||
69 | public void Initialise(string connect, string realm, int UpdateAccessTime) | ||
70 | { | ||
71 | m_ConnectionString = connect; | ||
72 | m_Table = realm; | ||
73 | |||
74 | DaysBetweenAccessTimeUpdates = UpdateAccessTime; | ||
75 | |||
76 | try | ||
77 | { | ||
78 | OpenDatabase(); | ||
79 | |||
80 | Migration m = new Migration(m_Connection, Assembly, "FSAssetStore"); | ||
81 | m.Update(); | ||
82 | } | ||
83 | catch (MySqlException e) | ||
84 | { | ||
85 | m_log.ErrorFormat("[FSASSETS]: Can't connect to database: {0}", e.Message.ToString()); | ||
86 | } | ||
87 | } | ||
88 | |||
89 | public void Initialise() | ||
56 | { | 90 | { |
57 | m_ConnectionString = connectionString; | 91 | throw new NotImplementedException(); |
58 | m_Table = table; | 92 | } |
93 | |||
94 | public void Dispose() { } | ||
59 | 95 | ||
60 | OpenDatabase(); | 96 | public string Name |
97 | { | ||
98 | get { return "MySQL FSAsset storage engine"; } | ||
61 | } | 99 | } |
62 | 100 | ||
101 | #endregion | ||
102 | |||
63 | private bool OpenDatabase() | 103 | private bool OpenDatabase() |
64 | { | 104 | { |
65 | try | 105 | try |
@@ -126,13 +166,15 @@ namespace OpenSim.Data.MySQL | |||
126 | } | 166 | } |
127 | } | 167 | } |
128 | 168 | ||
169 | #region IFSAssetDataPlugin Members | ||
170 | |||
129 | public AssetMetadata Get(string id, out string hash) | 171 | public AssetMetadata Get(string id, out string hash) |
130 | { | 172 | { |
131 | hash = String.Empty; | 173 | hash = String.Empty; |
132 | 174 | ||
133 | MySqlCommand cmd = new MySqlCommand(); | 175 | MySqlCommand cmd = new MySqlCommand(); |
134 | 176 | ||
135 | cmd.CommandText = String.Format("select id, name, description, type, hash, create_time, asset_flags from {0} where id = ?id", m_Table); | 177 | cmd.CommandText = String.Format("select id, name, description, type, hash, create_time, access_time, asset_flags from {0} where id = ?id", m_Table); |
136 | cmd.Parameters.AddWithValue("?id", id); | 178 | cmd.Parameters.AddWithValue("?id", id); |
137 | 179 | ||
138 | IDataReader reader = ExecuteReader(cmd); | 180 | IDataReader reader = ExecuteReader(cmd); |
@@ -158,17 +200,29 @@ namespace OpenSim.Data.MySQL | |||
158 | meta.CreationDate = Util.ToDateTime(Convert.ToInt32(reader["create_time"])); | 200 | meta.CreationDate = Util.ToDateTime(Convert.ToInt32(reader["create_time"])); |
159 | meta.Flags = (AssetFlags)Convert.ToInt32(reader["asset_flags"]); | 201 | meta.Flags = (AssetFlags)Convert.ToInt32(reader["asset_flags"]); |
160 | 202 | ||
161 | reader.Close(); | 203 | int AccessTime = Convert.ToInt32(reader["access_time"]); |
162 | 204 | ||
163 | cmd.CommandText = String.Format("update {0} set access_time = UNIX_TIMESTAMP() where id = ?id", m_Table); | 205 | reader.Close(); |
164 | 206 | ||
165 | cmd.ExecuteNonQuery(); | 207 | UpdateAccessTime(AccessTime, cmd); |
166 | 208 | ||
167 | FreeCommand(cmd); | 209 | FreeCommand(cmd); |
168 | 210 | ||
169 | return meta; | 211 | return meta; |
170 | } | 212 | } |
171 | 213 | ||
214 | private void UpdateAccessTime(int AccessTime, MySqlCommand cmd) | ||
215 | { | ||
216 | // Reduce DB work by only updating access time if asset hasn't recently been accessed | ||
217 | // 0 By Default, Config option is "DaysBetweenAccessTimeUpdates" | ||
218 | if (DaysBetweenAccessTimeUpdates > 0 && (DateTime.UtcNow - Utils.UnixTimeToDateTime(AccessTime)).TotalDays < DaysBetweenAccessTimeUpdates) | ||
219 | return; | ||
220 | |||
221 | cmd.CommandText = String.Format("UPDATE {0} SET `access_time` = UNIX_TIMESTAMP() WHERE `id` = ?id", m_Table); | ||
222 | |||
223 | cmd.ExecuteNonQuery(); | ||
224 | } | ||
225 | |||
172 | protected void FreeCommand(MySqlCommand cmd) | 226 | protected void FreeCommand(MySqlCommand cmd) |
173 | { | 227 | { |
174 | MySqlConnection c = cmd.Connection; | 228 | MySqlConnection c = cmd.Connection; |
@@ -214,7 +268,7 @@ namespace OpenSim.Data.MySQL | |||
214 | catch(Exception e) | 268 | catch(Exception e) |
215 | { | 269 | { |
216 | m_log.Error("[FSAssets] Failed to store asset with ID " + meta.ID); | 270 | m_log.Error("[FSAssets] Failed to store asset with ID " + meta.ID); |
217 | m_log.Error(e.ToString()); | 271 | m_log.Error(e.ToString()); |
218 | return false; | 272 | return false; |
219 | } | 273 | } |
220 | } | 274 | } |
@@ -272,20 +326,21 @@ namespace OpenSim.Data.MySQL | |||
272 | return count; | 326 | return count; |
273 | } | 327 | } |
274 | 328 | ||
275 | public void Delete(string id) | 329 | public bool Delete(string id) |
276 | { | 330 | { |
277 | MySqlCommand cmd = m_Connection.CreateCommand(); | 331 | using (MySqlCommand cmd = m_Connection.CreateCommand()) |
278 | 332 | { | |
279 | cmd.CommandText = String.Format("delete from {0} where id = ?id", m_Table); | 333 | cmd.CommandText = String.Format("delete from {0} where id = ?id", m_Table); |
280 | 334 | ||
281 | cmd.Parameters.AddWithValue("?id", id); | 335 | cmd.Parameters.AddWithValue("?id", id); |
282 | 336 | ||
283 | ExecuteNonQuery(cmd); | 337 | ExecuteNonQuery(cmd); |
338 | } | ||
284 | 339 | ||
285 | cmd.Dispose(); | 340 | return true; |
286 | } | 341 | } |
287 | 342 | ||
288 | public void Import(string conn, string table, int start, int count, bool force, StoreDelegate store) | 343 | public void Import(string conn, string table, int start, int count, bool force, FSStoreDelegate store) |
289 | { | 344 | { |
290 | MySqlConnection importConn; | 345 | MySqlConnection importConn; |
291 | 346 | ||
@@ -353,5 +408,7 @@ namespace OpenSim.Data.MySQL | |||
353 | 408 | ||
354 | MainConsole.Instance.Output(String.Format("Import done, {0} assets imported", imported)); | 409 | MainConsole.Instance.Output(String.Format("Import done, {0} assets imported", imported)); |
355 | } | 410 | } |
411 | |||
412 | #endregion | ||
356 | } | 413 | } |
357 | } | 414 | } |
diff --git a/OpenSim/Data/MySQL/Resources/FSAssetStore.migrations b/OpenSim/Data/MySQL/Resources/FSAssetStore.migrations new file mode 100644 index 0000000..87d08c6 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/FSAssetStore.migrations | |||
@@ -0,0 +1,18 @@ | |||
1 | # ----------------- | ||
2 | :VERSION 1 | ||
3 | |||
4 | BEGIN; | ||
5 | |||
6 | CREATE TABLE `fsassets` ( | ||
7 | `id` char(36) NOT NULL, | ||
8 | `name` varchar(64) NOT NULL DEFAULT '', | ||
9 | `description` varchar(64) NOT NULL DEFAULT '', | ||
10 | `type` int(11) NOT NULL, | ||
11 | `hash` char(80) NOT NULL, | ||
12 | `create_time` int(11) NOT NULL DEFAULT '0', | ||
13 | `access_time` int(11) NOT NULL DEFAULT '0', | ||
14 | `asset_flags` int(11) NOT NULL DEFAULT '0', | ||
15 | PRIMARY KEY (`id`) | ||
16 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | ||
17 | |||
18 | COMMIT; \ No newline at end of file | ||
diff --git a/OpenSim/Services/FSAssetService/FSAssetService.cs b/OpenSim/Services/FSAssetService/FSAssetService.cs index 3662e27..8276f33 100644 --- a/OpenSim/Services/FSAssetService/FSAssetService.cs +++ b/OpenSim/Services/FSAssetService/FSAssetService.cs | |||
@@ -33,6 +33,7 @@ using System.IO.Compression; | |||
33 | using System.Text; | 33 | using System.Text; |
34 | using System.Threading; | 34 | using System.Threading; |
35 | using System.Reflection; | 35 | using System.Reflection; |
36 | using OpenSim.Data; | ||
36 | using OpenSim.Framework; | 37 | using OpenSim.Framework; |
37 | using OpenSim.Framework.Console; | 38 | using OpenSim.Framework.Console; |
38 | using OpenSim.Server.Base; | 39 | using OpenSim.Server.Base; |
@@ -47,9 +48,7 @@ namespace OpenSim.Services.FSAssetService | |||
47 | { | 48 | { |
48 | public class FSAssetConnector : ServiceBase, IAssetService | 49 | public class FSAssetConnector : ServiceBase, IAssetService |
49 | { | 50 | { |
50 | private static readonly ILog m_log = | 51 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
51 | LogManager.GetLogger( | ||
52 | MethodBase.GetCurrentMethod().DeclaringType); | ||
53 | 52 | ||
54 | static System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); | 53 | static System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); |
55 | static SHA256CryptoServiceProvider SHA256 = new SHA256CryptoServiceProvider(); | 54 | static SHA256CryptoServiceProvider SHA256 = new SHA256CryptoServiceProvider(); |
@@ -64,9 +63,7 @@ namespace OpenSim.Services.FSAssetService | |||
64 | } | 63 | } |
65 | 64 | ||
66 | protected IAssetLoader m_AssetLoader = null; | 65 | protected IAssetLoader m_AssetLoader = null; |
67 | protected string m_ConnectionString; | 66 | protected IFSAssetDataPlugin m_DataConnector = null; |
68 | protected FSAssetConnectorData m_DataConnector = null; | ||
69 | protected string m_FsckProgram; | ||
70 | protected IAssetService m_FallbackService; | 67 | protected IAssetService m_FallbackService; |
71 | protected Thread m_WriterThread; | 68 | protected Thread m_WriterThread; |
72 | protected Thread m_StatsThread; | 69 | protected Thread m_StatsThread; |
@@ -78,7 +75,6 @@ namespace OpenSim.Services.FSAssetService | |||
78 | protected int m_missingAssets = 0; | 75 | protected int m_missingAssets = 0; |
79 | protected int m_missingAssetsFS = 0; | 76 | protected int m_missingAssetsFS = 0; |
80 | protected string m_FSBase; | 77 | protected string m_FSBase; |
81 | protected string m_Realm; | ||
82 | 78 | ||
83 | public FSAssetConnector(IConfigSource config) | 79 | public FSAssetConnector(IConfigSource config) |
84 | : this(config, "AssetService") | 80 | : this(config, "AssetService") |
@@ -87,8 +83,6 @@ namespace OpenSim.Services.FSAssetService | |||
87 | 83 | ||
88 | public FSAssetConnector(IConfigSource config, string configName) : base(config) | 84 | public FSAssetConnector(IConfigSource config, string configName) : base(config) |
89 | { | 85 | { |
90 | m_FsckProgram = string.Empty; | ||
91 | |||
92 | MainConsole.Instance.Commands.AddCommand("fs", false, | 86 | MainConsole.Instance.Commands.AddCommand("fs", false, |
93 | "show assets", "show assets", "Show asset stats", | 87 | "show assets", "show assets", "Show asset stats", |
94 | HandleShowAssets); | 88 | HandleShowAssets); |
@@ -109,35 +103,63 @@ namespace OpenSim.Services.FSAssetService | |||
109 | HandleImportAssets); | 103 | HandleImportAssets); |
110 | 104 | ||
111 | IConfig assetConfig = config.Configs[configName]; | 105 | IConfig assetConfig = config.Configs[configName]; |
106 | |||
112 | if (assetConfig == null) | 107 | if (assetConfig == null) |
113 | { | ||
114 | throw new Exception("No AssetService configuration"); | 108 | throw new Exception("No AssetService configuration"); |
115 | } | ||
116 | 109 | ||
117 | m_ConnectionString = assetConfig.GetString("ConnectionString", string.Empty); | 110 | // Get Database Connector from Asset Config (If present) |
118 | if (m_ConnectionString == string.Empty) | 111 | string dllName = assetConfig.GetString("StorageProvider", string.Empty); |
112 | string m_ConnectionString = assetConfig.GetString("ConnectionString", string.Empty); | ||
113 | string m_Realm = assetConfig.GetString("Realm", "fsassets"); | ||
114 | |||
115 | int SkipAccessTimeDays = assetConfig.GetInt("DaysBetweenAccessTimeUpdates", 0); | ||
116 | |||
117 | // If not found above, fallback to Database defaults | ||
118 | IConfig dbConfig = config.Configs["DatabaseService"]; | ||
119 | |||
120 | if (dbConfig != null) | ||
119 | { | 121 | { |
120 | throw new Exception("Missing database connection string"); | 122 | if (dllName == String.Empty) |
123 | dllName = dbConfig.GetString("StorageProvider", String.Empty); | ||
124 | |||
125 | if (m_ConnectionString == String.Empty) | ||
126 | m_ConnectionString = dbConfig.GetString("ConnectionString", String.Empty); | ||
121 | } | 127 | } |
122 | 128 | ||
123 | m_Realm = assetConfig.GetString("Realm", "fsassets"); | 129 | // No databse connection found in either config |
130 | if (dllName.Equals(String.Empty)) | ||
131 | throw new Exception("No StorageProvider configured"); | ||
132 | |||
133 | if (m_ConnectionString.Equals(String.Empty)) | ||
134 | throw new Exception("Missing database connection string"); | ||
135 | |||
136 | // Create Storage Provider | ||
137 | m_DataConnector = LoadPlugin<IFSAssetDataPlugin>(dllName); | ||
138 | |||
139 | if (m_DataConnector == null) | ||
140 | throw new Exception(string.Format("Could not find a storage interface in the module {0}", dllName)); | ||
141 | |||
142 | // Initialize DB And perform any migrations required | ||
143 | m_DataConnector.Initialise(m_ConnectionString, m_Realm, SkipAccessTimeDays); | ||
124 | 144 | ||
125 | m_DataConnector = new FSAssetConnectorData(m_ConnectionString, m_Realm); | 145 | // Setup Fallback Service |
126 | string str = assetConfig.GetString("FallbackService", string.Empty); | 146 | string str = assetConfig.GetString("FallbackService", string.Empty); |
147 | |||
127 | if (str != string.Empty) | 148 | if (str != string.Empty) |
128 | { | 149 | { |
129 | object[] args = new object[] { config }; | 150 | object[] args = new object[] { config }; |
130 | m_FallbackService = LoadPlugin<IAssetService>(str, args); | 151 | m_FallbackService = LoadPlugin<IAssetService>(str, args); |
131 | if (m_FallbackService != null) | 152 | if (m_FallbackService != null) |
132 | { | 153 | { |
133 | m_log.Info("[FALLBACK]: Fallback service loaded"); | 154 | m_log.Info("[FSASSETS]: Fallback service loaded"); |
134 | } | 155 | } |
135 | else | 156 | else |
136 | { | 157 | { |
137 | m_log.Error("[FALLBACK]: Failed to load fallback service"); | 158 | m_log.Error("[FSASSETS]: Failed to load fallback service"); |
138 | } | 159 | } |
139 | } | 160 | } |
140 | 161 | ||
162 | // Setup directory structure including temp directory | ||
141 | m_SpoolDirectory = assetConfig.GetString("SpoolDirectory", "/tmp"); | 163 | m_SpoolDirectory = assetConfig.GetString("SpoolDirectory", "/tmp"); |
142 | 164 | ||
143 | string spoolTmp = Path.Combine(m_SpoolDirectory, "spool"); | 165 | string spoolTmp = Path.Combine(m_SpoolDirectory, "spool"); |
@@ -147,7 +169,7 @@ namespace OpenSim.Services.FSAssetService | |||
147 | m_FSBase = assetConfig.GetString("BaseDirectory", String.Empty); | 169 | m_FSBase = assetConfig.GetString("BaseDirectory", String.Empty); |
148 | if (m_FSBase == String.Empty) | 170 | if (m_FSBase == String.Empty) |
149 | { | 171 | { |
150 | m_log.ErrorFormat("[ASSET]: BaseDirectory not specified"); | 172 | m_log.ErrorFormat("[FSASSETS]: BaseDirectory not specified"); |
151 | throw new Exception("Configuration error"); | 173 | throw new Exception("Configuration error"); |
152 | } | 174 | } |
153 | 175 | ||
@@ -156,14 +178,14 @@ namespace OpenSim.Services.FSAssetService | |||
156 | { | 178 | { |
157 | m_AssetLoader = LoadPlugin<IAssetLoader>(loader); | 179 | m_AssetLoader = LoadPlugin<IAssetLoader>(loader); |
158 | string loaderArgs = assetConfig.GetString("AssetLoaderArgs", string.Empty); | 180 | string loaderArgs = assetConfig.GetString("AssetLoaderArgs", string.Empty); |
159 | m_log.InfoFormat("[ASSET]: Loading default asset set from {0}", loaderArgs); | 181 | m_log.InfoFormat("[FSASSETS]: Loading default asset set from {0}", loaderArgs); |
160 | m_AssetLoader.ForEachDefaultXmlAsset(loaderArgs, | 182 | m_AssetLoader.ForEachDefaultXmlAsset(loaderArgs, |
161 | delegate(AssetBase a) | 183 | delegate(AssetBase a) |
162 | { | 184 | { |
163 | Store(a, false); | 185 | Store(a, false); |
164 | }); | 186 | }); |
165 | } | 187 | } |
166 | m_log.Info("[ASSET]: FS asset service enabled"); | 188 | m_log.Info("[FSASSETS]: FS asset service enabled"); |
167 | 189 | ||
168 | m_WriterThread = new Thread(Writer); | 190 | m_WriterThread = new Thread(Writer); |
169 | m_WriterThread.Start(); | 191 | m_WriterThread.Start(); |
@@ -184,7 +206,7 @@ namespace OpenSim.Services.FSAssetService | |||
184 | double avg = (double)m_readTicks / (double)m_readCount; | 206 | double avg = (double)m_readTicks / (double)m_readCount; |
185 | // if (avg > 10000) | 207 | // if (avg > 10000) |
186 | // Environment.Exit(0); | 208 | // Environment.Exit(0); |
187 | m_log.InfoFormat("[ASSET]: Read stats: {0} files, {1} ticks, avg {2:F2}, missing {3}, FS {4}", m_readCount, m_readTicks, (double)m_readTicks / (double)m_readCount, m_missingAssets, m_missingAssetsFS); | 209 | m_log.InfoFormat("[FSASSETS]: Read stats: {0} files, {1} ticks, avg {2:F2}, missing {3}, FS {4}", m_readCount, m_readTicks, (double)m_readTicks / (double)m_readCount, m_missingAssets, m_missingAssetsFS); |
188 | } | 210 | } |
189 | m_readCount = 0; | 211 | m_readCount = 0; |
190 | m_readTicks = 0; | 212 | m_readTicks = 0; |
@@ -196,7 +218,7 @@ namespace OpenSim.Services.FSAssetService | |||
196 | 218 | ||
197 | private void Writer() | 219 | private void Writer() |
198 | { | 220 | { |
199 | m_log.Info("[ASSET]: Writer started"); | 221 | m_log.Info("[FSASSETS]: Writer started"); |
200 | 222 | ||
201 | while (true) | 223 | while (true) |
202 | { | 224 | { |
@@ -236,7 +258,7 @@ namespace OpenSim.Services.FSAssetService | |||
236 | int totalTicks = System.Environment.TickCount - tickCount; | 258 | int totalTicks = System.Environment.TickCount - tickCount; |
237 | if (totalTicks > 0) // Wrap? | 259 | if (totalTicks > 0) // Wrap? |
238 | { | 260 | { |
239 | m_log.InfoFormat("[ASSET]: Write cycle complete, {0} files, {1} ticks, avg {2:F2}", files.Length, totalTicks, (double)totalTicks / (double)files.Length); | 261 | m_log.InfoFormat("[FSASSETS]: Write cycle complete, {0} files, {1} ticks, avg {2:F2}", files.Length, totalTicks, (double)totalTicks / (double)files.Length); |
240 | } | 262 | } |
241 | } | 263 | } |
242 | 264 | ||
@@ -326,13 +348,13 @@ namespace OpenSim.Services.FSAssetService | |||
326 | asset.Metadata.ContentType = | 348 | asset.Metadata.ContentType = |
327 | SLUtil.SLAssetTypeToContentType((int)asset.Type); | 349 | SLUtil.SLAssetTypeToContentType((int)asset.Type); |
328 | sha = GetSHA256Hash(asset.Data); | 350 | sha = GetSHA256Hash(asset.Data); |
329 | m_log.InfoFormat("[FALLBACK]: Added asset {0} from fallback to local store", id); | 351 | m_log.InfoFormat("[FSASSETS]: Added asset {0} from fallback to local store", id); |
330 | Store(asset); | 352 | Store(asset); |
331 | } | 353 | } |
332 | } | 354 | } |
333 | if (asset == null) | 355 | if (asset == null) |
334 | { | 356 | { |
335 | // m_log.InfoFormat("[ASSET]: Asset {0} not found", id); | 357 | // m_log.InfoFormat("[FSASSETS]: Asset {0} not found", id); |
336 | m_missingAssets++; | 358 | m_missingAssets++; |
337 | } | 359 | } |
338 | return asset; | 360 | return asset; |
@@ -353,13 +375,13 @@ namespace OpenSim.Services.FSAssetService | |||
353 | asset.Metadata.ContentType = | 375 | asset.Metadata.ContentType = |
354 | SLUtil.SLAssetTypeToContentType((int)asset.Type); | 376 | SLUtil.SLAssetTypeToContentType((int)asset.Type); |
355 | sha = GetSHA256Hash(asset.Data); | 377 | sha = GetSHA256Hash(asset.Data); |
356 | m_log.InfoFormat("[FALLBACK]: Added asset {0} from fallback to local store", id); | 378 | m_log.InfoFormat("[FSASSETS]: Added asset {0} from fallback to local store", id); |
357 | Store(asset); | 379 | Store(asset); |
358 | } | 380 | } |
359 | } | 381 | } |
360 | if (asset == null) | 382 | if (asset == null) |
361 | m_missingAssetsFS++; | 383 | m_missingAssetsFS++; |
362 | // m_log.InfoFormat("[ASSET]: Asset {0}, hash {1} not found in FS", id, hash); | 384 | // m_log.InfoFormat("[FSASSETS]: Asset {0}, hash {1} not found in FS", id, hash); |
363 | else | 385 | else |
364 | return asset; | 386 | return asset; |
365 | } | 387 | } |
@@ -649,7 +671,7 @@ namespace OpenSim.Services.FSAssetService | |||
649 | { | 671 | { |
650 | count = Convert.ToInt32(args[4]); | 672 | count = Convert.ToInt32(args[4]); |
651 | } | 673 | } |
652 | m_DataConnector.Import(conn, table, start, count, force, new StoreDelegate(Store)); | 674 | m_DataConnector.Import(conn, table, start, count, force, new FSStoreDelegate(Store)); |
653 | } | 675 | } |
654 | } | 676 | } |
655 | 677 | ||