public void Init() { // Configure Log4Net XmlConfigurator.Configure(new FileInfo(Constants.LOG_CONFIG_PATH)); // Set CWD so that native libs are found. Directory.SetCurrentDirectory(TestContext.CurrentContext.TestDirectory); // Load INI stuff var configSource = new ArgvConfigSource(new string[] { }); // Configure nIni aliases and locale Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US", true); configSource.Alias.AddAlias("On", true); configSource.Alias.AddAlias("Off", false); configSource.Alias.AddAlias("True", true); configSource.Alias.AddAlias("False", false); configSource.Alias.AddAlias("Yes", true); configSource.Alias.AddAlias("No", false); // Read in the ini file configSource.Merge(new IniConfigSource(Constants.INI_PATH)); #pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body try { Directory.Delete(DATABASE_FOLDER_PATH, true); } catch (Exception) { } try { File.Delete(WRITE_CACHE_FILE_PATH); } catch (Exception) { } #pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body Directory.CreateDirectory(DATABASE_FOLDER_PATH); // Start booting server var pidFileManager = new LibWhipLru.Util.PIDFileManager(Constants.PID_FILE_PATH); var chattelConfigRead = new ChattelConfiguration(DATABASE_FOLDER_PATH); var chattelConfigWrite = new ChattelConfiguration(DATABASE_FOLDER_PATH); var readerLocalStorage = new LibWhipLru.Cache.AssetLocalStorageLmdbPartitionedLRU( chattelConfigRead, DATABASE_MAX_SIZE_BYTES, TimeSpan.FromSeconds(1) ); var chattelReader = new ChattelReader(chattelConfigRead, readerLocalStorage); var chattelWriter = new ChattelWriter(chattelConfigWrite, readerLocalStorage); var storageManager = new LibWhipLru.Cache.StorageManager( readerLocalStorage, TimeSpan.FromMinutes(2), chattelReader, chattelWriter ); _service = new WhipLru( Constants.SERVICE_ADDRESS, Constants.SERVICE_PORT, Constants.PASSWORD, pidFileManager, storageManager ); _service.Start(); }
public TestLibWhipLru() : base(SERVICE_ADDRESS, SERVICE_PORT, SERVICE_PASSWORD) { LOG.Debug($"Initializing {nameof(TestLibWhipLru)}..."); #pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body try { System.IO.Directory.Delete("SpeedTestLibWhipLru", true); } catch (Exception) { } try { System.IO.File.Delete("SpeedTestLibWhipLru.wcache"); } catch (Exception) { } try { System.IO.File.Delete("SpeedTestLibWhipLru.pid"); } catch (Exception) { } #pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body var config = new Chattel.ChattelConfiguration( "SpeedTestLibWhipLru", "SpeedTestLibWhipLru.wcache", 100, (Chattel.IAssetServer)null ); _libWhipLruLocalStorage = new LibWhipLru.Cache.AssetLocalStorageLmdbPartitionedLRU( config, uint.MaxValue, TestLibWhipLruLocalStorage.DATABASE_PARTITION_INTERVAL ); _libWhipLruStorageManager = new LibWhipLru.Cache.StorageManager( _libWhipLruLocalStorage, TimeSpan.FromMinutes(2), null, null ); _libWhipLruStorageManager.StoreAsset(new InWorldz.Data.Assets.Stratus.StratusAsset { CreateTime = DateTime.UtcNow, // Close enough. Data = _knownAsset.Data, Description = _knownAsset.Description, Id = new Guid(_knownAsset.Uuid), Local = _knownAsset.Local, Name = _knownAsset.Name, Temporary = _knownAsset.Temporary, Type = (sbyte)_knownAsset.Type, }, result => {}); var pidFileManager = new LibWhipLru.Util.PIDFileManager("SpeedTestLibWhipLru.pid"); _libWhipLru = new LibWhipLru.WhipLru(SERVICE_ADDRESS, SERVICE_PORT, SERVICE_PASSWORD, pidFileManager, _libWhipLruStorageManager); _libWhipLru.Start(); Thread.Sleep(500); LOG.Debug($"Initialization of {nameof(TestLibWhipLru)} complete."); }