private List <IQuotaRule> CreateRules( IAbsFileSystem fileSystem, QuotaKeeperConfiguration configuration, IContentStoreInternal store) { var rules = new List <IQuotaRule>(); var distributedEvictionSettings = configuration.DistributedEvictionSettings; if (configuration.EnableElasticity) { var elasticSizeRule = new ElasticSizeRule( configuration.HistoryWindowSize, configuration.InitialElasticSize, EvictContentAsync, () => CurrentSize, store.ReadPinSizeHistory, fileSystem, store.RootPath, distributedEvictionSettings: distributedEvictionSettings); rules.Add(elasticSizeRule); } else { if (configuration.MaxSizeQuota != null) { rules.Add(new MaxSizeRule(configuration.MaxSizeQuota, EvictContentAsync, () => CurrentSize, distributedEvictionSettings)); } if (configuration.DiskFreePercentQuota != null) { rules.Add(new DiskFreePercentRule(configuration.DiskFreePercentQuota, EvictContentAsync, fileSystem, store.RootPath, distributedEvictionSettings)); } } if (!rules.Any()) { throw new CacheException("At least one quota rule must be defined"); } return(rules); }
/// <nodoc /> public static QuotaKeeper Create( IAbsFileSystem fileSystem, ContentStoreInternalTracer tracer, ContentStoreConfiguration configuration, long startSize, CancellationToken token, IContentStoreInternal store, DistributedEvictionSettings distributedEvictionSettings = null, bool useLegacyQuotaKeeper = false) { Contract.Requires(fileSystem != null); Contract.Requires(tracer != null); Contract.Requires(configuration != null); if (useLegacyQuotaKeeper) { return(new LegacyQuotaKeeper(fileSystem, tracer, configuration, startSize, token, store, distributedEvictionSettings)); } return(new QuotaKeeperV2(fileSystem, tracer, configuration, startSize, token, store, distributedEvictionSettings)); }
/// <summary> /// Initializes a new instance of the <see cref="FileSystemContentSession" /> class. /// </summary> public FileSystemContentSession(string name, ImplicitPin implicitPin, IContentStoreInternal store) : base(name, store, implicitPin) { }
protected async Task AssertDoesNotContain(IContentStoreInternal store, ContentHash contentHash) { var contains = await store.ContainsAsync(Context, contentHash); contains.Should().BeFalse($"Expected hash={contentHash.ToShortString()} to not be present but was"); }
protected async Task AssertContainsHash(IContentStoreInternal store, ContentHash contentHash) { var contains = await store.ContainsAsync(Context, contentHash); contains.Should().BeTrue($"Expected hash={contentHash} to be present but was not"); }