aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
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/Region
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/Region')
-rw-r--r--OpenSim/Region/Application/ConfigurationLoader.cs1
-rw-r--r--OpenSim/Region/Application/OpenSimBase.cs168
2 files changed, 151 insertions, 18 deletions
diff --git a/OpenSim/Region/Application/ConfigurationLoader.cs b/OpenSim/Region/Application/ConfigurationLoader.cs
index 228c0aa..638125c 100644
--- a/OpenSim/Region/Application/ConfigurationLoader.cs
+++ b/OpenSim/Region/Application/ConfigurationLoader.cs
@@ -268,6 +268,7 @@ namespace OpenSim
268 m_configSettings.StorageConnectionString = startupConfig.GetString("storage_connection_string"); 268 m_configSettings.StorageConnectionString = startupConfig.GetString("storage_connection_string");
269 m_configSettings.EstateConnectionString = startupConfig.GetString("estate_connection_string", m_configSettings.StorageConnectionString); 269 m_configSettings.EstateConnectionString = startupConfig.GetString("estate_connection_string", m_configSettings.StorageConnectionString);
270 m_configSettings.AssetStorage = startupConfig.GetString("asset_database"); 270 m_configSettings.AssetStorage = startupConfig.GetString("asset_database");
271 m_configSettings.AssetCache = startupConfig.GetString("AssetCache");
271 m_configSettings.ClientstackDll = startupConfig.GetString("clientstack_plugin"); 272 m_configSettings.ClientstackDll = startupConfig.GetString("clientstack_plugin");
272 } 273 }
273 274
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs
index 914bd7e..8198138 100644
--- a/OpenSim/Region/Application/OpenSimBase.cs
+++ b/OpenSim/Region/Application/OpenSimBase.cs
@@ -55,6 +55,12 @@ namespace OpenSim
55 { 55 {
56 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 56 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
57 57
58 // These are the names of the plugin-points extended by this
59 // class during system startup.
60
61 private const string PLUGIN_ASSET_CACHE = "/OpenSim/AssetCache";
62 private const string PLUGIN_ASSET_SERVER_CLIENT = "/OpenSim/AssetServerClient";
63
58 protected string proxyUrl; 64 protected string proxyUrl;
59 protected int proxyOffset = 0; 65 protected int proxyOffset = 0;
60 66
@@ -309,57 +315,183 @@ namespace OpenSim
309 } 315 }
310 316
311 /// <summary> 317 /// <summary>
312 /// Initialises the assetcache 318 /// Initialises the asset cache. This supports legacy configuration values
319 /// to ensure consistent operation, but values outside of that namespace
320 /// are handled by the more generic resolution mechanism provided by
321 /// the ResolveAssetServer virtual method. If extended resolution fails,
322 /// then the normal default action is taken.
323 /// Creation of the AssetCache is handled by ResolveAssetCache. This
324 /// function accepts a reference to the instantiated AssetServer and
325 /// returns an IAssetCache implementation, if possible. This is a virtual
326 /// method.
313 /// </summary> 327 /// </summary>
328
314 protected virtual void InitialiseAssetCache() 329 protected virtual void InitialiseAssetCache()
315 { 330 {
316 331
332 LegacyAssetServerClientPluginInitialiser linit = null;
333 CryptoAssetServerClientPluginInitialiser cinit = null;
334 AssetServerClientPluginInitialiser init = null;
335
317 IAssetServer assetServer = null; 336 IAssetServer assetServer = null;
318 string mode = m_configSettings.AssetStorage; 337 string mode = m_configSettings.AssetStorage;
319 338
320 if (m_configSettings.Standalone == false && 339 if (mode == null | mode == String.Empty)
321 m_configSettings.AssetStorage == "default") 340 mode = "default";
322 mode = "grid";
323 341
324 switch (mode) 342 // If "default" is specified, then the value is adjusted
343 // according to whether or not the server is running in
344 // standalone mode.
345
346 if (mode.ToLower() == "default")
325 { 347 {
348 if (m_configSettings.Standalone == false)
349 mode = "grid";
350 else
351 mode = "local";
352 }
353
354 switch (mode.ToLower())
355 {
356
357 // If grid is specified then the grid server is chose regardless
358 // of whether the server is standalone.
359
326 case "grid" : 360 case "grid" :
327 assetServer = new GridAssetClient(m_networkServersInfo.AssetURL); 361 linit = new LegacyAssetServerClientPluginInitialiser(m_configSettings, m_networkServersInfo.AssetURL);
362 assetServer = loadAssetServer("Grid", linit);
328 break; 363 break;
364
365
366 // If cryptogrid is specified then the cryptogrid server is chose regardless
367 // of whether the server is standalone.
368
329 case "cryptogrid" : 369 case "cryptogrid" :
330 assetServer = new CryptoGridAssetClient(m_networkServersInfo.AssetURL, 370 cinit = new CryptoAssetServerClientPluginInitialiser(m_configSettings, m_networkServersInfo.AssetURL,
331 Environment.CurrentDirectory, true); 371 Environment.CurrentDirectory, true);
372 assetServer = loadAssetServer("Crypto", cinit);
332 break; 373 break;
374
375 // If cryptogrid_eou is specified then the cryptogrid_eou server is chose regardless
376 // of whether the server is standalone.
377
333 case "cryptogrid_eou" : 378 case "cryptogrid_eou" :
334 assetServer = new CryptoGridAssetClient(m_networkServersInfo.AssetURL, 379 cinit = new CryptoAssetServerClientPluginInitialiser(m_configSettings, m_networkServersInfo.AssetURL,
335 Environment.CurrentDirectory, false); 380 Environment.CurrentDirectory, false);
381 assetServer = loadAssetServer("Crypto", cinit);
336 break; 382 break;
383
384 // If file is specified then the file server is chose regardless
385 // of whether the server is standalone.
386
337 case "file" : 387 case "file" :
338 assetServer = new FileAssetClient(m_networkServersInfo.AssetURL); 388 linit = new LegacyAssetServerClientPluginInitialiser(m_configSettings, m_networkServersInfo.AssetURL);
389 assetServer = loadAssetServer("File", linit);
390 break;
391
392 // If local is specified then we're going to use the local SQL server
393 // implementation. We drop through, because that will be the fallback
394 // for the following default clause too.
395
396 case "local" :
339 break; 397 break;
398
399 // If the asset_database value is none of the previously mentioned strings, then we
400 // try to load a turnkey plugin that matches this value. If not we drop through to
401 // a local default.
402
340 default : 403 default :
341 if (!ResolveAssetServer(out assetServer)) 404 try
342 { 405 {
343 SQLAssetServer sqlAssetServer = new SQLAssetServer(m_configSettings.StandaloneAssetPlugin, m_configSettings.StandaloneAssetSource); 406 init = new AssetServerClientPluginInitialiser(m_configSettings);
344 sqlAssetServer.LoadDefaultAssets(m_configSettings.AssetSetsXMLFile); 407 assetServer = loadAssetServer(m_configSettings.AssetStorage, init);
345 assetServer = sqlAssetServer; 408 break;
346 } 409 }
410 catch {}
411 m_log.Info("[OPENSIMBASE] Default assetserver will be used");
347 break; 412 break;
413
414 }
415
416 // Open the local SQL-based database asset server
417
418 if (assetServer == null)
419 {
420 init = new AssetServerClientPluginInitialiser(m_configSettings);
421 SQLAssetServer sqlAssetServer = (SQLAssetServer) loadAssetServer("SQL", init);
422 sqlAssetServer.LoadDefaultAssets(m_configSettings.AssetSetsXMLFile);
423 assetServer = sqlAssetServer;
348 } 424 }
349 425
426 // Initialize the asset cache, passing a reference to the selected
427 // asset server interface.
428
350 m_assetCache = ResolveAssetCache(assetServer); 429 m_assetCache = ResolveAssetCache(assetServer);
351 430
352 } 431 }
353 432
354 private bool ResolveAssetServer(out IAssetServer assetServer) 433 // This method loads the identified asset server, passing an approrpiately
434 // initialized Initialise wrapper. There should to be exactly one match,
435 // if not, then the first match is used.
436
437 private IAssetServer loadAssetServer(string id, PluginInitialiserBase pi)
355 { 438 {
356 assetServer = null; 439
357 return false; 440 m_log.DebugFormat("[OPENSIMBASE] Attempting to load asset server id={0}", id);
441
442 PluginLoader<IAssetServer> loader = new PluginLoader<IAssetServer>(pi);
443 loader.AddFilter(PLUGIN_ASSET_SERVER_CLIENT, new PluginProviderFilter(id));
444 loader.Load(PLUGIN_ASSET_SERVER_CLIENT);
445 if (loader.Plugins.Count > 0)
446 return (IAssetServer) loader.Plugins[0];
447 else
448 return null;
449
358 } 450 }
359 451
360 private IAssetCache ResolveAssetCache(IAssetServer assetServer) 452 /// <summary>
453 /// Attempt to instantiate an IAssetCache implementation, using the
454 /// provided IAssetServer reference.
455 /// An asset cache implementation must provide a constructor that
456 /// accepts two parameters;
457 /// [1] A ConfigSettings reference.
458 /// [2] An IAssetServer reference.
459 /// The AssetCache value is obtained from the
460 /// [StartUp]/AssetCache value in the configuration file.
461 /// </summary>
462
463 protected virtual IAssetCache ResolveAssetCache(IAssetServer assetServer)
361 { 464 {
362 return new AssetCache(assetServer); 465
466 IAssetCache assetCache = null;
467
468 m_log.DebugFormat("[OPENSIMBASE] Attempting to load asset cache id={0}", m_configSettings.AssetCache);
469
470 if (m_configSettings.AssetCache != null && m_configSettings.AssetCache != String.Empty)
471 {
472 try
473 {
474
475 PluginInitialiserBase init = new AssetCachePluginInitialiser(m_configSettings, assetServer);
476 PluginLoader<IAssetCache> loader = new PluginLoader<IAssetCache>(init);
477 loader.AddFilter(PLUGIN_ASSET_SERVER_CLIENT, new PluginProviderFilter(m_configSettings.AssetCache));
478
479 loader.Load(PLUGIN_ASSET_CACHE);
480 if (loader.Plugins.Count > 0)
481 assetCache = (IAssetCache) loader.Plugins[0];
482
483 }
484 catch (Exception e)
485 {
486 m_log.Debug("[OPENSIMBASE] ResolveAssetCache completed");
487 m_log.Debug(e);
488 }
489 }
490
491 // If everything else fails, we force load the built-in asset cache
492
493 return (IAssetCache) ((assetCache != null) ? assetCache : new AssetCache(assetServer));
494
363 } 495 }
364 496
365 public void ProcessLogin(bool LoginEnabled) 497 public void ProcessLogin(bool LoginEnabled)