aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Communications
diff options
context:
space:
mode:
authorSean Dague2009-02-16 12:20:31 +0000
committerSean Dague2009-02-16 12:20:31 +0000
commitf4bec00057fb6987f4ea166347156e1abb985ec1 (patch)
treea8b4e9461b077f1e2e36876d0aea263eb2ceb177 /OpenSim/Framework/Communications
parentcosmetic: adding region name to logging statement (diff)
downloadopensim-SC_OLD-f4bec00057fb6987f4ea166347156e1abb985ec1.zip
opensim-SC_OLD-f4bec00057fb6987f4ea166347156e1abb985ec1.tar.gz
opensim-SC_OLD-f4bec00057fb6987f4ea166347156e1abb985ec1.tar.bz2
opensim-SC_OLD-f4bec00057fb6987f4ea166347156e1abb985ec1.tar.xz
From: Alan Webb <awebb@linux.vnet.ibm.com>
The change makes two principal implementation changes: [1] It removes the hard coded set of possible asset server client implementations, allowing any arbitrary implementation that has been identified to the PluginLoader as an appropriate extension. The extension point for asset server client extension is /OpenSim/AssetServerClient. All of the old configuration rules have been preserved, and any of the legacy configuration values will still work as they did before, except the implementation is now loaded as a plug-in, rather than as a hard-coded instantiation of a specific class. The re-hashing of IAssetServer as an extension of IPlugin made upgrading of the implementation classes a necessity. Caveat: I have not been able to meaningfully test the crypto-grid clients. I believe they should work correctly, but the refactoring necessary to handle plug-in based initialization (vs constructor-based initialisation) admits the possibility of a problem. [2] The asset cache implementation, previously introduce as a hard-code class instantiation is now implemented as an IPlugin. Once again the previous (configurationless) behavior has been preserved. But now it is possible for those interested in experimenting with cache technologies to do so simply by introducing a new extension for the asset cache extension point (/OpenSim/AssetCache). I've tested all of the configuration settings, after applying the patch to a newly extracted tree, and they seem to work OK.
Diffstat (limited to 'OpenSim/Framework/Communications')
-rw-r--r--OpenSim/Framework/Communications/Cache/AssetCache.cs80
-rw-r--r--OpenSim/Framework/Communications/Cache/AssetServerBase.cs55
-rw-r--r--OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs48
-rw-r--r--OpenSim/Framework/Communications/Cache/FileAssetClient.cs37
-rw-r--r--OpenSim/Framework/Communications/Cache/GridAssetClient.cs31
-rw-r--r--OpenSim/Framework/Communications/Cache/SQLAssetServer.cs29
-rw-r--r--OpenSim/Framework/Communications/Resources/AssetCache.addin.xml17
7 files changed, 271 insertions, 26 deletions
diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs
index 1c8f9d6..76c6045 100644
--- a/OpenSim/Framework/Communications/Cache/AssetCache.cs
+++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs
@@ -48,8 +48,67 @@ namespace OpenSim.Framework.Communications.Cache
48 /// sends packetised data directly back to the client. The only point where they meet is AssetReceived() and 48 /// sends packetised data directly back to the client. The only point where they meet is AssetReceived() and
49 /// AssetNotFound(), which means they do share the same asset and texture caches.I agr 49 /// AssetNotFound(), which means they do share the same asset and texture caches.I agr
50 50
51 public class AssetCache : IAssetCache, IAssetReceiver 51 public class AssetCache : IAssetCache
52 { 52 {
53
54 #region IPlugin
55
56 /// <summary>
57 /// The methods and properties in this section are needed to
58 /// support the IPlugin interface. They cann all be overridden
59 /// as needed by a derived class.
60 /// </summary>
61
62 public virtual string Name
63 {
64 get { return "OpenSim.Framework.Communications.Cache.AssetCache"; }
65 }
66
67 public virtual string Version
68 {
69 get { return "1.0"; }
70 }
71
72 public virtual void Initialise()
73 {
74 m_log.Debug("[ASSET CACHE]: Asset cache null initialisation");
75 }
76
77 public virtual void Initialise(IAssetServer assetServer)
78 {
79 m_log.Debug("[ASSET CACHE]: Asset cache server-specified initialisation");
80 m_log.InfoFormat("[ASSET CACHE]: Asset cache initialisation [{0}/{1}]", Name, Version);
81
82 Initialize();
83
84 m_assetServer = assetServer;
85 m_assetServer.SetReceiver(this);
86
87 Thread assetCacheThread = new Thread(RunAssetManager);
88 assetCacheThread.Name = "AssetCacheThread";
89 assetCacheThread.IsBackground = true;
90 assetCacheThread.Start();
91 ThreadTracker.Add(assetCacheThread);
92
93 }
94
95 public virtual void Initialise(ConfigSettings settings, IAssetServer assetServer)
96 {
97 m_log.Debug("[ASSET CACHE]: Asset cache configured initialisation");
98 Initialise(assetServer);
99 }
100
101 public AssetCache()
102 {
103 m_log.Debug("[ASSET CACHE]: Asset cache (plugin constructor)");
104 }
105
106 public void Dispose()
107 {
108 }
109
110 #endregion
111
53 protected ICache m_memcache = new SimpleMemoryCache(); 112 protected ICache m_memcache = new SimpleMemoryCache();
54 113
55 private static readonly ILog m_log 114 private static readonly ILog m_log
@@ -83,7 +142,7 @@ namespace OpenSim.Framework.Communications.Cache
83 /// <summary> 142 /// <summary>
84 /// The 'server' from which assets can be requested and to which assets are persisted. 143 /// The 'server' from which assets can be requested and to which assets are persisted.
85 /// </summary> 144 /// </summary>
86 private readonly IAssetServer m_assetServer; 145 private IAssetServer m_assetServer;
87 146
88 public IAssetServer AssetServer 147 public IAssetServer AssetServer
89 { 148 {
@@ -132,17 +191,8 @@ namespace OpenSim.Framework.Communications.Cache
132 /// <param name="assetServer"></param> 191 /// <param name="assetServer"></param>
133 public AssetCache(IAssetServer assetServer) 192 public AssetCache(IAssetServer assetServer)
134 { 193 {
135 m_log.Info("[ASSET CACHE]: Creating Asset cache"); 194 m_log.Info("[ASSET CACHE]: Asset cache direct constructor");
136 Initialize(); 195 Initialise(assetServer);
137
138 m_assetServer = assetServer;
139 m_assetServer.SetReceiver(this);
140
141 Thread assetCacheThread = new Thread(RunAssetManager);
142 assetCacheThread.Name = "AssetCacheThread";
143 assetCacheThread.IsBackground = true;
144 assetCacheThread.Start();
145 ThreadTracker.Add(assetCacheThread);
146 } 196 }
147 197
148 /// <summary> 198 /// <summary>
@@ -342,7 +392,7 @@ namespace OpenSim.Framework.Communications.Cache
342 } 392 }
343 393
344 // See IAssetReceiver 394 // See IAssetReceiver
345 public void AssetReceived(AssetBase asset, bool IsTexture) 395 public virtual void AssetReceived(AssetBase asset, bool IsTexture)
346 { 396 {
347 397
348 AssetInfo assetInf = new AssetInfo(asset); 398 AssetInfo assetInf = new AssetInfo(asset);
@@ -393,7 +443,7 @@ namespace OpenSim.Framework.Communications.Cache
393 } 443 }
394 444
395 // See IAssetReceiver 445 // See IAssetReceiver
396 public void AssetNotFound(UUID assetID, bool IsTexture) 446 public virtual void AssetNotFound(UUID assetID, bool IsTexture)
397 { 447 {
398// m_log.WarnFormat("[ASSET CACHE]: AssetNotFound for {0}", assetID); 448// m_log.WarnFormat("[ASSET CACHE]: AssetNotFound for {0}", assetID);
399 449
diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs
index 5c902ec..7bb2ab9 100644
--- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs
+++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs
@@ -46,6 +46,61 @@ namespace OpenSim.Framework.Communications.Cache
46 protected Thread m_localAssetServerThread; 46 protected Thread m_localAssetServerThread;
47 protected IAssetDataPlugin m_assetProvider; 47 protected IAssetDataPlugin m_assetProvider;
48 48
49 #region IPlugin
50
51 /// <summary>
52 /// The methods and properties in this region are needed to implement
53 /// the IPlugin interface and its local extensions.
54 /// These can all be overridden as appropriate by a derived class.
55 /// These methods are only applicable when a class is loaded by the
56 /// IPlugin mechanism.
57 ///
58 /// Note that in the case of AssetServerBase, all initialization is
59 /// performed by the default constructor, so nothing additional is
60 /// required here. A derived class may wish to do more.
61 /// </summary>
62
63 public virtual string Name
64 {
65 // get { return "OpenSim.Framework.Communications.Cache.AssetServerBase"; }
66 get { return "AssetServerBase"; }
67 }
68
69 public virtual string Version
70 {
71 get { return "1.0"; }
72 }
73
74 public virtual void Initialise()
75 {
76 m_log.Debug("[ASSET SERVER]: IPlugin null initialization");
77 }
78
79 public virtual void Initialise(ConfigSettings settings)
80 {
81 m_log.Debug("[ASSET SERVER]: IPlugin null configured initialization(1)");
82 m_log.InfoFormat("[ASSET SERVER]: Initializing client [{0}/{1}", Name, Version);
83 }
84
85 public virtual void Initialise(ConfigSettings settings, string p_url)
86 {
87 m_log.Debug("[ASSET SERVER]: IPlugin null configured initialization(2)");
88 m_log.InfoFormat("[ASSET SERVER]: Initializing client [{0}/{1}", Name, Version);
89 }
90
91 public virtual void Initialise(ConfigSettings settings, string p_url, string p_dir, bool p_t)
92 {
93 m_log.Debug("[ASSET SERVER]: IPlugin null configured initialization(3)");
94 m_log.InfoFormat("[ASSET SERVER]: Initializing client [{0}/{1}", Name, Version);
95 }
96
97 public virtual void Dispose()
98 {
99 m_log.Debug("[ASSET SERVER]: dispose");
100 }
101
102 #endregion
103
49 public IAssetDataPlugin AssetProviderPlugin 104 public IAssetDataPlugin AssetProviderPlugin
50 { 105 {
51 get { return m_assetProvider; } 106 get { return m_assetProvider; }
diff --git a/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs b/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs
index 55db289..0f4e8ac 100644
--- a/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs
+++ b/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs
@@ -44,9 +44,37 @@ namespace OpenSim.Framework.Communications.Cache
44{ 44{
45 public class CryptoGridAssetClient : AssetServerBase 45 public class CryptoGridAssetClient : AssetServerBase
46 { 46 {
47
48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
49
50 private string _assetServerUrl;
51 private bool m_encryptOnUpload;
52 private RjinKeyfile m_encryptKey;
53 private readonly Dictionary<string,RjinKeyfile> m_keyfiles = new Dictionary<string, RjinKeyfile>();
54
55 #region IPlugin
56
57 public override string Name
58 {
59 get { return "Crypto"; }
60 }
61
62 public override string Version
63 {
64 get { return "1.0"; }
65 }
66
67 public override void Initialise(ConfigSettings p_set, string p_url, string p_dir, bool p_t)
68 {
69 m_log.Debug("[CRYPTOGRID] Plugin configured initialisation");
70 Initialise(p_url, p_dir, p_t);
71 }
72
73 #endregion
74
47 #region Keyfile Classes 75 #region Keyfile Classes
48 [Serializable] 76 [Serializable]
49 private class RjinKeyfile 77 public class RjinKeyfile
50 { 78 {
51 public string Secret; 79 public string Secret;
52 public string AlsoKnownAs; 80 public string AlsoKnownAs;
@@ -94,7 +122,7 @@ namespace OpenSim.Framework.Communications.Cache
94 /// this may not be the most efficient way of handling encryption, so - as 122 /// this may not be the most efficient way of handling encryption, so - as
95 /// soon as you feel comfortable with it - you may want to redesign this class. 123 /// soon as you feel comfortable with it - you may want to redesign this class.
96 /// </summary> 124 /// </summary>
97 private class UtilRijndael 125 public class UtilRijndael
98 { 126 {
99 /// <summary> 127 /// <summary>
100 /// Encrypts specified plaintext using Rijndael symmetric key algorithm 128 /// Encrypts specified plaintext using Rijndael symmetric key algorithm
@@ -332,15 +360,19 @@ namespace OpenSim.Framework.Communications.Cache
332 } 360 }
333 #endregion 361 #endregion
334 362
335 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 363 public CryptoGridAssetClient() {}
336
337 private readonly string _assetServerUrl;
338 private readonly bool m_encryptOnUpload;
339 private readonly RjinKeyfile m_encryptKey;
340 private readonly Dictionary<string,RjinKeyfile> m_keyfiles = new Dictionary<string, RjinKeyfile>();
341 364
342 public CryptoGridAssetClient(string serverUrl, string keydir, bool decOnly) 365 public CryptoGridAssetClient(string serverUrl, string keydir, bool decOnly)
343 { 366 {
367 m_log.Debug("[CRYPTOGRID] Direct constructor");
368 Initialise(serverUrl, keydir, decOnly);
369 }
370
371 public void Initialise(string serverUrl, string keydir, bool decOnly)
372 {
373
374 m_log.Debug("[CRYPTOGRID] Common constructor");
375
344 _assetServerUrl = serverUrl; 376 _assetServerUrl = serverUrl;
345 377
346 string[] keys = Directory.GetFiles(keydir, "*.deckey"); 378 string[] keys = Directory.GetFiles(keydir, "*.deckey");
diff --git a/OpenSim/Framework/Communications/Cache/FileAssetClient.cs b/OpenSim/Framework/Communications/Cache/FileAssetClient.cs
index 9a60b53..e6574a1 100644
--- a/OpenSim/Framework/Communications/Cache/FileAssetClient.cs
+++ b/OpenSim/Framework/Communications/Cache/FileAssetClient.cs
@@ -26,16 +26,49 @@
26 */ 26 */
27 27
28using System.IO; 28using System.IO;
29using System.Reflection;
30using log4net;
29using System.Xml.Serialization; 31using System.Xml.Serialization;
30 32
31namespace OpenSim.Framework.Communications.Cache 33namespace OpenSim.Framework.Communications.Cache
32{ 34{
33 public class FileAssetClient : AssetServerBase 35 public class FileAssetClient : AssetServerBase
34 { 36 {
35 private readonly string m_dir; 37
38 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
39
40 #region IPlugin
41
42 public override string Name
43 {
44 get { return "File"; }
45 }
46
47 public override string Version
48 {
49 get { return "1.0"; }
50 }
51
52 public override void Initialise(ConfigSettings p_set, string p_url)
53 {
54 m_log.Debug("[FILEASSET] Plugin configured initialisation");
55 Initialise(p_url);
56 }
57
58 #endregion
59
60 private string m_dir;
36 private readonly XmlSerializer m_xs = new XmlSerializer(typeof(AssetBase)); 61 private readonly XmlSerializer m_xs = new XmlSerializer(typeof(AssetBase));
37 62
38 public FileAssetClient(string dir) 63 public FileAssetClient() {}
64
65 public FileAssetClient(string p_url)
66 {
67 m_log.Debug("[FILEASSET] Direct constructor");
68 Initialise(p_url);
69 }
70
71 public void Initialise(string dir)
39 { 72 {
40 if (!Directory.Exists(dir)) 73 if (!Directory.Exists(dir))
41 { 74 {
diff --git a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs
index 1cc9833..6522ad0 100644
--- a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs
+++ b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs
@@ -36,11 +36,40 @@ namespace OpenSim.Framework.Communications.Cache
36{ 36{
37 public class GridAssetClient : AssetServerBase 37 public class GridAssetClient : AssetServerBase
38 { 38 {
39
40 #region IPlugin
41
42 public override string Name
43 {
44 get { return "Grid"; }
45 }
46
47 public override string Version
48 {
49 get { return "1.0"; }
50 }
51
52 public override void Initialise(ConfigSettings p_set, string p_url)
53 {
54 m_log.Debug("[GRIDASSET] Plugin configured initialisation");
55 Initialise(p_url);
56 }
57
58 #endregion
59
39 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 60 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
40 61
41 private string _assetServerUrl; 62 private string _assetServerUrl;
42 63
43 public GridAssetClient(string serverUrl) 64 public GridAssetClient() {}
65
66 public GridAssetClient(string p_url)
67 {
68 m_log.Debug("[GRIDASSET] Direct constructor");
69 Initialise(p_url);
70 }
71
72 public void Initialise(string serverUrl)
44 { 73 {
45 _assetServerUrl = serverUrl; 74 _assetServerUrl = serverUrl;
46 } 75 }
diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs
index 6266bf0..5274288 100644
--- a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs
+++ b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs
@@ -34,10 +34,39 @@ namespace OpenSim.Framework.Communications.Cache
34{ 34{
35 public class SQLAssetServer : AssetServerBase 35 public class SQLAssetServer : AssetServerBase
36 { 36 {
37
37 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 38 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
38 39
40 #region IPlugin
41
42 public override string Name
43 {
44 get { return "SQL"; }
45 }
46
47 public override string Version
48 {
49 get { return "1.0"; }
50 }
51
52 public override void Initialise(ConfigSettings p_set)
53 {
54 m_log.Debug("[SQLASSET] Plugin configured initialisation");
55 Initialise(p_set.StandaloneAssetPlugin,p_set.StandaloneAssetSource);
56 }
57
58 #endregion
59
60 public SQLAssetServer() {}
61
39 public SQLAssetServer(string pluginName, string connect) 62 public SQLAssetServer(string pluginName, string connect)
40 { 63 {
64 m_log.Debug("[SQLASSET] Direct constructor");
65 Initialise(pluginName, connect);
66 }
67
68 public void Initialise(string pluginName, string connect)
69 {
41 AddPlugin(pluginName, connect); 70 AddPlugin(pluginName, connect);
42 } 71 }
43 72
diff --git a/OpenSim/Framework/Communications/Resources/AssetCache.addin.xml b/OpenSim/Framework/Communications/Resources/AssetCache.addin.xml
new file mode 100644
index 0000000..61a9f0f
--- /dev/null
+++ b/OpenSim/Framework/Communications/Resources/AssetCache.addin.xml
@@ -0,0 +1,17 @@
1<Addin id="OpenSim.Framework.Communications" version="1.0">
2 <Runtime>
3 <Import assembly="OpenSim.Framework.Communications.dll"/>
4 </Runtime>
5 <Dependencies>
6 <Addin id="OpenSim" version="0.5" />
7 </Dependencies>
8 <Extension path="/OpenSim/AssetCache">
9 <Cache id="Default" provider="Default" type="OpenSim.Framework.Communications.Cache.AssetCache" />
10 </Extension>
11 <Extension path="/OpenSim/AssetServerClient">
12 <ServerClient id="Crypto" provider="Crypto" type="OpenSim.Framework.Communications.Cache.CryptoGridAssetClient" />
13 <ServerClient id="Grid" provider="Grid" type="OpenSim.Framework.Communications.Cache.GridAssetClient" />
14 <ServerClient id="File" provider="File" type="OpenSim.Framework.Communications.Cache.FileAssetClient" />
15 <ServerClient id="SQL" provider="SQL" type="OpenSim.Framework.Communications.Cache.SQLAssetServer" />
16 </Extension>
17</Addin>