public virtual void Initialize(IAssetServer assetServer) { m_log.InfoFormat("[ASSET CACHE]: Asset cache initialization [{0}/{1}]", Name, Version); m_assetServer = assetServer; m_assetServer.SetReceiver(this); }
/// <summary> /// Initializes the asset cache. This supports legacy configuration values /// to ensure consistent operation, but values outside of that namespace /// are handled by the more generic resolution mechanism provided by /// the ResolveAssetServer virtual method. If extended resolution fails, /// then the normal default action is taken. /// Creation of the AssetCache is handled by ResolveAssetCache. This /// function accepts a reference to the instantiated AssetServer and /// returns an IAssetCache implementation, if possible. This is a virtual /// method. /// </summary> protected virtual void InitializeAssetCache() { IAssetServer assetServer = null; string mode = m_configSettings.AssetStorage; if (String.IsNullOrEmpty(mode)) { throw new Exception("No asset server specified"); } AssetClientPluginInitializer linit = new AssetClientPluginInitializer(m_configSettings); //todo: hack to handle transition from whip if (mode.ToUpper() == "WHIP") { mode = mode.ToUpper(); } assetServer = loadAssetServer(mode, linit); if (assetServer == null) { throw new Exception(String.Format("Asset server {0} could not be loaded", mode)); } // Initialize the asset cache, passing a reference to the selected // asset server interface. m_assetCache = ResolveAssetCache(assetServer); assetServer.Start(); }
private IAssetServer LoadAssetDll(string dllName) { Assembly pluginAssembly = Assembly.LoadFrom(dllName); IAssetServer server = null; foreach (Type pluginType in pluginAssembly.GetTypes()) { if (pluginType.IsPublic) { if (!pluginType.IsAbstract) { Type typeInterface = pluginType.GetInterface("IAssetPlugin", true); if (typeInterface != null) { IAssetPlugin plug = (IAssetPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); server = plug.GetAssetServer(); break; } typeInterface = null; } } } pluginAssembly = null; return(server); }
/// <summary> /// Attempt to instantiate an IAssetCache implementation, using the /// provided IAssetServer reference. /// An asset cache implementation must provide a constructor that /// accepts two parameters; /// [1] A ConfigSettings reference. /// [2] An IAssetServer reference. /// The AssetCache value is obtained from the /// [StartUp]/AssetCache value in the configuration file. /// </summary> protected virtual IAssetCache ResolveAssetCache(IAssetServer assetServer) { IAssetCache assetCache = null; if (m_configSettings.AssetCache != null && m_configSettings.AssetCache != String.Empty) { m_log.DebugFormat("[OpenSim Base]: Attempting to load asset cache id = {0}", m_configSettings.AssetCache); try { PluginInitialiserBase init = new AssetCachePluginInitialiser(m_configSettings, assetServer); PluginLoader<IAssetCache> loader = new PluginLoader<IAssetCache>(init); loader.AddFilter(PLUGIN_ASSET_CACHE, new PluginProviderFilter(m_configSettings.AssetCache)); loader.Load(PLUGIN_ASSET_CACHE); if (loader.Plugins.Count > 0) { assetCache = (IAssetCache)loader.Plugins[0]; } } catch (Exception e) { m_log.Error("[OpenSim Base]: ResolveAssetCache failed"); m_log.Error(e); } } // If everything else fails, we force load the built-in asset cache return (IAssetCache) ((assetCache != null) ? assetCache : new AssetCache(assetServer)); }
/// <summary> /// /// </summary> public AssetCache(IAssetServer assetServer) { Console.WriteLine("Creating Asset cache"); _assetServer = assetServer; _assetServer.SetReceiver(this); Assets = new Dictionary <libsecondlife.LLUUID, AssetInfo>(); Textures = new Dictionary <libsecondlife.LLUUID, TextureImage>(); this._assetCacheThread = new Thread(new ThreadStart(RunAssetManager)); this._assetCacheThread.IsBackground = true; this._assetCacheThread.Start(); }
/// <summary> /// /// </summary> public AssetCache(IAssetServer assetServer) { Console.WriteLine("Creating Asset cache"); _assetServer = assetServer; _assetServer.SetReceiver(this); Assets = new Dictionary<libsecondlife.LLUUID, AssetInfo>(); Textures = new Dictionary<libsecondlife.LLUUID, TextureImage>(); this._assetCacheThread = new Thread(new ThreadStart(RunAssetManager)); this._assetCacheThread.IsBackground = true; this._assetCacheThread.Start(); }
/// <summary> /// Tries to retrieve the asset with the given id /// </summary> /// <param name="assetID"></param> /// <param name="server"></param> /// <param name="asset"></param> /// <returns></returns> private bool TryRequestAsset(OpenMetaverse.UUID assetID, IAssetServer server, out AssetBase asset) { try { asset = server.RequestAssetSync(assetID); } catch (AssetServerException e) { asset = null; m_log.ErrorFormat("[InWorldz.Stratus]: Unable to retrieve asset {0}: {1}", assetID, e); } return(asset != null); }
/// <summary> /// Tries to retrieve the asset with the given id /// </summary> /// <param name="assetID"></param> /// <param name="server"></param> /// <param name="asset"></param> /// <returns></returns> private bool TryRequestAsset(OpenMetaverse.UUID assetID, IAssetServer server, out AssetBase asset) { try { asset = server.RequestAssetSync(assetID); } catch (AssetServerException e) { asset = null; m_log.ErrorFormat("[InWorldz.Stratus]: Unable to retrieve asset {0}: {1}", assetID, e); } return asset != null; }
public virtual void Initialise() { //load the dlls this.AssetServer = this.LoadAssetDll(this.AssetDll); this.GridServer = this.LoadGridDll(this.GridDll); }
public virtual void Initialize(ConfigSettings settings, IAssetServer assetServer) { m_log.Debug("[ASSET CACHE]: Asset cache configured initialization"); Initialize(assetServer); }
/// <summary> /// Constructor. /// </summary> /// <param name="assetServer"></param> public AssetCache(IAssetServer assetServer) { Initialize(assetServer); _negativeCache = new LRUCache<UUID, DateTime>(NEGATIVE_CACHE_SIZE); ProviderRegistry.Instance.RegisterInterface<IAssetCache>(this); }
public override void Initialise(IPlugin plugin) { IAssetServer p = plugin as IAssetServer; p.Initialise(config, assetURL, currdir, test); }
/// <summary> /// Attempt to instantiate an IAssetCache implementation, using the /// provided IAssetServer reference. /// An asset cache implementation must provide a constructor that /// accepts two parameters; /// [1] A ConfigSettings reference. /// [2] An IAssetServer reference. /// The AssetCache value is obtained from the /// [StartUp]/AssetCache value in the configuration file. /// </summary> protected virtual IAssetCache ResolveAssetCache(IAssetServer assetServer) { /*IAssetCache assetCache = null; if (m_configSettings.AssetCache != null && m_configSettings.AssetCache != String.Empty) { m_log.DebugFormat("[OPENSIMBASE]: Attempting to load asset cache id = {0}", m_configSettings.AssetCache); try { PluginInitialiserBase init = new AssetCachePluginInitialiser(m_configSettings, assetServer); PluginLoader<IAssetCache> loader = new PluginLoader<IAssetCache>(init); loader.AddFilter(PLUGIN_ASSET_CACHE, new PluginProviderFilter(m_configSettings.AssetCache)); loader.Load(PLUGIN_ASSET_CACHE); if (loader.Plugins.Count > 0) assetCache = (IAssetCache) loader.Plugins[0]; } catch (Exception e) { m_log.Error("[OPENSIMBASE]: ResolveAssetCache failed"); m_log.Error(e); } } // If everything else fails, we force load the built-in asset cache return (IAssetCache) ((assetCache != null) ? assetCache : new Framework.Communications.Cache.AssetCache(assetServer)); */ return new Framework.Communications.Cache.AssetCache(assetServer); }
/// <summary> /// Initializes a new instance of the <see cref="T:ChattelConfiguration"/> class. /// If the localStoragePath is null, empty, or references a folder that doesn't exist or doesn't have write access, the local storage of assets will be disabled. /// The assetServer parameter allows you to specify a single upstream server for assets to be set to or read from. /// </summary> /// <param name="localStoragePath">Local storage folder path. Folder must exist or caching will be disabled.</param> /// <param name="writeCachePath">Path to the write cache file.</param> /// <param name="writeCacheRecordCount">Number of entries in the write cache file to support.</param> /// <param name="assetServer">Singular upstream server.</param> public ChattelConfiguration(string localStoragePath, string writeCachePath, uint writeCacheRecordCount, IAssetServer assetServer) : this(localStoragePath, writeCachePath, writeCacheRecordCount, assetServer != null ? new List <List <IAssetServer> > { new List <IAssetServer> { assetServer } } : null) { }
/// <summary> /// Initializes a new instance of the <see cref="T:Chattel.ChattelConfiguration"/> class with a singular upstream server. /// Use this when you don't want to cache any assets locally. However, bw warned: you'll have no automatic recovery if there's a process termination during or before the asset gets uploaded to the remote server. /// </summary> /// <param name="assetServer">Singular upstream server.</param> public ChattelConfiguration(IAssetServer assetServer) : this(null, null, 0, assetServer) { }
public void Initialise(ConfigSettings cs, IAssetServer server) { throw new NotImplementedException(); }
public void Initialize(ConfigSettings settings) { IConfig stratusConfig = settings.SettingsFile["InWorldz.Data.Assets.Stratus"]; if (stratusConfig != null && stratusConfig.GetBoolean("enabled", true)) { Config.Settings.Instance.Enabled = true; Config.Settings.Instance.CFSupport = stratusConfig.GetBoolean("CFSupport", true); Config.Settings.Instance.LegacySupport = stratusConfig.GetBoolean("LegacySupport", false); Config.Settings.Instance.WhipURL = stratusConfig.GetString("WhipURL", null); Config.Settings.Instance.UseAsyncStore = stratusConfig.GetBoolean("UseAsyncStore", false); if (Config.Settings.Instance.LegacySupport == true && Config.Settings.Instance.WhipURL == null) { //not allowed, we need a whip URL throw new Exception("To enable stratus legacy asset support, you must include the WhipURL setting"); } //used for testing. should be disabled except for unit tests Config.Settings.Instance.UnitTest_ThrowTimeout = false; Config.Settings.Instance.UnitTest_DeleteOldCacheFilesImmediately = false; Config.Settings.Instance.CFDefaultRegion = stratusConfig.GetString("CFDefaultRegion", null); Config.Settings.Instance.CFUsername = stratusConfig.GetString("CFUsername", null); Config.Settings.Instance.CFApiKey = stratusConfig.GetString("CFAPIKey", null); Config.Settings.Instance.CFContainerPrefix = stratusConfig.GetString("CFContainerPrefix", null); Config.Settings.Instance.CFWorkerThreads = stratusConfig.GetInt("CFWorkerThreads", 8); Config.Settings.Instance.CFUseInternalURL = stratusConfig.GetBoolean("CFUseInternalURL", true); Config.Settings.Instance.CFUseCache = stratusConfig.GetBoolean("CFUseCache", true); Config.Settings.Instance.CFCacheSize = stratusConfig.GetInt("CFCacheSize", 20 * 1024 * 1024); if (Config.Settings.Instance.CFSupport == true && (Config.Settings.Instance.CFUsername == null || Config.Settings.Instance.CFApiKey == null || Config.Settings.Instance.CFContainerPrefix == null || Config.Settings.Instance.CFDefaultRegion == null)) { //not allowed, we need the full cloudfiles auth information throw new Exception("To enable stratus Cloud Files support, you must include the CFDefaultRegion, CFUsername, CFAPIKey, and CFContainerPrefix settings"); } Config.Settings.Instance.WriteTarget = stratusConfig.GetString("WriteTarget", null); if (Config.Settings.Instance.CFSupport && Config.Settings.Instance.LegacySupport && Config.Settings.Instance.WriteTarget == null) { throw new Exception("If both legacy and Cloud Files support is enabled, you must specify 'whip' or 'cf' in the WriteTarget setting"); } Config.Settings.Instance.WriteTarget = Config.Settings.Instance.WriteTarget.ToLower(); m_log.InfoFormat("[InWorldz.Stratus] Plugin is enabled"); if (Config.Settings.Instance.LegacySupport) { _whipAssetClient = new Whip.Client.AssetClient(Config.Settings.Instance.WhipURL); _whipAssetClient.Initialize(settings); if (Config.Settings.Instance.CFSupport) { //legacy and CF support. _firstReadServer = _whipAssetClient; //whip is the first read server with legacy/cf since it has lower latency if (Config.Settings.Instance.WriteTarget == "whip") { _writeServer = _whipAssetClient; } } else { //just legacy _firstReadServer = _whipAssetClient; _writeServer = _whipAssetClient; } } if (Config.Settings.Instance.CFSupport) { _cfAssetClient = new CloudFilesAssetClient(); if (Config.Settings.Instance.LegacySupport) { _secondReadServer = _cfAssetClient; //cf is the second read server when whip is enabled //legacy and CF support if (Config.Settings.Instance.WriteTarget == "cf") { _writeServer = _cfAssetClient; } } else { _firstReadServer = _cfAssetClient; //first read server when only CF is enabled //just CF _writeServer = _cfAssetClient; } } _firstReadServer.SetReceiver(this); if (_secondReadServer != null) { _secondReadServer.SetReceiver(this); } } else { Config.Settings.Instance.Enabled = false; m_log.InfoFormat("[InWorldz.Stratus] Plugin is disabled"); } }
/// <summary> /// Attempt to instantiate an IAssetCache implementation, using the /// provided IAssetServer reference. /// An asset cache implementation must provide a constructor that /// accepts two parameters; /// [1] A ConfigSettings reference. /// [2] An IAssetServer reference. /// The AssetCache value is obtained from the /// [StartUp]/AssetCache value in the configuration file. /// </summary> protected virtual IAssetCache ResolveAssetCache(IAssetServer assetServer) { return(new Framework.Communications.Cache.AssetCache(assetServer)); }
public AssetCachePluginInitializer (ConfigSettings p_sv, IAssetServer p_as) { config = p_sv; server = p_as; }
/// <summary> /// Initialises the asset cache. This supports legacy configuration values /// to ensure consistent operation, but values outside of that namespace /// are handled by the more generic resolution mechanism provided by /// the ResolveAssetServer virtual method. If extended resolution fails, /// then the normal default action is taken. /// Creation of the AssetCache is handled by ResolveAssetCache. This /// function accepts a reference to the instantiated AssetServer and /// returns an IAssetCache implementation, if possible. This is a virtual /// method. /// </summary> protected virtual void InitialiseAssetCache() { LegacyAssetClientPluginInitialiser linit = null; CryptoAssetClientPluginInitialiser cinit = null; AssetClientPluginInitialiser init = null; IAssetServer assetServer = null; string mode = m_configSettings.AssetStorage; if (mode == null | mode == String.Empty) { mode = "default"; } // If "default" is specified, then the value is adjusted // according to whether or not the server is running in // standalone mode. if (mode.ToLower() == "default") { if (m_configSettings.Standalone == false) { mode = "grid"; } else { mode = "local"; } } switch (mode.ToLower()) { // If grid is specified then the grid server is chose regardless // of whether the server is standalone. case "grid": linit = new LegacyAssetClientPluginInitialiser(m_configSettings, m_networkServersInfo.AssetURL); assetServer = loadAssetServer("Grid", linit); break; // If cryptogrid is specified then the cryptogrid server is chose regardless // of whether the server is standalone. case "cryptogrid": cinit = new CryptoAssetClientPluginInitialiser(m_configSettings, m_networkServersInfo.AssetURL, Environment.CurrentDirectory, true); assetServer = loadAssetServer("Crypto", cinit); break; // If cryptogrid_eou is specified then the cryptogrid_eou server is chose regardless // of whether the server is standalone. case "cryptogrid_eou": cinit = new CryptoAssetClientPluginInitialiser(m_configSettings, m_networkServersInfo.AssetURL, Environment.CurrentDirectory, false); assetServer = loadAssetServer("Crypto", cinit); break; // If file is specified then the file server is chose regardless // of whether the server is standalone. case "file": linit = new LegacyAssetClientPluginInitialiser(m_configSettings, m_networkServersInfo.AssetURL); assetServer = loadAssetServer("File", linit); break; // If local is specified then we're going to use the local SQL server // implementation. We drop through, because that will be the fallback // for the following default clause too. case "local": break; // If the asset_database value is none of the previously mentioned strings, then we // try to load a turnkey plugin that matches this value. If not we drop through to // a local default. default: try { init = new AssetClientPluginInitialiser(m_configSettings); assetServer = loadAssetServer(m_configSettings.AssetStorage, init); break; } catch { } m_log.Info("[OpenSim Base]: Default assetserver will be used"); break; } // Open the local SQL-based database asset server if (assetServer == null) { init = new AssetClientPluginInitialiser(m_configSettings); SQLAssetServer sqlAssetServer = (SQLAssetServer) loadAssetServer("SQL", init); sqlAssetServer.LoadDefaultAssets(m_configSettings.AssetSetsXMLFile); assetServer = sqlAssetServer; } // Initialize the asset cache, passing a reference to the selected // asset server interface. m_assetCache = ResolveAssetCache(assetServer); assetServer.Start(); }
public override void Initialize(IPlugin plugin) { IAssetServer p = plugin as IAssetServer; p.Initialize(config); }
public void Initialize(ConfigSettings settings) { IConfig stratusConfig = settings.SettingsFile["InWorldz.Data.Assets.Stratus"]; if (stratusConfig != null && stratusConfig.GetBoolean("enabled", true)) { Config.Settings.Instance.Enabled = true; Config.Settings.Instance.CFSupport = stratusConfig.GetBoolean("CFSupport", true); Config.Settings.Instance.LegacySupport = stratusConfig.GetBoolean("LegacySupport", false); Config.Settings.Instance.WhipURL = stratusConfig.GetString("WhipURL", null); if (Config.Settings.Instance.LegacySupport == true && Config.Settings.Instance.WhipURL == null) { //not allowed, we need a whip URL throw new Exception("To enable stratus legacy asset support, you must include the WhipURL setting"); } //used for testing. should be disabled except for unit tests Config.Settings.Instance.UnitTest_ThrowTimeout = false; Config.Settings.Instance.UnitTest_DeleteOldCacheFilesImmediately = false; Config.Settings.Instance.CFDefaultRegion = stratusConfig.GetString("CFDefaultRegion", null); Config.Settings.Instance.CFUsername = stratusConfig.GetString("CFUsername", null); Config.Settings.Instance.CFApiKey = stratusConfig.GetString("CFAPIKey", null); Config.Settings.Instance.CFContainerPrefix = stratusConfig.GetString("CFContainerPrefix", null); Config.Settings.Instance.CFWorkerThreads = stratusConfig.GetInt("CFWorkerThreads", 8); Config.Settings.Instance.CFUseInternalURL = stratusConfig.GetBoolean("CFUseInternalURL", true); Config.Settings.Instance.CFUseCache = stratusConfig.GetBoolean("CFUseCache", true); Config.Settings.Instance.CFCacheSize = stratusConfig.GetInt("CFCacheSize", 20 * 1024 * 1024); if (Config.Settings.Instance.CFSupport == true && (Config.Settings.Instance.CFUsername == null || Config.Settings.Instance.CFApiKey == null || Config.Settings.Instance.CFContainerPrefix == null || Config.Settings.Instance.CFDefaultRegion == null)) { //not allowed, we need the full cloudfiles auth information throw new Exception("To enable stratus Cloud Files support, you must include the CFDefaultRegion, CFUsername, CFAPIKey, and CFContainerPrefix settings"); } Config.Settings.Instance.WriteTarget = stratusConfig.GetString("WriteTarget", null); if (Config.Settings.Instance.CFSupport && Config.Settings.Instance.LegacySupport && Config.Settings.Instance.WriteTarget == null) { throw new Exception("If both legacy and Cloud Files support is enabled, you must specify 'whip' or 'cf' in the WriteTarget setting"); } Config.Settings.Instance.WriteTarget = Config.Settings.Instance.WriteTarget.ToLower(); m_log.InfoFormat("[InWorldz.Stratus] Plugin is enabled"); if (Config.Settings.Instance.LegacySupport) { _whipAssetClient = new Whip.Client.AssetClient(Config.Settings.Instance.WhipURL); if (Config.Settings.Instance.CFSupport) { //legacy and CF support. _firstReadServer = _whipAssetClient; //whip is the first read server with legacy/cf since it has lower latency if (Config.Settings.Instance.WriteTarget == "whip") { _writeServer = _whipAssetClient; } } else { //just legacy _firstReadServer = _whipAssetClient; _writeServer = _whipAssetClient; } } if (Config.Settings.Instance.CFSupport) { _cfAssetClient = new CloudFilesAssetClient(); if (Config.Settings.Instance.LegacySupport) { _secondReadServer = _cfAssetClient; //cf is the second read server when whip is enabled //legacy and CF support if (Config.Settings.Instance.WriteTarget == "cf") { _writeServer = _cfAssetClient; } } else { _firstReadServer = _cfAssetClient; //first read server when only CF is enabled //just CF _writeServer = _cfAssetClient; } } _firstReadServer.SetReceiver(this); if (_secondReadServer != null) _secondReadServer.SetReceiver(this); } else { Config.Settings.Instance.Enabled = false; m_log.InfoFormat("[InWorldz.Stratus] Plugin is disabled"); } }
public AssetCachePluginInitializer(ConfigSettings p_sv, IAssetServer p_as) { config = p_sv; server = p_as; }
/// <summary> /// Initializes a new instance of the <see cref="T:Chattel.ChattelConfiguration"/> class with both local storage and a singular upstream server. /// Not recommended: with no write cache file you'll have no automatic recovery if there's a process termination during or before the asset gets uploaded to the remote server. /// </summary> /// <param name="localStoragePath">Local storage path.</param> /// <param name="assetServer">Singular upstream server.</param> public ChattelConfiguration(string localStoragePath, IAssetServer assetServer) : this(localStoragePath, null, 0, assetServer) { }
/// <summary> /// Constructor. /// </summary> /// <param name="assetServer"></param> public AssetCache(IAssetServer assetServer) { Initialize(assetServer); _negativeCache = new LRUCache <UUID, DateTime>(NEGATIVE_CACHE_SIZE); ProviderRegistry.Instance.RegisterInterface <IAssetCache>(this); }
/// <summary> /// Attempt to instantiate an IAssetCache implementation, using the /// provided IAssetServer reference. /// An asset cache implementation must provide a constructor that /// accepts two parameters; /// [1] A ConfigSettings reference. /// [2] An IAssetServer reference. /// The AssetCache value is obtained from the /// [StartUp]/AssetCache value in the configuration file. /// </summary> protected virtual IAssetCache ResolveAssetCache(IAssetServer assetServer) { return new Framework.Communications.Cache.AssetCache(assetServer); }