/// <summary> /// Initializes a new instance of the <see cref="MaxSizeRule"/> class. /// </summary> public MaxSizeRule(MaxSizeQuota quota, EvictAsync evictAsync, Func <long> getCurrentSizeFunc, DistributedEvictionSettings distributedEvictionSettings = null) : base(evictAsync, OnlyUnlinkedValue, distributedEvictionSettings) { Contract.Requires(quota != null); Contract.Requires(evictAsync != null); Contract.Requires(getCurrentSizeFunc != null); _quota = quota; _getCurrentSizeFunc = getCurrentSizeFunc; }
/// <summary> /// Initializes a new instance of the <see cref="DiskFreePercentRule"/> class. /// </summary> public DiskFreePercentRule( DiskFreePercentQuota quota, EvictAsync evictAsync, IAbsFileSystem fileSystem, AbsolutePath rootPath, DistributedEvictionSettings distributedEvictionSettings = null) : base(evictAsync, OnlyUnlinkedValue, distributedEvictionSettings) { Contract.Requires(quota != null); Contract.Requires(evictAsync != null); Contract.Requires(fileSystem != null); Contract.Requires(rootPath != null); _quota = quota; _fileSystem = fileSystem; _rootPath = rootPath; }
/// <summary> /// Initializes a new instance of the <see cref="ElasticSizeRule" /> class. /// </summary> public ElasticSizeRule( int?historyWindowSize, MaxSizeQuota initialElasticSize, EvictAsync evictAsync, Func <long> getCurrentSizeFunc, Func <int, PinSizeHistory.ReadHistoryResult> getPinnedSizeHistoryFunc, IAbsFileSystem fileSystem, AbsolutePath rootPath, double?calibrationCoefficient = default(double?), DistributedEvictionSettings distributedEvictionSettings = null) : base(evictAsync, OnlyUnlinkedValue, distributedEvictionSettings) { Contract.Requires(!historyWindowSize.HasValue || historyWindowSize.Value >= 0); Contract.Requires(evictAsync != null); Contract.Requires(getCurrentSizeFunc != null); Contract.Requires(getPinnedSizeHistoryFunc != null); Contract.Requires(fileSystem != null); Contract.Requires(rootPath != null); Contract.Requires(!calibrationCoefficient.HasValue || calibrationCoefficient.Value > 1.0); _historyWindowSize = historyWindowSize ?? DefaultHistoryWindowSize; _calibrationCoefficient = calibrationCoefficient ?? DefaultCalibrationCoefficient; _getPinnedSizeHistoryFunc = getPinnedSizeHistoryFunc; _getCurrentSizeFunc = getCurrentSizeFunc; _fileSystem = fileSystem; _rootPath = rootPath; _initialQuota = initialElasticSize ?? SmallQuota; var loadQuotaResult = LoadOrCreateNewAsync(_fileSystem, _initialQuota, _rootPath).GetAwaiter().GetResult(); _quota = loadQuotaResult.Quota; _historyTimestampInTick = loadQuotaResult.HistoryTimestampInTick; // TODO: CalibrateAsync method fails in tests all the time. Bug #1331905 CalibrateAsync().GetAwaiter().GetResult().IgnoreFailure(); Contract.Assert(IsInsideHardLimit(0, checkIfQuotaEnabled: false).Succeeded); }
/// <summary> /// Initializes a new instance of the <see cref="QuotaRule" /> class. /// </summary> protected QuotaRule(EvictAsync evictAsync, bool onlyUnlinked, DistributedEvictionSettings distributedEvictionSettings = null) { _distributedEvictionSettings = distributedEvictionSettings; _evictAsync = evictAsync; OnlyUnlinked = onlyUnlinked; }