public DistributedCacheServiceConfiguration( LocalCasSettings localCasSettings, DistributedContentSettings distributedCacheSettings) { LocalCasSettings = localCasSettings; DistributedContentSettings = distributedCacheSettings; }
/// <nodoc /> public static GrpcFileCopierConfiguration FromDistributedContentSettings(DistributedContentSettings dcs, int grpcPort) { var grpcCopyClientCacheConfiguration = GrpcCopyClientCacheConfiguration.FromDistributedContentSettings(dcs); var grpcFileCopierConfiguration = new GrpcFileCopierConfiguration() { GrpcPort = (int)grpcPort, GrpcCopyClientCacheConfiguration = grpcCopyClientCacheConfiguration, JunctionsByDirectory = dcs.AlternateDriveMap }; ApplyIfNotNull( dcs.GrpcFileCopierGrpcCopyClientInvalidationPolicy, v => { if (!Enum.TryParse <GrpcFileCopierConfiguration.ClientInvalidationPolicy>(v, out var parsed)) { throw new ArgumentException( $"Failed to parse `{nameof(dcs.GrpcFileCopierGrpcCopyClientInvalidationPolicy)}` setting with value `{dcs.GrpcFileCopierGrpcCopyClientInvalidationPolicy}` into type `{nameof(GrpcFileCopierConfiguration.ClientInvalidationPolicy)}`"); } grpcFileCopierConfiguration.GrpcCopyClientInvalidationPolicy = parsed; }); grpcFileCopierConfiguration.UseUniversalLocations = dcs.UseUniversalLocations; grpcFileCopierConfiguration.UseDomainName = dcs.UseDomainName; return(grpcFileCopierConfiguration); }
public DistributedContentStoreFactory(DistributedCacheServiceArguments arguments) { _logger = arguments.Logger; _arguments = arguments; _distributedSettings = arguments.Configuration.DistributedContentSettings; _keySpace = string.IsNullOrWhiteSpace(_arguments.Keyspace) ? ContentLocationStoreFactory.DefaultKeySpace : _arguments.Keyspace; _fileSystem = arguments.FileSystem; _secretRetriever = new DistributedCacheSecretRetriever(arguments); _orderedResolvedCacheSettings = ResolveCacheSettingsInPrecedenceOrder(arguments); Contract.Assert(_orderedResolvedCacheSettings.Count != 0); RedisContentLocationStoreConfiguration = CreateRedisConfiguration(); _distributedContentStoreSettings = CreateDistributedStoreSettings(_arguments, RedisContentLocationStoreConfiguration); _copier = new DistributedContentCopier( _distributedContentStoreSettings, _fileSystem, fileCopier: _arguments.Copier, copyRequester: _arguments.CopyRequester, _arguments.Overrides.Clock, _logger ); _redisMemoizationStoreFactory = new Lazy <RedisMemoizationStoreFactory>(() => CreateRedisCacheFactory()); }
public void RangeExlusivesAreChecked() { var settings = DistributedContentSettings.CreateDisabled(); settings.EvictionRemovalFraction = -1; var errors = settings.Validate(); errors.Count.Should().Be(1); errors[0].Should().Contain(nameof(settings.EvictionRemovalFraction)); settings.EvictionRemovalFraction = 1.1F; errors = settings.Validate(); errors.Count.Should().Be(1); errors[0].Should().Contain(nameof(settings.EvictionRemovalFraction)); settings.EvictionRemovalFraction = 1; errors = settings.Validate(); errors.Count.Should().Be(1); errors[0].Should().Contain(nameof(settings.EvictionRemovalFraction)); settings.EvictionRemovalFraction = 0; errors = settings.Validate(); errors.Should().BeEmpty(); }
internal DistributedCacheServiceArguments CreateDistributedCacheServiceArguments( IRemoteFileCopier copier, IContentCommunicationManager copyRequester, DistributedContentSettings dcs, HostInfo host, string cacheName, string cacheRootPath, uint grpcPort, int maxSizeQuotaMB, string dataRootPath, CancellationToken ct, int?bufferSizeForGrpcCopies, int?gzipBarrierSizeForGrpcCopies, LoggingSettings loggingSettings, ITelemetryFieldsProvider telemetryFieldsProvider) { var distributedCacheServiceHost = new EnvironmentVariableHost(); var localCasSettings = LocalCasSettings.Default( maxSizeQuotaMB: maxSizeQuotaMB, cacheRootPath: cacheRootPath, cacheName: cacheName, grpcPort: grpcPort, grpcPortFileName: _scenario); localCasSettings.PreferredCacheDrive = new AbsolutePath(cacheRootPath).GetPathRoot(); localCasSettings.ServiceSettings = new LocalCasServiceSettings(60, scenarioName: _scenario, grpcPort: grpcPort, grpcPortFileName: _scenario, bufferSizeForGrpcCopies: bufferSizeForGrpcCopies, gzipBarrierSizeForGrpcCopies: gzipBarrierSizeForGrpcCopies); var config = new DistributedCacheServiceConfiguration(localCasSettings, dcs, loggingSettings); return(new DistributedCacheServiceArguments(_logger, copier, copyRequester, distributedCacheServiceHost, host, ct, dataRootPath, config, null) { TelemetryFieldsProvider = telemetryFieldsProvider, }); }
public void RangesAreChecked() { var settings = DistributedContentSettings.CreateDisabled(); settings.BlobExpiryTimeMinutes = -1; var errors = settings.Validate(); errors.Count.Should().Be(1); errors[0].Should().Contain(nameof(settings.BlobExpiryTimeMinutes)); settings = DistributedContentSettings.CreateDisabled(); settings.MinimumSpeedInMbPerSec = -1F; errors = settings.Validate(); errors.Count.Should().Be(1); errors[0].Should().Contain(nameof(settings.MinimumSpeedInMbPerSec)); settings = DistributedContentSettings.CreateDisabled(); settings.CentralStoragePropagationDelaySeconds = 0; errors = settings.Validate(); errors.Should().BeEmpty(string.Join(", ", errors)); settings = DistributedContentSettings.CreateDisabled(); settings.BandwidthCheckIntervalSeconds = 1; errors = settings.Validate(); errors.Should().BeEmpty(string.Join(", ", errors)); }
private static LocalServerConfiguration CreateLocalServerConfiguration( LocalCasServiceSettings localCasServiceSettings, ServiceConfiguration serviceConfiguration, DistributedContentSettings distributedSettings) { serviceConfiguration.GrpcPort = localCasServiceSettings.GrpcPort; serviceConfiguration.BufferSizeForGrpcCopies = localCasServiceSettings.BufferSizeForGrpcCopies; serviceConfiguration.GzipBarrierSizeForGrpcCopies = localCasServiceSettings.GzipBarrierSizeForGrpcCopies; serviceConfiguration.ProactivePushCountLimit = localCasServiceSettings.MaxProactivePushRequestHandlers; serviceConfiguration.CopyRequestHandlingCountLimit = localCasServiceSettings.MaxCopyFromHandlers; var localContentServerConfiguration = new LocalServerConfiguration(serviceConfiguration); ApplyIfNotNull(localCasServiceSettings.UnusedSessionTimeoutMinutes, value => localContentServerConfiguration.UnusedSessionTimeout = TimeSpan.FromMinutes(value)); ApplyIfNotNull(localCasServiceSettings.UnusedSessionHeartbeatTimeoutMinutes, value => localContentServerConfiguration.UnusedSessionHeartbeatTimeout = TimeSpan.FromMinutes(value)); ApplyIfNotNull(localCasServiceSettings.GrpcCoreServerOptions, value => localContentServerConfiguration.GrpcCoreServerOptions = value); ApplyIfNotNull(localCasServiceSettings.GrpcEnvironmentOptions, value => localContentServerConfiguration.GrpcEnvironmentOptions = value); ApplyIfNotNull(distributedSettings?.UseUnsafeByteStringConstruction, value => { GrpcExtensions.UnsafeByteStringOptimizations = value; }); ApplyIfNotNull(distributedSettings?.Unsafe_DisableDeprecatedConcurrentAccessLock, value => { PassThroughFileSystem.ConcurrentAccess = new System.Threading.SemaphoreSlim(int.MaxValue); }); ApplyIfNotNull(distributedSettings?.ShutdownEvictionBeforeHibernation, value => localContentServerConfiguration.ShutdownEvictionBeforeHibernation = value); return(localContentServerConfiguration); }
private static LocalServerConfiguration CreateLocalServerConfiguration( LocalCasServiceSettings localCasServiceSettings, ServiceConfiguration serviceConfiguration, DistributedContentSettings distributedSettings) { serviceConfiguration.GrpcPort = localCasServiceSettings.GrpcPort; serviceConfiguration.BufferSizeForGrpcCopies = localCasServiceSettings.BufferSizeForGrpcCopies; serviceConfiguration.ProactivePushCountLimit = localCasServiceSettings.MaxProactivePushRequestHandlers; serviceConfiguration.CopyRequestHandlingCountLimit = localCasServiceSettings.MaxCopyFromHandlers; var localContentServerConfiguration = new LocalServerConfiguration(serviceConfiguration); ApplyIfNotNull(localCasServiceSettings.UnusedSessionTimeoutMinutes, value => localContentServerConfiguration.UnusedSessionTimeout = TimeSpan.FromMinutes(value)); ApplyIfNotNull(localCasServiceSettings.UnusedSessionHeartbeatTimeoutMinutes, value => localContentServerConfiguration.UnusedSessionHeartbeatTimeout = TimeSpan.FromMinutes(value)); ApplyIfNotNull(localCasServiceSettings.GrpcCoreServerOptions, value => localContentServerConfiguration.GrpcCoreServerOptions = value); ApplyIfNotNull(localCasServiceSettings.GrpcEnvironmentOptions, value => localContentServerConfiguration.GrpcEnvironmentOptions = value); ApplyIfNotNull(localCasServiceSettings.DoNotShutdownSessionsInUse, value => localContentServerConfiguration.DoNotShutdownSessionsInUse = value); ApplyIfNotNull(distributedSettings?.UseUnsafeByteStringConstruction, value => { GrpcExtensions.UnsafeByteStringOptimizations = value; }); ApplyIfNotNull(distributedSettings?.ShutdownEvictionBeforeHibernation, value => localContentServerConfiguration.ShutdownEvictionBeforeHibernation = value); return(localContentServerConfiguration); }
internal static IContentStore CreateLocalContentStore( DistributedContentSettings settings, DistributedCacheServiceArguments arguments, ResolvedNamedCacheSettings resolvedSettings, IDistributedLocationStore distributedStore = null) { settings = settings ?? DistributedContentSettings.CreateDisabled(); var contentStoreSettings = FromDistributedSettings(settings); ConfigurationModel configurationModel = new ConfigurationModel(new ContentStoreConfiguration(new MaxSizeQuota(resolvedSettings.Settings.CacheSizeQuotaString))); var localStore = ContentStoreFactory.CreateContentStore(arguments.FileSystem, resolvedSettings.ResolvedCacheRootPath, contentStoreSettings: contentStoreSettings, distributedStore: distributedStore, configurationModel: configurationModel); if (settings.BackingGrpcPort != null) { var backingStore = new ServiceClientContentStore( arguments.Logger, arguments.FileSystem, resolvedSettings.Name, new ServiceClientRpcConfiguration(settings.BackingGrpcPort.Value), arguments.Configuration.LocalCasSettings.CasClientSettings.RetryIntervalSecondsOnFailServiceCalls, arguments.Configuration.LocalCasSettings.CasClientSettings.RetryCountOnFailServiceCalls, scenario: settings.BackingScenario); return(new MultiLevelContentStore(localStore, backingStore)); } return(localStore); }
private static void InitializeActivityTrackerIfNeeded(Context context, DistributedContentSettings settings) { if (settings.EnableCacheActivityTracker) { CacheActivityTracker.Start(context, SystemClock.Instance, settings.TrackingActivityWindow, settings.TrackingSnapshotPeriod, settings.TrackingReportPeriod); } }
public DistributedContentStoreFactory(DistributedCacheServiceArguments arguments) { _logger = arguments.Logger; _arguments = arguments; _distributedSettings = arguments.Configuration.DistributedContentSettings; _keySpace = string.IsNullOrWhiteSpace(_arguments.Keyspace) ? ContentLocationStoreFactory.DefaultKeySpace : _arguments.Keyspace; _fileSystem = new PassThroughFileSystem(_logger); _secretRetriever = new DistributedCacheSecretRetriever(arguments); var bandwidthCheckedCopier = new BandwidthCheckedCopier(_arguments.Copier, BandwidthChecker.Configuration.FromDistributedContentSettings(_distributedSettings)); _orderedResolvedCacheSettings = ResolveCacheSettingsInPrecedenceOrder(arguments); Contract.Assert(_orderedResolvedCacheSettings.Count != 0); RedisContentLocationStoreConfiguration = CreateRedisConfiguration(); _distributedContentStoreSettings = CreateDistributedStoreSettings(_arguments, RedisContentLocationStoreConfiguration); _copier = new DistributedContentCopier <AbsolutePath>( _distributedContentStoreSettings, _fileSystem, fileCopier: bandwidthCheckedCopier, fileExistenceChecker: _arguments.Copier, _arguments.CopyRequester, _arguments.PathTransformer, _arguments.Overrides.Clock ); _redisMemoizationStoreFactory = new Lazy <RedisMemoizationStoreFactory>(() => CreateRedisCacheFactory()); }
internal DistributedCacheServiceArguments CreateDistributedCacheServiceArguments( IAbsolutePathFileCopier copier, IAbsolutePathTransformer pathTransformer, HostInfo host, string cacheName, string cacheRootPath, uint grpcPort, int maxSizeQuotaMB, string dataRootPath, CancellationToken ct, int?bufferSizeForGrpcCopies = null) { var distributedCacheServiceHost = new TestHost(); var localCasSettings = LocalCasSettings.Default( maxSizeQuotaMB: maxSizeQuotaMB, cacheRootPath: cacheRootPath, cacheName: cacheName, grpcPort: grpcPort, grpcPortFileName: _scenario); localCasSettings.PreferredCacheDrive = Path.GetPathRoot(cacheRootPath); localCasSettings.ServiceSettings = new LocalCasServiceSettings(60, scenarioName: _scenario, grpcPort: grpcPort, grpcPortFileName: _scenario, bufferSizeForGrpcCopies: bufferSizeForGrpcCopies); var redisConnectionString = Environment.GetEnvironmentVariable(EnvironmentConnectionStringProvider.RedisConnectionStringEnvironmentVariable); var distributedContentSettings = DistributedContentSettings.CreateEnabled(new Dictionary <string, string>() { { host.StampId, redisConnectionString } }); var config = new DistributedCacheServiceConfiguration(localCasSettings, distributedContentSettings); return(new DistributedCacheServiceArguments(_logger, copier, pathTransformer, distributedCacheServiceHost, host, ct, dataRootPath, config, null)); }
internal DistributedCacheServiceArguments CreateDistributedCacheServiceArguments( IAbsolutePathFileCopier copier, IAbsolutePathTransformer pathTransformer, DistributedContentSettings dcs, HostInfo host, string cacheName, string cacheRootPath, uint grpcPort, int maxSizeQuotaMB, string dataRootPath, CancellationToken ct, int?bufferSizeForGrpcCopies = null, int?gzipBarrierSizeForGrpcCopies = null) { var distributedCacheServiceHost = new EnvironmentVariableHost(); var localCasSettings = LocalCasSettings.Default( maxSizeQuotaMB: maxSizeQuotaMB, cacheRootPath: cacheRootPath, cacheName: cacheName, grpcPort: grpcPort, grpcPortFileName: _scenario); localCasSettings.PreferredCacheDrive = Path.GetPathRoot(cacheRootPath); localCasSettings.ServiceSettings = new LocalCasServiceSettings(60, scenarioName: _scenario, grpcPort: grpcPort, grpcPortFileName: _scenario, bufferSizeForGrpcCopies: bufferSizeForGrpcCopies, gzipBarrierSizeForGrpcCopies: gzipBarrierSizeForGrpcCopies); var config = new DistributedCacheServiceConfiguration(localCasSettings, dcs); return(new DistributedCacheServiceArguments(_logger, copier, pathTransformer, distributedCacheServiceHost, host, ct, dataRootPath, config, null)); }
public void ReadAndWriteSettings() { var dcs = DistributedContentSettings.CreateDisabled(); TestSerializationRoundTrip(dcs); dcs = DistributedContentSettings.CreateEnabled(new Dictionary <string, string>(), true); TestSerializationRoundTrip(dcs); }
private static IRetryPolicy CreateSecretsRetrievalRetryPolicy(DistributedContentSettings settings) { return(RetryPolicyFactory.GetExponentialPolicy( IsTransient, retryCount: settings.SecretsRetrievalRetryCount, minBackoff: TimeSpan.FromSeconds(settings.SecretsRetrievalMinBackoffSeconds), maxBackoff: TimeSpan.FromSeconds(settings.SecretsRetrievalMaxBackoffSeconds), deltaBackoff: TimeSpan.FromSeconds(settings.SecretsRetrievalDeltaBackoffSeconds))); }
public DistributedCacheSecretRetriever(DistributedCacheServiceArguments arguments) { _distributedSettings = arguments.Configuration.DistributedContentSettings; _loggingConfiguration = arguments.LoggingSettings?.Configuration; _logger = arguments.Logger; _host = arguments.Host; _secrets = new Lazy <Task <Result <RetrievedSecrets> > >(TryGetSecretsAsync); }
/// <nodoc /> public static ResourcePoolConfiguration FromDistributedContentSettings(DistributedContentSettings dcs) { var resourcePoolConfiguration = new ResourcePoolConfiguration(); ApplyIfNotNull(dcs.MaxGrpcClientCount, v => resourcePoolConfiguration.MaximumResourceCount = v); ApplyIfNotNull(dcs.MaxGrpcClientAgeMinutes, v => resourcePoolConfiguration.MaximumAge = TimeSpan.FromMinutes(v)); ApplyIfNotNull(dcs.GrpcCopyClientCacheGarbageCollectionPeriodMinutes, v => resourcePoolConfiguration.GarbageCollectionPeriod = TimeSpan.FromMinutes(v)); return(resourcePoolConfiguration); }
public DistributedContentStoreFactory(DistributedCacheServiceArguments arguments) { _logger = arguments.Logger; _arguments = arguments; _redisContentSecretNames = arguments.Configuration.DistributedContentSettings.GetRedisConnectionSecretNames(arguments.HostInfo.StampId); _distributedSettings = arguments.Configuration.DistributedContentSettings; _keySpace = string.IsNullOrWhiteSpace(_arguments.Keyspace) ? RedisContentLocationStoreFactory.DefaultKeySpace : _arguments.Keyspace; _fileSystem = new PassThroughFileSystem(_logger); _secretRetriever = new DistributedCacheSecretRetriever(arguments); }
private static ContentStoreSettings FromDistributedSettings(DistributedContentSettings settings) { return(new ContentStoreSettings() { UseEmptyFileHashShortcut = settings.EmptyFileHashShortcutEnabled, CheckFiles = settings.CheckLocalFiles, UseLegacyQuotaKeeperImplementation = settings.UseLegacyQuotaKeeperImplementation, UseNativeBlobEnumeration = settings.UseNativeBlobEnumeration, }); }
public void RetryIntervalForCopiesNull() { var dcs = DistributedContentSettings.CreateDisabled(); dcs.RetryIntervalForCopiesMs = null; var newDcs = TestSerializationRoundTrip(dcs); Assert.NotNull(newDcs.RetryIntervalForCopiesMs); Assert.Equal(DistributedContentSettings.DefaultRetryIntervalForCopiesMs.Length, newDcs.RetryIntervalForCopiesMs.Length); }
public void RetryIntervalForCopiesCustomJson() { int count = 100; var dcs = DistributedContentSettings.CreateDisabled(); dcs.RetryIntervalForCopiesMs = Enumerable.Range(0, count).ToArray(); var newDcs = TestJsonSerializationRoundTrip(dcs); Assert.NotNull(newDcs.RetryIntervalForCopies); Assert.Equal(count, newDcs.RetryIntervalForCopies.Count); }
public DistributedContentStoreFactory( DistributedCacheServiceArguments arguments, RedisContentSecretNames redisContentSecretNames) { _logger = arguments.Logger; _arguments = arguments; _redisContentSecretNames = redisContentSecretNames; _distributedSettings = arguments.Configuration.DistributedContentSettings; _keySpace = string.IsNullOrWhiteSpace(_arguments.Keyspace) ? RedisContentLocationStoreFactory.DefaultKeySpace : _arguments.Keyspace; _fileSystem = new PassThroughFileSystem(_logger); }
public void EnumsAreChecked() { var settings = DistributedContentSettings.CreateDisabled(); settings.ProactiveCopyMode = "Some invalid string"; var errors = settings.Validate(); errors.Count.Should().Be(1); errors[0].Should().Contain(nameof(ProactiveCopyMode)); }
private DistributedContentSettings TestSerializationRoundTrip(DistributedContentSettings dcs) { using (var stream = new MemoryStream()) { var ser = new DataContractSerializer(typeof(DistributedContentSettings)); ser.WriteObject(stream, dcs); stream.Seek(0, SeekOrigin.Begin); return((DistributedContentSettings)ser.ReadObject(stream)); } }
private static RetryPolicy CreateSecretsRetrievalRetryPolicy(DistributedContentSettings settings) { return(new RetryPolicy( new KeyVaultRetryPolicy(), new ExponentialBackoff( name: "SecretsRetrievalBackoff", retryCount: settings.SecretsRetrievalRetryCount, minBackoff: TimeSpan.FromSeconds(settings.SecretsRetrievalMinBackoffSeconds), maxBackoff: TimeSpan.FromSeconds(settings.SecretsRetrievalMaxBackoffSeconds), deltaBackoff: TimeSpan.FromSeconds(settings.SecretsRetrievalDeltaBackoffSeconds), firstFastRetry: false))); // All retries are subjects to the policy, even the first one }
private static ContentStoreSettings FromDistributedSettings(DistributedContentSettings settings) { return(new ContentStoreSettings() { CheckFiles = settings.CheckLocalFiles, UseNativeBlobEnumeration = settings.UseNativeBlobEnumeration, SelfCheckSettings = CreateSelfCheckSettings(settings), OverrideUnixFileAccessMode = settings.OverrideUnixFileAccessMode, UseRedundantPutFileShortcut = settings.UseRedundantPutFileShortcut, TraceFileSystemContentStoreDiagnosticMessages = settings.TraceFileSystemContentStoreDiagnosticMessages, }); }
private static ServiceConfiguration CreateServiceConfiguration( ILogger logger, IAbsFileSystem fileSystem, LocalCasSettings localCasSettings, DistributedContentSettings distributedSettings, AbsolutePath dataRootPath, bool isDistributed) { var namedCacheRoots = new Dictionary <string, AbsolutePath>(StringComparer.OrdinalIgnoreCase); foreach (KeyValuePair <string, NamedCacheSettings> settings in localCasSettings.CacheSettingsByCacheName) { var rootPath = localCasSettings.GetCacheRootPathWithScenario(settings.Key); logger.Debug($"Writing content store config file at {rootPath}."); WriteContentStoreConfigFile(settings.Value.CacheSizeQuotaString, rootPath, fileSystem); if (!isDistributed) { namedCacheRoots[settings.Key] = rootPath; } else { // Arbitrary set to match ServiceConfiguration and LocalContentServer pattern namedCacheRoots[localCasSettings.CasClientSettings.DefaultCacheName] = rootPath; } } if (!namedCacheRoots.Keys.Any(name => localCasSettings.CasClientSettings.DefaultCacheName.Equals(name, StringComparison.OrdinalIgnoreCase))) { throw new ArgumentException( $"Must have the default cache name {localCasSettings.CasClientSettings.DefaultCacheName} as one of the named cache roots."); } var result = new ServiceConfiguration( namedCacheRoots, dataRootPath, localCasSettings.ServiceSettings.MaxPipeListeners, localCasSettings.ServiceSettings.GracefulShutdownSeconds, (int)localCasSettings.ServiceSettings.GrpcPort, grpcPortFileName: localCasSettings.ServiceSettings.GrpcPortFileName, bufferSizeForGrpcCopies: localCasSettings.ServiceSettings.BufferSizeForGrpcCopies, proactivePushCountLimit: localCasSettings.ServiceSettings.MaxProactivePushRequestHandlers, logIncrementalStatsInterval: distributedSettings?.LogIncrementalStatsInterval, logMachineStatsInterval: distributedSettings?.LogMachineStatsInterval, logIncrementalStatsCounterNames: distributedSettings?.IncrementalStatisticsCounterNames, asyncSessionShutdownTimeout: distributedSettings?.AsyncSessionShutdownTimeout); ApplyIfNotNull(distributedSettings?.TraceServiceGrpcOperations, v => result.TraceGrpcOperation = v); return(result); }
public void NonDataContractsMemberIsDeserialized() { var dcs = DistributedContentSettings.CreateDisabled(); dcs.GrpcCopyClientGrpcCoreClientOptions = new ContentStore.Grpc.GrpcCoreClientOptions() { MaxReconnectBackoffMs = 120, }; var newDcs = TestSerializationRoundTrip(dcs); Assert.NotNull(newDcs.GrpcCopyClientGrpcCoreClientOptions); Assert.Equal(dcs.GrpcCopyClientGrpcCoreClientOptions.MaxReconnectBackoffMs, newDcs.GrpcCopyClientGrpcCoreClientOptions.MaxReconnectBackoffMs); }
public void PositiveOrZerosAreChecked() { var settings = DistributedContentSettings.CreateDisabled(); settings.ProactiveReplicationDelaySeconds = -1; var errors = settings.Validate(); errors.Count.Should().Be(1); errors[0].Should().Contain(nameof(settings.ProactiveReplicationDelaySeconds)); settings.ProactiveReplicationDelaySeconds = 0; errors = settings.Validate(); errors.Should().BeEmpty(); }
public static Configuration FromDistributedContentSettings(DistributedContentSettings dcs) { if (!dcs.IsBandwidthCheckEnabled) { return(Disabled); } return(new Configuration( TimeSpan.FromSeconds(dcs.BandwidthCheckIntervalSeconds), dcs.MinimumSpeedInMbPerSec, dcs.MaxBandwidthLimit, dcs.BandwidthLimitMultiplier, dcs.HistoricalBandwidthRecordsStored)); }