示例#1
0
        public TestLibWhipLruLocalStorage()
        {
            LOG.Debug($"Initializing {nameof(TestLibWhipLruLocalStorage)}...");

            _timer          = new System.Timers.Timer();
            _timer.Elapsed += TimerExpired;

#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
            try {
                System.IO.Directory.Delete("TestLibWhipLruCache", true);
            }
            catch {
                // Don't care.
            }
            try {
                System.IO.File.Delete("TestLibWhipLruCache.wcache");
            }
            catch {
                // Don't care.
            }
#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body

            var config = new Chattel.ChattelConfiguration(
                "TestLibWhipLruCache",
                "TestLibWhipLruCache.wcache",
                100,
                (Chattel.IAssetServer)null
                );

            _libWhipLruLocalStorage = new LibWhipLru.Cache.AssetLocalStorageLmdbPartitionedLRU(
                config,
                uint.MaxValue,
                DATABASE_PARTITION_INTERVAL
                );

            _libWhipLruStorageManager = new LibWhipLru.Cache.StorageManager(
                _libWhipLruLocalStorage,
                TimeSpan.FromMinutes(2),
                null,
                null
                );

            _libWhipLruStorageManager.StoreAsset(_knownAsset, result => {});

            LOG.Debug($"Initialization of {nameof(TestLibWhipLruLocalStorage)} complete.");
        }
示例#2
0
        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.");
        }